Correct, in my brief experience.Somebody wrote a while ago that it is not so critical as the duty cycle is most important,
It feels like that is an issue. How do I go about turning down the PWM clock?Try turning the PWM clock frequency down.
The servo has extra logic so that the duty cycle directly translates into a 0-180 degree position. Thus, a single PWM could potentially move the device 180 degrees.Oh, I think servos still need a continuous waveform. A single pulse will not work.
in setup_pwm read the commentchris.meyers.fsu wrote:.....
It feels like that is an issue. How do I go about turning down the PWM clock?
Sorry to go digging up an ageing post but could you elaborate on that? I'm trying to better understand the PWM functionality.Gert van Loo wrote: You have 12 bits so the maximum is 0xFFF which gives 4688 Hz.
But then you have the PWM count limit as well so if you set that to e.g. 2047 you get a frequency of 2.2 Hz.
(Not 100% sure about the last statement, I have to check that tomorrow.)
Sorry but that is not possible. A good PWM signal by definition will have a changing frequency.felixfurtak wrote:Hi Gert,
So in your code it seems that the PWM frequency will change depending on the duty cycle.
Is it possible to keep the PWM frequency the same, regardless of duty cycle?
This would be a preferred implementation for many people.
I have not tested this, but I suspect when the data sheet says "M is the data to be sent", it means the number of bits, not the actual pattern.alanb wrote:I'm thinking the lowest frequency with a 50% duty cycle you could achieve is ~147 Hz with the clock at 4688 Hz in MSEN=1 mode with a range of 64 bits and serial data to transmit being 0xFFFFFFFF. So unless my thinking is wrong this should give a 32 cycles high followed by 32 cycles low wave?
I,m with you Felix - surely the frequency is the same, but its the mark/space ratio that changes with PWM ?felixfurtak wrote:Hi Gert,
Thanks for your reply. I thought PWM had constant frequency by definition. Maybe there are some variants?
I'm not sure I understand why this would be impossible to generate, but thanks for the info.
The problem that I have is that with a changing frequency, the switching losses in my transistors will also increase as the frequency increases, which will reduce linearity of the PWM. I guess, putting a larger clock divider would help.
Ah sorry a frequency of 1/2 makes sense, didn't think that one through properly . I'm actually just attempting to put together a reasonable library for the GPIO pins and I'm trying to cover my bases so I don't leave anything desirable out. I came across this post and it got me thinking of ways to achieve this.Gert van Loo wrote:With 50% duty cycle you will get HALF your clock frequency as the output will toggle every clock.
The 4688Hz clock is if you use the Xtal 19.2MHz as source. If you find a lower source the frequency will also be lower.
I have no idea what all the clocks are which are available during normal operation.
I have never looked into the details of the MSEN=1 mode.
Also if very low frequencies are required you can use SW running from the system timer.
Thanks I wasn't sure if it meant what you suggested or treat the data register as actual data to be sent "serially". Reading over the data sheet again I would be inclined to agree with you here. I think I was combining PWM mode with MSEN=1 and Serialiser mode.jojopi wrote:I have not tested this, but I suspect when the data sheet says "M is the data to be sent", it means the number of bits, not the actual pattern.alanb wrote:I'm thinking the lowest frequency with a 50% duty cycle you could achieve is ~147 Hz with the clock at 4688 Hz in MSEN=1 mode with a range of 64 bits and serial data to transmit being 0xFFFFFFFF. So unless my thinking is wrong this should give a 32 cycles high followed by 32 cycles low wave?
So with MSEN=0, RANGE=8, DATA=3, you get a repeating pattern 00100101, and with MSEN=1, RANGE=8, DATA=3, you get repeating 11100000. To an application that cares only about the long-term average, these are the same output level: 3/8. Incidentally, MSEN=1 is what I would call PWM, and MSEN=0 is really Pulse Density Modulation.
In both cases, the output cycle time does not vary with duty cycle, as long as you adjust the duty cycle by changing DATA only and keeping RANGE constant.
Users browsing this forum: No registered users and 3 guests