Author Topic: Arduino code  (Read 1895 times)

0 Members and 1 Guest are viewing this topic.

Offline msrinivasan1995Topic starter

  • Contributor
  • Posts: 15
  • Country: in
Arduino code
« on: March 15, 2017, 07:44:11 am »
I'm working on developing solar inverter to feed my home load. I have decided on using H bridge MOSFET . All i need to get is that PWM generator from arduino. I have not fully understood how PWM works.  If anyone worked on the same, please share your code.
 

Offline Hideki

  • Frequent Contributor
  • **
  • Posts: 256
  • Country: no
Re: Arduino code
« Reply #1 on: March 15, 2017, 08:24:44 am »
Read the documentation for the arduino analogWrite function.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 13119
Re: Arduino code
« Reply #2 on: March 15, 2017, 09:32:14 am »
... and the 'Timer ... with PWM' sections of the datasheet for whatever MCU is on your Arduino. (ATmega328P on UNO).  Unexpected shoot-through driving your H-Bridge is expensive and explosive.
 

Offline Avacee

  • Supporter
  • ****
  • Posts: 299
  • Country: gb
Re: Arduino code
« Reply #3 on: March 15, 2017, 09:46:37 am »
https://www.arduino.cc/en/Tutorial/PWM

Please can you expand on what you don't understand so we can explain that part.
 
The following users thanked this post: msrinivasan1995

Offline amspire

  • Super Contributor
  • ***
  • Posts: 3802
  • Country: au
Re: Arduino code
« Reply #4 on: March 16, 2017, 12:21:31 am »
You can do basic PWM with the built in Arduino commands.

The ATMEGA cpu's actually have pretty powerful and versatile PWM features and to use them fully, you need to look at the cpu data sheet.

It usually involved setting up an interrupt routine to allow for properly synched changes and direct writing to the PWM control registers.

The key thing is do you know how you want the PWM registers to work? Do you want to be loading values from a lookup table into the PWM to create the sine wave? If so how often do you want to load a value. The shortest period the Arduino cpu can manage is an 8 bit period loaded every 16us, or a 10 bit period every 64us or a 12 bit every 256us. There is another PWM that makes symmetrical pulses, but you have to double the times above.

You need a gap between the mosfets on one side of the bridge turning off and the opposing one turning on - how are you going to generate it? (needs to be hardware, not software).

Designing a PWM to handle KW of power needs a lot of design skill - it is probably not as simple as you think. It can be dangerous work as you need goggles or a blast shield to test the inverter, and it is very difficult without tools like the differential probe that Dave is offering. You will go through a lot of blown mosfets and diodes before it works so it will cost more then you think.  Dangerous voltages everywhere.

If you are keen, try a low power (5vp-p, 1.7V RMS maximum) inverter first.  I would then move on to a 10W inverter. Then at least I would have learnt some of the problems in designing a 5kW inverter (or whatever you want).

Richard
 
The following users thanked this post: Ian.M

Offline Fire Doger

  • Regular Contributor
  • *
  • Posts: 208
  • Country: 00
  • Stefanos
Re: Arduino code
« Reply #5 on: March 17, 2017, 12:04:17 am »
As amspire said don't go for mains voltage at the first assembly because the possibilities to blow up everything is very high.
In theory its very easy but in practice there are lots of traps for young players.
Playing with small voltages may give you an example of how difficult may be and you will get some experience

I would definitely use an off the self inverter for application. Destroying your TV or PC or other devices (arduino is not famous for the most robust design) will cost you more.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf