If you're really looking to learn about PLCs, you NEED "Your Personal PLC Tutor - A Guide to Understanding PLCs" Easy to read and uses 'plain' language! Get $$FREE$$ priority mail shipping too!!! You WILL be glad you did!! Click Here now to order | |
1: FC37 |
Thread Tools | Display Modes | |
April 28th, 2008, 03:28 AM | #1 |
sapoleon Member Join Date: Aug 2003 Location: still in Israel Posts: 271 | S7 bytes to DInt Hi. I have a new project, and it's in siemens S7. I can say that I'm having a hard time, because it's my first project with S7. In the project, I read a Cognex camera through Profinet, I get a result, that is a numeric code in separate bytes. So... It's like a string. The thing is, that I have to send to an HMI this value like a DInt, and I don't have any idea on how to begin. I started looking for the IEC FC37 but it seems that I have to make a string out of the series of bytes that I get the bytes in PIB261 to PIB269 (always 9 cyphers). I will appreciate if someone can point me in the direction on how to make a string from the bytes, so I can try the FC37 and convert it to a DInt. Thanks. __________________ I am responsible except my very responsibility. J.P.Sartre Last edited by sapoleon; April 28th, 2008 at 03:33 AM. |
sapoleon | ||
View Public Profile | ||
Find More Posts by sapoleon | ||
April 28th, 2008, 04:05 AM | #2 | |
Bratt Member Join Date: Nov 2003 Location: West Sweden Posts: 382 | Create a new string in a datablock with 9 chars STRING[9] then you can simply move the data from the input area. You will also need to initialize the actual value of the string either you can write '000000000' in the inital and actual value of the datablock or write L 9 T DB1.DBB1 //Byte containg current length of string The first two bytes of a string contains max length and current length Here i created a string named text STRING[9] in db 1 L PIB261 T DB1.Text[1] //If your string is named text L PIB262 T DB1.Text[2] ...... CALL "STRNG_DI" S :=DB1.Text RET_VAL:=MD0 Last edited by Bratt; April 28th, 2008 at 04:19 AM. | |
zia | ||
Bratt | ||
View Public Profile | ||
Find More Posts by Bratt | ||
April 28th, 2008, 04:16 AM | #3 | |
L D[AR2,P#0.0] Member Join Date: Nov 2006 Location: UK Posts: 2,095 | Here's another example: | |
L D[AR2,P#0.0] | ||
View Public Profile | ||
Find More Posts by L D[AR2,P#0.0] | ||
April 28th, 2008, 04:33 AM | #4 | |
sapoleon Member Join Date: Aug 2003 Location: still in Israel Posts: 271 | Thanks A LOT for the quick responses. I see that i have to take into account 2 extra bytes in the string for max length and That is to say, that the string will be of 11 chars, but i still define it for 9 chars. In the method defined by Bratt, how can I access the two first bytes of the string? __________________ I am responsible except my very responsibility. | |
Absolut Like DB1.DBB 0 // Max
DB1.DBB1 //Current
Or by using the pointer version like L D [AR2,P#0.0] described but then you need to write in stl format.
If its always nine chars you can create the datablock and write '000000000' in the inital and actual value of the string then you dont need to write anything in the length bytes. The 2 length bytes will always contain nine. Actually you only ned to write the zeros in actual value but its good to write it in the inital value aswell if someone decides to initziale the datablock in the future.
DB1.DBB1 //Current
Or by using the pointer version like L D [AR2,P#0.0] described but then you need to write in stl format.
If its always nine chars you can create the datablock and write '000000000' in the inital and actual value of the string then you dont need to write anything in the length bytes. The 2 length bytes will always contain nine. Actually you only ned to write the zeros in actual value but its good to write it in the inital value aswell if someone decides to initziale the datablock in the future.
Last edited by Bratt; April 28th, 2008 at 04:45 AM.
2:FC38
String in Int. Was ist hier falsch ? Hallo, ich möchte einen String, der in einem DB Steht in eine INT wandeln. Der DB20 ist folgendermaßen angelegt: COMMENT ARRAY[0..1023] CHAR In den Positionen 8, 9, 10 und 11 steht jeweils ein ASCII zeichen. z.B. '4' '7' '1' '1' Diese 4 Zeichen sollen nun in ein INT gewandelt werden. ICh habe hierzu ohne Erfolg folgenden Code probiert. Code: CALL "BLKMOV" SRCBLK :=P#DB20.DBX8.0 BYTE 4 // //"RCV_DB_A"ment[8] byte 4 RET_VAL:=#RetVal DSTBLK :=P#DB21.DBX0.0 BYTE 4 L 4 //4 Zeichen Länge T DB21.DBB 0 //max T DB22.DBB 1 //aktuell CALL "STRNG_I" S :=DB21.IR_CODE_S //"RCV_DB_A".HS_IR_CODE RET_VAL:="IR_Nummer" Der DB21 ist angelegt wie folgt: IR_CODE_S string[20] IR_Nummer ist global angelegt als INT. Ich bekomme aber imm eine 0 in IR_Nummer, obwohl beim betrachten des DB20 dort die Zeichen für ca. 2 Sekunden stehen. Kann mir jemand helfen, bevor ich verzweifle. Danke. noeppkes ... |
发布评论