EE people: Do PWM timings need to be exact?

Status
Not open for further replies.

Leros

Lifer
Jul 11, 2004
21,867
7
81
I'm trying to drive an RC motor controller from a microcontroller instead of an RC receiver. The protocol between them is 50Hz PWM.

I messed around with various PWM scalers and I got a combination which gives me 50.08 Hz. Is that good enough?
 
Last edited:

Born2bwire

Diamond Member
Oct 28, 2005
9,840
6
71
I did that once, and then this happened.

2042c.jpg


Never again.

If the PWM is the base signal used to drive the motor I doubt you will have any problems. One of the advantages of using the microcontroller should be the ability to add a feedback loop too, that would definitely solve any drift problems. But I assume that the PWM is not being used as a timing signal, just the drive signal so it shouldn't be a problem.
 
Last edited:

Leros

Lifer
Jul 11, 2004
21,867
7
81
If the PWM is the base signal used to drive the motor I doubt you will have any problems. One of the advantages of using the microcontroller should be the ability to add a feedback loop too, that would definitely solve any drift problems. But I assume that the PWM is not being used as a timing signal, just the drive signal so it shouldn't be a problem.

The PWM is a timing signal. It just tells the motor controller what to do.

50Hz = 20ms periods
1.0ms pulse = full reverse
1.5ms pulse = stopped
2.0ms pulse = full forward
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
I think its just the length of the pulse, I'm not sure the timing is that huge of an issue. I guess I'll find out soon enough.

I don't have a oscilloscope at home which makes this a bit harder.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Not getting an exact 50Hz makes it hard to get a pulse period of 1.5ms (stopped).

I set the motor controller to exponential mode (as opposed to linear mode). This soften control in between forward and reverse, so I can stop it without an exact 1.5ms pulse. I just now have to calibrate for the exponential speed curve.

Note: I bet there is at least 1 guy who reads this and finds it interesting. I realize most of you don't care.
 

Born2bwire

Diamond Member
Oct 28, 2005
9,840
6
71
Ahhh, I thought you were controlling the speed of the moter by driving it with a PWM signal, the 50 Hz being the basic signal that is used. What is wrong with using say a 1000 Hz PWM and just adjusting the duty cycle as a function of number of pulse counts? It sounds like it should be the same as what you are currently doing but the rise and fall of the pulse will have tighter restrictions on it than a slower 50 Hz pulse.
 
Last edited:

Leros

Lifer
Jul 11, 2004
21,867
7
81
Ahhh, I thought you were controlling the speed of the moter by driving it with a PWM signal, the 50 Hz being the basic signal that is used. What is wrong with using say a 1000 Hz PWM and just adjusting the duty cycle as a function of number of pulse counts? It sounds like it should be the same as what you are currently doing but the rise and fall of the pulse will have tighter restrictions on it than a slower 50 Hz pulse.

That would work, but adds a little bit of complexity. And I'm in a frantic rushing mode right now.

Also it seems to be ok. I don't have fine grained speed control. I only get 4 speeds, but that should be sufficient.
 
Last edited:
Status
Not open for further replies.