AVR generated 12v pulse, just for fun

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

Hi All,

 

I have not done any circuit design in 40 years, and that was freshman circuits (from Smith) and a senior MCU project (w/ 6800), but I have done a lot of embedded s/w study and development.  I got into AVR MCUs about 9 months ago, and looking for smal projects to get my hands dirty.

 

Just for fun I wanted to see if I could design and prototype a 12v pulse for potential use in UPDI protocol.  The objective is learning correct electrical and software design.  Optimal end-cost of the implementation is not my objective, but comments appreciated on that in any case.

 

The components are AVR 5v MCU (e.g., mega328 or mega32U4), and the usual capacitors, resistors, etc.   My approach is to use a charge pump.  In three cycles I intend the following:

1) charge C1 from MCU

2) charge C2 from MCU

3) charge C3 from C1, C2 and MCU +5v in series

 

constraints:

1) The output should provide 11v-12v for a period of 100 ms.

2) There is no limit on time to charge C3, before 12v source becomes available.

3) The max output current draw is guessed to be 2 mA.  T

4) Since the MCU can provide ~ 40 mA to the pin I use 1 k resisters to limit  current to 5 mA.

5) With 0.1 uF caps, the time constant is (1000 ohm)*(0.1e-6 F) = 0.1 msec, clock at 8-ish kHz

 

In the table, +5v means pin is output-high, gnd means pin is output-low, inp means input-low. 

Note: On at least the mega328 the transition from output-high to input-low requires two separate instructions.

 

Is this sufficiently safe to hook up and go for a run to measure the output voltage?

 

In the diagram C1 is the lower 0.1 uF cap, C2 is the upper 0.1 uF cap and C3 is the right hand side cap.

 

 

 

 

 

Attachment(s): 

This topic has a solution.
Last Edited: Mon. Oct 14, 2019 - 12:53 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you do that what voltages will be at B2 and B3 during 3rd time period?  What are max ratings for the ports?  Do you think they are compatible?

 

 

David

 

edit - typo

Last Edited: Sat. Sep 28, 2019 - 03:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the third period ports B2 and B3 are input so essentially open, right?  The voltage will be above 5 v, but does that matter?

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

Yes, it matters.

 

For example, every AVR port pin has a pair of protection diodes. One  diode is from the port pin to ground and the other is from the port pin to Vcc. They are arranged so that the  diodes are reverse biased when the port pin is between Vcc and Ground. They are there to protect against static discharge. So, when you set those pins to be inputs, they are open circuit, sort of - until the pin voltage goes above Vcc or below ground by a few tenths of a volt.

 

Not sure if it is enough, but a simple charge pump will generate approximately 2xVcc. In a pinch, you can use a MAX232 and not bother with the RS232 interface circuitry. If course, this will side-step the goal of designing a circuit!

 

Jim

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

Last Edited: Sat. Sep 28, 2019 - 04:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

fyi, there's a shunt regulated 12.7V boost converter in STK500.

Schematic and layout | STK500 (sheet 6, lower right)

 

"Dare to be naïve." - Buckminster Fuller

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

Thanks all.   At least I didn't smoke a chip.   Maybe I get a chance another time.

 

Edit: And 328 data sheet says max input rating is Vcc+0.5v.  Lesson learned.

Last Edited: Sat. Sep 28, 2019 - 04:42 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And someone else had suggested ST662:

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

 

You could use PWM & make a little boost converter  5V to  12V...just need coil, diode, transistor & a few caps

You can even generate very high voltages, enough to treat your friends. 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Thanks.  That might be fun.  I will look into it.  I've gone back to my intro textbook and re-reading the semiconductor chapters.

When I was an undergrad many of my friends were EEs; they seemed to love the power converter class the best.  (Middlebrook and Cuk were the instructors!)

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

That really needs some feedback. You also need to choose a value for L1 that is appropriate for the "square wave" that drives the switch. If it does not have feedback, then you need to be careful of both the voltage rating of C1 and the reverse breakdown of D1. Without feedback, the output voltage is quite unpredictable and can be relatively high. If C1 is high enough in value without feedback, it can actually be more than a bit hazardous (short duration high current at high voltage).

 

Jim

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

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

That really needs some feedback

Oh absolutely!! I'm assuming the ADC is used for measuring so the pwm will maintain the proper setting.  At low freq (say 75KHz) (and not super efficient), no gate driver is needed (just 50 ohms to an AVR pin).

You can get 78KHz from a 20MHz AVr & 256  res PWM.

Note the standard simple boost cannot be 100% shut off (fwd diode), but an output transistor can switch the loading as desired

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Thanks.  Will submit for review before power-on!   (I have PhD in ECE/control just to indicate I know enough to be dangerous!)

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

I've just finished fixing a few problems with someone else's design on a  product that does just this. It controls a bock converter using PWM.  Interestingly the previous engineer used only the Integral term in PID control to control the PWM and it took absolutely ages to start up (About 2 seconds). I added some Proportional signal which made an order of magnitude difference but 'I couldm't control the overshoot.

 

I shall watch this thread with interest in your progress.

 

<edit>Silly typo: Changed "could control" to "couldn't control". Meaning I could not eliminate it completely.</edit>

 

Last Edited: Sun. Sep 29, 2019 - 08:20 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I added some Proportional signal which made an order of magnitude difference but 'I could control the overshoot.

Interesting, in that I do neither (though I am well versed in both). I make PWM adjustments simply step up or down as needed, maybe 100 adjustments a second, sometimes with a count or two of hysteresis to prevent chatter.  If the error to desired target level is large & above some threshold I take bigger steps (say 8x) & halve them at each iteration (4 2 1 ), until back to single stepping, now close around the target.  Sometimes I'll make the the PWM turn-down rate 2x faster than the turn-up rate, which reduces ping-ponging. With software you can do these fancier things that are very tough with opamp circuitry.  Of course, each has its merits.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sat. Sep 28, 2019 - 07:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Back 20 years ago I made 12V just for fun with a 8515 with a ferrit bead as a transformer, and I was surprised that I actually could make 12V 5ma with just 2 5V port pins.  

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

Was that really a ferrite bead which is quite lossy? Most ferrite beads of that era were around 0.7cm OD, maybe 0.5cm long and had a hole of a few mm in diameter. And they only allowed one wire through the hole because the hole is  small.

 

I can believe using small ferrite core that might be 1-2cm OD, or larger.

 

Jim

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

Last Edited: Sat. Sep 28, 2019 - 08:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

But nowadays you can just be lazy and pick a cheap boost controler like the sx1308.

Basically like the circuit in post #8 but instead of a MOSFET, you get MOSFET + control logic in a single package. I've tested this chip with crap components from Aliexpress and it works fine for 150mA or so (5V -> 12V), more than that and the poor quality inductor I'm using saturates and starts to heat up. For UPDI it should be more than enough.

 

Last Edited: Sat. Sep 28, 2019 - 10:45 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Perhaps they have an other name, it was a bead about 7 mm i diameter (I lived in US at that time so 1/4 inch I guess)made out of ferrite. It had a hole about 3mm, and then about 2 mm high.

There was plenty of space to make a transformer with a total of 20 turns with wire you can solder. (not sure for correct name)  

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

ka7ehk wrote:
Was that really a ferrite bead which is quite lossy?
reduced loss :

Wirewound Ferrite Beads | Coilcraft (3.43mm max height, approx 2 ohms min for 310mA max)

 

 

 

"Dare to be naïve." - Buckminster Fuller

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

So just taking my time to look at this, but wanting to post to keep the thread alive.   Right now looking very electronics-ish but the AVR coding will come along later.

 

Here is initial diagram.  I may modify a bit on the way.  I wonder if we can keep the inductor size small by adding a resistor in the closed path with the FET.

 

Below B0 is the AVR output for switching and A0 is the AVR analog input for measuring output voltage, scaled to be in the range 0-5v.

 

 

EDIT: I believe there is a sign error in the first equation: Ldi/dt = - (Vo - Vi)

Last Edited: Sun. Sep 29, 2019 - 05:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 I wonder if we can keep the inductor size small by adding a resistor in the closed path with the FET.

 

No, resistance increase losses

 

You calculate ckt by saying avg inductor voltage must be zero.  For %v in & 12V out , this gives a duty cycle of 58.3% (neglecting losses & drops)

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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


 

Let me pretend I still know this stuff (closed case):

 

 

V and L are constant in this case (assuming the MOSFET is a perfect switch) so they can be outside the integral:

 

Initial time is zero, so the equation for the closed case is

 

The other, lol, won't even try*.

 

* well, maybe later.

 

edit: This is a schematic of the idealized circuit:

 

Last Edited: Sun. Sep 29, 2019 - 07:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No integral or integration is needed, thus avoiding sudden sleepiness syndrome.  Just assume the AVG inductor voltage must be zero (equal & opposite areas).

The Volt-seconds areas during the on-time: Vin(DT) must match with the off-time: (Vout-Vin)(1-D)T   ...

 

or  simply Duty=(Vout-Vin)/Vout

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Are you sure? I don't believe the duty cycle will be independent from load.

 

edit: Anyway, your idea reminded me that indeed, some kind of conservation of energy approach will probably simplify the problem.

That is, in the steady state, the energy stored in the inductor will equate the energy loss in the load.

Last Edited: Sun. Sep 29, 2019 - 07:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


Ok, here we go cool

 

Energy stored in an inductor:

So substituting the equation

assuming I0 is zero, that is, the inductor gets fully discharged at each cycle, the energy stored in our inductor is

where tHIGH is the time the MOSFET is on (HIGH part of PWM wave)

 

During the discharge part, this energy is consumed by the load. The energy dissipated in our resistive load is:

where tLOW is the time the MOSFET is closed (LOW part of PWM wave)

 

Now, considering the duty cycle formula is:

 

and the frequency of the PWM wave is

 

If I didn't mess up somewhere, the duty cycle is given by the formula

where

 

Let me exemplify with f=1MHz, L=1uH, R=1 kohm, VIN=5V and VOUT=12V:

k=173.6 gives d aprox. 10%

 

With a heavier load of 50 ohm, we get k=8.7 so d is aprox. 38%

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

I have not designed these beasts before, but doing some sanity checks on sizing.  For example, for a 1 uH inductor, and constant 5 v supply, the current grows like 5 A / us when the FET is closed, right?  That's why I ask about putting a resistor in there to limit the current and be able to use small inductor.

Last Edited: Sun. Sep 29, 2019 - 10:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

right

 

jim

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

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

MattRW wrote:

I have not designed these beasts before, but doing some sanity checks on sizing.  For example, for a 1 uH inductor, and constant 5 v supply, the current grows like 5 A / us when the FET is closed, right?  That's why I ask about putting a resistor in there to limit the current and be able to use small inductor.

In small aux supplies like this, a resistor can be a good idea.

Yes, it increases losses, but in such a circuit you are chasing simplicity, more than top end efficiency.

I would suggest adding a Zener clamp to the final Vo, which ensures the ringing voltage can never get out of hand, no matter what loads change.

For many applications, no analog voltage feedback could be needed, the Zener does the regulation.

I've seen some designs feed the Zener to a transistor base, so the collector goes low as a 'voltage reached' digital flag, but if you know the L,C,R & loads, and PWM, you now how long it takes to reach clamp voltage.

 

Checking Digikey, it seems 1uH thru 33uH are all much the same price, & in 0805, so you can select inductor to suit operation.

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

sparrow2 wrote:

Perhaps they have an other name, it was a bead about 7 mm i diameter (I lived in US at that time so 1/4 inch I guess)made out of ferrite. It had a hole about 3mm, and then about 2 mm high.

There was plenty of space to make a transformer with a total of 20 turns with wire you can solder. (not sure for correct name)  

Most would call that a small ferrite toroid.

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

assuming I0 [iniital current] is zero, that is, the inductor gets fully discharged at each cycle

Well that might be nice, but it's not true for most real loading...the inductor is being charged ,or just supporting the loading (a triangle shape above zero, at an avg of the avg output current). 

 

The current triangle looks more & more like an RC if its time constant is too fast.

 

During the "D" on time, the inductor has a voltage of Vin (neglecting losses, such as fet drop & inductor IR loss)  so the area is Vin*DT

 

During the opposite (off) time the inductor has a voltage of Vin-Vout (neglecting the diode drop)  ...Vout>=Vin, so the area (positive quan) is (Vout-Vin)*(1-D)T

 

Regardless of shape, the avg voltage must ALWAYS be zero

 

These for an avg of zero, these areas must be equal & opposite.   ...note that just like the Buck,  both L & T (period,freq) drop out.  

 

Rearranging gives: Vout/Vin= 1/(1-D).

 

  

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Interesting, to me the idea of using an MCU to run a converter has merits.

Good to see people still investigate circuit operation by experimenting; I call it "Live" SPICE.

Find that it works best as it takes all possible practical parameters into account and due to its ad hoc/experimental nature gives one a much better chance to discover better solutions in terms of design and price.

Recently ran a few experiments with higher current (amps) boost, buck and buck/boost converters using the CTC on the 328 and found the mentioned resistor can be helpful.

The CTC of course can run things without processor support and checking it every few seconds or so is all that is needed for battery charging from a solar source.

I used an efficient inductor and used a 1.5" yellow/white core from a SMPS with 25 turns of 1mm enamelled copper wire, some 50uH.

(Great to be able to use that inches again, its illegal here)

Was able to get some decent currents and efficiency of over 80% with out to much effort.

So think a decent inductor, if you have space, is better than trying to scrimp on it.

 

Last Edited: Mon. Sep 30, 2019 - 12:38 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 I wonder if we can keep the inductor size small by adding a resistor in the closed path with the FET.

To be clear, no, a certain output rating will require a certain size inductor.  Adding a resistor will not reduce the size of the required inductance, but will increase the losses, and require something  to work harder to make up for it.

Adding a resistor might help avoid saturating the inductor, but hopefully you aren't doing that in the first place.   A current mode controller chip, will limit the current (indirectly including the inductor), anyhow.

A series resistor speeds up the L/R time constant, but lowers the final target (Ifinal) to V/R.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Wikipedia's page on switch-mode converters says that as long as the converter operates in "continuous" mode, the output voltage is determined by the input voltage and the duty cycle.

I interpret "continuous mode" means that the current is always being limited by the inductance - no zero-current initial state, no steady state at the end, no saturation effects, no imperfect components.

Getting that to work in practice means picking appropriate inductances, frequencies, paying attention to the output current, and so on...

 

Now, the needs of UPDI are a bit "interesting" WRT this problem.  Efficiency is unimportant, and the load current is going to be very low.  Also, you need to switch the signal between the 12V value, and a regular 5V (or lower) logic signal level.  Preferably without frying the pin that the logic signal is coming from.

 

 

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

westfw wrote:

Wikipedia's page on switch-mode converters says that as long as the converter operates in "continuous" mode, the output voltage is determined by the input voltage and the duty cycle.

I interpret "continuous mode" means that the current is always being limited by the inductance - no zero-current initial state, no steady state at the end, no saturation effects, no imperfect components.

Getting that to work in practice means picking appropriate inductances, frequencies, paying attention to the output current, and so on...

 

Now, the needs of UPDI are a bit "interesting" WRT this problem.  Efficiency is unimportant, and the load current is going to be very low.  Also, you need to switch the signal between the 12V value, and a regular 5V (or lower) logic signal level.  Preferably without frying the pin that the logic signal is coming from.

Yes, another thread mentioned 2x VCC for threshold, and it will be quite low currents.

At low tens-of-uA levels, the flyback converter will mostly be in ringing mode, a long way from continuous conduction.

You may find even the smallest PWM setting, generates enough ringing energy to pulse above 12V, hence the suggestion for a simple clamp zener, as you do want to avoid frying the device you are trying to program !

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

At low tens-of-uA levels, the flyback converter will mostly be in ringing mode, a long way from continuous conduction.

Nobody mentioned flyback, we are talking about a boost converter! Did you see a transformer fly by?

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

avrcandies wrote:

At low tens-of-uA levels, the flyback converter will mostly be in ringing mode, a long way from continuous conduction.

Nobody mentioned flyback, we are talking about a boost converter! Did you see a transformer fly by?

 

Hmm.....  a transformer is not a required part of flyback :)

 

The important detail of a flyback converter, is that the output diode conducts as the inductor flys back, so the diode is ON when the switch is OFF.

In the other type, a forward converter, load transfer is also when the switch is on, and likewise that may be transformer, or simply series inductor based. (called buck in the USA ) 

 

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

 

Hmm.....  a transformer is not a required part of flyback :)

 

I'll mostly disagree, since that is not the definition of a flyback converter, as far as I've heard.   It is derived from a boost or perhaps buck-boost type, but that does not mean it is a boost.  

 

I think another hearty bowl of solder soup will settle the matter for all.

 

 

The flyback converter is an isolated power converter. The two prevailing control schemes are voltage mode control and current mode control (in the majority of cases current mode control needs to be dominant for stability during operation)

Flyback converters are one of the simplest DC-DC converter topologies to include electrical isolation. Although generally only viable for lower range power supplies (up to 100W), they do have a number of advantages. Other than the converter’s inherent simplicity, perhaps the greatest of these is that the design does not require an additional inductor. The transformer provides isolation, and yet also functions as a pair of coupled inductors

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Boost/flyback the design procedure is much the same. Whilst if someone said ‘flyback’ converter, i’d expect to see the transformer. Where it gets fuzzy is where you have a tapped inductor or ‘autotransformer’ for a greater boost voltage. Is that a ‘boost’ or ‘flyback’ converter?

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


Yep, that seems to be at least the standard "naming convention"

 

This is a nice chart:   https://www.we-online.com/web/en/index.php/show/media/06_passive_components_-_custom_magnetics/blog_1/midcom_blog_photos/SMPSChart.pdf

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

Candyman, you are correct, but so is Who-me. Blue Steel, LaTigre or Magnum?

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

I have some simulations in Octave going.   Here is the set of equations:

 

 

I'm simulating, in Octave, from initial condition with capacitor discharged.  I wanted to see the start-up operation.   For sample period of 10 us I had to push the inductance up to 300 uH before I was able to achieve steady state.  I want to dig into that.   The following is with L 300 uH, C 10 uF, R 12 kohm and d 7/12.  In the following iL is in amps and Vo is in volts.

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

Should some evil, barefooted brat point out Roman Black's work?  http://romanblack.com/smps/conv.htm

 

I built one of his buck regulators to see if I could, grabbing junk box parts with values in the ballpark of his. Would you believe the stupid thing not only worked, but had nice characteristics.

 

 

The largest known prime number: 282589933-1

It's easy to stop breaking the 10th commandment! Break the 8th instead. 

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

Yeah, if the frequency is just 100kHz, you will need a sizeable inductor. Normally if you want to use small inductors, F should be a lot higher, like 1MHz or so.

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

why would you use Octave?  

Get a copy of LTspice...you will have a much better simulation (example inductor series resistance), transistor response, etc 

 

https://www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html

 

Try some of the many included circuits they include ...amplifiers, transistors, power circuits, timers, etc...you can see how they run...FREE

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Thu. Oct 3, 2019 - 04:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:

why would you use Octave?  

Get a copy of LTspice...you will have a much better simulation (example inductor series resistance), transistor response, etc 

 

https://www.analog.com/en/design-center/design-tools-and-calculators/ltspice-simulator.html

 

Try some of the many included circuits they include ...amplifiers, transistors, power circuits, timers, etc...you can see how they run...FREE

 

There are Mac and Windows downloads but no Linux.  Luckily, my there is NGspice for Linux, 600+ page manual, tutorials.  And it's integrated with KiCad.  And comes with shared library that I can link into my AVR chip simulator.

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

MattRW wrote:
There are Mac and Windows downloads but no Linux.
Way back, LTspice IV ran well on Wine 1.

LTspice XVII apparently runs well on Wine 4 though does have some defects, with workarounds, on CrossOver 18.1 on Chrome OS.

 

https://www.analog.com/media/en/simulation-models/spice-models/LTspice_ShortcutFlyer.pdf?modelType=spice-models

[page 2]

-wine Force use of WINE(Linux) workarounds

WineHQ - LTspice/Switcher CAD

LTSpice XVII | What Runs | CodeWeavers (CrossOver)

LTspice | Design Center | Analog Devices

 

edit :

Running Under Linux - LTwiki-Wiki for LTspice

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Sun. Oct 6, 2019 - 02:35 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A few updates: 

 

In this note there is a formula relating switching frequency and inductor size for continuous operation: min L > (Vo * period)/(16 * load current).

 

I have a simulation going in ngspice: it takes much longer than my octave sim, so thinking that is good to verify, and not sure it can be hooked up to a AVR chip sim.

 

I'm not sure operating in continuous mode with switching frequencies generated by AVR chip will be practical.

 

 

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

fyi, one tinyAVR with a boost converter :

ATtiny43U - 8-bit AVR Microcontrollers

 

"Dare to be naïve." - Buckminster Fuller

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

I'm not sure operating in continuous mode with switching frequencies generated by AVR chip will be practical.

Be sure to use an AVR that has the high speed PWM mode, such as the tiny85.  You can easily generate 75 or 100 KHz for your booster & it will work great.  Grab a fet, diode & inductor & build one up!  
In a hour you will have your voltage!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

gchapman wrote:

fyi, one tinyAVR with a boost converter :

ATtiny43U - 8-bit AVR Microcontrollers

 

Interesting, but note it is not a 12V capable boost design...

" Boost Converter: Built-in boost voltage converter providing 3V to the processor while only requiring between 0.7-1.8 volts from its external power supply (1.8-5.5 volts when the voltage converter is bypassed). "

Last Edited: Sun. Oct 13, 2019 - 12:21 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The original cap booster idea was dismissed because of the internal pin clamping diodes, but seems to be easy to overcome in various ways (diodes).

 

Some advantages are it uses common parts and its quite hard to get into trouble. Diode selection can be used to tweak max voltage, cap values can be tweaked as needed also. The output can be clamped, but with component value selection one could probably eliminate the need (or maybe use a resistor to create a minimum output load). Not much thinking required on the software side, either.

 

This version uses a complementary output pwm (or similar), but adding another diode and cap would then need only a single pwm output. I'm sure there are a thousand and one variations.

 

I used a max232 type chip for 12v when I made my avr 'Fuse Buster'-

http://www.mtcnet.net/~henryvm/4AvrFuseBuster/4avrfusebuster.JPG

but I also had an old style r232 port so had that available anyway.

 

edit-

also added an npn version, and changed the diodes to bat41 type to make up for the losses.

 

 

 

Attachment(s): 

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

also added an npn version, and changed the diodes to bat41 type to make up for the losses.

What keeps the voltage at 12V?  Prob unregulated & just happens to land near there, depending on load...Your other circuit had zeners!

 

You could prob mod the charge pump duty to perform starvation regulation  via the ADC

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

>What keeps the voltage at 12V?  Prob unregulated & just happens to land near there, depending on load...Your other circuit had zeners!

 

Will probably get lucky if it makes it much over 12v, and if it does I doubt the other end will care with only couple milliamps available at most (which also drops the voltage as it ramps up the very little available current it has). I think the datasheet says max 13v on the reset pin, and I think I read somewhere its probably happy with its '12v pulse' somewhere around 2xVcc, so an exact 12v is probably not that necessary and could also get by with 'normal' diodes and stay in the 11-12v area without any problems.

 

I would like to see the result of whatever happens here, but I have given up caring about using a updi pin for gpio use. If I need to use all the available pins I will move up to the next model with more pins to keep the programming pin free. The big advantage is there is only one in this case. Maybe when using an 8pin tiny it makes more sense, but an 8pin soic vs a 14pin soic is not much difference in price or size. When you move into the higher pin counts you also have the smaller sized packages available.

 

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

Just to keep this alive.   I'm working on compensator design for the following:

 

with Vi = 5 v, L = 330 uH, C = 1uF, R = 12, R = 12 kOhm.    I have derived linearized TF from duty cycle, to Vo.   I'm looking to run the control loop at 10 kHz, so I've added a .5 ms delay for ADC and computation.   The compenator is (s + 8)/(s +1)*(s + 80)/(s^2 + 200*s + 10000)*100/(s + 100).   The loop transfer function C(s)*P(s) looks like

where the orange box shows 10 dB gain margin and 45 deg phase margin.  The squiggle to the right of the box is the Bode step.  The design provides dc gain of ~95 so that for 5 v offset we get ~ 0.05 v hangoff.

 

more later ...

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

 

You prob don't need any graph or equation...simply measure the output voltage with the adc perhaps 200 times a second.  If the voltage is too low, increase the duty cycle by one step.  If it is too high, decrease the duty cycle by one step.  If it is an 8bit PWM, you have 256 choices (256 different voltage levels). The voltage will then be well-maintained at the desired setting (unless you have a severe transient somewhere).

 

You can code this up in probably 15 minutes & have it working great.

 

You can get fancier---if the voltage is way too low or too high, take bigger steps.  To prevent voltages chatter you can add a few steps of hysteresis.

    You can increase the apparent number of bits, one or two, by toggling between two duty cycle counts...this will be averaged out by the load capacitor, effectively giving finer voltage levels   

    You can add equations (such as integrating the long-term error & looking at the rate of voltage change (derivative) & correcting (predicting) the stepping.  

 

 

Opamps being "dumb" devices don't have this luxury & you are back to needing equations & so forth just to get started.  You don't get as many easy ways to talk with your opamps. In his case, software is king.

 

Mr Edison appeared with a a pear-shaped glass bulb.  Mr Edison asked Upton to calculate its inner volume. Upton was a very able mathematician, who after he finished his studies at Princeton went to Germany. He drew the shape of the bulb exactly on paper, and got the equation of its lines with which he was going to calculate its contents. Mr Edison appeared later on and asked him what it was. He showed Edison the work he had already done and told him he would very soon finish calculating it. "Why," said Edison, "I would simply take that bulb and fill it with mercury and weigh it; from the weight of the mercury, I'll get it in five minutes.

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Oct 20, 2019 - 08:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes, I could kludge a design together, but then if you don't get the performance you want you usually end up tinkering with it (i.e., trial and error) to get it to work right.  I'd rather start from design requirements and put together a design on paper that works, and debug that.   Good control designs often provide the cheapest design for meeting performance (e..g, equations and lines of code are cheaper than bigger, or more, parts).

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

I wouldn't call either method a kludge & there is probably some tweaking for both.  If you are investigating the time domain response, a method in the time domain is easier to diagnose.

 

The compenator is (s + 8)/(s +1)*(s + 80)/(s^2 + 200*s + 10000)*100/(s + 100) ...I suspect that more terms will be needed, due to nonlinearities & non-ideal parts.   What happens to the equations when few more parts (tweaks)are added?

 

The method I proposed requires essentially no computational load on the AVR & almost no programming---not even a division routine & allows fast reaction (ultimately limited by adc speed).  You can try it within minutes & see if it performs to your liking--no need to spend all day simulating. 

 

I'd be first to agree that if you want the highest humanly possible performance, a full set of equations and nitty modelling would be wonderful.   On the other hand "I need to generate 12V"  is along the lines of "I need a hamburger"  & Wendy's or Burger King is probably fine.

 

but wanting to post to keep the thread alive.  

 keep things simple ...you'd would have already had it working...and quite well. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Oct 20, 2019 - 09:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

MattRW wrote:

AVR generated 12v pulse, just for fun

Emphasis mine.  No need to critique the OP's technique, he made clear at the beginning why he was doing this.

Letting the smoke out since 1978

 

 

 

 

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

I am following this as a particularly interesting thread, don't see where any critique has been made.
avrcandies method is the same as I used, earlier on I called it "live spice", which is a term I phrased some 20 years ago.
Got it all working fine, using it in a solar charging device.

Last Edited: Mon. Oct 21, 2019 - 11:25 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

update: I have posted some code for handling the switch with varying duty cycle using timer0 in Fast PWM mode.  See here.

 

The next step is to create a task that operates at about 10 kHz to control the duty cycle as a function of measured output voltage.

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

The control loop is usually slower than the pwm freq. Reason being the capacitance on the output forms a pole so the output voltage can only change at a slower rate.

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

For my deisign I plan PWM to have period  ~ 1/256 kHz; control loop sample rate of  ~ 10 kHz;  control loop bandwidth ~ 100 Hz.

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

You can probably get by with a lot slower sampling rate---if you are varying the adjustment 100 times a second, that should be plenty.

I you look at a power supply do you need to check it 100 times a second?  Maybe for transients, especially if the capacitors are on the small side---otherwise, they keep things nice & steady. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

I decided to try my previously shown circuit since I was testing tca on the mega4809 (and see if simulated matches reality). I had some unknown small diodes (0.5v on diode check) and a few 10uf caps handy, so just used 3 of each as the only parts, without any output control. The tca is sending out 10kHz in freq mode on tw0 cmp pins, each with opposite polarity. The Vcc measures 4.7v, and the unloaded output at the last cap is 13-14v. I only had a 1k resistor laying around which was too much load, so unable to check what it can drive at the moment. I also had a 12v zener so put that on the output to keep it at 12v (when unloaded anyway).

 

The test code-

 

//headers here

int main(){

        //set clock to 10MHz
    Clkctrl::setupHiSpeed<10_MHz>();

 

        //PE0=WO0, PE1=WO1
        //2 frequency outputs of 10kHz, opposite polarity
    Tca< Tca0_E > tca;
    tca.freqMode( tca.CMP0, tca.OUT_NORMAL, 10_kHz, 10_MHz );
    tca.freqMode( tca.CMP1, tca.OUT_INVERT, 10_kHz, 10_MHz );
    tca.on();

   

    //my control loop :)

    for(;;){}

}

 

With some fine tuning and output control added, it would probably work pretty well for updi 12v use.

 

Edit-

adding a 10k load, voltage is at 12.1v, so it can do 1.2ma anyway.

Last Edited: Thu. Nov 7, 2019 - 03:05 PM