AT90PWM3 : PWM with ADC synchronization

Hello !

I have a little problem here... let me explain.

I want to extract maximum power from a small alternator, which gives

10-30V AC at 20-100 Hz depending on conditions. To do this, and get a DC voltage that doesn't vary too widely with RPM, I'll match the load to the alternator. I've got a H-bridge with the alternator at the center, a bidirectional current sense (AD8210) in the VCC rail, and PWM to adjust the voltage on the alternator. I've decided to sense the current in the Vcc rail of the H-Bridge to also permits detection of short to ground of one of the load wires. Since the internal inductance is more than 100 mH, and AC frequency between 20 and 100 Hz, PWM frequency doesn't need to ve very high.

It is, in fact, similar to motor control, but instead of trying to set motor speed, it is imposed. Same circuit, different software.

The control algorithm is : compute optimal load impedance given conditions (RPM, etc), sample current avd Vcc, set voltage on alternator using PWM.

Now here is where the interesting stuff starts : the load is AC-driven, it is inductive, and I want the DC current in the load to be as small as possible, because DC current is lost power, and at high doses, might saturate the core.

So, what I want to do is sample the current twice per PWM period :

- when the H-bridge connects the alternator "+" to Vcc and "-" to ground

- when the H-bridge connects the alternator "-" to Vcc and "+" to ground

So, at each PWM period, I'll get two current samples, in opposite directions (+i and -i), each having the same offset from current sense amp and ADC. Averaging will easily give the DC offset, and inverting every other measurement gives the instantaneous current for the control system.

Now, I'd like to use an AT90PWM3 for this ; I'm not religiously attached to this chip, but I like the PSC (power stage controller) peripherals, which nicely interface to the on-chip comparators, very useful for short circuit protection. Also, I can use the other PSC's for the battery charger, etc.

But the datasheet is not very clear on the ADC synchronization... I'd like to sample the current twice in each PWM period, and it looks like the hardware only supports doing this once per period...

If any of you have experience with this chip, help is welcome !

(Or I could use another uC, provided it can do that...)

Regards, Pierre

Reply to
PFC
Loading thread data ...

Il 18/09/2010 10:57, PFC ha scritto:

Take a look at RM0008 STM32 Reference Manual

formatting link
, pg 216). It can start ADC conversion on external interrupt or also after a fixed time after an external event.

L
Reply to
ded1549REMOVEME

WTF, you can get an ARM for $3 ? I'll take note of this for future projects. Are there some cheap programmers ?

Anyway, I had a quick look at the datasheet, and it doesn't seem this uC fits my application...

In the AT90PWM3, each PSC-PWM unit plugs has its own analog comparator which can directly influence the outputs. You can set the comparator thresholds in software and tell it what to do, like latching overcurrent protection, etc, without interrupt delay since it's hardware. I really like that, since I'll be using these to PWM some loads, implement a battery charger etc, using the on-chip stuff saves me 4 comparators + latches + a few passives and really simplifies the design...

I don't need a powerful CPU (8 bit is alright). I know there are dsPIC with similar peripherals, looking good until I read the very long and scary silicon errata.

I guess I'll have to make a proto, then ;)

Reply to
PFC

Il 18/09/2010 23:03, PFC ha scritto:

I think this family starts from 2$ or a bit less (I'm italian, so I don't know how much does it cost in $). If you are new to ARM world, I suggest you to buy a Keil evaluation board + ULINK jtag dongle. It's not the cheapest system, but in my opinion it has the best performance/cost. I bought one MCBSTM32UME for about 150$. If you want the cheapest devel system, you can use gnu and a wiggler interface.

I have never used this part; I suggested you the STM32 because you asked for an ADC which sampling is related to some external events. Normally I do these stuffs in software.

I used Microchip a lot. Nowadays an arm cortex M3 costs like an 8 bit micro so, except for very specific system, I use arm only.

Bye!

L
Reply to
ded1549REMOVEME

Answering my own question (now that I have an AT90PWM3B protoboard on my desk...)

- ADC synchronization with PSC peripherals isn't difficult, but you got to carefully calculate the ADC synchronization tick, since the ADC sampling only starts a few ADC clocks after said tick, and remember the little note in the datasheet that says you got to use PLL clock for the CPU core.

- It is not possible to see the instant of ADC sampling on the scope (you get an interrupt when the result is ready though)

- It is not possible to sample twice in each PWM cycle (as I wanted to do), however since it is possible to sample at any instant in the PWM cycle, just using two adjacent cycles solves the problem.

Reply to
PFC

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.