yeah, i have been keeping the reset pin high. i have also tried to reset it after every loop...and i can get it to slow down from 80 to 0 using the same program without a problem.
yeah, i have been keeping the reset pin high. i have also tried to reset it after every loop...and i can get it to slow down from 80 to 0 using the same program without a problem.
so i got the motors workign by changing the caps across the leads. i found out a couple days ago that the drawers i keep my caps in got messed up, so i ended up putting in 22pf caps instead of 1uf caps.
so now i added on the parallax ping ultrasonic sensor, and its messing something up. heres the short code for the sensor:
PulsOut ultra, 5
PulsIn ultra, 1, ping
"ultra is the port, and ping is the distance variable. the pulsin line seems to work, and the LED lights on the ping sensor, but everytime i send the pulsout command, it sends wierd characters to the LCD, and the "ping" variable doesnt change from 0.... the LCD is on portf.0 and the ping sensor is on portf.1.... the traces are fairly far apart, and there is nothing touching them.
if i delete the pulsout line, everything displays where its supposed too, and the ping var = 0...
i know i didnt describe it the best, but if anyone has any ideas, please let me know...
Those ultrasonic transducers generate some fairly high voltages while doing their work. I can easily see one of those dumping current across traces and causing your problems. Maybe try putting a series resistor inline with portf.0 and see what happens. Don't run the transducer, start low on the resistance, work your way up until the LCD doesn't work anymore, then back off one or two values. Then fire up the transducer and see what happens...
Have you ever been 'bit' by one? I wouldn't touch the bare metal on it while it's doing it's 'transducing'.
Did you set the ultra pin to 0 before using Pulsout?
Pulsout works by toggling the pin twice. To get positive pulses, the pin needs to be set low first. (if it wasn't already there)
<br>
DT
yes, i took it low before doing anything. heres a little more of the code:
trigger con 5
baudLCD CON 32 'baud rate for lcd
lcd VAR PORTF.0 'lcd port
ping VAR byte
ultra VAR PORTF.1
PORTF.1 = 0
ping = 0
SerOut2 lcd, baudlcd,[254,"G",1,1,"Ping Test"] 'display test on lcd in position 1,1
start:
Pause 1000
PulsOut ultra, trigger 'send trigger to ping
PulsIn ultra, 1, ping 'wait for ping variable
Pause 1000
SerOut2 lcd, baudlcd,[254,"G",2,2,#ping," "] 'display pin var in position 2,2
GoTo start
End
so wheni take out the "pulsout ultra, trigger" line, everything works great (except the ping sensor cause it doesnt get its pulse). i added in long pauses so i could tell where the problem is. my LCD will display "ping test" in the correct position, then waits a second, displayes a wierd character, waits another second and then displays a couple wierd characters and then the ping variable. when it shows the wierd characters and ping variable, it just adds them right behind "ping test", not in the position its supposed to be in..
Try this out and see what happens:
trigger con 5:baudlcd con 32:lcd var portf.0: ping var byte:ultra var portf.1: portf.1=0: ping=0:SerOut2 lcd, baudlcd,[254,"G",1,1,"Ping Test"]
start:
Pause 1000
PulsOut ultra, trigger
PulsIn ultra,1,ping
flags.0=0
Pause 1000
SerOut2 lcd, baudlcd,[254,"G",2,2,#ping," "]
GoTo start
End
The flags.0 = 0 basically resets the LCD, might help, might not...never know...
EDIT: And as mister_e noted below, flags.0 don't help here...DOH!!!
Last edited by skimask; - 22nd May 2007 at 16:34. Reason: Doh!
FLAGS work ONLY with LCDOUT...
DragonFire, did you set the TRISF as well? unless PORTF.1=0 won't do anything as the default setting for PORTF 'should' be input ... yeah i love guessing
So OR you set TRISF.1 = 0 at the top of your code, OR you can use LOW PORTF.1. LOW/HIGH will do it for you.
It's up to you.
NOW, you can't use PULSIN/PULSOUT as you did, PULSOUT is not working in background, so it will finish to do it's job, then your program will execute PULSIN. As the pulse is already gone, it won't read it.
Of course, an interrupt would do the trick... of course with DT instant interrupt, not PBP ON INTERRUPT.
What i figure to be working, in your ISR, you start a timer, you change the interrupt trigger type (rising/falling edge), then at the next interrupt, you read the Timer value.
Still possible to use the CCP module... it's design for it.
I suggest you to read the following Tips 'n Tricks doc of Microchip. It's all there
http://ww1.microchip.com/downloads/e...Doc/41214a.pdf
EDIT: i saw you READ/WRITE to the same pin (ultra)?
SEROUT2 should be used with DEC modifier instead of #... maybe this is why you have some weird character.
I heard some LCD may need some CR or LF character to work properly.. not sure if this could apply to yours.
Last edited by mister_e; - 22nd May 2007 at 15:37.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
i just gave that a try, and it does the same thing.... im going to haved to play around with it a little more later...
the pijng sensor im using, only has one I/O pin, it actaully takes the "trigger pulse" in and then waits 200uS and then sends out the ultrasonic pulse, so that part of the code was copied right out of their demo code for the BS2. i have had it working before on a 877a, so i just copied my code from that.. im sure its just a stupid little thing...
it actually seems like maybe the baudrate is just a tiny bit off, but i can send the first command fine...
Last edited by dragons_fire; - 22nd May 2007 at 15:57.
Bookmarks