Pages: [1] 2 3 ... 5   Go Down
Author Topic: Diecimila resets easily when controlling a motor  (Read 5261 times)
0 Members and 1 Guest are viewing this topic.
Brooklyn, NY, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 115
arduino for all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Hey all,

I am pretty sure I found a bug in the Diecimila.  Basically, I hooked up the basic motor control using a TIP120 transistor and a pot.  I followed this lab:

http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads

When I turn the pot above about 1/3, then the Diecimila starts reseting a lot, sometime so much it doesn't come back until I turn it down again.  I tried this with USB power and a wall wort.  When I ran the Diecimila off of USB power, then ran the transistor of a totally separate power supply with its ground wire connected to the Arduino ground, it then worked fine.

When I ran the exact same circuit and code using an Arduino #1296, it worked fine, with both the exact USB port or the exact same wall wort or the external power supply.

It seems that there is something fishy going on.
Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

To me it just sounds like the ATmega168 is browning out.

Stick a few big capacitors in so the motor cant suck all the juice out of the circuit and see if it helps.
Logged

Brooklyn, NY, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 115
arduino for all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The key part here is that the same exact setup worked fine with an Arduino #1296.  This happened to me on the Diecimila even when using an external power supply.
Logged

Bangkok, Thailand
Offline Offline
Newbie
*
Karma: 0
Posts: 47
Arduino POP!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Try addition 4700uF /16V. capacitor on +12 supply to reduce back EMF load effect and add more diode to prevent reverse voltage back to TIP120 and may effect I/O pin

it's should to work better.. smiley
« Last Edit: October 18, 2007, 06:27:12 am by worapoht » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I know the power supply circuit changed somewhat between the older Arduino boards and the Diecimila.  In particular, the FTDI chip is now powered whether you're using USB or external power (to suppress extraneous serial data), meaning that the total load on the power supply is larger with the Diecimila than the older board.

As others have said, I don't think it's a bug in the Diecimila so much as a different handling of a slightly sketchy circuit.  Just because something used to work doesn't mean it's the right way to do it.  
Logged

Brooklyn, NY, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 115
arduino for all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


I am not trying to say that this circuit is a good one to use, but it is definitely a good one to learn from because it's so simple.  But the real key is that this circuit works totally fine on the Arduino and Arduino NG, but causes repeated resets on the Diecimila.  I made a video to illustrate it:

http://dropbox.at.or.at/dropbox/diecimila_motor_problem.mov  (25MB)

It seems to me that it's related to the frequency of the motor, rather than the current.  I'll try adding a filter cap to isolate it.  But since Arduino is a learning platform, I think that the Diecimila should be as robust as the previous generations.
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As do I.  This change was to make the Diecimila more robust in other ways than the previous boards.  Unfortunately, one of the challenges of making a flexible board that's simply enough to use as a teach platform is balancing all the different requirements.  In this case, we traded off a bit of capacity to ensure sketch startup when powering with an external supply.
Logged

Brooklyn, NY, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 115
arduino for all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I started the meta-conversation a bit prematurely...  smiley-grin back to the details of what's happening.  Tom and I just spent some quality time debugging this with his boards.  It seems that there is at least one red herring in this.  Since it works fine when the motor power supply is totally separate, we are changing that tutorial on Tom's site to reflect that.

I measured the current from the motor, it uses 130mA at full speed.  So I don't think that current is an issue here, just to put that to rest.  I am using a 400mA supply, Tom was using a 1000mA supply.  Plus I am using Vin to power the motor, which if I understand correctly, is just a pass thru from the external power supply.

So my Arduino NG also resets in this circuit.  But for some reason, my Diecimila sets the PWM pin to 0 when it restarts, while my Arduino and Arduino NG leaves it at the same level.  Tom's Diecimila left it at the same level too.  With the arduinos that don't turn off the PWM, you don't really notice the reset in this circuit since it just means that you can't change the speed of the motor for a couple of seconds. The thing that leaves me wondering is, does the PWM keep running even when the chip is resetting?  How come my Diecimila does reset the PWM?

So far, the status is that the Diecimila seems more sensitive to the motor noise, i.e. it resets more easily.  But the Arduino NG resets too.  None of them reset when the motor power goes straight to the breadboard.  Would there be any downside to adding something to make it more resilient to noise?  I don't mean it to make bad circuit designs work, but more in general, to make the Arduino more stable.

Also, I am curious what the mechanism is that is causing the reset...


« Last Edit: October 18, 2007, 03:19:38 pm by eighthave » Logged

Montréal, Qc
Offline Offline
Full Member
***
Karma: 1
Posts: 185
Practice safe hex!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

For one, you should check motor current at full stop torque (that is, stop the shaft while running it full power) that's your max possible current. Torque is what uses current, not speed. As for the PWM. I've noticed this behaviour on my NG, but I have the Diecimila bootloader. But as far as I can see in the Makefile, both use the same fuse (David maybe you can correct me here). So I'm really not sure where the issue is here.
Logged

"Pilots believe in a clean living... they never drink wisky from a dirty glass."

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It might be the brownout fuse.  The chip might act differently if a reset is caused by the detection of a brownout than if brown-out detection is disabled and the chip resets because it loses power completely.  While the fuses burned with the current burn bootloader menu items are the same for the NG and Diecimila, we shipped the NG's without brown out detection enabled (if I remember right).  You might try reburning the bootloaders on your board and seeing if that changes its behavior.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 135
Posts: 6786
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It would be interesting to know the reason for the reset.  The AVR stores bits in a register that distinguish between power-on reset, brown-out reset, watchdog reset, and reset input reset; I don't THINK that the bootloader clears those bits, so your sketch could examine them and show which had occurred somehow...

Logged

Brooklyn, NY, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 115
arduino for all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am pretty sure the current is not the issue, since things worked fine when I connected the power supply directly to the motor.  But to make sure, I did some measurements.  Previously, I measured the current while the motor was in this circuit illustrated in the video.

This time I am testing with a 12V, 1000mA supply.

open supply voltage: 13.5V
voltage with motor on full stop: 8.8V
full speed, no load current: 0.08A
full stop current: 1.2A

It seems very unlikely to me that the ATMEGA168 would brown out if there was 8.8V on the regulator.  Also, if I hook up the Arduino to USB power and the motor to the external power it still happens.  Also, the reset doesn't happen when the motor is starting, but rather after it's running for a bit.  From what I understand, there should be a current spike when the motor starts.

Also, from what I understand, the reset state is written to the EEPROM.  I set the whole EEPROM to 0, then the reset motor control sketch again.  All of the EEPROM bytes were still 0.
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

hi


I would not spend too much time speculating about the fact that it resets on one Arduino and not on the other. That's because neither were really designed for noisy power supply environments.  The Diecimila in particular has about 35 cents worth of power supply filtering, with a whopping capacitance of... 100uF. Whew, I'm drowning in electrolyte here!

As a result of the lean power supply filtering, and if you want predictability, it is wise to keep noisy things like motors, solenoids and other inductive loads as far away as possible from the Arduino's +5 logic supply .

I will bet  you a bag of grommets that adding 220Uf to the +5 supply causes your Diecimila reset problem to go away immediately. Solder it right on top of the Atmega and give it a try.  And if that does not work, put a .1 across the Atmega +5/GND pins.

You guys must have a scope there, so what does the reset line look like? Put the +5 power supply on channel A and the reset line on channel B, set it AC coupling on both channels, with really fast trigger and capture if available... all will become evident.  

FWIW,  in the past I've had to add one or more of the following to get prevent interaction between the logic and motor supply:

- .1 caps on supplies near motor V+, to quench high-frequency noise caused by pwm switching
-  220Uf to 1000Uf  caps on either or both logic and motor supplies
- .01 on the motor itself to quench high frequency noise that is emitted electromagnetically ( i.e. radio noise)
-  schottky 'freewheeling' diodes on the motor to clamp inductive spikes
- diodes or low value (.1R) resistors inline with the motor power supply, to encourage the noise to stay in the motor supply
- in extreme cases an opto-isolator between the uProcessor and the motor driver  silicon.

In general I just put a whole truckload of 100Uf and .1Uf capacitors on the logic supply, and keep the supplies as separate as possible, and as a result I pretty much never have to deal with what you're describing.

D
« Last Edit: October 19, 2007, 02:55:05 am by Daniel » Logged

Brooklyn, NY, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 115
arduino for all
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


One of the main reasons I am going into detail on this is to write a tutorial about it.      But also in the process, it seems that the Diecimila (mine at least) is more sensitive to noise than the previous versions.  It would be quite helpful to figure out how to improve that situation.

Do you have any diagrams for what you describe that I could use in a tutorial?
Logged

Daniel
Guest
 Bigger Bigger  Smaller Smaller  Reset Reset

hi

sure i could dig up some diagrams, but each solution is symptom-driven, so it is best to find out why the reset is happening and then apply the simplest solution. Did you try the extra filter caps on the Diecimila? If that works, tutorial-wise it would be just a matter of saying add 220Uf or something to the +5/GND pins. I am almost certain that that is why it is happening, and I still have that bag of grommets.

If you really want to get to the bottom of things to discover why your Diecimila is more sensitive to noise than earlier versions, then the scope is the ticket. I can only think of  three ways that the reset could be happening: via the reset line, a brownout on the power supply line, or within the code somewhere. The scope will tell you if it's one of the first two.  From that you can suggest a tutorial workaround.

D
« Last Edit: October 20, 2007, 06:04:05 am by Daniel » Logged

Pages: [1] 2 3 ... 5   Go Up
Jump to: