Author Topic: Problem with PIC BASIC  (Read 2770 times)

0 Members and 1 Guest are viewing this topic.

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Problem with PIC BASIC
« 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


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
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: Problem with PIC BASIC
« Reply #1 on: October 15, 2007, 04:48:30 AM »
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?

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Problem with PIC BASIC
« Reply #2 on: October 15, 2007, 07:07:17 AM »
I'm using the PIC16F685. All the pins work. No im not using port b
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: Problem with PIC BASIC
« Reply #3 on: October 15, 2007, 07:28:48 AM »
what about RA3(port a pin 3)?this is an open drain output and needs a pull up resistor

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Problem with PIC BASIC
« Reply #4 on: October 15, 2007, 10:30:49 AM »
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.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: Problem with PIC BASIC
« Reply #5 on: October 15, 2007, 04:55:57 PM »
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

Offline airman00Topic starter

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,653
  • Helpful? 21
  • narobo.com
Re: Problem with PIC BASIC
« Reply #6 on: October 15, 2007, 06:37:48 PM »
Thanks anyway,

I ended up using A2D instead of the pot command

Thanks for your help! ;D
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: Problem with PIC BASIC
« Reply #7 on: October 15, 2007, 07:15:28 PM »
i was thinking of suggesting the a2d port bits :)

 


Get Your Ad Here