Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 03:27 28 Jun 2022 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Electronics : 3 phase inverter for AC induction and servo motors

     Page 4 of 4    
Author Message
InPhase

Senior Member

Joined: 15/12/2020
Location: United States
Posts: 146
Posted: 03:27am 29 May 2022
Copy link to clipboard 
Print this post

  Haxby said  I have never thought of having separately programmable on and off time. That's an interesting feature.

What are the ramifications of a very long dead time and vastly different on/off time?


If I try to use the 3 phase IGBT modules that I have, I'd be inclined to start with a 1.5uS dead time and a low-ish 5khz frequency.


The longer the dead time, the higher the inductive "kickback" from the transformer.
 
Haxby

Guru

Joined: 07/07/2008
Location: Australia
Posts: 397
Posted: 04:59am 29 May 2022
Copy link to clipboard 
Print this post

Thanks gents. And what about the switching frequency?

The modules I have say they will switch at 20khz maximum, so I reckon 5 to 10khz would be closer to their normal operating frequency, and that's what I'd aim for.

I'm guessing that the lower the switching frequency you go, the worse the sine wave looks, but that would likely only be an issue close to the zero crossing, which is where the IGBTs will be on for a very very short time. The rest of the sine wave will have longer on time, no matter what switching frequency you choose. so that's just my theory. Am I getting that right?

Sorry if these questions sound basic.
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1133
Posted: 09:19am 31 May 2022
Copy link to clipboard 
Print this post

I will test at both 20kHz and 10kHz
Looking at the rise and fall times of the IGBTs I think 20kHz will present
no problems.
But I am a hacker so its always "well that worked out well! no idea why.."
Rain this next 5 days so It's On..
wronger than a phone book full of wrong phone numbers
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1133
Posted: 05:17am 07 Jun 2022
Copy link to clipboard 
Print this post

further adventures in generating 3 phase PWM with complimentary outputs and deadtime
have this code working with the "BlackPill" micro.
This is a very cheap, small but capable micro.
about $5.50 with shipping  
It has hardware floating point which makes it about 15x faster
than the 32bit Arduino Due and a lot faster again than the Nano
when doing floating point math.
I like floating point hardware..

You use the Arduino IDE and load the boards for STM32 from STMicro
select STM32F4, choose F401CC, program it with the serial cable in DFU mode

This code is tiny but is the guts of 3 phase + comp outs + DT

volatile int pa, sa[400][3];
HardwareTimer t1(TIM1);

void t1_int(void)
{
 if ((TIM1->SR & 0x0010) == 0x0010)
  {  
   TIM1->SR =0;    // reset int flag - mandatory or else it fires continuously
     
   pa++;   //clock the phase angle counter
   if (pa >= 400)    // done 360 degrees?
     {
       pa = 0;       // then restart at 0 degrees
       GPIOC->ODR = 0x8000;    GPIOC->ODR = 0x0000;    //send a sync pulse for DSO
     }  
   TIM1->CCR1 = sa[pa][0];     // phase 1 pwm width
   TIM1->CCR2 = sa[pa][1];     // phase 2
   TIM1->CCR3 = sa[pa][2];     // phase 3
  }
}


void setup()
{
int i;
float th,p;
// sine() lookup table, with the three phases different by 120 degrees
for (i=0; i < 400; i++)
 {
   th = 2.0 * 3.14159 * (float)i / 400.0;
   p = (1.0 + sin(th)) * 2100;
   sa[i][0] = (int)p;
   th = 2.0 * 3.14159 * (float)(i + 133) / 400.0;    // 399 entries in table = 360 degrees
   p = (1.0 + sin(th)) * 2100;                       // so +133 entries = 120 degrees
   sa[i][1] = (int)p;
   th = 2.0 * 3.14159 * (float)(i + 266) / 400.0;
   p = (1.0 + sin(th)) * 2100;
   sa[i][2] = (int)p;
 }

pa = 0;         // init phase angle = zero

// TIMER1 configs
PWM_pin_config();
Timer1_config();
t1.attachInterrupt(t1_int);
HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn ,1,3);
TIM1->DIER = 0x0001;    // let it rip, enable TIMER1

// PC13 LED setup and PC15 for 50Hz sync pulse
pinMode(PC13,OUTPUT);
pinMode(PC15,OUTPUT);
}

void loop()
{
// put the AC voltage control code here
// not a lot to see, we've seen it before
}



void Timer1_config(void)
{
 //
 // timer1, ch1,2,3 OC and OCN outputs enabled with deadtime
 // correct signaling for 3 phase inverter
 //
 uint16_t ccmr1=0, ccmr2=0,  ccer=0;
 __HAL_RCC_TIM1_CLK_ENABLE();
 TIM1->BDTR = 0x0c50;    // DT part is low 8 bits
 TIM1->PSC = 0;
 TIM1->ARR = 4200;
 TIM1->CR1 = 0;
 TIM1->RCR = 0;

 // ch1,2 TIM_OCPreload_Enable & PWM mode 1
 // ch1,2,3 OC and OCN config   OC enabled, active high, OCN enabled, active high
 TIM1->CCER = 0x0555;
 TIM1->CCMR1 = 0x6868;
 TIM1->CCMR2 = 0x0068;

 TIM1->CCR1 = 1;     // ch1 pwm width
 TIM1->CCR2 = 1;     // ch2 pwm width
 TIM1->CCR3 = 1;     // ch3 pwm width
 TIM1->CCR4 = 1;    
 
 TIM1->CR2 = 0;
 TIM1->CR1 |= 0x0080;    // enable preload
 TIM1->BDTR |= 0x8000;   // enable PWM outputs, needed for timer1
 TIM1->CR1 |= 0x0001;    // enable timer
}


void PWM_pin_config(void)
 {
 // manual GPIO setup, the HAL functions do not work with TIMER1 ALT1 complimentary output pins
 // timer 1, ch 1,2,3 alt functions out A8,9,10  
 __HAL_RCC_GPIOA_CLK_ENABLE();
 GPIOA->PUPDR =   0x00154000;    // 10,9,8 pins pull up  01
 GPIOA->OSPEEDR = 0x003fC000;    // speed is 11 or fastest
 GPIOA->MODER =   0x002a8000;    // Alt function
 GPIOA->OTYPER = 0;              // output push-pull
 GPIOA->AFR[1] = 0x00000111;     // AF = 0001 = AF1
 // timer1 ch 1,2,3 complimentary outputs B13,14,15
 __HAL_RCC_GPIOB_CLK_ENABLE();
 GPIOB->PUPDR =   0x54000000;
 GPIOB->OSPEEDR = 0xfc000000;
 GPIOB->MODER =   0xa8000000;
 GPIOB->OTYPER = 0;
 GPIOB->AFR[1] =  0x11100000;
 }

wronger than a phone book full of wrong phone numbers
 
iannez
Newbie

Joined: 05/07/2019
Location: Italy
Posts: 22
Posted: 04:00pm 07 Jun 2022
Copy link to clipboard 
Print this post

Peter great job as always!

I lost more an afternoon to understand why with timer1 it is necessary
TIM1-> BDTR | = 0x8000;

In other timers it is not necessary.

Can you trust the precision of the Deadtime compared to the classics IR2110 or 2183?
Cheers, Angelo
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1133
Posted: 09:50pm 07 Jun 2022
Copy link to clipboard 
Print this post

Hi Angelo

for most timers it's not but for TIMER1 (only one with DT)
TIM1-> BDTR | = 0x8000 is needed. on page 310



Precision of DT is very good. the 0x50 as used is
80 clocks delay of the 84MHz main clock
We can resolve it to single clock counts and from what I've seen
on the DSO it's invariant over time.
wronger than a phone book full of wrong phone numbers
 
Revlac

Guru

Joined: 31/12/2016
Location: Australia
Posts: 658
Posted: 12:23pm 08 Jun 2022
Copy link to clipboard 
Print this post

Nice work Peter, its a nice little board for that price, just thinking about the potential size of the 3Phase inverter, and that tiny board is the brains that run it, compare it to something that was built maybe 15 years or so ago.
Cheers Aaron
Off The Grid
 
Haxby

Guru

Joined: 07/07/2008
Location: Australia
Posts: 397
Posted: 02:38am 12 Jun 2022
Copy link to clipboard 
Print this post

Poida, if I was to design an Arduino clone brain board for my 3 phase power board, would you recommend I use the black pill as the basis?
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1133
Posted: 11:12am 14 Jun 2022
Copy link to clipboard 
Print this post

for sure the black pill micro.
3.3V outputs so choose your gate drive IC input resistors carefully.
Maybe they are voltage inputs, not current driven so it's all OK.

The Arduino nano can only do one pair of complimentary outputs
and those do not have dead time. So scrub that.

The Arduino mega can do 3 channels of the same but no dead time.
No good. Unless you choose to use IR's gate drive ICs that generate dead time
or roll your own with caps, logic gate ICs and whatnot.

The STM32F401 (black pill) can do 3 channels with dead time.
I can give you the pinout for the PWM outputs and analog inputs.

from



it's
ch1 high side A8, lowside B13
ch2 high side A9, low B14
ch3 high side A10, low B15
Analog inputs are A0,A1, A2 for the 3 phase Vfb and maybe A3 for a AC output setting
if needed, else just use trimpots on all 3 Vfb.
All analog inputs need to be between 0 and 3.3V

pin B9 could be inverter run/stop signal

pin PC13 is connected to the on-bard LED so I use that
to signal inverter is running.

uploading the firmware needs a bit of software to be installed.
Let's go there when needed.
(STM cube programmer and arduino IDE plus STM's board definitions.
It works fine on Windows 10)

close examination of the above image shows pin B14 is "timer 2/channel 2"
this is a mistake. It's timer 1/channel 2 which is what we need.

Before you draw up a PCB please make me confirm the pinout by physical testing.
(I just confirmed the pinout this morning at work. They made an error in the above image)
Edited 2022-06-15 07:47 by poida
wronger than a phone book full of wrong phone numbers
 
Haxby

Guru

Joined: 07/07/2008
Location: Australia
Posts: 397
Posted: 12:57am 15 Jun 2022
Copy link to clipboard 
Print this post

Great thanks. I've got a black pill coming from China now. Hopefully customs won't get alarmed if the declaration states "black pills" on it.  
I'll test it all before I get a PCB designed.
 
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1133
Posted: 02:43am 15 Jun 2022
Copy link to clipboard 
Print this post

there will be a serial LCD function, using the 20x4 LCD+nano hack of mine.
Serial data out for the LCD will be on pin PB10. The LCD+nano needs 5V and ground too.

inverter run/stop is currently on PB9 (not PB8 as above)

PC15 has a 50Hz square wave output, syncronised to the AC pwm outputs
I use this as a trigger for the oscilloscope

PC13 is connected to the LED and is inverted with LED output
i.e. logic 1 = LED off and logic 0 = LED on
that's a bit odd but whatever..

When designing the PCB allow for a socket for the black pill.
programming can be a bit hit and miss and I have always needed to squeeze
the micro between 2 fingers when entering DFU mode prior to loading firmware.
Can't do that if it's soldered in place.
wronger than a phone book full of wrong phone numbers
 
     Page 4 of 4    
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2022