Shop OBEX P1 Docs P2 Docs Learn Events
Need some Help working the last bug out of my program — Parallax Forums

Need some Help working the last bug out of my program

Matthew HMatthew H Posts: 23
edited 2008-09-04 01:13 in Propeller 1
Hello, this summer have been working on making a robot out of my old RC car. It uses the PING))) sensor mounted on a servo to avoid objects. I have finally got everything working except for one little bug. I have the program setup so that one Cog handles scanning with the ping and then steers the wheels in the right direction. At the same time, another Cog checks the RPM of the drive wheels, then adjusts the output of a Pololu Micro Motor Controller to try and keep the RPM at a constant rate.

The Problem is, both of these routines don't work at the same time. I have narrowed it down to this, both routines need to call Simple Serial's Start and set the motor controller's reset pin High or they don't work. When the speed controlling cog first sends a command to the motor controller it dose not work and the scan/steering control cog's commands to the motor controller stop working too. Both of these routines work and do what I want them to when the other is removed from the program. I have attached the entire program and all of the associated objects. I know that my code may not be that well organized, but please take the time to look through it and let me know if you have any ideas. Feel free to ask for anymore information that might help you help me.

Thanks, Matthew

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2008-09-04 00:19
    You described exactly the problem you have. Having 2 cogs trying to drive the same serial output pin is giving you the problem. I would suggest that the AutoSpeed cog updates a variable with the speed rather than trying to write to the serial port. Then the main loop reads the speed variabel and calls MC.Forward(speed) in its repeat loop.
    i..e in the Autospeed delete the serial.start and serial.tx, write MSpeed to a variable - Speed. Then in Main jut after the main repeat insert if Speed > 0 MC.Forward(Speed) else MC.Reverse(-Speed)
    Dont forget to initial speed to 0
  • Matthew HMatthew H Posts: 23
    edited 2008-09-04 00:50
    Thanks a lot for the help Timmoore, I did what you said and it fixed the problem! I feel kind of dumb because I didn't see that, oh well.

    Matthew
  • Paul BakerPaul Baker Posts: 6,351
    edited 2008-09-04 01:13
    No worries·Matthew, it's helpful to assign responsibility for devices connected to the Propeller, with other processes talking to the responsible process. This eliminates the problem with more than one process trying to use it at the sme time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.

    Post Edited (Paul Baker (Parallax)) : 9/4/2008 1:20:29 AM GMT
Sign In or Register to comment.