Trigger ADC at Ton/2

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

I am using timer overflow as an ADC trigger source to make a measurement during ON time of the PWM pulse.

Is there any hack/ way to trigger and sample these ADC measurements right in the middle of the PWM pulse, at Ton/2?

Thanks a lot!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Use a second output compare register set at half the value of the first. Wire up that output to trigger the ADC.

Seriously, take a look at the list of ADC trigger sources.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Jim.

I should have mentioned, I am working with Timer 1 on tiny261. The only ADC trigger source associated with it is the Timer/Counter1 Overflow.

I need to use timer 1 to generate a high frequency PWM, where timer 1 is getting clocked from the 64MHz PLL.

Assuming I can run the ADC at 500KHz with an 8bit resolution, the sample and hold time would be 1.5 ADC Clock cycles = 3usec. The high frequency PWM has a period = 16usec. If there is some way to trigger the ADC at Ton/2, I can probably live with minimum Ton greater than 3usec.

Any ideas?

Thanks a lot...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Any ideas?

--Run timer0 "in sync" with Timer1, and ADATE off of that.
--Use phase-correct PWM, inverted. (I think that the overflow will then be in the middle of the "on" time.)

Quote:

Assuming I can run the ADC at 500KHz

Quote:

The high frequency PWM has a period = 16usec.

Let's think about that for a moment. 500kHz ADC clock is 2us per ADC clock. 13 ADC clocks for a conversion, so a conversion takes 26us. With a skinny ISR it will still be a few us to service the ADC complete and clear the timer overflow flag.

So that is ~30us per conversion. PWM period is 16us. Hmmm...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have had good results running ADC clock at 1MHz for 8-bit resolution.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks theusch.

Quote:

So that is ~30us per conversion. PWM period is 16us. Hmmm...

I guess that might be OK because I don't have to take a sample , say every single PWM pulse. I can live with one ADC sample and conversion every few PWM pulses...

I am still not clear about how to run the slow 8bit timer 0 "in sync" with the 10bit timer 1 running off of the 64Hz PLL.