PDA

View Full Version : converting decimal to 8 bit binary, or do I even need to?



keithv
- 29th August 2016, 17:59
I need an 8-bit binary number to make the digital potentiometer I'm using work. I'm using an analog potentiometer connected to the ADC to get that number. It seems to give me a decimal number between 0 - 255. I'm assuming this, because the LABX-1 example program http://melabs.com/samples/LABX1-16F887/adcin3x.htm found here. The ADC_BITS is set to 8 instead of the default 10. But I don't see anywhere in the program where the 8-bit ADCIN is converted to decimal. Yet the LCD displays the value in decimal. So I'm assuming that the ADC output is in decimal. Is that correct? If so, what is the best way to convert it to an 8-bit binary number.

towlerg
- 30th August 2016, 01:59
Decimal ard hexadecimal just ways for us dumb humans to represent numbers. The PIC does everything in binary so if you want to set the top bit of a port it makes no difference if you write $80 or 128 or %10000000.

keithv
- 30th August 2016, 17:11
Thanks! I got the digital pot working. It wasn't a matter of binary vs. decimal. I was configuring something else incorrectly.