Storing Cookies (See : http://ec.europa.eu/ipg/basics/legal/cookies/index_en.htm ) help us to bring you our services at overunity.com . If you use this website and our services you declare yourself okay with using cookies .More Infos here:
https://overunity.com/5553/privacy-policy/
If you do not agree with storing cookies, please LEAVE this website now. From the 25th of May 2018, every existing user has to accept the GDPR agreement at first login. If a user is unwilling to accept the GDPR, he should email us and request to erase his account. Many thanks for your understanding

User Menu

Custom Search

Author Topic: Single Coil Two Transistor Boost Circuits  (Read 56352 times)

TinselKoala

  • Hero Member
  • *****
  • Posts: 13958
Re: Single Coil Two Transistor Boost Circuits
« Reply #45 on: June 25, 2014, 04:21:27 PM »
It takes a little time to turn the Arduino output on and off, so at very short intervals the actual pulse you get is longer than the "delayMicroseconds" would imply. This is why you need to check with a scope and fine-tune to your exact requirements by "fudging" the dwell and gap values until your actual output is what you want.

For example, here's what you get with gap = dwell = 2 "microseconds".



Farmhand

  • Hero Member
  • *****
  • Posts: 1583
Re: Single Coil Two Transistor Boost Circuits
« Reply #46 on: June 26, 2014, 01:05:42 AM »
Tinsel doesn't the Arduino software have a "pwm wizard" to calculate and produce the required code for specific frequency and duty
cycle for pwm capable outputs ?

Seems like one advantage of the picaxe is that it can run from 5.5 volts down to 3 volts. And pwm outputs only require that two fields be entered into the pwm wizard, the frequency and the duty, it then gives the code to paste into the program.

The pwm output never exactly matches what we want unless all the timings add up neatly. That is the one thing, but it does get very close.

..

MarkE

  • Hero Member
  • *****
  • Posts: 6830
Re: Single Coil Two Transistor Boost Circuits
« Reply #47 on: June 26, 2014, 01:18:49 AM »
It takes a little time to turn the Arduino output on and off, so at very short intervals the actual pulse you get is longer than the "delayMicroseconds" would imply. This is why you need to check with a scope and fine-tune to your exact requirements by "fudging" the dwell and gap values until your actual output is what you want.

For example, here's what you get with gap = dwell = 2 "microseconds".
This assembly code  can be called using the following prototype with values from 1 to 256 (pass in 0) and will generate a delay of 8N ticks including the basic call and return overhead.  If you need a very specific absolute and short delay of M clocks, then you can insert in-line assembly of RJMPs and NOPs.  RJMPs take two clocks and NOPs one clock.  Or you can code RJMPs in C:

goto mylabel01 ;
mylabel01:
goto mylabel02 ;
mylabel02:
...
goto mylabelx ;
mylabelx:


The overhead may be higher in Arduino land.  It takes a grand total of 12 bytes instruction memory.

void delay8NTicks( unsigned char n ) ;

//----------------------------------------------------------------------------------------------------------------------------------
// delay8NTicks
//
.nocc_start
_delay8NTicksLoop:
    rjmp   _delay8NTicks01 ;
_delay8NTicks01:
    rjmp   _delay8NTicks ;
_delay8NTicks::
    dec    R16 ;
    tst     R16 ;
    brne    _delay8NTicksLoop ;
    ret ;
.nocc_end

TinselKoala

  • Hero Member
  • *****
  • Posts: 13958
Re: Single Coil Two Transistor Boost Circuits
« Reply #48 on: June 26, 2014, 01:34:05 AM »
Tinsel doesn't the Arduino software have a "pwm wizard" to calculate and produce the required code for specific frequency and duty
cycle for pwm capable outputs ?

Seems like one advantage of the picaxe is that it can run from 5.5 volts down to 3 volts. And pwm outputs only require that two fields be entered into the pwm wizard, the frequency and the duty, it then gives the code to paste into the program.

The pwm output never exactly matches what we want unless all the timings add up neatly. That is the one thing, but it does get very close.

..
No, the Arduino handles PWM differently, I think. It produces either the "fast PWM" at 62.5 kHz or "phase correct PWM" at 31.25 kHz and provides 256 levels of duty cycle from 0 to 100 percent at those frequencies, on all 6 of the PWM-enabled pins. "analogWrite(pin, value);"  is all that's needed to set the PWM output in code. The actual PWM frequency can be "hacked" by more complex coding to produce other frequencies but this is waay beyond where I'm at.

The sketch above seems to be the most flexible way of doing pulse control with full frequency control up to 80 kHz and duty cycle from 1 to 99 percent. I've written a more complicated program that uses two potentiometers to set the "gap" and "dwell" parameters live while running, and displays the values on the LCD screen, but I won't bore you with that.

This is interesting though. Here is another way of doing the same thing, but restricted to 50-50 duty cycle. But it's slower! Can only reach about 68 kHz. with "1" set as pulse duration, whereas the first sketch gets to 80 kHz with both dwell and gap set to "1".

// TK's Barebones Pulser 0
// Symmetrical (50-50 duty cycle) 5 V pulses on OutPin

int OutPin = 6;
int Vout = LOW;
int pulse = 1;  // sets square pulse duration (approx microseconds)

void setup() {
  pinMode(OutPin, OUTPUT);
 }

void loop() {
  digitalWrite(OutPin, Vout);
  delayMicroseconds(pulse);
  Vout = !Vout;
}

// this way gives only 68 kHz max !

ETA: Adding the line
pulse = analogRead(A1);
in the loop allows setting the frequency from between about 400 Hz to about 4 kHz by using a 50K pot, wiper to A1 and legs to GND and +5V.

TinselKoala

  • Hero Member
  • *****
  • Posts: 13958
Re: Single Coil Two Transistor Boost Circuits
« Reply #49 on: June 26, 2014, 01:38:54 AM »
This assembly code  can be called using the following prototype with values from 1 to 256 (pass in 0) and will generate a delay of 8N ticks including the basic call and return overhead.  If you need a very specific absolute and short delay of M clocks, then you can insert in-line assembly of RJMPs and NOPs.  RJMPs take two clocks and NOPs one clock.  Or you can code RJMPs in C:

goto mylabel01 ;
mylabel01:
goto mylabel02 ;
mylabel02:
...
goto mylabelx ;
mylabelx:


The overhead may be higher in Arduino land.  It takes a grand total of 12 bytes instruction memory.

void delay8NTicks( unsigned char n ) ;

//----------------------------------------------------------------------------------------------------------------------------------
// delay8NTicks
//
.nocc_start
_delay8NTicksLoop:
    rjmp   _delay8NTicks01 ;
_delay8NTicks01:
    rjmp   _delay8NTicks ;
_delay8NTicks::
    dec    R16 ;
    tst     R16 ;
    brne    _delay8NTicksLoop ;
    ret ;
.nocc_end

Thanks... but that's a bit over my pay grade, I'm afraid. Stirs up some deeply buried memories of long nights, cold pizza and warm Pepsi, coding nightmares better left buried and forgotten. I'll stick to my freshman Fortran-style flow that I can translate into pseudo-c++ for the Arduino IDE, and leave the Real Programming to the Real Programmers!

 ;)

MarkE

  • Hero Member
  • *****
  • Posts: 6830
Re: Single Coil Two Transistor Boost Circuits
« Reply #50 on: June 26, 2014, 01:49:02 AM »
Thanks... but that's a bit over my pay grade, I'm afraid. Stirs up some deeply buried memories of long nights, cold pizza and warm Pepsi, coding nightmares better left buried and forgotten. I'll stick to my freshman Fortran-style flow that I can translate into pseudo-c++ for the Arduino IDE, and leave the Real Programming to the Real Programmers!

 ;)
The Arduino language supports the Goto statement.  You should try something like:

DigitalWrite( pinX, high )  ;
goto delay01 ;
delay01:
goto delay02 ;
delay02:
DigitalWrite( pinX, low ) ;

This should give you a four clock long high pulse on pinX.  On a chip running 8 MHz just duplicate to delay08 and you will get a 16 clock long, IE 2us long high pulse.

TinselKoala

  • Hero Member
  • *****
  • Posts: 13958
Re: Single Coil Two Transistor Boost Circuits
« Reply #51 on: June 26, 2014, 04:15:28 AM »
OK, that I can understand. Here's the code fully "arduinoized" and tested, runs a nice square pulse with minimal jitter at 104.8 kHz.

//------------------------------------------
//----MarkE's Pulser Code               
//----gives 104.8 kHz
//------------------------------------------

void setup(){
  pinMode(6,OUTPUT);
}
void loop() {
delay00:
  digitalWrite( 6, HIGH )  ;
  goto delay01 ;
delay01:
  goto delay02 ;
delay02:
  digitalWrite( 6, LOW ) ;
  goto delay05 ;
delay05:
  goto delay00 ;
}

//-----------------------------------------

Thanks !

(ETA: This appears to be the fastest with this method, even if I only use a single goto:delay pair for HIGH and LOW, it still runs at 104.8 kHz.)
(ETA2: Atmel 328P)

TinselKoala

  • Hero Member
  • *****
  • Posts: 13958
Re: Single Coil Two Transistor Boost Circuits
« Reply #52 on: June 26, 2014, 04:30:43 AM »
Heh... the bottle neck is clearly in the "digitalWrite" statements and the main loop. (The MarkE code never makes the main loop, it's all happening inside the goto loops.)

This code produces a nice square pulse train but only 98.3 kHz!

void setup(){
  pinMode(6,OUTPUT);
}
void loop(){
  digitalWrite(6,HIGH);
  digitalWrite(6,LOW);
}


Farmhand

  • Hero Member
  • *****
  • Posts: 1583
Re: Single Coil Two Transistor Boost Circuits
« Reply #53 on: June 26, 2014, 04:32:56 AM »
For beginners like me it might help if more code is posted.

A simple single block for pin B.4 on a picaxe 14M2 to go high for 70 mS and low for 70 mS would go
Main:
       do
       high B.4 pause 70
       low B.4 pause 70
       loop

But that might be slow and not give exactly 70 mS.

Another way is the pulsout command

Block below is from picaxe manual 2
main:
        pulsout B.1,150 ; send a 1.50ms pulse out of pin B.1
        pause 20 ; pause 20 ms
        goto main ; loop back to start

For low frequency pulsing with picaxe like I did with the capacitor pulser is very easy, I just write code blocks and after the first one or two I call each one the same with ascending numbers for multiple blocks, first one or two blocks might be "Main:" or Intro:, then Main:.  A better way than using the analogue to digital converter and voltage divider would be to use a push button to send an input pin high which would cycle the program through the different blocks, if it was written to do so.

In the program below the Sing0: code block is  virtually non functional except to ensure pin B.4 is actually low to begin with and
only remains for ease of giving function back to it.

Main:
do
setfreq m4..........................................Sets core frequency, can be 4,8,16 or 32 mHz for M2 parts.
readadc B.5,b1....................................Reads Analogue to digital converter on pin B.5 to variable b1 (Pin B.5 gets the divided v)
if b1 => 160 then goto sing3..............(Depending on the Voltage level detected at B.5 and read to variable b1 jump to
if b1 => 80 then goto sing2.................whichever block the pot setting determins).
if b1 => 60 then goto sing
if b1 < 40 then goto sing0
pause 300
loop
sing0:
Low B.4
pause 1000
goto main
sing:
pause 100
do
high B.4 pause 70
low B.4 pause 700
readadc B.5,b1
if b1 < 60 then goto main
if b1 => 80 then goto sing2
pause 100
loop
sing2:
do
high B.4 pause 70
low B.4 pause 600
readadc B.5,b1
if b1 < 80 then goto sing
if b1 => 160 then goto sing3
loop
sing3:
do
high B.4 pause 70
low B.4 pause 500
readadc B.5,b1
if b1 < 160 then goto sing2
if b1 => 200 then goto sing4
loop
sing4:
do
high B.4 pause 70
low B.4 pause 400
readadc B.5,b1
if b1 < 200 then goto sing3
if b1 => 225 then goto sing5
loop
sing5:
do
high B.4 pause 70
low B.4 pause 300
readadc B.5,b1
if b1 < 225 then goto sing4 
loop


...

TinselKoala

  • Hero Member
  • *****
  • Posts: 13958
Re: Single Coil Two Transistor Boost Circuits
« Reply #54 on: June 26, 2014, 04:44:35 AM »
Everything I've posted above is a complete functioning program!
Just copypaste into the Arduino IDE, compile for your particular board, upload, connect the gate of the mosfet to the Out pin and Bob's yer Uncle!

Of course your example is a lot more feature-filled, showing how you can change between program segments using voltages read from the voltage divider. I just feed in a delay figure directly using the

pulse=analogRead(potwiperpin);
delayMicroseconds(pulse);

statements or similar.

MarkE

  • Hero Member
  • *****
  • Posts: 6830
Re: Single Coil Two Transistor Boost Circuits
« Reply #55 on: June 26, 2014, 05:15:36 AM »
OK, that I can understand. Here's the code fully "arduinoized" and tested, runs a nice square pulse with minimal jitter at 104.8 kHz.

//------------------------------------------
//----MarkE's Pulser Code               
//----gives 104.8 kHz
//------------------------------------------

void setup(){
  pinMode(6,OUTPUT);
}
void loop() {
delay00:
  digitalWrite( 6, HIGH )  ;
  goto delay01 ;
delay01:
  goto delay02 ;
delay02:
  digitalWrite( 6, LOW ) ;
  goto delay05 ;
delay05:
  goto delay00 ;
}

//-----------------------------------------

Thanks !

(ETA: This appears to be the fastest with this method, even if I only use a single goto:delay pair for HIGH and LOW, it still runs at 104.8 kHz.)
(ETA2: Atmel 328P)
I am glad that it helps.  I have yet to dig into how Arduino code compiles.  I was hoping that the compiler would be smart enough to reduce the goto's to the next line into RJMP +0 assembly instructions.  It looks like the compiler is inserting overhead of more than 30 instructions.

Farmhand

  • Hero Member
  • *****
  • Posts: 1583
Re: Single Coil Two Transistor Boost Circuits
« Reply #56 on: June 26, 2014, 05:16:47 AM »
Yeah I'm keen to use Arduino so your code helps me a lot, I might get it out and have a play with it. 100 kHz or so is plenty fast
enough for most booster situations I think. I went down to 30 kHz last night messing about and my little dog started growling at me.
After a while I realized it might be the circuit noise. I wonder what our electronic world sounds like to a dog. Probably very noisy and annoying.  :-\ One reason I think I would like to use about 60 kHz or above, surely they couldn't hear that.


P.S. I was writing my previous post before the last two went up I think. Mine looks out of place now a bit. But anyway some might use picaxe. I think micro's are a great way to control and interface separate circuits, as well as they can do a lot themselves.
..

TinselKoala

  • Hero Member
  • *****
  • Posts: 13958
Re: Single Coil Two Transistor Boost Circuits
« Reply #57 on: June 26, 2014, 05:48:52 AM »
I am glad that it helps.  I have yet to dig into how Arduino code compiles.  I was hoping that the compiler would be smart enough to reduce the goto's to the next line into RJMP +0 assembly instructions.  It looks like the compiler is inserting overhead of more than 30 instructions.
I can't see any big change in frequency when I use 4 or 6 pairs of goto:label statements, and since the main loop with just the write instructions is actually slower than the goto loop, I think that the extra overhead is mostly in the write statements. I might do some additive tests to see how many goto pairs I have to put in before the frequency changes much.

Farmhand

  • Hero Member
  • *****
  • Posts: 1583
Re: Single Coil Two Transistor Boost Circuits
« Reply #58 on: June 26, 2014, 11:51:36 AM »
I noticed with this circuit that when the load is 3 x 5 mm LED's between the diode output and the positive rail that the ring down is clipped on
the negative side of the oscillations and the very first one seems to have a "charging" type appearance but upside down.
As shown in the first scope shot.

However in the second shot with the load of 2 x AA cells in series between the diode output and the circuit ground the oscillations are free and not clipped.

It appears that if the ring down is "very ringy" when the load is between the diode output and the positive rail some power may be returned. Possibly bringing the ring down back to supply voltage quicker (if there was enough time for that).

Just a small thing I noticed, not sure if my assumption is correct. Just sayin.  :)
..
Maybe if I connect my scope to the computer I can get better scope shots.

...

Farmhand

  • Hero Member
  • *****
  • Posts: 1583
Re: Single Coil Two Transistor Boost Circuits
« Reply #59 on: June 26, 2014, 12:05:25 PM »
Tonight's experiment will be to test the run time for the circuit as adjusted shown last post from 2 x 50 Farad capacitors charged to 0.75 volts each,
which is about 14 Joules per capacitor (28 total), I'll put them in series and run from 1.5 volts down to 0.8 volts, which will be 0.4 volts
on each capacitor and about 4 Joules per capacitor (8 joules total). Leaving me with 8 Joules total from 28 Joules to begin with.
So I'll use 20 Joules, and time it. I'll run the 3 x 5 mm LED's as load.
...

EDIT:....

Results: With 20 Joules it ran for 24 minutes before going under 0.8 volts, at 1.5 volts it had 8.3 volts across the LED's and they
were quite bright, at 0.8 volts input it had 7.8 volts across the 3 x 5 mm LED's, not as bright, but still bright to look at and throwing
useful light.

Works out to I think about 0.83 Joules per minute average, and divided by 60 seconds = about  0.014 Watts power draw average I think.

And it kept running for a further 4 minutes when at 0.68 volts the lights went out.

Not bad and thats with an MPSA06 transistor. about 5 on 6 off I think at the start, 1 mH inductor.

..
« Last Edit: June 26, 2014, 02:07:18 PM by Farmhand »