Yeah it's a bit obvious as there's no ADC in the 16F628... only analog comparator.
OUPS!
Yeah it's a bit obvious as there's no ADC in the 16F628... only analog comparator.
OUPS!
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Oops, so whats the correct code or example to read a potentiometer?Originally Posted by mister_e
Thanks (that was fast)
You might look at the manual for the POT command. This is one option for measuring an analog signal without an ADC module. Another option is to use an external ADC or better yet, use a PIC with an ADC module on it. the 628 only has a comparator module.
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
ok, I can use 18F6220, so this is the new code:Originally Posted by rhino
adcon0=1
lectura var byte
trisa=%00000111
lectura=0
mainloop:
Adcin 0, lectura
serout porta.3,6,[#lectura,"."]
Adcin 1, lectura
serout porta.3,6,[#lectura,"."]
Adcin 2, lectura
serout porta.3,6,[#lectura,"."]
serout porta.3,6,[10,13]
Goto mainloop
End
Im trying to read 3 potentiometers on ra0/1/2
I use serouts to know if I read something
[edit] this code is working I missed the # in the serout
now I want to use the read value to set HPWM
so I added this
DEFINE OSC 4
adcon0=1
Rval var byte
Gval var byte
Bval var byte
trisa=%00000111
mainloop:
Adcin 0, Rval
serout porta.3,2,[#Rval,"."]
Adcin 1, Gval
serout porta.3,2,[#Gval,"."]
Adcin 2, Bval
serout porta.3,2,[#Bval,"."]
serout porta.3,2,[10,13]
hpwm 3,Rval,300
hpwm 4,Gval,300
hpwm 5,Bval,300
Goto mainloop
End
no luck again![]()
Last edited by peu; - 16th January 2006 at 19:50.
I can't even find a data sheet for 18F6220. Are you sure that is what you have. Also... there are TONS of examples here, and at MELabs website, and rentron.com on how to use the ADC module.
Wisdom is knowing what path to take next... Integrity is taking it.
Ryan Miller
Bookmarks