cancel
Showing results for 
Search instead for 
Did you mean: 

RC PWM output 8ch

jdpv
Associate II
Posted on March 16, 2015 at 13:53

hi,

i'm trying to generate 8 pwm signals with different phase shift and different and independent pulse width.

As far as i understood the toggle mode won't let you change the pulse of each signal independetly. I've been looking through the examples but i didn't get anything clear from them.

Can this be donde by hw or do i need to do it by sw?

An image of what i want to achieved.

http://www.tkjelectronics.dk/uploads/ReceiverSum.png

#rc #stm32f4 #pwm #phaseshift
6 REPLIES 6
Posted on March 16, 2015 at 13:59

If you're driving servos why do you need a phase shift?

Toggle mode can be used independently on all four channels of a timer.

If you want the final combined signal, just create THAT, with a single channel/output

http://www.tkjelectronics.dk/uploads/ReceiverSum.png

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jdpv
Associate II
Posted on March 16, 2015 at 14:31

Hi clive1,

That image was just an example. I'm not using servos. The signals are meant to go to a flight controller of a quadrotor. All the RC receivers i've seen with the oscilloscope have a phase delay in each signal. That's what i'm trying to simulate.

Posted on March 16, 2015 at 16:27

Probably because the RC data signal is serial in nature, and the signals start as each is decoded.

Ok, so if you have a singular signal, with a defined periodicity for the repeating pattern, then use a single timer channel in toggle, define the period and sequence the mark/space offsets into the compare register, and feed that table via DMA at the CCx trigger.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jdpv
Associate II
Posted on March 16, 2015 at 18:46

Maybe i'm not understanding you but what is the channel in toggle mode for?

I could use 8 different timers to generate the signals and start them with a sw delay. The delay is constant. But i see it as a waste of resources.

Let's say i undertood your procedure.

- Write a table with 8 different values (delays)

- Configure a 2x50Hz timers (4 channel each)

- Configure channels as PWM? or toggle?

- Configure each channel to be triggered with a value of the  DMA table

Am i wrong?
Posted on March 16, 2015 at 19:57

One would want to consider Toggle mode because each timer has a SINGLE counting element. You can't place the rising edge of the PWM output you want just anywhere.

If you wanted 50 Hz phase aligned PWM, you'd use PWM mode, 4 channels per timer.

If you wanted the single OR'd signal in the diagram you cited, you'd use the DMA method I outlined.

For the method you want, you'd be better doing it with CCx interrupts on each channel. There may be some multi-channel DMA methods for the TIM, but I haven't dug into them.

The phase shift could be to stop all the servos moving at the same time? I'd guess you'd need to determine if it is actually necessary, of if you're creating a complication that doesn't exist.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jdpv
Associate II
Posted on March 16, 2015 at 21:35

Thank you clive, 

i'll try the CCx interrupts.

I guess the RC signals are delayed so they can be read with the input/capture feature. Otherwise all the interruptions would jump at the same time making it impossible to get the width of the pulse.