Components and supplies
Transformer 12v to 220v / 600VA
Arduino Nano R3
Linear Regulator (7805)
Breadboard (generic)
IRF3205
Dual H-Bridge motor drivers L293D
Tools and machines
Multimeter
Wire
Soldering iron (generic)
Veroboard
Project description
Code
Inverter arduino code
arduino
Complete code of the driver stage.
1#include "TimerOne.h" // include TimerOne.h 2#define low_battery_voltage 10.2 // define high battery voltage limit as 14.2 3#define high_battery_voltage 14.4 // define low battery voltage limit as 10.2 4int dutycycle = 0; // Initailize duty cylce variable as integer data type 5int sense_value =0; // Initialize sense_value variable to capture the adc reading of battery voltage (range from 0 to 1023) 6float battery_voltage = 0.0; // Initialize battery_voltage variable as a float data type to convert sense_value to actual battery voltage 7 8 9void setup() // Setup function 10{ 11 pinMode (9,OUTPUT); // set pin 9 as an output pin for pwm 12 pinMode (10,OUTPUT); // set pin 10 as an output pin for pwm 13 Timer1.initialize(20000); // Initailize timer1 time period as 20 milli second (50 Hz frequency) 14 Timer1.attachInterrupt(battery_voltage_measurement); // battery_voltage_measurement function will be executed every 20 milli second using timer 1 overflow interrupt 15 TCCR1A = (TCCR1A & 0x0F) | 0xB0 ; // set pin 10 inverted of pin 9 16} 17 18void battery_voltage_measurement() // battery_voltage_measurement function starts 19{ sense_value = (analogRead(A0)); // read battery voltage on pin A0 & capture that value in sense_value variable 20 // {warning - arduino pin accept only upto 5v so don't forget to map upper 21 // battery volatge i.e 14.2v to 5v using voltage divider resistor network} 22 23 battery_voltage = sense_value * (14.4/1023.0); // convert sense_value (0 to 1023) to range (0 to 14.2) 24 if(battery_voltage < 14.4 && battery_voltage > 10.2) // if battery voltage is under limit i.e between 10.2 and 14.2 then dutycycle will be 150 25 { 26 dutycycle = 300; 27 } 28 29 30 else if(battery_voltage < 10.2 || battery_voltage > 14.4) // if battery voltage is below 10.2v or above 14.2v , 31 { 32 dutycycle = 0; //set the duty cycle to 0 and inverter will go in cutoff mode 33 } 34 35 36} // battery_voltage_measurement function ends 37 38 39 void loop() // loop function starts 40{ 41 Timer1.pwm(9,dutycycle,20000); // Timer1.pwm function takes argument as (pin no. , dutycycle , time period) 42 Timer1.pwm(10,1023-dutycycle,20000); 43 44} // loop function ends 45 46 47 48 49 50 51 52 53 54
Inverter arduino code
arduino
Complete code of the driver stage.
1#include "TimerOne.h" // include TimerOne.h 2#define 3 low_battery_voltage 10.2 // define high battery voltage limit as 14.2 4#define 5 high_battery_voltage 14.4 // define low battery voltage limit as 10.2 6int 7 dutycycle = 0; // Initailize duty cylce variable as integer data type 8int 9 sense_value =0; // Initialize sense_value variable to capture the 10 adc reading of battery voltage (range from 0 to 1023) 11float battery_voltage = 12 0.0; // Initialize battery_voltage variable as a float data type to 13 convert sense_value to actual battery voltage 14 15 16 17void setup() // 18 Setup function 19{ 20 pinMode (9,OUTPUT); // set pin 9 as an output 21 pin for pwm 22 pinMode (10,OUTPUT); // set pin 10 as an output pin 23 for pwm 24 Timer1.initialize(20000); // Initailize timer1 time period 25 as 20 milli second (50 Hz frequency) 26 Timer1.attachInterrupt(battery_voltage_measurement); 27 // battery_voltage_measurement function will be executed every 20 milli second 28 using timer 1 overflow interrupt 29 TCCR1A = (TCCR1A & 0x0F) | 0xB0 ; // 30 set pin 10 inverted of pin 9 31} 32 33void battery_voltage_measurement() 34 // battery_voltage_measurement function starts 35{ sense_value = 36 (analogRead(A0)); // read battery voltage on pin A0 & capture that 37 value in sense_value variable 38 // 39 {warning - arduino pin accept only upto 5v so don't forget to map upper 40 // 41 battery volatge i.e 14.2v to 5v using voltage divider resistor network} 42 43 44 battery_voltage = sense_value * (14.4/1023.0); // convert sense_value 45 (0 to 1023) to range (0 to 14.2) 46 if(battery_voltage < 14.4 && battery_voltage 47 > 10.2) // if battery voltage is under limit i.e between 10.2 and 14.2 then dutycycle 48 will be 150 49 { 50 dutycycle = 300; 51 } 52 53 54 55 else if(battery_voltage < 10.2 56 || battery_voltage > 14.4) // if battery voltage is below 10.2v or 57 above 14.2v , 58 { 59 dutycycle = 0; //set the duty cycle 60 to 0 and inverter will go in cutoff mode 61 } 62 63 64 65} 66 // battery_voltage_measurement function ends 67 68 69 70 void loop() // 71 loop function starts 72{ 73 Timer1.pwm(9,dutycycle,20000); // Timer1.pwm 74 function takes argument as (pin no. , dutycycle , time period) 75 Timer1.pwm(10,1023-dutycycle,20000); 76 77 78} 79 // loop function ends 80 81 82 83 84 85 86 87 88 89 90 91 92 93
Downloadable files
Inverter
It's complete schematic of the power inverter, drawn in EAGLE software
Inverter
Comments
Only logged in users can leave comments