Synchronized PWM with Attiny13/25

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

I'm using Attiny13A but i have also Attiny25.

 

I have an external PWM at some tens of KHz. With 50% duty cycle

 

I want to have another PWM in phase with with the external one with variable duty cycle. Is there a need to draw?

 

It's a SMPS. An creates pulses and Attiny controls a synchronous rectifier bridge.

 

How to do ?

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

For example, that:

http://www.microchip.com/Develop...

 

But made a part with Attiny.

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

How tightly do the two have to be synchronized? And how much cycle-cycle variation is permitted? It is really hard to get closer than 10-15 MCU clocks.

 

Best solution is two signals from one counter, one fixed duty cycle, other variable.

Jim

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

Last Edited: Tue. Feb 13, 2018 - 09:36 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Best solution is two signals from one counter, one fixed duty cycle, other variable."

Very correct ... but only theoretically.

I do not want to control the primary transformer with a microcontroller driving MOSFET.  If the microcontroller has an error SMPS burn instantly.

There are software  methods to control the failure of a pin, but I still do not trust.

 

I prefer to use a dedicated IC like IR2153(tested at low voltage),    To bring the signal from the IR2153 LOW MOSFET Gate to Attiny.

 

Attiny will only control the synchronous rectifier. If an error occurs only decreases the efficiency but does not burn out.

 

" And how much cycle-cycle variation is permitted?" 

I work at diy level, I do not have an oscilloscope, but I can measure the result (if the SMPS efficiency has increased).

 

The big difference between Attiny and dsPIC33(from the link above) is the price. I intend to make a cheap SMPS. I do not intend to copy the schematic from the link above

 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//// As software

 

I use MikroC, If you consider another compiler is more appropriate please tell me.

 

-  If(pin==1) {.....}  I do not think it's a good idea because an unknown number of processor cycles is lost until routine treatment.

 

- Using an interrupt at changing of status of a pin (gate of Low MOSFET resistive divided) is better, because we know the number of cycles "which are lost" exacted.

 

In MikroC I had difficulty in the interruption routine.

May I start from another example with the compiler you have, to have something in common

 

 

 

 

 

Last Edited: Wed. Feb 14, 2018 - 06:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Lose cycles to jump in routine, but if I use logical IC they have a response time. CD40s and 74s.

E.g. CD4093 NAND datasheet 200-500nS.

For Attiny13 working on internal oscillator at 9.5MHz is the equivalent of 5 processor cycles, and a jump to the routine should take 2 cycles.

 

" And how much cycle-cycle variation is permitted?"  

It is very difficult to describe theoretically transient phenomena from the transformer right after the rising edge appears in the primary.

That's why I want to test in practice, to have a PWM with the best resolution and the best synchronization which I can obtain.

 

Edit: I could probably have made this device easier without a controller. But I want to test it in various situations. And if it does not work at least I learned something aboutut AVR programming

Last Edited: Wed. Feb 14, 2018 - 07:09 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need to define :

I want to have another PWM in phase with with the external one

how should they look like when the new one is 20 % (in the center off, one edge at the same time or ?)

and again what kind of dynamic changes do we have here?

 

remember that a tiny25 can run the clk at 64MHz.

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

This is a very bad idea overall, since the tiny can only create the proper pwm after the fact.  While it could adjust itself to align with the main pwm, if the main PWM suddenly decreases, the tiny won't know until its too late, so will generate a potentially devastating improper cycle, until it notices the change in the main pwm (after the smoke).  The sync rect pwm usually looks like the main except inverted, with a small  (sub us) deadtime thrown in.  You might be able to use the micro safely if you also include some anti-crossconduction logic.  But then, why use the micro?

 

 

I work at diy level, I do not have an oscilloscope

 This is about the worst possible news if you are developing a SMPS & trying to create & verify waveforms...better off just buying a prefab power supply module...plenty available

When in the dark remember-the future looks brighter than ever.

Last Edited: Wed. Feb 14, 2018 - 04:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The yellow line is the given PWM. 50% if I neglect dead time between 20KHz and 70KHz, but constantly from the moment it started.

 

The Blue Line is the PWM Attiny must generate.  

 

In this test I want the duty cycle to depend on consumption

 

Repeat, these are just tests, it would be simple to copy the schematic and HEX from the link in post 2

Attachment(s): 

Last Edited: Wed. Feb 14, 2018 - 05:00 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Very well, if you insist...since both shouldn't/can't be "on" at once (not sure from your pictures which way is "on" for blue), you need a small delay.  Just trigger an IRQ on the rising yellow trace, then start a timer and generate your desired pulse. 

If the tiny is doing only this function, you might be faster just polling the yellow pin (no IRQ), in a tight loop, set your blue pin & just use some nested statements (inc , dec, etc)  to generate the desired amount of time (width), then kill the pin & start polling again.  

 

Again, a scope is really vital for this type of experimenting.  Try to get/borrow one. 

 

but constantly from the moment it started....

In this test I want the duty cycle to depend on consumption

You want it constant, but to depend on consumption???   A circuit diagram is needed at this point!

When in the dark remember-the future looks brighter than ever.

Last Edited: Wed. Feb 14, 2018 - 05:14 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First of all, I would like to learn to use Arduino IDE to compile the program for Attiny13.

"You want it constant, but to depend on consumption???"  Yes, because they use constant load, eg a power resistor.

 

"Diagram?" When I'm just learn to write an interruption routine for Atmel?

I have worked before that many years with PIC (Microchip). Only now, "I discover" the Atmel.

 

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

First of all, I would like to learn to use Arduino IDE to compile the program for Attiny13.

"You want it constant, but to depend on consumption???"  Yes, because they use constant load, eg a power resistor.

 

"Diagram?" When I'm just learn to write an interruption routine for Atmel?

I have worked before that many years with PIC (Microchip). Only now, "I discover" the Atmel.

If you want it constant, then it will not depend on anything ...it is constant 

 

 A circuit diagram is needed at this point!

 

 

When in the dark remember-the future looks brighter than ever.