Synchronizing ADC conversion with PWM?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Synchronizing ADC conversion with PWM?

504 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by apullin on Sun Jan 17 16:55:38 MST 2016
Hi folks,

Is there a way with the LPC17xx to sync or trigger an ADC sample & conversion from the start of the PWM period? Or end or the period, or the low-transition.

The application is to the speed control of a brushed DC motor. The ADC will sense the back EMF of the motor, ideally in the last 5% or so of the PWM period, and then PWM just gets limited to 95% maximum.

I am looking at the User Manual, and nothing it jumping out at me, but I am not familiar with LPC peripherals. I have previously implemented this on a dsPIC, but it has hardware support specially for this operation, where there is a "Special Event" counter triggered by the start of the PWM period, clocked by the PWM clock, and the expiration of that count can be used to initiate the ADC samp&conv.

It occurs to me that I could do this by using a timer with match registers to set period & duty cycle (output pins or interrupt + software GPIO), and then a third match register w/ interrupt to start the ADC with a software write.

Does that make sense?
Since I need 4x PWM w/ equal period, that should be doable with just 2x timers.

If there is a more clever or elegant way to put that together with functionality already existing in the LPC17xx peripherals that I have missed, please let me know!
Labels (1)
0 Kudos
2 Replies

401 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by apullin on Mon Jan 18 18:09:05 MST 2016
Hrm, OK, after looking over the MCPWM section, it doesn't look like exactly the functionality I am looking for there exists. But, it does look like the ADC can be triggered from MAT0.3. So I'll have to use two of the four timers, both set with the same Limit values. But if I am understanding correctly, I'll able to do it entirely in peripherals then, as long as the right MATX.Y pins are available.

If some LPC expert wanted to think that plan over and verify that it sounds reasonable, that would be very helpful!

The QEI interface is useful, and the mbed project has even written a nice module for it that makes it "just work". But, for this project, we are trying to do an average speed control of a plain DC motor without having to add a shaft encoder.
0 Kudos

401 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MikeSimmonds on Sun Jan 17 17:50:52 MST 2016
I have not used it myself, but I believe that there is a motor control specific PWM on the 17xx series.
Checked -- chapter 25 in UM10360 for 176x and chapter 27 in UM10470 for 177x/178x.

And ISTR that there are app notes also.

Presumably, if you are controlling a motor, these are better than the general purpose PWM peripherals.

EDIT: There is also a QEI (quadrature encoder interface) which I would guess gives feedback from a
motor or other rotary device.

Cheers, Mike.
0 Kudos