Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20562

BASCOM-AVR : how to assembled a three bye array in one data type : REPLY

$
0
0
With all our discussion a good keyword I have learned putting bytes array in long but this also swap my received byte array sequence. manually I swapped the first and 3rd byte and putting in long I get the correct value. but still there is serious problem . what I am getting it is big number for the current when I divide by some number to get near figure to my real current say one amp it remove my fractional parts of current. it only gives the whole number. say If i am getting the all 3 bytes value Decimal 1048576 hex 100000 when I divide by 1048576 to get 1 Amp that is my real current by clamp meter I get only one no fractional parts At least I should have figure up to 3 decimal like 1.589. bur in long it is not possible when I convert to it small I get 0.00 Dim R_data(4) As Byte Dim Current_l As Long Dim Current_s As Single Dim Irms_data(4) As Byte At Current_s Overlay R_data(1) = &H04 R_data(2) = &H60 R_data(3) = &H00 Irms_data(1) = R_data(3) Irms_data(2) = R_data(2) Irms_data(3) = R_data(1) Print "" Print "" Current_l = Current_s / 286720 Current_l = Current_s Print Hex(current_l) ; " " ; Current_l Print Hex(current_s) ; " " ; Current_s End Answer below: 00000000 0 00046000 0.0 My questions How to get fractional parts as well ? I am doing manual swapping the 1st and 3rd bytes manual is there some other better way to do it?

Viewing all articles
Browse latest Browse all 20562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>