Let's Make Robots!

Explain PWM to me, please.

I just need a good breakdown. The eventual goal is to obtain higher (or much higher) torque from my motors but at lower speeds. I am to beleive that PWM makes slower motors but also weak motors. I need strong, slow motors.

So we got duty cycle and frequency, I got that, sorta. Duty is just simple on and off, at 50% it will be on for 1/2 the time and off for the other 1/2. Frequency is uhh, I dunno. Let's say we are running at 1000hz (I know regular PWM freqs. are much higher) -so something loops around 1000 times a second. I got that. Now, it seems to me that you got yourself a loop inside of a loop. Or at least you have one loop and another telling it how fast to loop.

1st --Tell me if I am right or wrong or whatever you got

2nd --Back to the first question: Slow speed, high torque. I figure I can hook up a measure-thingie and look around for how many amps are cruising through --More current, at a given speed should mean more torque, right? -- Or is this just a measurement of inefficiency? At any rate, I would love it if someone could explain how these two numbers relate and how each could/should be adjusted?

Word to ya' motha!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
The pot, adc and pwm are just to adjust the speed for the test. The actual power coming from the generator is measured with the multi-meter. The LCD displays what the pot is set at and what PWM freq. we are at. I don't think I would want to sync the motors on the fly... I am just syncing the motors for it's single-speed slow. I.e when in auto mode, I want this going straight down the hallway --When in R/C, I don't mind if they are a little off.

You all got to the real root of the problem here... higher or lower freq. --and thus, again, the limits of picaxes. I appreciate everyone's help. I have been big into the experimentation lately as I want to get all of Walter's "sub-systems" 100% before I start sticking them all back together. I have already found the greatest way in the world to sync my wheel speeds, now just some playing with your suggestions on getting some torque. Thanks again

By the way,

I tried to use my encoders as speedometers using the count command but alas, did not get clean enough data. However, and this is the greatest way to do this I think... I simply put walter up on blocks so his wheels could turn freely and attached his PWM to an ADC and a pot. Turn the pot, regulate the speed with this number showing up on my LCD. Next, I took a simple motor (no gearing, just a little motor) and attached a small wheel. Hooked up the ol' measure thingie to the motor and stuck the motor's wheel up against walter's wheel. I got's me a lil' gen'rater here, folks! Wheel goes faster, motor generates more juice, multi-meter shows more volts. Boom, same amount of power comming from each wheel --same speed. Done.

One generator on each wheel, right? Two ADC inputs? A clever voltage comparator would feed only the difference (positive or negative) into an ADC. Delegating the "if b1 > b2" to the hardware.

Would be a pain to calibrate (in hardware), but that is just one programmer's opinion.

Hi Chris

Dont know if this is any help (it certainly doesn't answer your question), but I use a dedicated picaxe (08M) to drive 2 motors at 250Hz or 500Hz. Explanation and source code can be found here (08M dual software PWM)

I assume you are using the picaxe PWM outputs to drive your motors now. If so I have posted a simple circuit that you can try here: http://letsmakerobots.com/node/17095

It will allow you to drive your motors at lower frequecies of your choice.

Ok, it seems like you're mostly on track CtC. Just to clarify, 1000Hz means 100 cycles per second, where one PWM cycle involes the motors being turned both on and off. 1000 cycles per second is the same as 1/1000th of a second per cycle, so each on and off action lasts for 1/1000 = 0.001s before repeating itself; this duration is called the period.
The duty cycle is the percentage of that period that the power is on for - 50% duty at 1000Hz is therefore 50% of 0.001s, which is 0.0005s. The off time must make up the other half, so in total we have 0.0005s of power on, followed by 0.0005s of power off, and then the power comes back on again.

Normally you choose a PWM frequency that suits your controller, driver, and motor comfortably. Once that's sorted you very rarely want to change it, you just change the duty as voodoo mentioned. Since the driver is going from supplying full-power to zero-power throughout the cycle, the motor is also going from full-torque to zero-torque. At a very low PWM frequency the motor would shudder along poorly, so higher frequencies are chosen to smooth out motor performance. Also, frequencies above 20kHz are common as these are too high for human ears to hear. Once a suitable PWM frequency is established, the average motor torque is essentially a percentage of the maximum torque based on the duty cycle - 50% duty means 50% torque.

As far as relating the current to torque goes... it gets kinda complicated. I'd suggest instead simply monitoring your speed and adjusting the duty cycle up or down until you get the speed you want. If you want a slow speed, no problem, just keep dailing up the duty until you have enough torque to travel at that speed. If the load on the motor decreases (favourable terrain? downhill slope?) then the change in speed will be detected by the sensors, and the duty cycle gets cut back, since you now need less torque to move at the desired speed.

Although I understand that higher frequencies give smoother performance I always find when using a picaxe to drive a motor that these frequencies provided very poor torque at low RPM. I believe this is due to the inductive reactance increasing and limiting the overall power.

I found that the best frequency for my motors was between 100Hz and 200Hz. (typical hobby servos work at about 100Hz).

Due to the sharp square wave transitions common in PWM, inductive reactance should be constant regardless of PWM frequency, however the reactance 'cooldown' period would definitely consume a larger portion of the PWM cycle's on time, reducing the amount of power able to be delivered to the motor. I haven't personally run into any problem with PWM up to 20kHz, but fortunately it's easy to adjust the PWM fequency in software.

Unfortunately it is not easy to change the frequency much in software with the picaxe. The PWM commands have a limited frequency range and cannot got lower than your clock frequency/1024. With a 4Mhz clock you won't get much lower than 4KHz.

Using basic to generate the PWM is too slow. I used this technique with my 6WD demo videos. Using a 20X2 at 64MHz I could only get about 190Hz with steps of 20% or 95Hz with 10% steps.

CTC may be better off with a dedicated PWM generator that is serial controlled.

Hmmm, a discrete PWM generator is definitely starting to sound like a good idea. You can't use a timer-based interrupt routine on a PICAXE can you?