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.

gyulasun

Hi Dann,

Good you managed to make it work, albeit with that unwanted issues.  Perhaps a 'dead bug' construction
instead of the protoboard may cure the problem.
You can think of spurious oscillations due to not enough decoupling on input pins and / or the 5V reference pin.
See this motor speed control circuit based on TL494 where the wiper of duty cycle control pot is shunted by
a 220 uF, rather unusual:  http://www.nawattakam.com/talk/index.php?topic=784.0  Also, the pin connections
around the duty cycle circuit are different from the schematics shown in this forum hence from what you built. 
Maybe it would be worth rewire your board for the changes because pin 4 (dead time control) is grounded
which is your duty cycle control input at present and receives varying DC voltage from the wiper of the potmeter.
The motor speed control circuit in the above link gives almost 100% duty control by combining the two out of phase
outputs for the motor via the two power MOSFETs, originally the TL494 gives duty control from 1% to 45% only, if I
understand correctly.  Good luck.

Gyula

madddann

Hi Gyula.

Thanks for that schematic, I fiddled with the circuit some more time and got it to work (above certain frequency). It seems that below 30kHz the duty cycle anomaly on one of the outputs starts to happen.
Anyway I just realized this chip will not go below 1kHz, so it doesn't help me with what I'm experimenting right now.
I also have an SG3525, but the lowest it will go is 100Hz, which is still higher than I would like.

So now I came full circle, and learned something useful along the way.


@all.

Now back to the arduino plan.
I'll write down the specs needed here again:

-two phase PWM square wave generator
-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) like the signals PWM1 and PWM3 here: https://batchloaf.files.wordpress.com/2015/03/four_phase_pwm.png

I have an arduino nano 328p, V3.

Anyone that enjoys fiddelin with code Is welcome  :) .

Maybe somewhere on the net already exsists some code for a 4 phase or 6 phase PWM controller with adjustable frequency...
If anyone happens to know about it please post it here.
Any help is appreciated.

Thanks everyone!

gyulasun

Hi Dann,

I understand your aim to use your Arduino chip. Hopefully the needed specifications you set out can be
achieved either by your chip or by a PIC chip (microcontroller).

Yet, I would again like to refer to an 'analog' way of producing shifted pulses. You surely heard about
modified sine wave inverters, these are basically DC to AC power converters and their output waveforms
try to mimic the needed sine wave shape as close as possible. And this involves the producing of shifted
pulses first. See such circuit here, with scope shot on the waveform you would need:
https://www.homemade-circuits.com/how-to-build-simplest-modified-sine/ 
Unfortunately, this circuit does not include duty cycle control.  It could be provided by using a dual monostable
multivibrator (say CD4538) which would stretch out or reduce the pulse width coming from IC2 (CD4017)
and you could control the pulse width by a double (stereo) potmeter or individually for the two channels.
Here is another circuit to produce the shifted pulses, with other than the CD4017:
http://www.instructables.com/id/Modified-Sine-Wave-Signal-Generator/  but it does not have duty cycle control either.

Good luck.
Gyula

madddann

Hi! Thanks for the suggestions Gyula.

I think I have some of those SN74LSxx chips and I also have a variable frequency PWM (555 + comparator) that I used before,
so I may come up with some mix that works. Will try to play tomorrow in multisim.

Today I got some help from someone close and we did program (just few lines of code) the arduino nano to output two PWM signals shifted by 180°, at a fixed frequency.
So I did play a bit with my figuera setup and noticed that variable phase shift would come also handy  ;D .
I also think that the mosfets are cutting off almost half (top section) of the resonant wave, so will have to replace them with ordinary transistors.
The problems pile up one after another, but hopefully the solutions will outmatch them.

On the arduino forum I found some discussion and code that would do what I need, but it's for arduino mega: https://forum.arduino.cc/index.php?topic=482903.0
Maybe I'll ask there for some help.

Dann



kEhYo77

YO!

I spent the whole weekend trying to figure this out and here it is!!!
3 controlling pots: Frequency / Duty / Range
Max operational frequency around 500 kHz
Min operational frequency around 1 Hz
The resolution of duty cycle goes down the higher you go up in given frequency range.


Enjoy!!!


Quote
// Dual pin PWM PUSH-PULL generator FOR Arduino UNO on pins 9&10
// by kEhYo77 2018


int user_cycles;
int user_duty;
int user_range;
int temp_cycles;
int temp_duty;
int temp_range;
int tuner;
unsigned long past = 0;


void set(int cycles, float duty) {
 
  char oldSREG;
 
  int dutyCycle = cycles * duty;
  if (dutyCycle < 6) {
    dutyCycle = 6; // Prevent duty cycle from being too short
  }

  oldSREG = SREG; // Save the registers
  cli(); // Disable interrupts for 16 bit register access
  ICR1 = cycles; // ICR1 is TOP in p & f correct pwm mode
  OCR1A = cycles-dutyCycle/2+1; //Pin 9 match
  OCR1B = dutyCycle/2-1; //Pin 10 match
 
  SREG = oldSREG; // Restore the registers
}


void setup() {

  pinMode(A0, INPUT); //analoque pot input Frequency
  pinMode(A1, INPUT); //analoque pot input DutyCycle
  pinMode(A2, INPUT); //analogue pot input Range
 
  bitClear(ADCSRA,ADPS0); //running analog pot input
  bitClear(ADCSRA,ADPS1); //with high speed clock
  bitSet(ADCSRA,ADPS2); //set prescaler to 16
   
  pinMode(9, OUTPUT); //output A
  pinMode(10, OUTPUT); //output B


  TCCR1A = 0; //clear timer1 registers
  TCCR1B = 0;
  TCNT1 = 0;


  TCCR1A |= _BV(COM1A1) | _BV(COM1A0);
  //Output A. Set OC1A/OC1B on Compare Match,
  //Clear OC1A/OC1B at BOTTOM (inverting mode)


  TCCR1A |= _BV(COM1B1);
  //Output B. Clear OC1A/OC1B on Compare Match when up-counting.
  //Set OC1A/OC1B on Compare Match when down-counting.


  TCCR1B |= _BV(WGM13); //PWM Phase Correcrt mode 10 to ICR1
  TCCR1A |= _BV(WGM11); //WGM13:WGM11 set 1010
  TCCR1B |= _BV(CS10); //set prescaler 1
}


void loop() {
  if ((millis() - past) >= 500) { //read pots every half second
  temp_cycles = analogRead(A0);
  temp_duty = analogRead(A1);
  temp_range = analogRead(A2);
  past = millis();
   
  if (temp_cycles != user_cycles || temp_duty != user_duty) {
    user_cycles = temp_cycles;
    user_duty = temp_duty;
    set(user_cycles * tuner, user_duty / 1024.0);
  }


  if (temp_range != user_range) {
  if (temp_range <= 250) { TCCR1B |= (1<<CS10); TCCR1B &= ~((1<<CS11) | (1<<CS12)); tuner = 1; } // prescaler 1 ( 8 kHz - 300 kHz )
  if (temp_range > 250 & temp_range <= 500) { TCCR1B |= _BV(CS11); TCCR1B &= ~((1<<CS10) | (1<<CS12)); tuner = 8; } //prescaler 8 ( 120 Hz - 40 kHz )
  if (temp_range > 500 & temp_range <= 750) { TCCR1B |= _BV(CS10) | _BV(CS11); TCCR1B &= ~(1<<CS12); tuner = 16; } //prescaler 64 ( 4 Hz - 1 kHz )
  if (temp_range > 750 & temp_range <= 1024) { TCCR1B |= _BV(CS12); TCCR1B &= ~((1<<CS10) | (1<<CS11));  tuner = 32; } //prescaler 256 ( 1 Hz - 60 Hz )
  user_range = temp_range;
  }


  }
}