11/17/2018 7:51 PM | |
Joined: 11/7/2011 Last visit: 1/27/2023 Posts: 96 Rating: (0) |
DEAR EVERYONE, I WANT TO KNOW CAN WE CONVERT A REAL NUMBER INTO POINTER FORMAT FOR EXAMPLE,SAY CONTENT OF DB1.DBD4 WHICH IS 1.5 ,INTO POINTER FORMAT .IF IT IS POSSIBLE HOW IT IS DONE ,ACTUALLY ,I WOULD LIKE USE THIS FOR INPUT/OUTPUT MAPPING WITH DB ADDRESS. THANKS,SAMIR ------------------------------------------------------------------------------------------ |
Last edited by: Jen_Moderator at: 11/19/2018 8:01:50 AMNew subject after splitting |
|
11/19/2018 6:36 PM | |
Joined: 11/7/2011 Last visit: 1/27/2023 Posts: 96 Rating: (0) |
DEAR SIR, I WANT TO DO DI MAPPING ,FOR THAT ,I CREATED DB5(REAL_DB) WHICH CONTAINS DI ADDRESS(I.E INITIALIZED VALUE),AND ANOTHER DB4(WHICH WILL BE USED IN PROGRAM) INSTEAD OF DIRECT DI INPUT.AND IN FC3 MAPPING PROGRAM IS WRITTEN. BUT MY PROGRAM IS NOT WORKING.I HAVE UPLOADED THE SAMPLE PROGRAMME PLEASE HELP ME AFTER GOING THROUGH IT. THANKS , SAMIR AttachmentIO_MAP.zip (201 Downloads) |
11/20/2018 7:52 AM | |
Posts: 2826 Rating: (686) |
|
11/20/2018 10:10 AM | |
Joined: 9/23/2005 Last visit: 11/18/2024 Posts: 4795 Rating: (733) |
@Samir: what is not working in your code as expected by you is this:
To understand why it is not working you need to know 2 things. 1) The format of the addresses in S7: byte.bit notation (e.g. p#1.5) is coded on 32 bits (dword) as follows: 0000 0000 0000 0bbb bbbb bbbb bbbb bxxx - where bbbb bbbb bbbb bbbb is natural binary coded byte address and xxx is bit address. So address p#1.5 looks like this: 0000 0000 0000 0000 0000 0000 0000 1101 2) The format of the real numbers which is according to the IEEE754 binary32. So the REAL#1.5 looks like this: 0011 1111 1100 0000 0000 0000 0000 0000 As you may notice they have nothing in common. To obtain address you should extract integer and fraction parts of your REAL number and then assemble a pointer out of them. Personally, I'd use integer data type to "code" the address in a human-readable format instead of REAL, i.e. p#1.5 would be stored as 15. Then it's less effort to convert it into a proper S7 address. |
Regards, |
|
Follow us on