8/4/2011 1:53 PM | |
Joined: 1/28/2009 Last visit: 5/26/2023 Posts: 6802 Rating:
|
Check the following codes.Characters in MB0 to MB3 converted to hex equivalent and stored in MB10 to MB13. Finally hex equivalent is calculated by: hex=(MB10+ (MB11*16) + (MB12*16^2) +(MB13*16^3) ) The codes should be modifed for error detection [code] L 0 T #BUFFER L P#M 0.0 LAR1 LAR2 L 4 LP: T #Zählung A( L MB [AR1,P#0.0] L 65 >=I ) A( L MB [AR1,P#0.0] L 70 <=I ) JCN SND L MB [AR1,P#0.0] L 55 -I T MB [AR2,P#10.0] JC END SND: NOP 0 A( L MB [AR1,P#0.0] L 48 >=I ) A( L MB [AR1,P#0.0] L 57 <=I ) JCN END L MB [AR1,P#0.0] L 48 -I T MB [AR2,P#10.0] END: NOP 0 +AR1 P#1.0 +AR2 P#1.0 L #Zählung LOOP LP L MB 11 L 16 *I L MB 10 +I T #BUFFER L 256 L MB 12 *I L #BUFFER +I T #BUFFER L 4096 L MB 13 *I L #BUFFER +I T #BUFFER T MW 200 [/code] Attachment1.pdf (601 Downloads) |
Last edited by: hdhosseini at: 8/5/2011 10:45 PM//attachment revised Last edited by: hdhosseini at: 8/5/2011 10:27 PM//Zählung Last edited by: hdhosseini at: 8/5/2011 10:37 AM |
|
This contribution was helpful to
3 thankful Users |
8/5/2011 12:38 PM | |
Joined: 10/22/2008 Last visit: 4/28/2023 Posts: 355 Rating:
|
Sure. I noticed it. |
8/8/2011 3:32 PM | |
Joined: 1/28/2009 Last visit: 5/26/2023 Posts: 6802 Rating:
|
Hi Check the following S7 Program for a function which do the conversion and error detection! Regards AttachmentCHR2HEX_FUNCTION.zip (1174 Downloads) |
This contribution was helpful to
2 thankful Users |
8/10/2011 1:18 PM | |
Posts: 148 Rating:
|
There is a function converting tow char bytes " #Char1,#Char2" to one byte output "#sum" [code] L #Char1 T MB 0 L #Char2 T MB 2 A M 0.6 = #Ch1Up9 A M 7.6 = #CH2Up9 L 12 L MB 0 SLW T MW 0 A #Ch1Up9 JNB _002 L MW 0 L W#16#9000 +I T MW 0 _002: L MW 2 L W#16#F00 AW T MW 2 A #CH2Up9 JNB _003 L MW 2 L W#16#900 +I T MW 2 _003: L MW 0 L MW 2 OW T MW 4 L MB 4 T #sum [/code] I have already tested it . If you have a question or need the reverse function Hex2Char just ask the attached is the program in ladder AttachmentChar2hex.zip (405 Downloads) |
Last edited by: AmirAlwaled at: 8/10/2011 1:21 PMAdding attachment Description |
|
2/26/2014 8:37 AM | |
Posts: 344 Rating:
|
new question is splittet to Can I get it to do 4 "Char" into an INT?. |
8/23/2018 12:50 PM | |
Joined: 6/19/2017 Last visit: 5/26/2023 Posts: 6900 Rating:
|
New question published by AutoGen_700091 is split to a separate thread with the subject how do change char to byte in TIA. Best regards |
My Forum is the place to personalize your profile, |
|
Follow us on