Hello
There is one confusion before I implement my code in hardware.
I read the pic microcontroller I am using is 10 bit. The signal I am acquiring through pin configured as analgoue vary from 0 to 5 volt. I want to activate few leds if certain condition is met. Knowing that ADC converts the signal into 1024 steps where each step is equal to roughly 0.00489.
Question is what value could I use in the software within decision statements such as if/else. Do I use values straight as 2, 3, 4 or corresponding quantized step value such as 512 for 2.5, 216 for 1.25. In other word which one of the following statement is correct.
1)
acq_volt=Adc_read(1) // acquire through channel one of adc module
if(acq_volt>2.5)
PORTB=0X01;
2)
acq_volt=Adc_read(1)
if(acq_volt>512)
PORTB=0X01;
Many thanks for help
There is one confusion before I implement my code in hardware.
I read the pic microcontroller I am using is 10 bit. The signal I am acquiring through pin configured as analgoue vary from 0 to 5 volt. I want to activate few leds if certain condition is met. Knowing that ADC converts the signal into 1024 steps where each step is equal to roughly 0.00489.
Question is what value could I use in the software within decision statements such as if/else. Do I use values straight as 2, 3, 4 or corresponding quantized step value such as 512 for 2.5, 216 for 1.25. In other word which one of the following statement is correct.
1)
acq_volt=Adc_read(1) // acquire through channel one of adc module
if(acq_volt>2.5)
PORTB=0X01;
2)
acq_volt=Adc_read(1)
if(acq_volt>512)
PORTB=0X01;
Many thanks for help