Go Down

Topic: Can anyone help with my switching signal problem? (Read 666 times) previous topic - next topic

Hi everyone!
I have been trying for a few days now to figure out how to generate two switching signals simultaneously using an arduino.. with no major breakthroughs as of yet..

The most annoying part is that i feel my problem is very simple in reality but i just cannot figure it out! Essentially all i want to do is generate 2 simple 30KHz square waves with a duty cycle of 45%. The second square wave should be delayed by 0.5*Period so that only one signal is HIGH and any time. like the first 2 waveforms in this photo.


Does anyone know how to program this using an arduino, i can easily generate a simple 30khz signal (essentially the blink example that comes with the arduino software) but i dont know how to generate 2 simultaneously.
Any help would be greatly appreciated!

in case anyone is wondering i am building a half-bridge induction heater any am using the signals to control a pair of IGBT transistors.
like this schematic.



Direct port manipulation comes to mind, you should look into it.
My GitHub:


Leonardo has Dead Time generator on Timer4, I think specifically design to drive 3 phase motors. Haven't seen any library or IDE support, but you may try to search. Otherwise dig into data sheet. If jitter not an issue, you can try any others arduino board w/o hardware build-in support, than you run interrupt subroutine (TimerOne or MsTimer2) and switch outputs "manually"


You don't actually want to switch the two parts of the H-bridge simultaneously because if you do then you will get shoot through where the transistors are on at the same time. This happens because the transistors do not follow the input signal exactly at the same time. Using just NPN transistors means that you can't switch any voltage higher than the level of the signal because that top transistor is acting as an emitter follower.
If you want to use this arrangement and avoid shoot through then turn the transistor off before you turn the other one on.

Hi HazardsMind,

Thank you for the suggestion, I never heard of direct port manipulation before now.
I feel it might be possible to use this method, the main problem i can see is the delay incurred when the program reaches the end of the loop.
Any suggestions on how to overcome this?

Hi Grumpy_Mike,
Thanks for your reply.
Yes i am well aware of that, as you can see in my original post there is a link showing the switching signal waveforms.
In these waveforms only one pin is high at any one time, this is to maintain Zero Voltage Switching Conditions.


My GitHub:

Jan 27, 2013, 12:43 am Last Edit: Jan 27, 2013, 01:27 am by PidgeyDoyle Reason: 1
I dont have any way to measure frequency at the moment, but here is a basic idea of the direction i am going!!

float SWFreq = 30000;
float period = (1/SWFreq);
float ontime = (0.45*period*1000);
float bothoff = (0.05*period*1000);

void setup()
  DDRD = B01001000; // set PORTD (digital 7~0) to outputs

void loop()
  PORTD = B01000000; //pin 7 is high
  PORTD = B00000000; //all pins are off
  PORTD = B00001000; //pin 1 is high 
  PORTD = B00000000;//all pins are off

EDIT: Changed int to float.

I guess all i need to do is measure the delay caused by the loop ending and subtract it from the delay(bothoff); in the last line of code?


That is not the way to generate a signal, you are using the whole of the processor. What you want to do is to set up a timer to trigger at regular intervals, the use the interrupt service routine to switch your pins.
If it is an induction heater why does it have to be so precise a frequency anyway?

Hi GrumpyMike,

I think you are right, my direct port manipulation code worked very well for low frequencies but didnt really work at khz levels.
The frequency generation doesn't have to be that accurate, just so long as zero voltage switching is maintained.
I have looked into interrupts like you said, once again my problem is that I cant figure out how to generate 2 signals to 2 pins without screwing everything up!!


Go Up