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 these Archives, I am asking that you help him
by making a donation on the Paypal Button above.
You can visit us or register at my main site at:
Overunity Machines Forum



Arduino signal generator

Started by ayeaye, October 27, 2016, 02:33:55 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

ayeaye

My Arduino Nano. Costs $2.26 with shipping when bought from ebay  http://www.ebay.com/itm/MINI-USB-Nano-V3-0-ATmega328P-CH340G-5V-16M-Micro-controller-board-For-Arduino-N-/141975930194?hash=item210e6cc552:g:e58AAOSwpDdVL5yR . Because it's small, it comes quite fast, and it comes directly to your mailbox, so it's easy to get. If one is very rich, one may think about buying that one for $3.78 with shipping, which also comes with the right usb cable  http://www.ebay.com/itm/ATMEGA328P-FT232RL-FTDI-Micro-controller-Module-for-Arduino-Nano-V3-0-With-Cable-/381801276448?hash=item58e5212420:g:kVMAAOSwHnFVybGk . Though if one happens to have some very old digital camera somewhere or something, then its usb cable is exactly the right one.

ayeaye

The Digispark ATtiny85 board costs in ebay $1.52 with shipping  http://www.ebay.com/itm/Digispark-ATTINY85-General-Micro-USB-Development-Board-For-Arduino-New-WA-/281921984524?hash=item41a3dc180c:g:lMEAAOSwXshWqy3A . A link to their license https://creativecommons.org/licenses/by-sa/3.0 . That one has really not much more on it, bout the ATtiny85 integrated circuit, and a voltage regulator, which is also unnecessary when powered by usb. The only thing is that for using a separate ATtiny85 like that, a bootloader has to be written into it, which needs a programmator. This one goes to the standard usb socket, there is also a variety with a micro usb socket on it, but that one is somewhat more expensive. Can be used with the Arduino software, but read above about the limitations of this one.

madddann

Hello everyone!

I know this thread is old, but since the topic is right, I will post here.
I'm looking for some arduino code, or someone that would be so kind and write it for me and whoever may need it next.
What I'm looking for is a two phase PWM signal generator with:
-variable frequency from 1Hz (or at least around 5Hz) up to whatever is possible - reasonable  (adjustable with pot.)
-variable duty cycle from 1% to 100%, resolution the more the better (adjustable with pot.)
-two outputs shifted (delayed) for half the total period (180°), (not inverted - same signal on both channels only shifted)

Well, that's it. I would try to modify the last code posted by user ayeaye if I only had a clue what is written inthere  :D .
I have an arduino nano 328p, V3.

I'm experimenting with a Figuera type setup, that's what I need the two phase signal generator for.
I rarely post, so I'll understand if this goes unnoticed, but this is the only time in 10 years that I'm asking for something, so please, If someone with the right skills is reading this and willing to help out, I will be very gratefull.

Dann


kEhYo77

Reposting this from Figuera thread.

All you need is:[/size]1. ONE 10k/100k Ohm potentiometer. Connect the middle leg to Arduino's "A0" analog input. The other two legs of the pot goes to +5V and GND on Arduino.2. TWO Logic Level MOSFET transistors to do the switching (Logic level - like in IRL series -  means that a mosfet is in a conduction saturation state at just +5V put to its gate). Connect the Gate of one mosfet to "Pin 3" and the others' gate to "Pin 11". Sources go to the "GND" of the Arduino board.3. Connect +(positive) from a battery to both "North" & "South" coils and their ends to both drains in the two mosfets and -(negative) to the Arduino's "GND" close to the Source legs of mosfets.4. Connect fast shottky diodes across each coil to do the freewheeling of current.Program description:Arduino is generating a digital signal at 32 kHz frequency using 2 PWM outputs. The value for each "sample" is taken from the sine table. There are 256 values of resolution for the "shape" of the sine wave and 256 values of amplitude. You can change phase shift by changing "offset" variable. Potentiometer allows to set the analog frequency from 0 to 1023 Hz at 1 Hz resolution...NOW copy the code below to Arduino IDE window and save it to the microconroller and HERE YOU GO! 

Quote
/* CLEMENTE FIGUERAS GENERADOR DRIVER
* modification by kEhYo77
*
* Thanks must be given to Martin Nawrath for the developement of the original code to generate a sine wave using PWM and a LPF.
* http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/
*/




#include "avr/pgmspace.h" //Store data in flash (program) memory instead of SRAM




// Look Up table of a single sine period divied up into 256 values. Refer to PWM to sine.xls on how the values was calculated
PROGMEM  prog_uchar sine256[]  = {
  127,130,133,136,139,143,146,149,152,155,158,161,164,167,170,173,176,178,181,184,187,190,192,195,198,200,203,205,208,210,212,215,217,219,221,223,225,227,229,231,233,234,236,238,239,240,
  242,243,244,245,247,248,249,249,250,251,252,252,253,253,253,254,254,254,254,254,254,254,253,253,253,252,252,251,250,249,249,248,247,245,244,243,242,240,239,238,236,234,233,231,229,227,225,223,
  221,219,217,215,212,210,208,205,203,200,198,195,192,190,187,184,181,178,176,173,170,167,164,161,158,155,152,149,146,143,139,136,133,130,127,124,121,118,115,111,108,105,102,99,96,93,90,87,84,81,78,
  76,73,70,67,64,62,59,56,54,51,49,46,44,42,39,37,35,33,31,29,27,25,23,21,20,18,16,15,14,12,11,10,9,7,6,5,5,4,3,2,2,1,1,1,0,0,0,0,0,0,0,1,1,1,2,2,3,4,5,5,6,7,9,10,11,12,14,15,16,18,20,21,23,25,27,29,31,
  33,35,37,39,42,44,46,49,51,54,56,59,62,64,67,70,73,76,78,81,84,87,90,93,96,99,102,105,108,111,115,118,121,124




};
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) //define a bit to have the properties of a clear bit operator
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))//define a bit to have the properties of a set bit operator




int PWM1 = 11; //PWM1 output, phase 1
int PWM2 = 3; //PWM2 ouput, phase 2
int offset = 127; //offset is 180 degrees out of phase with the other phase




double dfreq;
const double refclk=31376.6;      // measured output frequency
int apin0 = 10;




// variables used inside interrupt service declared as voilatile
volatile byte current_count;              // Keep track of where the current count is in sine 256 array
volatile unsigned long phase_accumulator;   // pahse accumulator
volatile unsigned long tword_m;  // dds tuning word m, refer to DDS_calculator (from Martin Nawrath) for explination.




void setup()
{
  pinMode(PWM1, OUTPUT);      //sets the digital pin as output
  pinMode(PWM2, OUTPUT);      //sets the digital pin as output
  Setup_timer2();
 
  //Disable Timer 1 interrupt to avoid any timing delays
  cbi (TIMSK0,TOIE0);              //disable Timer0 !!! delay() is now not available
  sbi (TIMSK2,TOIE2);              //enable Timer2 Interrupt




  dfreq=10.0;                    //initial output frequency = 1000.o Hz
  tword_m=pow(2,32)*dfreq/refclk;  //calulate DDS new tuning word
 
  // running analog pot input with high speed clock (set prescale to 16)
  bitClear(ADCSRA,ADPS0);
  bitClear(ADCSRA,ADPS1);
  bitSet(ADCSRA,ADPS2);




}
void loop()
{
        apin0=analogRead(0);             //Read voltage on analog 1 to see desired output frequency, 0V = 0Hz, 5V = 1.023kHz
        if(dfreq != apin0){
          tword_m=pow(2,32)*dfreq/refclk;  //Calulate DDS new tuning word
          dfreq=apin0;
        }
}




//Timer 2 setup
//Set prscaler to 1, PWM mode to phase correct PWM,  16000000/510 = 31372.55 Hz clock
void Setup_timer2()
{
  // Timer2 Clock Prescaler to : 1
  sbi (TCCR2B, CS20);
  cbi (TCCR2B, CS21);
  cbi (TCCR2B, CS22);




  // Timer2 PWM Mode set to Phase Correct PWM
  cbi (TCCR2A, COM2A0);  // clear Compare Match
  sbi (TCCR2A, COM2A1);
  cbi (TCCR2A, COM2B0);
  sbi (TCCR2A, COM2B1);
 
  // Mode 1  / Phase Correct PWM
  sbi (TCCR2B, WGM20); 
  cbi (TCCR2B, WGM21);
  cbi (TCCR2B, WGM22);
}








//Timer2 Interrupt Service at 31372,550 KHz = 32uSec
//This is the timebase REFCLOCK for the DDS generator
//FOUT = (M (REFCLK)) / (2 exp 32)
//Runtime : 8 microseconds
ISR(TIMER2_OVF_vect)
{
  phase_accumulator=phase_accumulator+tword_m; //Adds tuning M word to previoud phase accumulator. refer to DDS_calculator (from Martin Nawrath) for explination.
  current_count=phase_accumulator >> 24;     // use upper 8 bits of phase_accumulator as frequency information                     
 
  OCR2A = pgm_read_byte_near(sine256 + current_count); // read value fron ROM sine table and send to PWM
  OCR2B = pgm_read_byte_near(sine256 + (uint8_t)(current_count + offset)); // read value fron ROM sine table and send to PWM, 180 Degree out of phase of PWM1
}

http://www.youtube.com/watch?v=hC70s3tYaGs&hd=1

madddann

Wow! Thank you kEhYo77, now i remember seeing your video... long time since then...
The code you posted will sure come handy in the future, but what I need right now is much simpler, I knew I forgot to mention something.

What I'm asking for is just two square wave signals offset by half the period (180°), with adjustable on time and frequency, thats all.

Like the two signals "PWM1" and "PWM3" on this picture: https://batchloaf.files.wordpress.com/2015/03/four_phase_pwm.png

I'm doing Figuera experiments "Tesla style" - creating two resonant tanks with oposite signals - wich the electromagnets are a part of.
I'm sure you could try this also on your setup (from the video)... just add capacitors to the coils (electromagnets) and excite the hell out of it  ;D .

Thanks again! If you or anyone else would put together the code for the two square wave signals, that would be great.

Dann