Shop OBEX P1 Docs P2 Docs Learn Events
Having trouble using GPS as input for routine to control 2 motors — Parallax Forums

Having trouble using GPS as input for routine to control 2 motors

ZaeroZaero Posts: 9
edited 2008-12-09 06:13 in BASIC Stamp
Hello fellow board members,

I am working on a program to use the Parallax GPS Module to determine the position of a cart that will be automated to move using this positioning. The cart uses 2 100W DC motors (LINK HERE) with the idea to run them both independently to create turning and speed. I am using the Sabertooth 2x25 speed controller (LINK HERE) to drive the motors from a single 12V battery (NiCad, 12Ah rating).

My thinking is that I have to (1) establish my local position using the GPS module, then (2) compare that position with another position nearby of my choice and lastly (3) have the BS2 output the required response to the speed controller in order to drive the motors to have the cart close in on my position of choice. Of course, these 3 steps are repeated until the local position reported by the GPS module is sufficiently close to my position of choice.

The speed controller has 4 ways of receiving input:
1) Analog Input using PWM technique to give proportional control of the motors (BS2 is not fast enough to create outputs with frequencies that can be used effectively by the speed controller)
2) R/C Input using the BS2 to create a pseudo R/C input that is just a series of pulses (This is what I tried to use).
3) Simplified serial using TTL level RS-232 data that relates to speed and direction (never considered using either style of serial input)
4) Packetized serial which uses packeted data (address byte, a command byte, a data byte and a 7 bit checksum)

Now, its seems like my logic, as I mentioned above, is OK. However, once I run the routine I am not getting any response from the motors (hence from the speed controller).

I am attaching a copy of my code for your viewing.

Can I get someone to look over my code and see if they can see where I went wrong? Of course if the program is OK then the speed controller is the problem. But at least someone can help me determine what generally is the problem.

Thank you.

Comments

  • SRLMSRLM Posts: 5,045
    edited 2008-12-09 04:47
    You can use PWM to control your sabertooth. Look in their manual on page 8, "Mode 2". They specifically state that you can use a BS2 with it. It has a timeout/not-timeout select feature, so you don't need to worry about refreshing it.
  • ZaeroZaero Posts: 9
    edited 2008-12-09 04:56
    I was concerned that the I cannot get a PWM frequency higher than 1000Hz with the BS2. However, maybe I am wrong, but from page 356 of the BS Reference manual about PWM mentions "cycle time" and I thought that this is the frequency that that speed controller refers to. Apparently, BS2 does create a 1000Hz duty cycle but that is its max (which also creates a 5V output).
  • SRLMSRLM Posts: 5,045
    edited 2008-12-09 06:13
    You control your speed controller (when on the PWM setting) with the PULSOUT command. The sabertooth can be hooked up just like a servo to an R/C controller or a uC: you send it a pulse width of 1 to 2 ms every 20 ms. That is about a 50 HZ rate. The PWM command is to "allow the BASIC Stamp (a purely digital device) to generate an analog voltage."(355) Essentially, servo (or sabertooth) PWM is a different beast entirely.

    Take a look at some continuous rotation servo control programs to see how to program it. A good spot to look would be in the Robotics With the Boe Bot book, under the movement sections.
Sign In or Register to comment.