I had a good luck today and first time seen LEDs coming on with my code. I am now trying to switch LEDS using analogue input. I know the code but slightly confused with using registers:
get_vol()
{
while (ADCON.Go==1)
{
return (((ADRESH*256) + ADRESL) * 0.00489);
}
}
void main ();
{
if ( get_vol() <2.5)
{ PORTC=get_vol();}
}
1) Lets say we acquiring data off a voltage sensor, at what point does the pic controller decide data is acquired and clear ADCON.GO to 0. Does it scan the input only once?
2) I copied "(((ADRESH*256) + ADRESL) * 0.00489);" from a book. I however does not understand whats happening here:
The ADFM is one means right justified. Why multiplied ADRESL with 256 and nothing with ADRESL and why multiplier with quantization step 0.00489.
Please help!
Kind Regards
get_vol()
{
while (ADCON.Go==1)
{
return (((ADRESH*256) + ADRESL) * 0.00489);
}
}
void main ();
{
if ( get_vol() <2.5)
{ PORTC=get_vol();}
}
1) Lets say we acquiring data off a voltage sensor, at what point does the pic controller decide data is acquired and clear ADCON.GO to 0. Does it scan the input only once?
2) I copied "(((ADRESH*256) + ADRESL) * 0.00489);" from a book. I however does not understand whats happening here:
The ADFM is one means right justified. Why multiplied ADRESL with 256 and nothing with ADRESL and why multiplier with quantization step 0.00489.
Please help!
Kind Regards