Bootloader without turning pins on/off when booting up

Hey all is there any bootloader for the Nano 328 that's just like the stock bootloader but modified so that when power is applied or reset it do not turn on all the digital/analog pins on/off?

Thanks!

David

The bootloader touches three pins: TX, RX, and digital pin 13.

Are you asking for a bootloader that does not blink the LED on pin 13?

When the uC is reset, all IO pins go to INPUT state until the sketch set them to outputs as needed.
I don’t think you can avoid that.
Maybe you want to go bootloaderless and have your sketch start immediately upon reset, and be able to call your pinModes faster for the outputs.
Or used DDR to set them as outputs followed by PORTx commands to set them high low.
Could probably have that as the first couple of lines in void setup.

Thanks for all the reply's so far.

The reason i am needing to do this is because i have a 8 port relay board connected to A0, A1, A2, A3, A4, A5, D12 & D11. Hooked up to 4 of those relay outputs are my garage door switches so when the power is applied to the arduino they all (the relays) blink and cause my garage door to either open or close... That's not a good thing if the power goes out and comes back on and my garage door opens when i am not at home...

How would one use the IDE with no bootloader? I figured the bootloader that is shipped with the Arduino is what allows it to be used in the IDE?

Unless they are pulled to a safe level those pins are floating for a while after the board is powered up, they could then do anything and you relay board will follow suite. If the board uses any form of latched logic you are in trouble.

Do you have a schematic of the relay board?


Rob

To use the board with no bootloader: Connect a programmer such as Atmel AVR ISP MKii to the ICSP header and use File:Upload Using Programmer

You could also add 5K or 10K pullup or pulldown resistors to the IO pins to pull them up or down and prevent floating and false switching.

Here is the board:

They seem to all flash the relay board a few times when the ardunio restarts or has power applied to it.

CrossRoads: To use the board with no bootloader: Connect a programmer such as Atmel AVR ISP MKii to the ICSP header and use File:Upload Using Programmer

You could also add 5K or 10K pullup or pulldown resistors to the IO pins to pull them up or down and prevent floating and false switching.

And after doing so would it still allow me to program and send it over to the arduino through the IDE?

As for the resistors.... the relays turn on when 5v are applied to it. So i am guessing that i would need to have pull down resistors to prevent that from happening, correct?

Also, would this work just as well as the Atmel AVR ISP MKii?

http://microcontrollershop.com/product_info.php?products_id=4541

"would it still allow me to program and send it over to the arduino through the IDE?"

"File:Upload Using Programmer" is part of the IDE. It is just a different path for getting programs into the uC - instead of the Serial Rx/Tx pins, it uses the SPI pins. You connect a AVR ISP to the board instead of using the onboard USB/Serial adapter.

Yes, sounds like you need pull down resistors.

Pocket Programmer - possibly. Some of them have problems loading to the larger chips like the '2560, but only for really large programs. I have no experience with it - browse the forum for issues, or wait to see if someone else comments on it. Or check the source website - that is a Sparkfun, or maybe an Adafruit design?

Schematic says Limor Fried - so that's an Adafruit.com sourced part.

How come the power supply is coming from an Android but the control signals from an Arduino?

That board uses optocouplers to drive the relays, pull downs would be a good bet but a schematic would be helpful.


Rob

CrossRoads: "would it still allow me to program and send it over to the arduino through the IDE?"

"File:Upload Using Programmer" is part of the IDE. It is just a different path for getting programs into the uC - instead of the Serial Rx/Tx pins, it uses the SPI pins. You connect a AVR ISP to the board instead of using the onboard USB/Serial adapter.

After uploading the bootloader then can i switch back to the USB since my program sends commands/listens to the Arduino serial?

Graynomad: Unless they are pulled to a safe level those pins are floating for a while after the board is powered up, they could then do anything and you relay board will follow suite. If the board uses any form of latched logic you are in trouble.

Do you have a schematic of the relay board?

Not true about the possibility of floating input condition. Most of those asian relay boards use a 'current loop' input through the optoisolators input led and are an active low input to turn on the relay (arduino output pin needs to be set to LOW to turn on a relay), so only a +5vdc wire (from the arduino) and a wire(s) from the arduino output pin(s) need to be wired to the relay board to operate the channels, no pull-up or pull-downs required and no arduino ground wire is needed to just operate the optoisolator channels. However the relay board itself does require +5vdc and ground to power the relay coils so if one is going to power the relay coils with the arduino's +5vdc voltage source then a ground is also required from the relay board to a arduino board. However that defeats the advantage of having optoisolators in the first place, so that is rather strange. However most of these relay boards I've seen have a jumper clip so that if the jumper is removed The arduino's +5vdc is not wired to the relay coil circuit but just to the optoisolators input led pins, so you are then free to use an external source of +5vdc voltage to provide power for the relay coil circuits and take full advantage of the isolation properties of the optoisolators. Also if your going to be using the android's +5vdc to power the relay board then you must also connect the androids ground to the arduino ground for the opto input circuits to work properly, that is probably the source of your problems. Here is a a typical asian relay board (a single channel version) which has a schematic drawing that should show better what I was trying to explain above. http://www.ebay.com/itm/251061549983?ssPageName=STRK:MEWAX:IT&_trksid=p3984.m1423.l2649 Lefty


Rob

"After uploading the bootloader then can i switch back to the USB since my program sends commands/listens to the Arduino serial?" After uploading your sketch via "File:Upload Using Programmer" your sketech will run the same as if you had uploaded in the normal manner - so if it communicated with the PC before, it will continue to do so. It will just not uoload sketches via the serial port, until you re-install a bootloader. It will start the sketch immediately after a reset.

Yes, so regardless of the voltages there will be no current flowing until the pins are set to outputs.


Rob

The AVR chips disconnect their inputs when they reset. They're floating, not connected to anything. It's a hardware feature, nothing anybody can do about it.

OTOH if you get rid of the bootloader then your program will start up in microseconds. The difference between maintaining the pin state and your program setting pin state at startup will be tiny.

if you get rid of the bootloader then your program will start up in microseconds.

I'm afraid not. There are times built in to allow the clocks to stabalize and similar. Up to about 100ms worth... See the datasheet chapter on clock options.

I haven't yet seen a relay board that needs pullup or pulldown resistors to avoid the relays coming on during power up. Perhaps you should post your code?

Here is my code:

int relay_1 = 14; //analog pin A0 -> digital to relay 1 [for door unlock]
int relay_2 = 15; //analog pin A1 -> digital to relay 2 [for door lock]
int relay_3 = 16; //analog pin A2 -> digital to relay 3 [My garage door UP/DOWN]
int relay_4 = 17; //analog pin A3 -> digital to relay 4 [Wifes garage door UP/DOWN]
int relay_5 = 18; //analog pin A4 -> digital to relay 5 [n/a]
int relay_6 = 19; //analog pin A5 -> digital to relay 6 [n/a]
int relay_7 = 13; //Digital pin D13 to relay 7 [n/a]
int relay_8 = 12; //Digital pin D12 to relay 8 [n/a]
String readString;

void setup()
{
  pinMode(relay_1, OUTPUT); // sets the analog pin A0 to digital as output [for door unlock]
  pinMode(relay_2, OUTPUT); // sets the analog pin A1 to digital as output [for door lock]
  pinMode(relay_3, OUTPUT); // sets the analog pin A2 to digital as output [My garage door up/down]
  pinMode(relay_4, OUTPUT); // sets the analog pin A3 to digital as output [Wifes garage door up/down]
  pinMode(relay_5, OUTPUT); // sets the analog pin A4 to digital as output [n/a]
  pinMode(relay_6, OUTPUT); // sets the analog pin A5 to digital as output [n/a]
  pinMode(relay_7, OUTPUT); // sets the digital D13 as output [n/a]
  pinMode(relay_8, OUTPUT); // sets the digital D12 as output [n/a]
  Serial.begin(115200);
}

void loop()
{
  while (Serial.available())
  {
    delay(1);
    if (Serial.available() >0)
    {
      char c = Serial.read();
      readString += c;
    }
  }
  
  if (readString == "frontDoorUNLOCK") {
    digitalWrite(relay_1, HIGH);
    delay(1000);
    digitalWrite(relay_1, LOW);
    Serial.println("unlocked");
  } else if (readString == "frontDoorLOCK") {
    digitalWrite(relay_2, HIGH);
    delay(1000);
    digitalWrite(relay_2, LOW);
    Serial.println("locked");
  }
  
  if (readString == "myGarage") {
    digitalWrite(relay_3, HIGH);
    delay(500);
    digitalWrite(relay_3, LOW);
    Serial.println("done");
  } else if (readString == "wifesGarage") {
    digitalWrite(relay_4, HIGH);
    delay(10000); //Needed to bypass damaged sensors on the garage door
    digitalWrite(relay_4, LOW);
    Serial.println("done");
  }
  
  if (readString == "testRelay") {
    digitalWrite(relay_1, HIGH);
    delay(500);
    digitalWrite(relay_1, LOW);
    digitalWrite(relay_2, HIGH);
    delay(500);
    digitalWrite(relay_2, LOW);
    digitalWrite(relay_3, HIGH);
    delay(500);
    digitalWrite(relay_3, LOW);
    digitalWrite(relay_4, HIGH);
    delay(500);
    digitalWrite(relay_4, LOW);
    digitalWrite(relay_5, HIGH);
    delay(500);
    digitalWrite(relay_5, LOW);
    digitalWrite(relay_6, HIGH);
    delay(500);
    digitalWrite(relay_6, LOW);
    digitalWrite(relay_7, HIGH);
    delay(500);
    digitalWrite(relay_7, LOW);
    digitalWrite(relay_8, HIGH);
    delay(500);
    digitalWrite(relay_8, LOW);
  }
  
  readString = "";
  delay(100);
}

retrolefty:

Graynomad: Unless they are pulled to a safe level those pins are floating for a while after the board is powered up, they could then do anything and you relay board will follow suite. If the board uses any form of latched logic you are in trouble.

Do you have a schematic of the relay board?

Not true about the possibility of floating input condition. Most of those asian relay boards use a 'current loop' input through the optoisolators input led and are an active low input to turn on the relay (arduino output pin needs to be set to LOW to turn on a relay), so only a +5vdc wire (from the arduino) and a wire(s) from the arduino output pin(s) need to be wired to the relay board to operate the channels, no pull-up or pull-downs required and no arduino ground wire is needed to just operate the optoisolator channels. However the relay board itself does require +5vdc and ground to power the relay coils so if one is going to power the relay coils with the arduino's +5vdc voltage source then a ground is also required from the relay board to a arduino board. However that defeats the advantage of having optoisolators in the first place, so that is rather strange. However most of these relay boards I've seen have a jumper clip so that if the jumper is removed The arduino's +5vdc is not wired to the relay coil circuit but just to the optoisolators input led pins, so you are then free to use an external source of +5vdc voltage to provide power for the relay coil circuits and take full advantage of the isolation properties of the optoisolators. Also if your going to be using the android's +5vdc to power the relay board then you must also connect the androids ground to the arduino ground for the opto input circuits to work properly, that is probably the source of your problems. Here is a a typical asian relay board (a single channel version) which has a schematic drawing that should show better what I was trying to explain above. http://www.ebay.com/itm/251061549983?ssPageName=STRK:MEWAX:IT&_trksid=p3984.m1423.l2649 Lefty


Rob

The relay board is powered by an external power supply. However, i DID have to attached the ground to the arduino also because when i did not, they relays did not come on after 5v was sent from the pins. After hooking up the arduinos' ground also, it worked.