Overunity.com Archives is Temporarily on Read Mode Only!



Free Energy will change the World - Free Energy will stop Climate Change - Free Energy will give us hope
and we will not surrender until free energy will be enabled all over the world, to power planes, cars, ships and trains.
Free energy will help the poor to become independent of needing expensive fuels.
So all in all Free energy will bring far more peace to the world than any other invention has already brought to the world.
Those beautiful words were written by Stefan Hartmann/Owner/Admin at overunity.com
Unfortunately now, Stefan Hartmann is very ill and He needs our help
Stefan wanted that I have all these massive data to get it back online
even being as ill as Stefan is, he transferred all databases and folders
that without his help, this Forum Archives would have never been published here
so, please, as the Webmaster and Creator of this Forum, I am asking that you help him
by making a donation on the Paypal Button above
Thanks to ALL for your help!!


Single Coil Two Transistor Boost Circuits

Started by Farmhand, June 11, 2014, 12:13:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MarkE

Quote from: TinselKoala on June 25, 2014, 07:38:54 PM
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

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

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

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

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.