| Posted: 06:11am 02 May 2026 |
Copy link to clipboard |
 Print this post |
|
G'day John (DigitalDreams) Had a similar problem with a sensor a while ago, there are probably better solutions but the one I used was:
Option Default Integer
a$=" " ' Set string length to 3 (24 bit) byte(a$,1)=0:byte(a$,2)=0:byte(a$,3)=0 ' Set default value
a$=chr$(0)+a$ ' make 24 bit value 32 bit b=str2bin(int32,a$)/256 ' correct to 24 bit value
If the data is big endian the extra chr$(0) will need to be added to the end:
a$=a$+chr$(0) ' make 24 bit value 32 bit b=str2bin(int32,a$,BIG)/256 ' correct to 24 bit value
Hope this helps.
Regards, Lyle. Edited 2026-05-02 16:19 by mozzie |