Variable frequency?? only switching

Hello, I am working on 3 phase variable frequency drive. I have to generate frequency from 10hz to 500hz (variable).

I am using simple techniques to generate variable frequencies from 10hz to 99hz for switching of PIN (HIGH or LOW)

but when i generate 100hz or more then 100hz, it even don't work. I know there's a problem with either delay or delayMicroSeconds.

for example: my desired frequency= 200hz

so here what i am doing

void delaymicro()
{

del= 833.3333333;
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
delayMicroseconds(del);

digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
delayMicroseconds(del);

digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
delayMicroseconds(del);

digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
delayMicroseconds(del);

digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
delayMicroseconds(del);

Serial.print("delay=");
Serial.println(del);

digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
delayMicroseconds(del);

}

explanation:

we have 6 delays working here. 6x833.33=5000us of total time period so frequency: frequency=1/(5000us)=200hz

but the delaymicroseconds dont work.

i get the out put frequency of randomly generated 100hz but never more then that, its always incorrect.

P.S: a,b,c are the pins for the 3 phases, you have nothing to do with that. there are the pins connected at digital 2, 3, 4 ** a, b, c**

Please post all of your code. The code fragment you posted cannot compile.

econjack: Please post all of your code. The code fragment you posted cannot compile.

here you go dear.

 double del;
double t;
double freq;
double T;
double tim;


int a=2;
int b=3;
int c=4;

void setup() {
  Serial.begin(9600);

pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);

//------------------------------
freq=200.00;
if (freq>100.00)
{
Serial.print("freq=");
Serial.println(freq);

t=1/(freq);

Serial.print("t=");
Serial.println(t);

T=t/4;

Serial.print("T=");
Serial.println(T);

tim=(2.00/3.00)*T;

del=tim*1000000;
Serial.print("delay=");
Serial.println(del);

}

}

void loop() {
 if (freq>100.00)
{
  Serial.println("heyy");
  delaymicro();
}

  
}






void delaymicro()
{

digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
delayMicroseconds(del);
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
delayMicroseconds(del);
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
delayMicroseconds(del);
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
delayMicroseconds(del);
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
delayMicroseconds(del);

Serial.print("delay=");
Serial.println(del);

digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
delayMicroseconds(del);

}

The Serial.print lines are slowing down your timing. My guess is that you have Serial.begin(9600).

Change it to Serial.Begin(115200) or take the lines out completely, and see what it does to the frequency.

cattledog:
The Serial.print lines are slowing down your timing. My guess is that you have Serial.begin(9600).

Change it to Serial.Begin(115200) or take the lines out completely, and see what it does to the frequency.

I don’t think that this is a issue. By the way i have tried. It doesn’t work as well.
I think it’s a problem with delayMicroseconds function.

I don't think that this is a issue. By the way i have tried.

Run your code with and without the print lines in the timing section. I certainly get close to 200Hz when I run it.

void delaymicro()
{

digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
delayMicroseconds(del);
digitalWrite(a, HIGH);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
delayMicroseconds(del);
digitalWrite(a, HIGH);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
delayMicroseconds(del);
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, LOW);
delayMicroseconds(del);
digitalWrite(a, LOW);
digitalWrite(b, HIGH);
digitalWrite(c, HIGH);
delayMicroseconds(del);

//Serial.print("delay=");
//Serial.println(del);

digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, HIGH);
delayMicroseconds(del);

}

Hi,

Can please you post a diagram of what you are trying to achieve at the outputs of the arduino to make your VSD drive?

Are you making square waves or modulating the PWM to produce sinewave 3 phase output?

Thanks.. Tom.... :)

TheEvilGenius427: here you go dear.

Is that really an appropriate tone from someone that is hoping for free assistance ?

...R

cattledog: Run your code with and without the print lines in the timing section. I certainly get close to 200Hz when I run it.

void delaymicro()
{

digitalWrite(a, HIGH); digitalWrite(b, LOW); digitalWrite(c, HIGH); delayMicroseconds(del); digitalWrite(a, HIGH); digitalWrite(b, LOW); digitalWrite(c, LOW); delayMicroseconds(del); digitalWrite(a, HIGH); digitalWrite(b, HIGH); digitalWrite(c, LOW); delayMicroseconds(del); digitalWrite(a, LOW); digitalWrite(b, HIGH); digitalWrite(c, LOW); delayMicroseconds(del); digitalWrite(a, LOW); digitalWrite(b, HIGH); digitalWrite(c, HIGH); delayMicroseconds(del);

//Serial.print("delay="); //Serial.println(del);

digitalWrite(a, LOW); digitalWrite(b, LOW); digitalWrite(c, HIGH); delayMicroseconds(del);

}

Karma goes to you Sir. Thank You. I missed that serial command. Hats off!

TomGeorge: Hi,

Can please you post a diagram of what you are trying to achieve at the outputs of the arduino to make your VSD drive?

Are you making square waves or modulating the PWM to produce sinewave 3 phase output?

Thanks.. Tom.... :)

hi, http://electronicdesign.com/site-files/electronicdesign.com/files/uploads/2013/10/1107InterfaceConnectionFig1-large.jpg

its much similar to that, but once i release my product then i will surely reveal the design, i am currently working on it, the architecture is still under considerations. hopefully till June 2016.

thankyou

Robin2:
Is that really an appropriate tone from someone that is hoping for free assistance ?

…R

Apparently it’s common in some cultures, similar to starting a letter with Dear Sir or Madam, and then dropping the Sir or Madam bit to reply to an individual. I don’t think anything negative was implied.

Not that I like the form of address…

Hi,

TheEvilGenius427: hi, http://electronicdesign.com/site-files/electronicdesign.com/files/uploads/2013/10/1107InterfaceConnectionFig1-large.jpg

its much similar to that, but once i release my product then i will surely reveal the design, i am currently working on it, the architecture is still under considerations. hopefully till June 2016.

thankyou

|500x144

So you won't be attempting to PWM at a higher frequency to provide a sinewave shaped current to each motor phase? You will be providing just 10Hz to 500Hz square-wave to each motor phase, you are going to need some substantial filtering on the motor side as well as the supply side to keep switching noise to a minimum. I am not sure what scale this VSD is going to, Power Level? DC Bus Voltage? Have you analized the switching currents involved considering the changing impedance of the motor over the 10Hz to 500Hz range. Thanks Tom.... :)

TomGeorge: Hi, |500x144

So you won't be attempting to PWM at a higher frequency to provide a sinewave shaped current to each motor phase? You will be providing just 10Hz to 500Hz square-wave to each motor phase, you are going to need some substantial filtering on the motor side as well as the supply side to keep switching noise to a minimum. I am not sure what scale this VSD is going to, Power Level? DC Bus Voltage? Have you analized the switching currents involved considering the changing impedance of the motor over the 10Hz to 500Hz range. Thanks Tom.... :)

Hi, yes it won't be a pure sine wave. For generating pure 3 phase sine wave, we have to connect LC circuit with free wheeling diodes and after that each output ( L1, L2, L3) should be connected through centre tap tranformer and after that make a "Y" formation to get neutral & 3 phases. Sorry you may be not clear about it, it's a heavy circuit, i will post it once i launch it fully.

It's a power level based VFD.

Thanks for the suggestions. Impedance matching is a big probem for me.