Just for fun, here are a few photos and the "hello motor" code.
I'm using an ST IPM15b eval board, which is not much more than a breakout board for the STGIB15CH60TS integrated power module. Six 15a 600V IGBT's plus all their gate drive and protection circuitry, all in one $16 brick. Takes a lot of the black magic out of the power electronics. Much larger IPM's are available, but I thought I'd learn some of the ways to let the smoke out, using this small inexpensive smoke before I move up to the larger stuff.
One gotcha is that this module is not isolated from the power line. So the Teensy ground could be at 115v or whatever, typically half of the incoming AC voltage. Yikes! At first my improvised isolation transformer was not right, and I let the smoke out. Fortunately not my own smoke out of myself! This stuff can be dangerous. Got a better isolation setup now.
And... I really like the Adafruit USB isolator. Keep your fragile PC away from all that high voltage nastiness. Highly recommended.
So here are three photos of the experimental setup.
https://eriknjacob.smugmug.com/Tech2017
From left to right you can see a small 3-phase AC blower motor, then past the current probes is the IPM15 eval board powering it. There is a Variac in the background setting the input voltage to the IPM. Moving right is the Teensy on a breadboard, controlling the IPM. Then the Adafruit USB isolator in front of the scope showing current in one of the three legs. Yes, not very sine-like but the motor is running quietly and happily. Not bad for one afternoon of work!
The third photo is a hand drawn "six step" trapezoidal waveform for a three phase motor. This is typically used in BLDC motors. If you look closely the three phases are in three different colors.
What is the recommended way to post code here?
Here is my motor control program, cut-n-pasted.
Yes I know there is a lot this program does not do -- pwm for voltage control, true sine, etc. But hey, it's Hello World, spinning a motor in 100 lines of code.
// first motor control program
// EK 1/15/2017
// BLDC-style six-step motion, open loop, simple.
// Just get the damn thing running!
// pindefs
//switch pins are on PWM-capable pins even tho we're not doing PWM now.
const int AL = 3;
const int AH = 4;
const int BL = 5;
const int BH = 6;
const int CL = 9;
const int CH = 10;
const int LED = 13;
void setup() {
// put your setup code here, to run once:
// pindefs
// set pins as outputs
pinMode (AL, OUTPUT);
pinMode (AH, OUTPUT);
pinMode (BL, OUTPUT);
pinMode (BH, OUTPUT);
pinMode (CL, OUTPUT);
pinMode (CH, OUTPUT);
pinMode (LED, OUTPUT);
// and make sure they are all turned off
ShutDown();
// parameters for operation
const float hz = 20; // speed to run -- 60hz = full rated speed
const int runtime = 3600; // seconds to run
int steptime;
steptime = 1000000 / (hz*6); // time in microseconds for each step. six steps per cycle.
digitalWrite (LED, 1);
DoWave(steptime, (runtime*hz));
digitalWrite (LED,0);
// that's all folks!
ShutDown();
}
void loop() {
// put your main code here, to run repeatedly:
}
//////////////// SUBROUTINES
//-------------------------------------------
void DoWave(int steptime, int n)
{
int qq;
for (qq=0; qq<n; qq++)
{
//step 1
digitalWrite (AL,1); //A goes negative
digitalWrite (CL,0); // turn off C
delayMicroseconds (steptime);
//step 2
digitalWrite (BH,0); //B was high now off
digitalWrite (CH,1); // C goes high
delayMicroseconds (steptime);
//step 3
digitalWrite (AL,0);
digitalWrite (BL, 1);
delayMicroseconds (steptime);
//step 4
digitalWrite (CH,0);
digitalWrite (AH, 1);
delayMicroseconds (steptime);
//step 5
digitalWrite (BL,0);
digitalWrite (CL, 1);
delayMicroseconds (steptime);
//step 6
digitalWrite (AH,0);
digitalWrite (BH, 1);
delayMicroseconds (steptime);
} // next qq
} // return
void ShutDown(void)
{
digitalWrite (AH,0);
digitalWrite (AL,0);
digitalWrite (BH,0);
digitalWrite (BL,0);
digitalWrite (CL,0);
digitalWrite (CH,0);
}