DEBUG function DEC
jackass867
Posts: 1
alright heres my·problem I have an input var·byte and then I would like to display the decimal value. I've had no problem doing this, however I would then like to use that decimal value and perform some mathematical operations on it. I've figured out some roundabout ways to do this, but as the computations become more involved it has become nearly impossible. So what I am wondering is if there is any way to use that decimal value outside of the debug command. If anyone has any ideas please let me know. here is a sample of my code
· LOW ADC_cs··························· ' Set Clock Select Low - enable
· SHIFTIN ADC_data, ADC_clk, MSBPOST, [noparse][[/noparse]ADC_value\9]· ' Read value of ADC
· HIGH ADC_cs·························· ' Set Clock Select High - disable
· DEBUG CR, "ADC: ", DEC ADC_value····· ' Print return carriage, and ADC value
· DEBUG CR,"Volt=", DEC ((ADC_value*5)/255),".",····· ' voltage corresponding to ADC_value
· DEC (((ADC_value*5)//255)*100)/255,"V"
· DEBUG CR,"GF=", DEC ((ADC_value*5*10)/255),".",····· ' voltage corresponding to ADC_value
· DEC (((ADC_value*5*10)//255)*100)/255,"m/s^2"
thanks for the help!
· LOW ADC_cs··························· ' Set Clock Select Low - enable
· SHIFTIN ADC_data, ADC_clk, MSBPOST, [noparse][[/noparse]ADC_value\9]· ' Read value of ADC
· HIGH ADC_cs·························· ' Set Clock Select High - disable
· DEBUG CR, "ADC: ", DEC ADC_value····· ' Print return carriage, and ADC value
· DEBUG CR,"Volt=", DEC ((ADC_value*5)/255),".",····· ' voltage corresponding to ADC_value
· DEC (((ADC_value*5)//255)*100)/255,"V"
· DEBUG CR,"GF=", DEC ((ADC_value*5*10)/255),".",····· ' voltage corresponding to ADC_value
· DEC (((ADC_value*5*10)//255)*100)/255,"m/s^2"
thanks for the help!
Comments
mV = ADC_value */ 5000
The factor 5000 comes from 5000mV per 256 counts. See the Stamp manual and also this link for Stamp math.
Once the value is in mV, display it:
DEBUG DEC mV/1000, ".", DEC3 mV, CR ' x.xxx
or do additional math.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com