Step7 300 CPU INT to CHAR Problem

blizagga

Member
Join Date
Jul 2008
Location
EL PASO
Posts
4
Hello guys, i have a problem and need your help.

Im sending data to a PC using an OPC server from the PLC.

I need to send the serial number of part that has been tested and pass good.

I had it store in a DBW48_Serial_Number its an INT.

I want to convert it into CHAR and store it in DBB105_Serial_Number - DBB111_Serial_Number. the serial number has 5 digits.

And im having alot of problems and headaches with this issue.

I need your help.
 
Thanks for your fast reply. Im still having some problems getting it right.

I can see the serial # on the DBW48, 5185, but i cant see it on the Digits.

PLCSERIALNUMBERCODE1.JPG
 
Last edited:
You are using symbolic addressing, but, let's assume for simplicity, that you want to write the digits to DB1451.DBB106/7/8/9/10

Code:
L B[ar1,p#3.0]
T DB1451.DBB106
L B[ar1,p#4.0]
T DB1451.DBB107
...etc

will do the job.
 
If you want the code to work if you change the symbolic addresses then you will need the following FC (I have called it FC99, but you can rename it as required)

Code:
FUNCTION FC 99 : VOID
TITLE =
VERSION : 0.1

VAR_INPUT
  pPtr : POINTER ; 
END_VAR
VAR_OUTPUT
  dwAreaPtr : DWORD ; 
  iDb : INT ; 
END_VAR
BEGIN
NETWORK
TITLE =
	  L	 P##pPtr; 
	  LAR1  ; 
	  L	 W [AR1,P#0.0]; 
	  T	 #iDb; 
	  L	 D [AR1,P#2.0]; 
	  LAR1  ; 
	  T	 #dwAreaPtr; 
	  SET   ; 
	  SAVE  ; 
END_FUNCTION


here is an example in use:
fc16001.JPG
 
Thanks i belive this wil work cause i can se se serial in the input but not the output.

I ve changed the DBB106 to DBB100, its the same.

plcDATA.JPG
 
I'm not sure whether it's relevant or not, but, first of all your comments on the String length Bytes are not correct, the first Byte (P#0.0) should be the maximum length the String can have and the second Byte is the actual length of the current String. I had some problems playing with Strings two or three years back and I seem to remember that in fact it didn't matter what the maximum length was set to (it could even be left at zero, if I remember correctly), but the actual length had to be correct. In your case, the actual length is set to zero!

As I say, I'm not sure if it's relevant or not, because it's not clear whether you're working with a genuine Step7 generated String here, or just a collection of Bytes which you are defining as a String. In the former case an actual String length of zero is likely to cause problems, in the latter case, it's probably irrelevant.
 
Hello guys, sorry for not replying faster had a lot of work with a production line.

I dont know why the FC 99 has alot of syntaxis errors.

And for the FC 16 or I_String. its loaded into the PLC.

I still have the same problem.

Need you help alot.
 

Similar Topics

I've tried few options to upload data from the cpu (WITHOUT having to stop/run the cpu again, but struggle a bit. Please help-out if you can! My...
Replies
2
Views
3,959
Just wondering if anyone has managed to set up safety Comms between two safety s7-300 controllers. With one programmed via Tia portal and one...
Replies
1
Views
2,164
Welcome every body. how do siwarex module FTA have Calibration ?????? thanks
Replies
4
Views
2,248
I am new to Seimens and am having trouble with the SCADA portion of my project. This is completely different than any Rockwell/GE/WW software I...
Replies
3
Views
6,311
Hello all, I have a fc block that is in SCL from one proj that I would like to put in another. I've read about the source code file wich I can get...
Replies
1
Views
4,935
Back
Top Bottom