How to setup ADC to high part of PWM duty cycle on a HCS08

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to setup ADC to high part of PWM duty cycle on a HCS08

1,212件の閲覧回数
etanner
Contributor I

I have my ADC reading a few different things using the ADC conversion complete interrupt.

 

What I need is to measure at Voltage to the Motor.  A PWM from the MCU is driving a motor control circuit.  How do I ensure I am reading the High part of the PWM duty cycle, While still, periodically read the other analog values on separate analog input channels?

 

Thanks,  

ラベル(1)
0 件の賞賛
返信
1 返信

695件の閲覧回数
bigmac
Specialist III

Hello, and welcome to the forum.

 

One method would be to enable overflow interrupts for the TPM module that generates the PWM signal.  The overflow interrupt would then occur immediately after the PWM signal changed state.  Within the overflow ISR you would start a new ADC reading, and immediately exit the ISR.  Then use the ADC interrupt to read the result in the normal manner.

 

On the other hand, if you required to start the measurement some time after the PWM signal changed state, perhaps to avoid coinciding with a voltage spike or "ringing", you might utilize another output compare channel on the same TPM module.  The channel value setting would determing the amount of delay until the interrupt occurred.  Of course, this delay must alway be less than the minimum pulse width applied to the motor.

 

To synchronise the other ADC measurements, so that they do not coincide with the time critical measurement, you might set a flag at the same time the time critical measurement is started.  Then within the ADC ISR, the flag would indicate that the current result was the time critical measurement one.  The ADC ISR would clear the flag, and commence a new sequence of non-critical measurements.

 

Regards,

Mac

 

0 件の賞賛
返信