Ideas for motor speed control

I have an idea of how to do a electronic speed control for some DC motor (H-bridges).
I built this circuit and it works pretty well. Its a PWM generator based on this great tutorial . I had to convert it to a NE556 instead of a NE555 but it works well with a 100K linear pot..

speed_controller1.jpg

So, the Pot is mechanical ! - I wanted the bot to be able to control its own speed, not manually set it. So, I came up with this - its a 12 bit binary counter (only using 6 bits), which should give me 64 speed settings. (specs)

 

speed_controller2.jpg

PRO
1. I have the mc14040B on hand and I hate waiting for mail
2. 64 seems like a decent number of speed settings
3. 1 chip 6 resistors and 6 npn bipolar transistors does not seem like a huge number of components
4. stopping would be as simple as hitting the reset line
5. incrementing the speed would be just sending another clock pulse to the mc14040b

CON
1. In order to decrement the speed I would need to reset the whole chip and "quickly" increment to a lower speed (seems sloppy)
2. I have a feeling that this could be done with fewer components.


I'm going to build it anyway and will keep this post updated - (if anyone is interested), but since there are so many great "techies" out there - some could tell me "ha ha GroG - my granny used to build that circuit with vacume tubes, now its a single solid state speed control package ZX115 ! "

 

UPDATE 20081007

Well it all went together pretty smoothly. I had a little trouble remembering on how to interface with other subchannels of the dio. But, luckly I mapped the hole thing out here .

The circuit currently has 330 Ohm resistor for all the bridges - but I will change this to Rik's suggestion of R/2 setup where each resistor is half its neighbor. This should allow for a binary step through a full 64 different speed values. Since I did not have the full resistor set the different values I can get with a 330 are as follows:

dio line - ohms
d0 - 330
d1 - 165
d2 - 110
d3 - 82.5
d4 - 66
d5 - 55

 

DSCI0011_0.jpg

Yeah I know its messy - but it's a prototype :P

Circuit Diagram

speed_controller6.jpg

 

I did not reach 100% duty cycle - but I think I should be able to get it when I have lower resistor values.

 

Here are some of the results:

d0 high - 330 ohms

DSCI0024.jpg

d0 & d1 high 165 ohms

DSCI0023_0.jpg

all on 55 ohms

DSCI0019.jpg

 

TODO:

1. find other resistor values beside 330 so I can get 100% duty cycle when all inputs are high
2. connect the input to one of the large drive motors on loki
3. work on the web interface motor module to accept a speed value

 

UPDATE 20081008

DRAT DRAT DRAT DRAT DRAT ! I connected the large motors to the speed controller and all was working fairly well. With 7 speed control positions using 6 x 330 ohm resistors. When all the DIO ports were off there was still an irratating noise of the PWM. I wanted to see if I could turn this off completely. Unfortunately, I continued to experiment with the large motors - when I was going through a sequence of turning 100% duty cycle off, the H-bridge fried. And it looks like this time it took the computer with it. Yes, I know I should have them completely electrically isolated with opto-couplers, but I wanted to have the computers battery charged by the wheelchair charger. It was my intention to have a relay in the system which would connect the two power systems together only when charging... but now I will suffer for charging ahead.. DRAT! I have not yet assesed all the damage, the computer does not boot, I'm hoping i can re-initialize the bios - or at the least the CPU or memory is still good. Did is say DRAT?

 

Nuke.jpg

 

Lessons Learned

1. ISOLATE THE CONTROL ELECTRONICS FROM THE POWER SYSTEM (EXPECIALLY HIGH CURRENT SYSTEMS)
DUH ! I know this - now I should actually DO IT ! I'll probably be using the DIO card (if its not fried too) and this will be a bit of a pain to create 96 opto couplers for it - but I'll do it to save the computer.

2. The H-bridges I'm using I believe are not heavy duty enough - they are supposed to have current protection - but I think they are a bit underbuilt for the wheelchair - I will be looking into options of geting or building a larger H-bridge that can handle 80 amps - the spike of dropping the speed from 100% down to a lower value seems to be frying it.

Crap, back to the drawing board. :P

 

Digital potentiometer?

There is a chip called a digital pot, in several flavors that can be “talked to” differently. Analog Devices has a digital pot selection, and I think the AD5220 is closest to the implementation you have above, but giving 128 steps. Cost is about $2 or possible “sample rates”.

I believe there are also some PWM chips (L297 to go with the L298, others) too, but not sure what your application is.

I’m curious why you are generating PWM this way, rather than programming a micro to do it?

not a fan of the ZX115

Go for it Grog! First make it work, then make it work elegantly. For varying interpretations of elegant.

I have a question about the design. The only diff between the pot-design and the counter-design seems to be in the Diode/Diode/Pot (DDP) circuit in the top left of the first diagram. You propose to replace the DDP by some sort of DA convertor made of the counter, 6 transistors with matching (pull down) resistors (CTR6).

I (think I) can see how the CTR6 might replace a pot, but how is it replacing two countering diodes?

Thanks robologist! I

Thanks robologist! I vaguely remember BOA mention something of the sorts in a different context. Yes, that seems just the ticket. I’ll look into the PWM chips too.

Glad you asked, my project already has a computer - the computer has a PCI-DIO-96 to control 96 digital lines. Controlling the large motors digitally has been a challenge. In the process i realized that i need a large range for speed control (the thing is wicked fast @100% duty). First, I tried PWM from the computer, but it was not very satisfactory - it was pretty jerky - it might have been the way i hooked it all up but i think the computer was getting interrupted to do other processing. Even if it was smooth, it seemed a poor use of resources, i dont want it tied up sending a constant stream of signal to a motor, it’s going to be busy with other things like vision.

I’ve never had a microcontroller, but after watching this site, i’ve come to the conclusion that it would be fun. in the future of my project i could see the possibility of adding a micro-controller connected to the computer… kind of like your cerebellum & cerebrum talking to one another :stuck_out_tongue: the micro-controller could be in charge of managing a funtionally related set of IO, but at the moment it seems a bit overblown to do speed control - and a bit pricey…

i’ll keep working on this circuit - thanks for the info - i like that the up/down is symmetric on the digital pot.

thanks for the support rik!

thanks for the support rik! - good rule to follow - although my concept of elegant needs alot of interpretation, more like make it work or watch the smoke :slight_smile:

Good catch! - i was just trying to digitize the pot - i was hoping to rip it all out (refactor?) but the diode & diode of the DDP seems to be critical - so now i’ll wire it this way…

speed_controller3.jpg

 

It seems to work(ish), although i don't have the mc14040b wired in yet - just testing it with a bunch of resistors .... kindof irratating noise :P - but the 555 seems to have an operating range there

What a marooon, as bugs

What a marooon, as bugs bunny would say … the answer (or at least an answer) was staring me in the face - i’ve got 96 bits of control, about time i start using them… just use 6 bits from it and turn the resistor bridge off or on in any sequence. I think i might be in the habit of trying to conserve data ports…

speed_controller4.jpg

i’ll keep updating this with my progress - thanks for the ideas.

Possible micro

Something like an Atmel Tiny2313 could take the place of both the 555 and digital pot, and has 4 lines of PWM available if needed. It could be signaled with 1 wire or 4 wires or however you chose, from the PCI-DIO-96 card you have. I’ve wired up a predecessor of this (90S2313) on a small board that was around $8 of parts at the time (maybe $11 now) including the 2313. Programming would involve a little bit of learning, but shouldn’t be too bad.

In more complex robots, I’d always hoped to have a fairly capable micro for low level real time requirements, with an upper PC based brain that handled tasks like vision (object recog, ranging, navigation), speech recognition, and overall task planning. I’d estimated it would command and receive data from the micro, that handled PWM, odometry, analog sensor data, timer sensor data, and any other tasks that required direct attention and constant updates in a real time sense. Each device to it’s own specialty, essentially.

 

I just read the Fine Manuals.

And I now understand better what a 555 pwm generator is.

Please redraw your circuit. I did it on a piece of paper. Just focus on the R/C oscilator.

Pin 9 [output] intermittently acts as a source (charging C1) and as a sink (discharging C1). That’s why there are two diodes. In your first diagram D1 (right hand) brings the current from a sourcing [output] to C1. D2 (not numbered, but on left hand) does the opposite: takes current from C1 sinking it into [output].

The state of [output] switches each time either:
- [trigger] falls below 1/3 VCC or
- [threshold] rises above 2/3 VCC.

Pot R1 is acting as a combo of two resistors. The charging current goes through the right hand side. The discharging current through the left hand side. But always connected throug the middle hand to [output]. Alas, not in your latest diagram (Bugs Bunny version). The diodes and amputated pot act as an electronics cul-de-sac, a dead end! The only possible source/sink for C1 remaining are [trigger] and [threshold].

alternative (warning: very complicated)

Check out the diagrams I drew on my whiteboard. The top circuit is the DDR part of the oscilator as proposed by the walkthrough you mentioned.

Note, I may have swapped the numbers on the diodes compared to your circuits. Capacitor C1 is again charged by a current sourced from [output] on the 555. When the timer reverses its action, C1 gets discharged through the sinking [output]. As discussed. I indicated these currents in red. Let's assume a 8% percent duty cycle. Maybe it's 92%. I don't really care what you're doing with the drain of the 555.

The second diagram might be (I am really unsure!) a replacement for the DDR circuit. The digital pins from your computer are represented as b0 - b5, with b0 being the least significant bit. The horizontal line above a bitname indicates the inverse of that bit. As if a invertor was placed in series. I left out all the wiring to the actual digital ports.

Let's again assume a duty cycle of 8% or in this binary case: 5/63th. Decimal 5 reads as 101 in binary. We are talking 6 bit words, so that makes 000101. The inverse of that is used for the second part of the "pot". Calculate the inverse on your computer as 63 - 5 = 48. Or actually use six invertors on an IC. Or think up a smarter transistor setup that inverts the meaning of the bits. Or maybe I already designed such setup, and I am not smart enough to realise that.

The resistors are reminiscent of a R/2R ladder. But this ladder is not converting a binary word into a voltage. We are trying to produce a resistance. I am not sure you should have the vertical resistors at twice the the value of the horizontal ones (as in a traditional R/2R ladder). Maybe the other way around, maybe same values all around, maybe it makes no big difference.

I hope this circuit works like this. The binary 000101 will activate transistors b0 and b2 in the upper part (replacing D1). At the same time the corresponding transistors in the lower part are blocking. The remaining transistor pairs b5, b4, b3, b1 behave the other way around (is that artsy-speak for inverted?).

The effective resistance of the resulting combination in the upper half would be

maroontje.jpg



Experiments will have to show if that’s really 5/63th of ehhmm, something. I don’t even know what 0% or 100% should look like. Maybe I should cut a resistor or two, maybe add a resistorless transistor, or diode? Bugs would know, or Mathew maybe…

8ik

you got it robologist !

you got it robologist ! i started a little experimenting with RTT but i believe trying to process video and handle mapping and motor control might be a bit much for one computer - again, i’m pretty ignorant of micro-controllers, but everyone here seems to be having great fun with them. i imagine i could turn a computer into a extremely capable “microcontroller” with RTT, but i thought i could get on by adding just a few discreet circuits. (funny how you can’t even get a 500 Mhz computer on ebay any more - not worth the shipping)

you would recommend the Atmel Tiny2313 because of 4 PWM lines and personal experience? Is it a microcontroller without a bootloader? - most here seem familiar with PicAx, Arduino and such.

Thanks for the walk through!

Thanks for the walk through!

uh … wow … very high geek points for having your own white-board, I had one too but had to get rid of it when someone (me) wrote on it with a permanent pen… your whiteboard has a nipple?

In regards to my diagram - your right again!

Here is what I plan to do - i’ve tested it without the transistors, just several different resistor combinations and it behaves as I would (more or less) expect it too. The more resistors attached to the circuit the lower the resistance the faster the motor turns. I will look at R/2R ladders and see how it might behave vs the simple resistor bridge. Thanks again for all the info. I’ll keep updating this post as I make progress.

speed_controller5.jpg

test without transistors?

That means without the NI-DIO as well, right? Just a manual jumping of wires?

I still doubt if you will get full range 0% - 100% duty cycles with your setup. But then, I am not too sure about mine.

8ik

correct - i did a test with

correct - i did a test with 3 1K resistors and just jumped them together and individually - I also have to find a real 100K to go across at the top of the diode because, i was in a hurry and just stuck in a 30K (it was nearby) - maybe i’ll leave the pot in since it has 100K on one side and use it to manually adjust the whole thing before the DIO gets to it…

next experiment would be to attach the transistors

after that would be to wire in the DIO

you’re probably right about the limited range - i don’t think i got that even with the POT - it made a noise when it was all the way off (not quite 0% duty) and i could tell based on speed that it was not 100% when turned all the way.

I’ll keep this forum entry posted with my progress.

Thanks for your input Rik !

Micros

The Tiny2313 is one of the smaller micros, that would be suited to a few tasks. It is capable of more than your current requirements. And I’ve only done a simple “Hello World” program on a similar AVR. There are some devices that use similar small devices to serve up data to others, like the many sonar rangers out there. I had a small programmer that consisted of a number of resistors on lines to the parallel port for mine, no bootloader, though those can be had for the device. In this case, the programmer was so simple, a bootloader wasn’t really needed.

The Arduino uses another micro of the AVR family, a bigger brother essentially, but with a bootloader.

graag gedaan

You’re welcome. I enjoy this experimenting by proxy :wink:

Thanks for the info

Thanks for the info robologist,

I’ll look into the details. Your suggestion is helpful. I’ve definately would be interested in integration of micros in the future - seem much faster than building circuits from scratch. This time, however, I’ll be making the circuit since i have parts near by… and i hate waiting…

hi Rik!yeah - the pictures

hi Rik!

yeah - the pictures aren’t that great - (trying to find out how to use this cheap digital camera) - anyway, the top level of each picture is 5V the bottom 0V. With that in mind, you can see that there is a change with a higher percentage of the line in the 5V level depending on how many DIO lines are set high.

heh, yeah i think i can manage a 0 ohm resistor, i use them more often than i should (too many unintentional shorts) :stuck_out_tongue:

At the moment ALL the resistors are 330 so (d0 and d1) combine to be 1/(1/330 + 1/330) = 165 ohm

I think i now understand a little more about the R/R2 ladders - one purpose being cheap and easy in that they only require 2 resistor values. I have several different resistors, so I’ll probably use several different values instead of creating the r2 bridge. I think that different motor characteristics will required different effective values, for example the motor i am testing with now does not actually move until d0 d1 & d2 are on…

Since the large motors are more important to me - this will be my next focus…

I’ll keep you posted.

GroG

pics in scope

Just to be sure: I was not knocking your equipment. I envy the scope. The ripple was a dig at your nipple comment earlier.

[note to self: more emoticons you stupid]

:sunglasses:

About those resistor values: I get it now. I was under the false impression that you improvised a series of values. Never understood the weird values in that series until now.

What was not clear from your update is that the machine is now depending on the number of DIO lines set high at the same time. Not on which ones. Reducing your resolution to 1+6=7 distinct values, rather than 2^6=64 values.

Good plan to customize your resistor values to something you actually need. There is no need for fine resolution between 0 and , say, 15% when the motors will not respond to any of those values. The same might be true for the 85%-100% range.

Did you notice on the scope that your cycle length (period) gets longer as you decrease the resistance over your "digital pot"? That is probably a result from your design which does not control the "complement value" in you analogue pot R1. That one is still fixed (at 100k?).

 

so sorry

Sorry to read about your smoke. I sympathize.

8-(

Thanks Rik,Oh well , if your

Thanks Rik,

Oh well , if your not breaking anything - your not learning :stuck_out_tongue: I’ll probably not have alot of updates now, but maybe a better understanding of it all in a couple weeks. Thanks for you help & interest.

over and out for now,

GroG