Dual micro motor controller problem. With the controller

I have a problem with my Dual micro motor controller, that i never noticed until now.
Hardware, Botboard 2, Basic Atom Pro 28-m.

If i repeat the same control code, and it resends the signals, sometimes the speed will change, even though the speed is hard set.

Motors and Motor Controller share their own 5.0v 1.5A regulator(w/ heatsink). Both motors are Solarbotics GM9’s.

movement
if (cbot = 1000 and switcher = 0) then
 SEROUT p10, i9600, [$80, 0, 0, 0]
 SEROUT p10, i9600, [$80, 0, 2, 0] 
elseif (cbot = 1001 and switcher = 0)                        ;forward full speed
  SEROUT p10, i9600, [$80, 0, 0, 127]
  serout p10, i9600, [$80, 0, 2, 127] 
  PAUSEUS 400000
elseif (cbot = 1002 and switcher = 0)                        ;backwards full speed
  SEROUT p10, i9600, [$80, 0, 1, 127]
  serout p10, i9600, [$80, 0, 3, 127] 
  PAUSEUS 400000
elseif (cbot = 1003 and switcher = 0)                        ;rotate left, right track forward, left track reverse at reduced speed
  SEROUT p10, i9600, [$80, 0, 2, 90] 
  SEROUT p10, i9600, [$80, 0, 1, 90] 
  PAUSEUS 400000
elseif (cbot = 1004 and switcher = 0)                        ;Rotate right opposite of above
  SEROUT p10, i9600, [$80, 0, 3, 90] 
  SEROUT p10, i9600, [$80, 0, 0, 90] 
  PAUSEUS 400000
elseif (cbot = 1005 and switcher = 0)                        ;forward Slow
  SEROUT p10, i9600, [$80, 0, 0, 40]
  serout p10, i9600, [$80, 0, 2, 40] 
  PAUSEUS 400000
elseif (cbot = 1006 and switcher = 0)                        ;backwards slow
  SEROUT p10, i9600, [$80, 0, 1, 40]
  serout p10, i9600, [$80, 0, 3, 40] 
  PAUSEUS 400000
elseif (cbot = 1007 and switcher = 0)                        ;rotate left slow
  SEROUT p10, i9600, [$80, 0, 2, 35] 
  SEROUT p10, i9600, [$80, 0, 1, 35] 
  PAUSEUS 400000
elseif (cbot = 1008 and switcher = 0)                        ;Rotate right slow
  SEROUT p10, i9600, [$80, 0, 3, 35] 
  SEROUT p10, i9600, [$80, 0, 0, 35] 
  PAUSEUS 400000
endif
goto main

If i send the code cbot = 1005, multiple times, sometimes the speed on one or both motors will change, sometimes even go in reverse. Most noticable when switching between the two rotate commands, if i’m rotating left, and i put in the rotate right command, sometimes it’ll go in forward or reverse, but at the rotate speeds, meaning 1 of the two commands didn’t go through.

Both of my motors use single 100uf capacitors, i’ll be adding 2nd and 3rd capacitors to each motor in a few minutes, but i don’t think that’s the problem.

Should i change the baud rate? Is the controller itself defective? What about adding a 10-20 millisecond pause in between SEROUT commands.
I’ve had problems before when switching from forward or reverse, to one of the rotate commands, 1 motor will slow/move correctly, while the other will still be going at the previous commands direction and speed.
But only now that i use 2 speed sets has the problem become more noticeable, it’s actually a problem now.
Because now i have to press the input command a few times just to get it to the right speed, Where before, if the first time didnt work, another button tap and it would kick in, Now it takes 3-4 taps to get the speed right.

PS
Pretty soon i’ll be changing the code to only use 5 commands, based on a variable speed. (i’ll use multipliers and (gears) on the speed, from
131.75 for slowest
2
31.75 for slow
331.75 for medium
4
31.75 for fast. (4*31.75 = 127)

PPS
i plan on getting Pololu Low-Voltage Dual Serial Motor Controller eventually, but i have no money, and a new wireless adapter comes first.
Edit: are the serial comands for both the dual micro and the Low-voltage dual motor controller the same?
Can i just swap them out? or do i have to change my code?
Also does the one i linked suffer from the same problems?

I added 2 more “104” disc capacitors to each motor, didn’t fix it, but changing the i9600 on the commands to i4800 did fix it for the most part. Not sure what was causing it, but i wont complain about it being fixed.
Shame i cant upgrade the firmware on this thing.

Okay, to start with, the 100uF capacitors are a really bad idea. We recommend 0.1 uF ceramic capacitors. You are probably wasting most of your power by charging and discharging it, and you are damaging or destroying the capacitor every time you apply a reverse voltage (assuming it is electrolytic.)

Next, when you say that the motors and Dual Serial Motor Controller share a 5V regulated supply, do you mean that you are using that as your logic supply as well? That is asking for trouble, since every time the voltage drops due to a high load, you could be resetting the motor controller.

Finally, your motors have a stall current of 670mA at 5V. If you throw both channels instantly from forward to reverse, each one will take about double the stall current, so you will be drawing more than 2A from your 1.5A supply, and also possibly damaging the motor controller, which is rated for 1A per channel peak. That is probably why it worked better at 4800 baud - the extra delay between commands might have been just enough to let one motor get out of its stall before the other one started going. I would bring the motors to a complete stop first before starting them up again.

Why? Is there something you would change?

-Paul

The ceramic disc capacitors say 104 on them. It’s been a few months since i did anything with my robot, so i obviously forgot the codes. All 3 capacitors on each motor say 104, so they are indeed 0.1uF, i don’t know why i was thinking 100uF.
Funny thing is i was the one that suggested you guys carry those capacitors. Still wish you guys had some 3A voltage regulators.

I’ll put the logic power on my botboards supplied power, take it off the motor controllers power.
I only test the rapid switching if directions while the robot is being held in the air (else it’ll run right off my desk), it’s not something i do on a regular basis.

Coming to a complete stop, might work if i just copy/paste the stop commands right above all the movement commands so it sends 4 commands 2 stop, and 2 new movement commands each time. Maybe that’ll give it enough time as not to overload it.
maybe:

elseif (cbot = 1001 and switcher = 0)                        ;forward full speed
  SEROUT p10, i9600, [$80, 0, 0, 0]
  SEROUT p10, i9600, [$80, 0, 2, 0]
  pauseus 40000 ;20 millisecond pause
  SEROUT p10, i9600, [$80, 0, 0, 127]
  serout p10, i9600, [$80, 0, 2, 127] 
  PAUSEUS 400000
elseif (cbot = 1002 and switcher = 0)                        ;backwards full speed
  SEROUT p10, i9600, [$80, 0, 1, 0]
  SEROUT p10, i9600, [$80, 0, 3, 0]
  pauseus 40000 ;20 millisecond pause
  SEROUT p10, i9600, [$80, 0, 1, 127]
  serout p10, i9600, [$80, 0, 3, 127] 
  PAUSEUS 400000

You think changing it like that would help enough? I plan on getting a new regulator, but i cant afford one right now so i don’t want this one to die on me.

Edit:
Nevermind fixed this second problem, was accidentally trying to use 2 separate baudrates cause i copy/pasted from old code.

Okay, 104 is 0.1uF. Good.

But 20ms is not much of a delay. Can you afford to wait longer, like half a second, to make sure that your robot really has stopped? I do not have any information about your design, so it would be hard for me to guess how long it will take until your wheels stop turning. I also don’t understand why you are using the regulated power for your motors. What is your battery voltage?

-Paul

Edit: Heres pictures of my robot on the lynxmotion site, you cant see the motor controller, as it’s hidden behind the servo connector pins. i’ll MSpaint a power plan. thread

Battery voltage is 8.4v
I don’t have money to spend on batteries, so i’m using Ni-MH batteries from other things, crashed RC helicopters currently.
I also have 9.6 and 10.8v but my botboard’s logic voltage is limited to 9v, and my 9v regulator needs more than 10.8v to step down to 9v.

They are essentially 7 AAA cells bound together.
tamiya-model.com/shop/esky-e … 02870.html
Those.

You sell similar models too pololu.com/catalog/product/1009
Except i use the JST connectors.

My current setup is
Battery has direct power to my botboard
the battery also splits into now (2, 5v regulators)

Regulator 1: 5v 1A Load:
4 micro servos.

Regulator 2: 5v 1.5A load:
2 GM9 motors
1x 5v 0.2A 3cm x 3cm fan, to cool the regulators, Does a fine job too.

I moved the motor controller onto the botboards regulated 5v power.

I made it wait 50ms, after sending stop commands.
So just to switch from forward to reverse, it’ll send stop commands, wait 50ms, then send the new commands.
Half a second would be to much, it doesn’t sound like much, but half a second is longer than it sounds.
Though i can set it to 250ms and still be comfortable with it’s response time.
It seems the more code i add, the laggier it feels.

As you can see below, my code has gone through a few upgrades. I currently have a Thread open on the basic micro site, on how to make the robot stop when i let go of the forward button, without continuing to to finish off any buffer.

New basic studio, the IDE for basic atoms, theres 2 types of pause, normal “pause” which is ms, and pauseus, which is in 0.5us, so 100,000 = 50ms. (i switched everything to pauseus, before realising the old pause command still worked, earlier versions of the ID didn’t have 2 pause commands)

pause 500
enablehserial
enablehservo

SETHSERIAL H9600, H8databits, Hnoparity, h1stopbits
PAUSEUS 40000

high p7
high p10
PAUSEUS 400000
LOW p11                                  ;motor controller reset on pin 13 
PAUSEUS 400000
HIGH p11 
PAUSEUS 600000                           ;motor controller startup time 


Hservo [p5\0,p6\0]                       ;Center arm servos.
hservowait [p5,p6]
PAUSEUS 2000000
Hservo [p1\0,p3\12000]
hservowait [p1,p3]
PAUSEUS 2000000


main
switcher var bit
cbot var word
drive1 var sword
drive2 var sword
drive3 var sword
drive4 var sword
change var bit
gear var nib                
speed var byte
Starterclk var bit

if (gear = 1) then
  speed = 30
 elseif (gear = 2)
  speed = 60
 elseif (gear = 3)
  speed = 90
 elseif (gear = 4)
  speed = 127
else
speed = 90
endif

hserin 8000000, main,[dec4 cbot]
hserout [dec cbot,",",sdec drive1,",",sdec drive2,",",sdec drive3,",",sdec drive4,"    "]  ; Debug code return.

if (Starterclk = 0) then
 drive4 = 12000
 gear = 3
 Starterclk = 1
endif

if (cbot = 777 and switcher = 1) then                        ;Switches from Arm to Rover mode
 switcher = 0
 cbot = 0
  Sound P9,[100\5000,80\4500,60\4000]
 goto main
elseif (cbot = 777 and switcher = 0)                         ;Switches from Rover to arm mode.
 switcher = 1
 cbot = 0
  Sound P9,[60\2500,80\3000,100\3500]
 goto main
elseif (cbot >= 1000 and cbot <= 1100 and switcher = 0)      ;Rover controls.
 goto movement
elseif (cbot >= 1000 and cbot <= 1100 and switcher = 1)      ;Arm controls.
 goto robotarm
endif
goto main


movement

if (cbot = 1000 and switcher = 0) then
 SEROUT p10, i4800, [$80, 0, 0, 0]
 SEROUT p10, i4800, [$80, 0, 2, 0] 
elseif (cbot = 1001 and switcher = 0)                        ;forward full speed
  SEROUT p10, i4800, [$80, 0, 0, 0]
  SEROUT p10, i4800, [$80, 0, 2, 0]
  pauseus 100000 
  SEROUT p10, i4800, [$80, 0, 0, (speed)]
  serout p10, i4800, [$80, 0, 2, (speed)] 
  PAUSEUS 100000
elseif (cbot = 1002 and switcher = 0)                        ;backwards full (speed)
  SEROUT p10, i4800, [$80, 0, 1, 0]
  SEROUT p10, i4800, [$80, 0, 3, 0]
  pauseus 100000 
  SEROUT p10, i4800, [$80, 0, 1, (speed)]
  serout p10, i4800, [$80, 0, 3, (speed)] 
  PAUSEUS 100000
elseif (cbot = 1003 and switcher = 0)                        ;rotate left, right track forward, left track reverse at reduced (speed)
  SEROUT p10, i4800, [$80, 0, 2, 0]
  SEROUT p10, i4800, [$80, 0, 1, 0]
  pauseus 100000                               
  SEROUT p10, i4800, [$80, 0, 2, (speed)] 
  SEROUT p10, i4800, [$80, 0, 1, (speed)] 
  PAUSEUS 100000
elseif (cbot = 1004 and switcher = 0)                        ;Rotate right opposite of above
  SEROUT p10, i4800, [$80, 0, 3, 0]
  SEROUT p10, i4800, [$80, 0, 0, 0]
  pauseus 100000              
  SEROUT p10, i4800, [$80, 0, 3, (speed)] 
  SEROUT p10, i4800, [$80, 0, 0, (speed)] 
  PAUSEUS 100000
elseif (cbot = 1005 and gear >1 and switcher = 0) 
 gear = gear - 1
 Sound P9,[100\3000]
elseif (cbot = 1006 and gear < 4 and switcher = 0) 
 gear = gear + 1
 Sound P9,[100\5000]
endif
goto main

robotarm
if (cbot = 1000 and change = 0 and switcher = 1) then						;Resets Servos
 drive1 = 0
 drive2 = 0
 drive3 = 0
 drive4 = 12000
 change = 1
 goto pantilt
elseif (cbot = 1003 and drive1 < 12250 and change = 0 and switcher = 1)     ;Rotate CW
 drive1 = drive1 + 250
 change = 1
 goto pantilt
elseif (cbot = 1004 and drive1 > -12750 and change = 0 and switcher = 1)    ;Roate CCW
 drive1 = drive1 - 250
 change = 1
 goto pantilt
elseif (cbot = 1001 and drive2 < 13500 and drive4 > -13000 and change = 0 and switcher = 1)     ;Extend Arm
 drive2 = drive2 + 250
 drive4 = drive4 - 250
 change = 1
 goto pantilt
elseif (cbot = 1002 and drive2 > -8000 and drive4 < 12000 and change = 0 and switcher = 1)  ;Retract arm
 drive2 = drive2 - 250
 drive4 = drive4 + 250
 change = 1
 goto pantilt
elseif (cbot = 1005 and drive2 < 13500 and change = 0 and switcher = 1)     ;first arm forward
 drive2 = drive2 + 250
 change = 1
 goto pantilt
elseif (cbot = 1006 and drive2 > -8000 and change = 0 and switcher = 1)     ;first arm up
 drive2 = drive2 - 250
 change = 1
 goto pantilt
elseif (cbot = 1007 and drive4 < 12500 and change = 0 and switcher = 1)     ;Second arm down
 drive4 = drive4 + 250
 change = 1
 goto pantilt
elseif (cbot = 1008 and drive4 > -13000 and change = 0 and switcher = 1)    ;second arm up
 drive4 = drive4 - 250
 change = 1
 goto pantilt
elseif (cbot = 1009 and drive3 < 3000 and change = 0 and switcher = 1)      ;Grabber Close
 drive3 = drive3 + 250
 change = 1
 goto pantilt
elseif (cbot = 1010 and drive3 > -6000 and change = 0 and switcher = 1)     ;grabber open
 drive3 = drive3 - 250
 change = 1
 goto pantilt
endif
goto main

pantilt
if change = 1 then
 hservo [p5\drive1\100,p6\drive2\100]
 hservo [p1\drive3\100,p3\drive4\100]
 hservowait [p1,p3,p5,p6]
 change = 0
 goto main
endif
goto main

Power lay out, it’s kind of confusing, i hope you understand it.

The botboard has 2 power inputs, which can be shared, but are not.
VL which is for the the logic voltage, and VS which is just for the servos.
You can set the power for each set of 5 IO pins, So i can have the servos run of separate power than another device plugged into the same board.

Giving the helicopters these batteries were designed for draw a lot more power than my entire robot, i doubt i have any problems with not getting enough juice out. I haven’t had any dropouts anyways.
Currently besides some ineffecient coding, i think i’m set.

I ran the motors at full speed for about 2 minutes or so, the regulator they, and the fan share, with it’s nice beautiful heatsink, (which the fan is blowing on) wasn’t even warm to the touch, wasn’t cold, just neutral.

If i go for a 5v battery, my botboard will lack enough voltage as it needs at least 7.2v, and a boost regulator… well i cant find any in the stuff i salvaged.
As you can see in the pictures linked in my previous post, my rover is small, the battery i have is velcroed under the rover, even then it kind of disrupts movement over some objects. So a second battery, I can do it, but i’m running out of places to put stuff. I’m going to borrow a high rest camera within a week or 2 and get some nice detail pictures.

And i’ll stop now because i’m babbling again. I do that… a lot. Young ladies do that.

Hello.

That’s a pretty nice drawing. So, everything is working now? (Or at least the motor controller?)

- Jan

yup.
But just because it appears to be working, doesn’t mean i couldn’t be damaging it in the background.
So i still welcome any input.

Got a question, if i relpeatedly send the forward signal, while its already moving, does that cause any spikes? or does it just ignore a command it’s already running?

I’m driving myself nuts trying to figure out an auto stop command for this thing, and one of the side effects is it’ll loop the run signal.
If it doesn’t cause any damage, then i’m home free, but i have a feeling the dual micro controller does NOT ignore a command it’s already running, and reruns the command causing a millisecond stop and rerun.

If this is the case, i think i figured out what can be improved upon.
and that is, if it’s givin a signal for a specific motor, that it’s already running, to skip that command, and not re-initiate that motor.

Well, it is definitely more clear now. Are you sure that you need 7.2V for the BotBoard II? Can you point me to where you saw that specification? It is generally a bad idea to use a linear regulator to power motors, and if you could use a slightly lower voltage battery (7.2V instead of 8.4V would keep the max voltage when freshly charged within the 9V limit) you could connect it directly to the Dual Serial Motor Controller. You would probably need to reduce your PWM values to keep the current within the limits of the motor controller.

Anyway, I am glad you have it mostly working, and I hope to see some great pictures of the robot here soon!

-Paul

Sadly the BB2 manual says the logic voltage is between 7.2 and 9v

Servo voltage is between 4.8 and 7.2v, but i actually only have servos running off the servo voltage.

I only have 1 battery at my disposal that has a lower voltage than 8.4v, and that’s a 5v li-ion battery.
The LI-Ion battery probably has more mAh than 2 of my 8.4v batteries put together. I need to find another connector to use this one.

I wouldn’t mind using the Li-Ion battery for both the servos and the motors, but i’ll still need to find another battery for the botboard 2.
Maybe you can figure this out for me. I think i asked over at the lynxmotion forums once, but never got a clear answer.

lynxmotion.com/images/html/build151.htm

The VL, VS and VL-VS link confuse me.
I’ve ran power into the VL with the VS linked, but the power all came off the 5v regulator so it didn’t matter.
I removed the link and power them separately now.

If i add the link back, and power the VS with 5v, would it work? i’m confused about that. The VL says it needs 7.2v, Yet it says not to use the VL/VS link when power is coming into the VL, i just assumed they meant, don’t have any devices running off the VS power.

If possible, i’ll gladly run the whole robot off my Li-Ion battery. It’s smaller, lighter, more power, and no need for regulators.
Only thing, everything would be sharing the same power.

It sure looks to me like VL can be 5.5-9V. Why do you think there is a 7.2V limit? The only reference to 7.2V on that page is the maximum level for VS.

If you set VL=VS, I suppose that means that the two inputs are electrically connected. So you could use 5.5V up to whatever your servos could handle.

I am not sure that a lithium pack would help you much here. If your servos are working okay on the 5V linear regulator (which I do also think is a bad idea), you should just try to eliminate the regulator for the motors, and I think you will get a much more reliable design.

-Paul

The manual, shows a picture pointing to size=150[/size] which states 7.2 - 9v, on the VL.

heres the exact manual.
BotBoard manual.PDF (930 KB)

That looks like a typo to me. They specifically talk about the low-dropout regulator being able to take as low as 5.5V, right? Maybe you should check with the lynxmotion.

-Paul

I checked with my multimeter, my charged 5v battery actually puts out 5.38v, the next lowest battery i have is 8.4v, which is what i’m currently using.

The 5.38v would be fine for the servos and motors i’m sure, but it’s to much for the BB if i bypass the regulator, but not enough, if i USE the onboard regulator. I just cant win!

Edit:
I still want a firmware upgrade, that ignores commands it’s already running.

If i send my forward command repeatedly, it’ll start and stop each time, it will “jitter” if it’s sent fast enough. I had to program a skip command to my robot, if it’s still receiving a code input. (At least this stops me from rapidly switching between forward and reverse)
If it ignored currently running commands, i could send it a thousand times without even a hic-up.
Because of this little problem, it took me 4 hours to change the code on my robot, most of it was a timing issue, i needed it to wait long enough for my terminal programs macro-repeat as so it doesn’t time out and stop.
As seen Here

So if the motor controller didn’t do that, i wouldn’t need loose timings. Currently my robot will run for 0.4 seconds after i let go of the button. It’s tolerable, but still a long time. It’s the difference between stopping at the edge of a desk, and stopping upside down on the floor. (at least at max speed of 127)

Oh yeah, I forgot to answer your question. The motor controller doesn’t “ignore” anything you send it, but it should not cause any spikes if you send the forward command twice in a row. However, based on your code I think you might be talking about setting the speed to 0, delaying, and then setting it to a high speed again many times. Of course in that case you will get lots of spikes.

-Paul

I rewrote how the code sends maybe a dozen times last night. Removed the stop codes altogether (besides my original stop override.)

I was wrong, i narrowed down the problem.
The problem is how my terminal program and keyboard work.
If you hold down A such as aaaaaaa
you’ll notice a slight pause between the first and second A, that isn’t present in the rest of the A’s.
If my auto-stop code is to fast, it’ll detect the tiny pauses between each A.

And i can’t program the terminal to use expressions, so it sends Go once while A is held down, then sends stop when no keys are pressed. I’d have to write a program that does that in c# or C++. Write the expressions directly into the program.
I technically have a very basic one that does just that, sends a stop code when nothing is held down, but it kind of… doesn’t work.

What bothers me the most… I haven’t seen any really good terminal programs, especially ones designed for robots that use serial or usb-> serial interface.

I’ll attach the terminal i’m using, you’ll notice the 12x F1-F12 macros available. (Scanned with ESET Nod32 anti virus, it’s clean)
But i haven’t found any that offer the same functionality with ease of use.
I’m getting confused having to learn so many different coding languages.

I just want one, when active allows me to control my robot with normal keyboard keys, WASD,QE, and a few others when needed.
Maybe ones with expressions, so i can write if/then/else expressions right into the terminal.

if W = 1 then Movement = forward else movement = stop

I think i saw one, 232 Analyze, But it’s free version didn’t support macros, and my hobby budget is only at $20.
Edit: sounds like simpleterm gold, might work too, but like 232analyze, it’s really expensive.

So, can’t you adjust the stopping time to make it work the way you want to? I don’t think that changing the terminal program is the way to go.

-Paul

I have removed the terminal file that you posted. I do not think that this forum is an appropriate place for exchanging executable files like that. Even if that one is perfectly clean, I don’t want to generally encourage people to run executable files posted here, and it would be a lot better for everyone if you posted a link to the web site instead. Anyway, I think we can understand what you mean without running the program on our own computers.

-Paul

Ok no problem.

If anyone wants it, i’ll put up a link on request.

Sadly my timings are about as tight as i can get them. 400ms is enough to pass the first repeat pause. 350ms is not.
Without having a terminal that automatically sends a stop code when no buttons are pressed, i think that’s about as good as i’ll get for now.
If you know of any good free terminal programs that support macros, don’t hold out on me man!

Edit:
While lurking in the software forum, i found this post

EXCELLENT! it supports more macros, up to 24 with shift+F keys
Sadly it doesn’t fix the timing, but at very least i can control more stuff.
I didn’t recognize the name Bray as Br@y++, silly me.