Go Down

Topic: can anyone help me to run 4step commutation of mosfet bridge  (Read 438 times) previous topic - next topic

swapnilthink

Hi...............

I am trying to make power Electronic assisted OLTC (on load tap changing) transformer. for that i need to do 4step commutation of mosfet bridge to switch the tap position without current interruption.

here is the coding which I have done to run the project.....

Code: [Select]
const int mosfet1 = 3;
const int mosfet2 = 4;
const int mosfet3 = 5;
const int mosfet4 = 6;
const int led = 8;
const int pb1 = 9;
const int pb2 = 10;
const int ontime1 = 4;
const int ontime2 = 8;
const int offtime1 = 2;
const int offtime2 = 6;

byte mosfet1state = LOW;
byte mosfet2state = LOW;
byte mosfet3state = LOW;
byte mosfet4state = LOW;
byte ledstate = LOW;
byte pb1state = LOW;
byte pb2state = LOW;

unsigned long currentmillis = 0;
unsigned long currentmillis1 = 0;
unsigned long currentmillis2 = 0;
unsigned long currentmillis3 = 0;
unsigned long currentmillis4 = 0;
unsigned long prevmosfet1millis = 0;
unsigned long prevmosfet2millis = 0;
unsigned long prevmosfet3millis = 0;
unsigned long prevmosfet4millis = 0;
unsigned long pb1millis = 0;
unsigned long pb2millis = 0;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);

pinMode (mosfet1, OUTPUT);
pinMode (mosfet2, OUTPUT);
pinMode (mosfet3, OUTPUT);
pinMode (mosfet4, OUTPUT);
pinMode (led, OUTPUT);
pinMode (pb1, INPUT_PULLUP);
pinMode (pb2, INPUT_PULLUP);
}

//=====================================================================

void loop() {
  // put your main code here, to run repeatedly:

  currentmillis = millis();
  currentmillis1 = millis();
  currentmillis2 = millis();
  currentmillis3 = millis();
  currentmillis4 = millis();
  updatemosfet1state();
  updatemosfet2state();
  updatemosfet3state();
  updatemosfet4state();
  updateledstate();
 
}

//======================================================================

void updatemosfet1state()
{
  if (pb1 == HIGH)
  {
    mosfet1state == HIGH;
    digitalWrite(mosfet1, mosfet1state);
  }
   else if (currentmillis1 - prevmosfet1millis >= ontime1)
    {
      mosfet1state != mosfet1state;
    }
  else
   {
    mosfet1state == LOW;
   }
}

//========================================================================

void updatemosfet2state()
{
  if (pb1 == HIGH)
  {
    mosfet2state == HIGH;
    digitalWrite(mosfet2, mosfet2state);
  }
  else if (currentmillis2 - prevmosfet2millis >= ontime2)
      {
      mosfet2state != mosfet2state;
      }
  else
   {
    mosfet2state == LOW;
   }
}

//========================================================================

void updatemosfet3state()
{
  if (pb1 == HIGH)
  {
    mosfet3state == LOW;
    digitalWrite(mosfet3, mosfet3state);
  }
   else if (currentmillis3 - prevmosfet3millis >= offtime1)
    {
      mosfet3state != mosfet3state;
    }
  else
   {
    mosfet3state == LOW;
   }
}
//=========================================================================

void updatemosfet4state()
{
  if (pb1 == HIGH)
  {
    mosfet4state == LOW;
    digitalWrite(mosfet4, mosfet4state);
  }
   else if (currentmillis4 - prevmosfet4millis >= offtime2)
    {
      mosfet4state != mosfet4state;
    }
  else
   {
    mosfet4state == LOW;
   }
}
//==========================================================================

void updateledstate()
{
  if (pb1 == HIGH)
  {
    ledstate == HIGH;
    digitalWrite(led, ledstate);
  }
  else
   {
    ledstate == LOW;
   }
}
//==========================================================================


For more details of the project please see the attachment......

Questions:
1. How to run all the 4 mosfets simulteneously with different ON & OFF time?
2. the firing circuit should run only after switching the position of mechanical switch (shown in the   attachment). for that i used normally closed switch to sense the position of mechanical switch which will produce +5V after releasing the mechanical switch position from posi.1 & posi.2

MarkT

[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

Go Up