Good Day to all Gurus,
I found this neat and short sketch Arduino 3 Phase Motor Controller - Dave Hakkens for 3-phase-motor. Unfortunately the site is temporarily close and the author is no where to find.
void setPhase(unsigned char ph);
void advancePhase(char dir);
const unsigned char AHPin = 12;
const unsigned char ALPin = 6;
const unsigned char BHPin = 11;
const unsigned char BLPin = 5;
const unsigned char CHPin = 10;
const unsigned char CLPin = 4;
const unsigned char delayPin = A0;
char currentPhase = 0;
char motorDirection = 1;
unsigned long previousDelay = 0;
const unsigned char phaseStates[6]{
B011000,
B010010,
B000110,
B100100,
B100001,
B001001
};
void setPhase(unsigned char ph){
unsigned char phase = phaseStates[ph];
digitalWrite(AHPin, (phase & B100000) >> 5);
digitalWrite(ALPin, (phase & B010000) >> 4);
digitalWrite(BHPin, (phase & B001000) >> 3);
digitalWrite(BLPin, (phase & B000100) >> 2);
digitalWrite(CHPin, (phase & B000010) >> 1);
digitalWrite(CLPin, phase & B000001);
}
void advancePhase(char dir){
currentPhase += dir;
if(currentPhase > 5){
currentPhase = 0;
}else if(currentPhase < 0){
currentPhase = 5;
}
}
void setup(){
pinMode(AHPin, OUTPUT);
pinMode(ALPin, OUTPUT);
pinMode(BHPin, OUTPUT);
pinMode(BLPin, OUTPUT);
pinMode(CHPin, OUTPUT);
pinMode(CLPin, OUTPUT);
pinMode(delayPin, INPUT);
}
void loop(){
long delay = map(analogRead(delayPin), 0, 1024, 0, 100000);
if(micros() - previousDelay <= delay) { return; }
previousDelay += delay;
advancePhase(motorDirection);
setPhase(currentPhase);
}
I tested the sketch using UNO ATMEGA328 and it works perfectly fine.
I managed to change the binary pattern and the frequency range to suit my Single Phase VFD intention.
My question now is I cant find which function to edit to change the phasing from 120 to 90 deg.
I appreciate very much If you guys can assist me in pointing/editing the right function to change the 120 to 90 deg.
Thanks and keep safe ...
Joey