Society of Robots - Robot Forum
Software => Software => Topic started by: airman00 on October 14, 2007, 04:30:28 PM
-
Using the pot command in PIC BASIC I was able to get an 8 bit reading of the resistance of two sensors. When I tried to do this with 3 sensors I was only able to get readings from two of them.
The pot command works like this: http://www.societyofrobots.com/robotforum/index.php?topic=2095.0 (http://www.societyofrobots.com/robotforum/index.php?topic=2095.0)
Why is it that I can get readings from only two lines and then the third one gives me 0 all the time. I tried seperately and they all worked but whenever I did three together, one was always not working. Any idea why? I'm thinking its something to do with the capacitor
Here is my program:
v1 var byte
v2 var byte
v3 var byte
pause 1000 'Allow time for LCD display
main:
pot portb.6,255,v1 'Read resistance of CdS #1 photocell
pot portb.5,255,v2 'Read resistance of CdS #2 photocell
pot portb.7,255,v3 'Read resistance of CdS #2 photocell
'Display information
serout portb.4,6,[$fe,$01] 'lear the screen
Serout portb.4,6, [27, 42, 128] ' set screen to half brightness
pause 25
serout portb.4, 6, ["S.1 S.2 S.3 "]' Display this on LCD
serout portb.4,6,[$fe,$C0] 'Move to line 2
pause 5
serout portb.4,6,[#v1, 6]
serout portb.4,6,[" ",#v2, 6]
serout portb.4,6,[" ",#v3, 6] ' Display reading in decimal format
pause 100
goto main
-
which pic are you using?, and is there a particular port pin that isnt working properly? sometimes you need to configure the port pin to be an i/o port, (on 877a portb6 and b7 can both be either configured for ttl (i/o) input or scmitt trigger input (pgd/pgc) maybe because of this one of them cant be used with the pot command) .would you also be using portb3 for anything with the low voltage programming fuse bit set?
-
I'm using the PIC16F685. All the pins work. No im not using port b
-
what about RA3(port a pin 3)?this is an open drain output and needs a pull up resistor
-
so i need to put a resistor there for the third pot command to work???
any other things,
MCLEAR is disabled and that pin is an input instead.
-
i dont think the pot command will work at all on RA3 unfortunately.
the pot command does this:
turn the port bit to output and send it low (output a 0)
then turn the port bit back into an input
time how long it takes for the port to be driven high by the capacitor
---------
RA3 can only be an input - it cant be an output, due to the multi function capabilities. since the pot command needs to use it as an output(to drive it low) and then switch to an input it wont work
you would have to use a different port bit
-
Thanks anyway,
I ended up using A2D instead of the pot command
Thanks for your help! ;D
-
i was thinking of suggesting the a2d port bits :)