chipKIT® Development Platform

Inspired by Arduino™

PWM signal latching low until next high of PWM

Created Sat, 30 Nov 2013 02:39:30 +0000 by mjlynch712


mjlynch712

Sat, 30 Nov 2013 02:39:30 +0000

Hi,

I'm wanting to incorporate a feedback system into a high voltage supply. Up until now I've mainly usually discrete PWM drivers, or 8-bit PICs in BASIC to driver a number of transformers.

I'm thinking of using the ChipKIT DP32 as it is easy to embed. I would like some help on the code front of generating the PWM output. My outline is that it

  1. Generates a (roughly) 20kHz PWM signal
  2. constantly reads an ADC pin
  3. Once the ADC reaches above a threshold voltage the PWM signal goes low
  4. However it automatically goes high again and continue pulsing like nothing happened

I have included a rather awful diagram to add a little graphic help :)

Any help in this matter would be greatly appreciated.

MJ


majenko

Thu, 19 Dec 2013 23:56:13 +0000

Hmm... That's a tricky one. It's not easy to turn off PWM part way through a period and know when that period is up.

You could try using the timer overflow interrupt which would occur at the end of each period to reset the duty cycle to the desired value, then your pulse would just set the duty cycle to 0 - though that change may not take effect until the start of the next cycle (depending on configuration).

It might be simpler to manually generate the waveform.


EmbeddedMan

Fri, 20 Dec 2013 14:04:07 +0000

Yeah, I'm with you on that majenko. Doing this in software on the chipKIT should be a piece of cake, and you can have complete control over every aspect of it that way. 20KHz is super easy with processors this fast.

*Brian


crazy

Tue, 22 Apr 2014 21:00:11 +0000

hi I want to make a pulse width as the picture in attachment.how code example write regards chipkit uno 32


crazy

Tue, 22 Apr 2014 21:01:24 +0000

hi I want to make a pulse width as the picture in attachment.how code example write regards chipkit uno 32