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 2 Guests are viewing this topic.

TinselKoala

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

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

Quote from: TinselKoala on June 25, 2014, 10:21:27 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

Quote from: Farmhand on June 25, 2014, 07:05:42 PM
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

Quote from: MarkE on June 25, 2014, 07:18:49 PM
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!

;)