PWM Controlled by ADC conversion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-08-23 3:02 AM
PWM Controlled by ADC conversion
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:03 AM
Any one have developed something similar? Or I´m so confused that it cant´be done? I think that is possible to define the PWM signal after the ADC conversion finishes. I´ll almost try it, because my job depends on it hahaha.
I´ll post my result here of course :)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:03 AM
ADC done -> ISR -> do whatever to PWM -> restart ADC -> exit ISR.
Timing: 12 clocks from ADC done to ISR. Perhaps another dozen to PWM change. At a 72 MHz processor clock this 0.33 microseconds delay. I would write the ISR in assembly, but that’s just me. Expect longer times using the STM32 library. Or do I not understand what you need to do?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:03 AM
Hello PicGuy:
Thkas for reply. What I want to do is: 1.- Init 20KHz ADC conversion 2.- Wait ADC conversion Time (1uS in my project) 3.- Launch the TIM1 PWM with 20KHz 4.- Make another ADC conversion That is what I want to do. An Image is better than one thousand of words.Some Engineer of my departament says that the EOC(End of conversion ADC flag) must enter into a ISR, that is which must launch the PWM. He?s said me that it will be transparent for me with TIM1 Advanced Control Timer only I?ve to do is configure it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:03 AM
suggestion??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:03 AM
I would make it a bit differently.
1 - Activate a PWM and make it generate a periodic interrupt on the timer overflow. 2 - From the PWM ISR start the ADC conversion. 3 - On the ADC end-of-conversion interrupt, read the result and change the PWM duty cycle, stop the ADC. PWM and ADC conversion would happen at the same time and not sequentially because the ADC conversion time is much shorter than the PWM cycle time. Giovanni --- ChibiOS/RT - http://chibios.sourceforge.net- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:03 AM
Hi giovanni:
I will do like you say. Do you have code to do it? I´m newbie in STM32 and I am not enough good yet to program it. Thanks anyways- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:03 AM
Hi Gerardo,
You may look at the project in my signature, incidentally it has an ADC and PWM drivers (and others) for STM32. Probably an RTOS is too much for that simple application but you could give a look at the device drivers implementation and take some code there. Probably I will add a demo that does exactly that when I will have some time, it should be a good example but I can't make promises on when. Giovanni --- ChibiOS/RT - http://chibios.sourceforge.net- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:03 AM
Woow Giovanni.
It would be fantastic to see this work done. I will check your web. When I have finished this i will mail you to give my advances. Thks