3A speed controller

I’m new to this automation game, but had quite a lot of fun trying out servo and stepper motors with boards from different suppliers here in the UK. I bought a Pololu 3A Motor controller with feedback last week and initially set it up to run a little 6v dc motor using the servo control set up I was already using. A bit messy, but it worked. USB to RS232 converter, null modem cable, RS232 to TTL converter, servo controller, speed controller. Trouble is the motor stops between each command, so I’m trying to implement direct control from serial commands so I can ramp speeds etc. So far with no success.

The TTL converter’s output is Logic 0 0v, Logic 1 5v. Communication looks like it’s behaving when I connect the Tx and Rx (no ground) to the MC board, but whatever the wiring option or code we’ve sent so far just results in a flashing green LED which I take to be an error. No motor movement at all. A friend has been helping with C# coding. e.g.

    SerialPort port = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);

    port.Open();

    byte speed = 50;

    port.Write(new byte[] { 128, 0, 0, speed }, 0, 4);

    System.Threading.Thread.Sleep(1000);
       
    speed = 0;

    port.Write(new byte[] { 128, 0, 0, speed }, 0, 4);

    port.Close();

Any ideas on how to get this thing working gratefully received.

Sorry you’re having trouble. Why aren’t you connecting ground between the motor controller and your TTL converter? It may be picking up the fluctuations of the Tx line from your TTL converter, but without a ground reference to measure against it really can’t read the signal!

The fact that it responds at all to your serial commands makes me think that you have Tx and Rx (Rx isn’t entirely necessary here) wired properly to the serial in and out pins of the motor controller, and that your RS232 to TTL converter really wants a null modem cable. I would have guessed it just wanted a DB9 extension cable, what kind is it? Also, at first glance your code looks alright. That is to say the byte string you build follows protocol, but I can’t say about your serial port commands, what language are you using?

Since you had the controller working with RC input, you must have had everything wired up correctly, the only difference now should be that you should have both blue jumpers removed to set the motor controller to serial input with no feedback (for now), and the serial connections made.

Did connecting ground between the level converter and the motor controller fix your problem?

-Adam

Adam, thanks for the comments.
I’m basing the connections on the behavior of the Tx/Rx LEDs on the TTL converter. I expected to need the ground connected, but this results in the Tx being constantly illuminated (high?) with no response to serial signals, and the green LED on the MC lit. With the ground disconnected, the TTL converter Tx (and Rx)LED flicker as and when serial commands are sent, but the MC board red and green LED are lit until the serial commands when the green starts flashing about twice a second (and the TTL Rx LED for the time the port is open). That can be reset by grounding pin 5. I’ve also tried removing the Rx and every other permutation I can think of.

I can’t remember the spec of the null modem cable, but it works with the servo board and doesn’t without it. Yes all the jumpers are removed.

The language is C#.

The only thing I haven’t tried is making a common ground with the 6v MC and the 9v TTL converter batteries and using that as the ground. I may be wrong but it doesn’t sound a good idea.

Any other suggestions? I’m all out of ideas.

Thanks

Dave

In general, but with a few exceptions, all your DC electronics need to share a common ground to work together. Remember that a voltage isn’t an absolute value, it’s a difference in electrical potential. Your motor controller is expecting logic signals at 5V above its own ground, and the TTL converter is outputting signals at 5V above its own ground, but if the two ground lines aren’t connected together there is no way for the motor controller to accurately measure the incoming high and low pulses (and not just from an unintentional offset, it will see the voltage fluctuating wildly).

Connecting all your ground lines together won’t let unwanted current flow, it will just provide a common reference for the other voltages involved. It wouldn’t necessarily be a bad idea to connect the ground terminal of your TTL converter’s 9V battery to your motor controller, but it is unnecessary since the ground pin of the converter’s DB9 port (which you should connect to the ground pin of your motor controller) is almost certainly directly connected to the ground pin of the battery already! I’m not going to say this is so with 100% certainty because I don’t know what kind of converter you’re using, so it could have some awful crazy design, but I doubt it.

What make & model of USB to RS-232 and RS-232 to TTL converters are you using? If they have decent specs available we can figure out for sure what the wiring should be.

-Adam

Adam, thanks again for the suggestions.

After my last post I tried connecting the grounds for both batteries and the MC and TTL converter pins. I think there is progress of sorts. With the Rx connected there was no communication, but disconnected only the green LED on the LMC board was illuminated (not both) which starts flashing when serial commands are sent. But, there is still no motor movement.

I guess the MC board should be seeing the signals now. Just doesn’t understand them. My friend feels certain that the code should work, so I’m still at a loss as to how to move forward. Can anyone offer any example code in C# or any other common language?

The pdf for the TTL converter is here:
robomicro.co.uk/anytime/pdf_ … 8dp314.pdf

I suspect we might be at the point

I take it back, you should be using a null-modem cable with this converter (good call).

They’re using the bad way to describe their TTL pins though: what they call TX (pin 3) is actually meant to be connected to the Tx pin of your motor controller, so it’s actually the data receiving pin of the converter (aka Rx). Likewise, what they call the Rx pin (pin 4) is actually the TTL transmitting pin of the converter (aka Tx), and wants to be connected to the Rx pin of the motor controller.

So, the connections you should have are:

Pin 2 (gnd) on the converter to GND on the motor controller
Pin 3 (Tx data) on the converter to Pin 4 (green LED/Serial output) on the motor controller (not really necessary)
Pin 4 (Rx Data) on the converter to Pin 3 (serial input) on the motor controller

If it’s a real null-modem cable (i.e. not just three wire ground-ground, rx-tx, tx-rx) it should be taking care of any handshaking/flow control, so you shouldn’t need to do anything with the other pins of the converter.

If you have these connections set up right I’m flummoxed.

-Adam

Adam. Connecting TTL converter pin 4 to MC pin 3 works!!! Absolutely fantastic.

(Now I’ll just have to figure out how the configuration using the servo controller worked in the first place.)

Thanks enormously for your help. It’s a relief to get back to the fun bit of making things move.

Dave

Glad to hear it, and good luck with your project. What are you making anyway?

-Adam

It’s a positioning gizmo for macro photography. Thought it might be easier to juggle the bugs and stuff around than me and a camera. I guessed it would be a fun starter project (some of it’s been fun). Maybe I could do things like chase the bugs with a robot mounted camera in the future? Think I need to learn a bit more basic electronics first.

Thanks again.

Dave