Pages: [1]   Go Down
Author Topic: Trouble with arduino nano serial resetting  (Read 673 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have a small circuit that I am working on to simply talk to an I2C sensor and/or program it with a given I2C address. I can talk to the sensor fine, I can use my toggle switches to determine which address to program into the sensor. All that stuff works. The problem is that this particular sensor requires that in order to program it/etc , the first command after powerup must be to put it into command mode. This also works fine. The trouble came when I wanted to use a toggle switch to power the sensor off, then back on again without having to disconnect the usb cable from the nano every time.

When I have the arduino powered on, and everything is working fine, I flip the switch off to turn off the sensor, adjust my address toggles, turn the sensor on and then press the button to program it. My LEDs indicate that this actually works ( and later on I can verify that the sensor has the new address) but during this process the serial port seems to reset or something because if I try to send anything in the serial monitor (that was already open and working fine) I get the error below:

Error inside Serial.serialEvent()
java.io.IOException: Bad file descriptor in nativeavailable
   at gnu.io.RXTXPort.nativeavailable(Native Method)
   at gnu.io.RXTXPort$SerialInputStream.available(RXTXPort.java:1532)
   at processing.app.Serial.serialEvent(Serial.java:258)
   at gnu.io.RXTXPort.sendEvent(RXTXPort.java:732)
   at gnu.io.RXTXPort.eventLoop(Native Method)
   at gnu.io.RXTXPort$MonitorThread.run(RXTXPort.java:1575)


Any thoughts? I was thinking maybe I need a current limiting resistor or something on the 3v3 line? Perhaps the sensor pulls too much current on startup or something? Though this doesn't seem to happen if I just leave the switch on the whole time. Also this seems to work fine if I supply the sensor with 5v, which I can do but the sensors are calibrated for 3.3 right now.

*SEE ATTACHED SCHEMATIC*

* schematic.pdf (7.49 KB - downloaded 12 times.)
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is the Arduino resetting? It's not obvious from your description whether you would know, so you might need to change your sketch to make it obvious.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

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

As best as I can tell the arduino is not resetting (I think).

The sensor programming code will blink one of the leds fast while its programming, then if it succeeds it will keep that led on for like two seconds, then the code will return that led to a heartbeat blink. This happens so I believe the arduino isn't completely resetting.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(I think).

Can you add code to the setup() function to do something to make it completely obvious when the board has reset, to remove that uncertainty?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

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

There is code in setup that would make it obvious if the arduino resets. also, my heartbeat led would temporarily stop (which it does if I manually press the reset button).

A capacitor on the 3v3 pin solved the problem. A glitch on that line might have been enough to cause the ftdi chip to reset? This doesn't happen when I use 5v instead, presumably because the 3v3 is supplied by the ftdi chip and the 5v is from the regulator.
Logged

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

There is code in setup that would make it obvious if the arduino resets. also, my heartbeat led would temporarily stop (which it does if I manually press the reset button).

A capacitor on the 3v3 pin solved the problem. A glitch on that line might have been enough to cause the ftdi chip to reset? This doesn't happen when I use 5v instead, presumably because the 3v3 is supplied by the ftdi chip and the 5v is from the regulator.

Are you using the 3.3v to power anything? There is quite a low maximum current rating for that voltage source, something like 50 ma maximum with no protection for the FTDI chip if you draw too much current from that pin.

Lefty
Logged

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

There is code in setup that would make it obvious if the arduino resets. also, my heartbeat led would temporarily stop (which it does if I manually press the reset button).

A capacitor on the 3v3 pin solved the problem. A glitch on that line might have been enough to cause the ftdi chip to reset? This doesn't happen when I use 5v instead, presumably because the 3v3 is supplied by the ftdi chip and the 5v is from the regulator.

Are you using the 3.3v to power anything? There is quite a low maximum current rating for that voltage source, something like 50 ma maximum with no protection for the FTDI chip if you draw too much current from that pin.

Lefty


Not to sound like a jerk or anything but I don't think you read my previous posts or looked at the schematic. Otherwise it would be clear that yes I am powering the sensor off of the 3.3v line and I was asking about the possibility of pulling too much from the pin in this settup and causing the FTDI chip to glitch.

Regardless, the cap on the 3v3 pin solved the issue. The sensor is definitely not drawing 50mA, and if for some reason it is on powerup thats a problem but I guess for now it seems to be solved.
Logged

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

There is code in setup that would make it obvious if the arduino resets. also, my heartbeat led would temporarily stop (which it does if I manually press the reset button).

A capacitor on the 3v3 pin solved the problem. A glitch on that line might have been enough to cause the ftdi chip to reset? This doesn't happen when I use 5v instead, presumably because the 3v3 is supplied by the ftdi chip and the 5v is from the regulator.

Are you using the 3.3v to power anything? There is quite a low maximum current rating for that voltage source, something like 50 ma maximum with no protection for the FTDI chip if you draw too much current from that pin.

Lefty


Not to sound like a jerk or anything but I don't think you read my previous posts or looked at the schematic. Otherwise it would be clear that yes I am powering the sensor off of the 3.3v line and I was asking about the possibility of pulling too much from the pin in this settup and causing the FTDI chip to glitch.

Regardless, the cap on the 3v3 pin solved the issue. The sensor is definitely not drawing 50mA, and if for some reason it is on powerup thats a problem but I guess for now it seems to be solved.
Your welcome.

Lefty
Logged

Pages: [1]   Go Up
Jump to: