Go Down

Topic: Controlling an animatronics bust (Read 5 times) previous topic - next topic


74HC595s is going to be the winner. I even think I have some!


So it is established that there are many advantages to using the 74HC595 for my project. However, thinking this through using them with the analog PWM on the OE line would result in the same duty cycle going to all motors enabled at the same time. While trying to wrap my head around it, I see that what I need to do is have a timer going on 8ms ticks that triggers the 74HC595 routine. Then every 1ms, I need to update the 74HC595 with the pins that will be enabled for that 1ms. So, really I am back at software PWM, right? Or.... do I need to make my PWM 1Khz (every 1ms) and adjust my individual pins every 1ms?

Either way, I can see that I will need to pulse the OE line every 1ms and update my pins in between. I can't see any other way. The reason is because one motor may be running for 800ms before it reaches it's postion, while in that time the smaller movements will require other duty cycles as they are reaching their own positions. I've got the general idea in my head, so I'll get it eventually, just wondered if someone already knows the solution.


While waiting for my shift registers to arrive, I have started working on getting just one motor working reliably using the PID library and PWM. What I have learned is that the H-Bridges just do not respond well to PWM at all. They will not move at all until you reach a PWM of around 60. But this is not linear. Once they are moving, you can decrease the PWM down to about 38 before they stop running again. The speed changes very rapidly above 60, but then very very slowly towards 255.

I think this is why I cannot seem to get the PID library to work. It cannot control the speed as it approaches zero error. However, it seems to just quit trying and leaves the motor position far off the mark. (the motors will whine if a PWM above 0 is commanded to it) The motors do not whine. They act as if they have reached their position.

Unfortunately, I think I am going to have to devise a completely custom system. I will continue to focus on one motor to develop a solution that works before worrying about integrating all 10 motors at the same time.


Feb 11, 2013, 04:49 pm Last Edit: Feb 11, 2013, 04:57 pm by laadams85 Reason: 1
You may have to try to work with the voltage somehow.  At the same PWM the motor with go faster or slower if you increase or decrease the voltage.  I'm not even really sure how you would get that to work electronically but it's an idea.

Edit: This may or may not be correct, probably not.  Motors aren't my specialty.


I could add an offset to the error output to scale it up to a minimum, but not sure how I will deal with zero then. I am going to play around with gains some more tonight. I read some more today and I *think* that playing with the integral gains might help. However, the fact that it is not linear (meaning once it is moving, it can take a lower PWM than if it is still) is going to pose some issues, I think.

I think the original application got around this by using a slower PWM frequency. 1ms (12.5% duty cycle) is the minimum pulse width used. At 9V, that would mean the motor would see an average voltage of 1.125V. I doubt the motors really move at that low of a voltage... but it only uses that voltage as it approaches zero error, so it was moving to being with. From the signals I looked at, it seems to always start out at full speed and only adjusts as it is reaching the setpoint.

A 12.5% duty cycle with the analogWrite values is 31. The motor does not move at an analogWrite value of 31. I imagine that has to do with the responsiveness of the H-Bridge. Using the default PWM frequency (490hz on pins 3,9,10,11), the motor output is high only for 250us at 12.5%. At 50% duty cycle, I get 1ms which is the lowest the original PWM uses. I assume that this is why it begins to turn on around that point. The highest it would ever be is 2ms for 100% duty cycle. The original application goes up to 8ms.

You can change the PWM frequency, but it will affect the timers used by other functions. BTW, pins 5 and 6 are twice as fast at 980hz.

In the end, I think I am going to just have to come up with a software PWM method.

Go Up