For debugging purpose I always suggest people use a LCD, ICD or use PC Terminal to see what's happen INSIDE the PIC.
Also, post your PIC model, whole code so we see your ADC DEFINES. Is the ADC result left or right justified, stuff like that.
For debugging purpose I always suggest people use a LCD, ICD or use PC Terminal to see what's happen INSIDE the PIC.
Also, post your PIC model, whole code so we see your ADC DEFINES. Is the ADC result left or right justified, stuff like that.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
I am using PIC 16f877A
this is the code
DEFINE ADC_BITS 8 ' Set number of bits in result
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50
ADCON1 = 0 ' PORTA is analog
pw VAR BYTE
TRISA = 255
TRISD = 0
start:
ADCIN 0,pw
if (pw > 220) and (pw<252) then
pulsout portd.3,220
else
goto start
endif
goto start
This program works, when I move Joypad to the right motor move to the coresponding postion, I wanna know what is the right value of variable pw, when my joypad is moved al the way to the right and al the way to the left??
OK, so you have the results left justified, it should work. BUT maybe you have some nifty noise on the line or something like that. Allow a certain error margin.
test 0
If pw<5 then
test 255
if pw>250 then
still stucked?!? well let's try a variant of it
Test 0
if ADRESH<5 then
test 255
if ADRESH>250 then
about now?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
So this ADRESH is the adress where AD save it's value ?
what if I have two, three or four AD, is it all stored in same adress ?
Yup they all have the same register.
ADCIN select the channel, perform the conversion, then read it from ADRESH/ADRESL register, then dump it to your variable.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
thx Steve
I will probably have few questions, now I will contion on my work
thx
Bookmarks