Help with MOTOR CONTROLLER 18V7

I have just got this motor controller and had a few questions i wanted to clear up. I have read the manual available but i’m still unsure.

My setup is this controller, a 3-9 volt motor, 6v power supply and an Arduino due.

Firstly just to clarify a few things: if i just want to use it to control the speed and direction of the motor i connect it as follows:

Vin: Battery positive
GND: GND
OUTB: One side of the motor
OUTA: Other side of motor

GND: ground on Arduino
RX: Hardward Serial TX on Due

One question do i need the Vin on the TTL side?

Moving onto code, i have seen the example code and i understand most of it, obviously as i am using hardware serial i will replace all software serial. I understand the command bits about forward and backward and -3200 is full reverse, 0 is stop and 3200 is full forward etc… but i don’t understand the following bit:

Serial2.write(speed & 0x1F);
Serial2.write(speed >> 5);

Thank you

Hello.

You should not connect power to VIN on the serial interface side of the Simple Motor Controller. You can find a simple wiring example for connecting to a microcontroller when using TTL serial to interface with the Simple Motor Controller under the “Connecting a Serial Device” section of the user’s guide.

It sounds like you are not sure what the ampersand and double greater-than signs mean in those two lines of code. In the code you posted, those operations are used for bit-masking and bit-shifting, respectively. You can search the Internet for those terms to learn more about what those commands specifically do and for examples of how they can be used for bit-masking and bit-shifting.

-Jon

Thank you. I just wanted to double check I understood the wiring which it seems like I have.
I will research those operators more, I just wanted to understand what the code was doing rather than copying and pasting it.

I can’t seem to get the motor controller to work…

I have wired it up as follows:

Although on the serial side i have only connected the TX and GND as that is all i need.

As i am using a Due the code i am using i replaced Software Serial to Hardware Serial so i have the following:

I am running it all from 4AAs, which should be sufficient as it powers the motor fine when plugged in directly to the motor.

When i attach it all together and run the code i just have a red LED error and yellow flashing LED and nothing else. The status LED is indicating that the controller has learnt the TTL serial baud rate but is not driving the motor.

I’m not sure where i am going wrong?

I thought i would use a new post for an update as i have made some progress…

I had a few errors, from Vin to serial, which have now all been dealt with and do not appear any longer.

I lowered the Vin errors to 4.5V as sometimes when my motor was in use it would drop down close to that, i will look at getting better batteries but for the time being it gets round that.

I then ran the code above and it ran forwards fine but when it got to reverse it just seemed to skip it and go back to going forwards. I then made it run at speeds 1600,800,400,200,0,-1600. Again it slowed down progressively but skipped the -1600. I then added in -200,-400,-800 and it ran all the way to -1600. From that i drew the conclusion that it didn’t like the big jump from 0 to -1600 but it was happy with 0 to 1600.

I wondered if i am doing something wrong, it just seems strange that one way it is fine the other way it has to be increased slowly. Any insights or tips?

Thank you

I did not notice anything obviously wrong with your code. In general, it is common for brushed DC motors to have slightly different behavior for each direction of rotation. In this case, I suspect one direction of rotation to draw slightly more current than the other direction of rotation, and that your batteries are able to supply that current in one direction, but not the other.

By the way, the Simple Motor Controller has a minimum input voltage of 5.5V, so while lowering the Low VIN shutoff or Low VIN startup parameters might get your system running, it is outside the operating range of the device and not recommended for reliable operation. I am not entirely sure what kind of batteries you are using, but a 4 cell rechargeable battery, which has a nominal voltage of 4.8V, will not be a sufficient supply for that motor controller. However 4 alkalines, which have a nominal voltage of 6V, should be okay. Can you try upgrading your power source, like you were thinking of doing, to something like a 2S LiPo or benchtop power supply to see if that helps? A rechargeable battery that uses more than 5 cells should work, too.

-Jon