Arduino code - Page 1
Forum section: electronics / projects

author: msrinivasan1995
author_rank: Contributor
timestamp: March 15, 2017, 07:44:11 am
content: 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.

author: Hideki
author_rank: Frequent Contributor
timestamp: March 15, 2017, 08:24:44 am
content: Read the documentation for the arduino analogWrite function.

author: Ian.M
author_rank: Super Contributor
timestamp: March 15, 2017, 09:32:14 am
content: ... 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.

author: Avacee
author_rank: Unknown
timestamp: March 15, 2017, 09:46:37 am
content: https://www.arduino.cc/en/Tutorial/PWMPlease can you expand on what you don't understand so we can explain that part.

author: amspire
author_rank: Super Contributor
timestamp: March 16, 2017, 12:21:31 am
content: 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

author: Fire Doger
author_rank: Regular Contributor
timestamp: March 17, 2017, 12:04:17 am
content: 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 experienceI 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.