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**