Try this;
Code:X VAR WORD Y VAR WORD AD_10BIT: FOR X = 0 TO 1023 ' Simulate 0 TO 5V Y = X */ 1251 ' For 10-bit A/D (5V/1023)*256 = 1.251 SEROUT GPIO.1,N2400, ["X = ",DEC X," : = ",DEC Y DIG 3,".",DEC3 Y,"V",13,10] NEXT
Try this;
Code:X VAR WORD Y VAR WORD AD_10BIT: FOR X = 0 TO 1023 ' Simulate 0 TO 5V Y = X */ 1251 ' For 10-bit A/D (5V/1023)*256 = 1.251 SEROUT GPIO.1,N2400, ["X = ",DEC X," : = ",DEC Y DIG 3,".",DEC3 Y,"V",13,10] NEXT
This is what I came up with.
Code:adval0 = 4828 adval0 =adval0/151 'should give me 31 in this example. if adval0 > 99 then 'if adval was say 131 result would be 1. and remainder should calculate to 3*10+1 being 31. total of 1.31 result= adval0 dig 2 remainder= adval0 dig 1*10 remainder= remainder + adval0 dig 0 else if adval0 < 99 then result= 0 remainder= adval0 endif endif
Look about right?
Bookmarks