Hi again,
As the Subject states, I need help understanding the behavior of the Arduino 101 whenever it performs a switch-over from USB to DC Power input. Here is the scenario I am having trouble understanding.
- Plug in the USB connection. Leave the DC power input unconnected or powered off.
- Upload the Sketch and test using the Serial Monitor.
(All serial communications functions of the Sketch work as expected. - Plug in or turn on power to the DC power input barrel connector.
- Observe that the Arduino -seems- to reboot.
(I hear the USB disconnect and reconnect chimes on the attached PC.) - The Serial Monitor does not print the Sketch's debug messages and does not accept commands for the Sketch.
I am puzzled by the reboot when power is applied to the DC power barrel when the card is already being powered by the USB. I had assumed that the auto-power-switching circuitry of the Arduino 101 would simply "OR" in the power sources seamlessly without a reboot.
My project drives some LED strings that required more power than can be derived from the on-board regulators. I am driving these strings from the Vin power input via an ULN2003 driver. My project Sketch senses whether power has been applied to the DC input jack before allowing the 101 to output PWM signals to the ULN2003 driver.
I had built the code such that as the Sketch starts up, it measures the voltage of the Vin (through a voltage divider to an analog input) and then decides whether to allow further operations. I had hoped that I could simply blink a status LED showing that the project was running but needed DC power before continuing. The reboot and loss of serial communications keeps that from happening at the moment.
I did try powering up the 101 from the DC Jack first and then plugging in the USB cable. That sequence works. The serial port communications operate as expected when the 101 doesn't have to switch from external power to USB power. It only seems to be a problem when switching from USB to DC jack power.
Finally, my questions:
a) Is the reboot expected when switching power from USB to DC jack input?
Are there any strapping options that might prevent the reboot?
b) Is the loss of the serial port "real" or simply an artifact of the IDE and it's dual use of the port?
In other words, is this an IDE problem and the board should work standalone?
(It seems not but I have only done limited testing that way.)
I know that many here want to see schematics and code before answering general questions, so for completeness, here is a partial schematic of the design and code. The schematic shows a prototype board version which only uses four LED "strings" (of one LED each for now) and is thus missing the ULN2003 driver. Since the project is still incomplete and currently over 800 lines long, I have only attached the setup() and loop() sections of code. They should give a vague idea of what I am doing.
//================================================================================
/*================================================================================
* Initial set up of the Multi-Spectral Light Box Controller.
*===============================================================================*/
//================================================================================
void setup()
{
// Start the serial port interface
Serial.begin(9600); // Initialize Serial communication
while(!Serial); // Wait for serial port to connect.
#ifdef DEBUGMODE
Serial.print("Serial Port Enabled / Connected. Initializing hardware...\n");
#endif
DeviceStatus = STARTUP;
ShowStatus(DeviceStatus);
memset(CmdBuffer, 0, 20); // Initialize the serial command buffer
for (int led = 0; led < MAXLEDS; led++)
pinMode(LED_pin[led], OUTPUT); // Set the PWM pins to OUTPUT mode.
// Set the initial conditions for the Multi-Spectral Light Box
MotorState = STOPPED;
LEDState = OFF;
CoverState = NOTKNOWN;
MasterEnable = false;
// Turn all LEDs off to begin
setLEDsOnOff(OFF);
// Load the current default stored profile from EEPROM
CurrentProfile = 0;
memset(ProfileName, 0, 14);
readProfile(CurrentProfile);
// Read the input voltage on the Vin pin.
pinMode(Voltage_Pin, INPUT); // Set up the Voltage measurement pin
#ifndef ARDUINO_ARCH_ARC32
// The Arduino 101 can only use a 3.3v reference voltage. The analogReference()
// function will give a compile-time error on the 101.
// If compiling for other Arduino boards, remember to change the Vin voltage
// divider to give an input voltgae appropriate to the selected reference.
analogReference(INTERNAL); // Set the voltage reference to 5v
#endif
ReadVinVoltage();
// Hardware Setup and Initialization are now complete.
// If no errors were encountered, go to operational status.
if (DeviceStatus == STARTUP)
DeviceStatus = NORMAL;
ShowStatus(DeviceStatus);
#ifdef DEBUGMODE
Serial.print("Hardware initialization has been completed...\n");
#endif
}
//================================================================================
/*================================================================================
* The main loop.
* This simply waits for commands to arrive via the serial port. When a
* transmission is detected, the command is read and saved into the command
* buffer.
* Following the command reciept, the command is parsed and executed.
*===============================================================================*/
//================================================================================
void loop()
{
// Check that we are not in an error condition.
if (DeviceStatus != NORMAL)
{
//================================================
// TODO: Need to Complete Status LED blink coding.
//================================================
}
// Attempt to process any commands sent to the device.
// (Do not lock out serial communications completely even in an error condition.
if (Serial.available())
{
ReadCommand();
#ifdef DEBUGMODE
Serial.print("Command recieved. Cmd = \'");
Serial.print(CmdBuffer);
Serial.println("\'");
#endif
ParseCommand();
}
}
Any help with my two main questions above is appreciated.
Best Regards,
John