TreadBot


Closed Thread
Results 1 to 40 of 177

Thread: TreadBot

Hybrid View

  1. #1
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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...

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    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...
    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'.

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    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

  4. #4
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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..

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    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!

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

  7. #7
    Join Date
    Apr 2006
    Location
    Alberta Canada
    Posts
    166


    Did you find this post helpful? Yes | No

    Default

    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.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dragons_fire View Post
    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...
    Can you slow down your SERIAL LCD? (notice how I remembered it was a serial lcd this time?) Run it at 2400 baud instead of 9600, or maybe slower, and see what happens?

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts