Pages: [1]   Go Down
Author Topic: Output high at bootup (need to stay low) Solved  (Read 668 times)
0 Members and 1 Guest are viewing this topic.
The Netherlands
Offline Offline
Sr. Member
****
Karma: 4
Posts: 332
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I supply power at the MEGA it sets two outputs HIGH which start a motor to turn for a scond or so.

When I power up the LED 13 blinks two times.
Pin is set as output PWM and drive a FET to drive an single motor.
As soon as I supply the power the motor starts to turn until the second blink of LED13 is OFF.

Is there a way during boot-power up to keep the output low?

I googled and also used the search function here but no useable info.

Paco
« Last Edit: December 01, 2012, 09:58:45 am by backbone » Logged

Never to old to learn and I learn every day

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please post your code, using code tags button (#).
Logged

The Netherlands
Offline Offline
Sr. Member
****
Karma: 4
Posts: 332
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry the full code is more then 9500 characters! So I can not put it between code tags! :-(

Paco
Logged

Never to old to learn and I learn every day

The Netherlands
Offline Offline
Sr. Member
****
Karma: 4
Posts: 332
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I zip the .ino

* slotracecontroller_306_ino.zip (6.4 KB - downloaded 13 times.)
Logged

Never to old to learn and I learn every day

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 146
Posts: 5522
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I supply power at the MEGA it sets two outputs HIGH which start a motor to turn for a scond or so.

They're probably not high, just floating.

Try connecting them to ground via a 4.7k resistor (or something in that range).

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

NL
Offline Offline
Newbie
*
Karma: 1
Posts: 33
Tech Tinkerer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you use pull-down resistors on those 2 pins?

When the MCU resets, all i/o pins go into Tri-State (High Impedance) and then default to input pins (Also high input resistance) until your sketch defines them as output pins.

Using a resistor (one for each pin, 10K/47K or so) to ground will make sure the pin stays LOW unless explicitly driven HIGH by the output.

Hope this helps,
Guido
Logged

Offline Offline
Edison Member
*
Karma: 26
Posts: 1339
You do some programming to solve a problem, and some to solve it in a particular language. (CC2)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
void setup()
{
  Serial.begin(9600);                       // Output to serial writing or BT

  pinMode(led7Pin, OUTPUT);                // initialize the led as a output control pin //
  pinMode(led8Pin, OUTPUT);                // initialize the led as a output control pin //
  pinMode(led12Pin, OUTPUT);                // initialize the led as a output control pin //
  pinMode(led13Pin, OUTPUT);                // initialize the led as a output control pin //
  //pinMode(11,INPUT); //for calibration push button
  //digitalWrite(11, HIGH);    // enable the 20k internal pullup for MEGA board
  digitalWrite((54), HIGH);  // enable the 20k internal pullup for MEGA board

// lots of code

I'd try to drive the pins to a known state at the beginning of setup().
Logged

The Netherlands
Offline Offline
Sr. Member
****
Karma: 4
Posts: 332
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I first pulled down the outputs 9 and 10 to GND with 13K7 resistor.
Same problem.
Then added the code that controls the outputs below the pinmode declarations
Same problem.
Then I moved it up directly under serial begin.
Problem solved.

Thanks for your cooperation. I hope others benefit from it too.

Code:
void setup()
{
  Serial.begin(9600);                       // Output to serial writing or BT

  speedfinalValue =  0; //this value determens if the motor is running. if value = 0 then PWM signal = 0
  brakeNValue = 0; //this value determens if the motor is braked. if value = 0 then PWNM signal = 0
 
  pinMode(led7Pin, OUTPUT);                // initialize the led as a output control pin //
  pinMode(led8Pin, OUTPUT);                // initialize the led as a output control pin //
  pinMode(led12Pin, OUTPUT);                // initialize the led as a output control pin //
  pinMode(led13Pin, OUTPUT);                // initialize the led as a output control pin //
  //pinMode(11,INPUT); //for calibration push button
  //digitalWrite(11, HIGH);    // enable the 20k internal pullup for MEGA board
  digitalWrite((54), HIGH);  // enable the 20k internal pullup for MEGA board
Logged

Never to old to learn and I learn every day

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8525
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'd try to drive the pins to a known state at the beginning of setup().
They are still floating for 1-2 seconds as the chip starts up and (by far the longest) the bootloader screws around.

Pull down resistors are the only answer I think.

EDIT: I see you last post, don't know how that's worked but if it has well and good.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Pages: [1]   Go Up
Jump to: