Pages: [1]   Go Down
Author Topic: First Ardiuno Project Mosfet Inverter  (Read 1181 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey everybody this is my first post and I just ordered my first arduino so I'm very anxious I to get started, this is my first code:

I decide to skip the traditional Blinking LED (though I want to integrate it in) and went for a mosfet inverter that operates at 60 Hz - it will only be a square wave but I'll develop it as I get more confident in programming.

I would appreciate any feedback on the code itself:

other than actually acting as a switching power supply; I also want a visual indication that is running so and LED out of pin 8 will be occurring (my main question is how to I get two loops Running together in order to generate a inverter with a blinking LED that will allow the Inverter not to be affected by time).

Also is there any good free ebooks to help progress my learning?

Thanks so much

Nick

h/* Inverter Full Bridge Rectifier - Square Wave Inteverter operating at 60 Hertz */

int POT = 4;//Postive waveform ON TOP MOSFET OF BRIDGE RECTIFIER
int POB = 5;//Positive waveform ON BOTTOM MOSFET OF BRIDGE RECTIFIER
int NOT = 6;//Negative Waveform ON TOP MOSFET OF BRIDGE RECTIFIER
int NOB = 7;//Negative Waveform ON BOTTOM MOSFET OF BRIDGE RECTIFIER
int LED = 8;//LED to indicate circuit is running

void setup(){
pinMode(POT,  OUTPUT);//Enable POT AS AN OUTPUT
pinMode (POB, OUTPUT);//ENABLE POB AS AN OUTPUT
pinMode (NOT, OUTPUT);//ENABLE NOT AS AN OUTPUT
pinMode (NOB, OUTPUT);//ENABLE NOT AS AN OUTPUT
pinMode (LED, OUTPUT);//ENABLE LED AS AN OUTPUT
}

void loop(){
  digitalWrite (LED,HIGH);//Displays Circuit is running
  digitalWrite(POT & POB, HIGH); //ENABLE CURRENT PATH FOR POSITIVE WAVEFORM
  delay(8.333333);//DELAY IS ESTABLISHED BY 1/(60*2)= 8.333333 mS
  digitalWrite(POT & POB, LOW); //disable current path for positve waveform
  digitalWrite(NOT & NOB, HIGH);// enable current path for negative waveform
  delay(8.333333);////DELAY IS ESTABLISHED BY 1/(60*2)= 8.333333 mS
  digitalWrite (NOT & NOB , LOW);// disable current path for negative waveform
Logged

Check out my Electrical Engineering Channel at:

http://www.youtube.com/user/ElectricalNick?feature=mhee

Santa Fe
Offline Offline
Full Member
***
Karma: 1
Posts: 201
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code will toggle pins on and off but I am not sure you will get 8.333333 mS accuracy in the toggles.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for looking over the code.

I am in complete agreance with you about the accuracy - but to be honest I'm curious, I'm going to meassure the accuarcy witht the scope after I uploaded the code. I want to see the limitations of programming; as I used to be about all through hole components but the results of programming (for both accurcacy and ease of use) are unargueable.

But is it possible to have two loops occuring at the same time? And does anyone know of any good free ebooks (please include the links).

Thanks again,

Nick
Logged

Check out my Electrical Engineering Channel at:

http://www.youtube.com/user/ElectricalNick?feature=mhee

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17259
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

delay(8.333333); for sure won't work as delay uses an unsigned long as it's argument, not a floating point argument. You would have to use delayMicroseconds(8333); instead and even then delayMicroseconds has a built in (I believe I recall) 4 usec step size resolution.

Lefty

Logged

Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 50
Posts: 2195
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You need to look at blink without delay if you want to get more than one thing to happen at the same time.

Mark
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 285
Posts: 25642
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@Nicksek, this seems to be very similar to your other thead on a very similar subject with the same mistakes.
Do you want me to merge them so people won't waste time answering stuff that has already been answered, or just lock this thread?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

AWOL, sorry about flooding the content just a newbie and eager to get things running; if you want to merge them I would be greatful.
Thanks for the feedback

Nick
Logged

Check out my Electrical Engineering Channel at:

http://www.youtube.com/user/ElectricalNick?feature=mhee

Pages: [1]   Go Up
Jump to: