0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« on: February 10, 2011, 06:47:19 am » |
Hello all, For testing purpose I have here a very simple setup using the Duemilanove. Just a 10k potentiometer on the Analog Pin 0. An scope connected to pwm out pin 11.
Now the code is just your basic analogRead from the potentiometer and digitalWrite to pwm pin 11. This works obviously great. I have full pwm control on pin 11, no problems there.
BUT, I have noticed with the scope on pin 11. That that pin goes high for half a second orso when I boot up the Arduino. Meaning when I plug in the usb cable. So it very shortly hoes high, displaying a pwm signal. Then goes low and after a second or so comes up high again and the board is ready to use. So it seems, while the Arduino is booting just after you plug in the power it very briefly sets the pwm high.
This is not wanted since further on I want to control a full bridge motor controller with the Arduino. And I can not have unwanted high signals on bootup.
So is there a way to keep all pins absolutely low until the Arduino is fully booted?
Thanks! Kind regards, Steven
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #1 on: February 10, 2011, 08:18:51 am » |
This happens because initially the pins default to being inputs and they float high. You can stop this by simply putting a 10K pull down resistor on each output. That is a resistor connected between the output and ground.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #2 on: February 10, 2011, 08:36:54 am » |
Hi and thanks for the reply. Yes I forgot to mention that, but indeed I am using pull down resistors as well.
The brief signal I'm seeing during the Arduino boot sequence is a 5v pwm signal. It only seems to happen on the pwm pins. I see no such thing happening on the other 'normal' pins.
Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #3 on: February 10, 2011, 08:41:05 am » |
That is odd, do you see this if you don't initialises the the pins on start up. Maybe you need to set them to zero before you define them as inputs in the start up function.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 116
Posts: 10134
|
 |
« Reply #4 on: February 10, 2011, 02:45:14 pm » |
How long ago did you get the Arduino? Does it have Optiboot installed?
PLEASE do not cross-post.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #5 on: February 11, 2011, 05:10:49 am » |
Hello all, Very sorry for the double post. I removed the other. Here is some additional info: The circuit:  And here is a video: http://home.planet.nl/~sintt000/Arduino.wmvYou can see that after the usb cable is plugged in you see the pwm signal very briefly, then it goes away and after a while the booting is done and the board is ready to use. But this short pwm output during booting is not wanted when driving H bridges and such. The Arduino board was bought about 4 months ago. The code: int Pwm_output_pin_11 = 11; int Potmeter_pin = 0; int Potmeter_value = 0;
void setup() { pinMode(Pwm_output_pin_11, OUTPUT); }
void loop() { Potmeter_value = analogRead(Potmeter_pin); analogWrite(Pwm_output_pin_11, Potmeter_value / 4); }
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15310
Measurement changes behavior
|
 |
« Reply #6 on: February 11, 2011, 12:11:22 pm » |
A quick experiment. Load the IDE example blink program into the arduino and then disconnect and reconnect the USB cable and see if your scope still shows the pin #11 PWM signal or not during the bootloader initialization.
Lefty
|
|
|
|
« Last Edit: February 11, 2011, 12:12:57 pm by retrolefty »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #7 on: February 14, 2011, 03:37:17 am » |
Hi Lefty, Thanks for the suggestion. I tried that and no, pin #11 stays low on startup, but in the code it is not initialized either. But pin #13 is initialized in the code, so I tried that one next. And yes during boot-up that one also goes though some high cycles before normal operation is started.
Any idea? Anyone else here with a scope who can test this?
Many thanks! Kind regards, Steven
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 116
Posts: 10134
|
 |
« Reply #8 on: February 14, 2011, 03:43:46 am » |
I tried that and no, pin #11 stays low on startup That rules out the bootloader. How does this behave... int Pwm_output_pin_11 = 11; int Potmeter_pin = 0; int Potmeter_value = 0;
void setup() { pinMode(Pwm_output_pin_11, OUTPUT); Potmeter_value = analogRead(Potmeter_pin); delay( 50 ); Potmeter_value = analogRead(Potmeter_pin); delay( 50 ); Potmeter_value = analogRead(Potmeter_pin); delay( 50 ); }
void loop() { Potmeter_value = analogRead(Potmeter_pin); analogWrite(Pwm_output_pin_11, Potmeter_value / 4); }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #9 on: February 14, 2011, 05:45:55 am » |
Hi Coding Badly, Thanks for the code. I tried it and here are the results: home.planet.nl/~sintt000/Arduino2.wmvThe video starts the moment I plug in the usb cable. Almost directly a high output, then a little while nothing, then the board is ready to go. Thanks Kind regards, Steven
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 116
Posts: 10134
|
 |
« Reply #10 on: February 14, 2011, 07:06:27 pm » |
Is the glitch also present on digital pin 3 (PD3/OC2B)?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #11 on: February 15, 2011, 05:42:36 am » |
Yes the result is the same.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 116
Posts: 10134
|
 |
« Reply #12 on: February 15, 2011, 02:06:22 pm » |
I hate to continue sending you on "little errands" but it will help to definitively isolate the offending line(s) of code. Is there a glitch present on digital pin 5 (PD5/OC0B)? Is there a glitch present on digital pin 6 (PD6/OC1B)? Is there a glitch present on digital pin 9 (PB1/OC1A)? Is there a glitch present on digital pin 10 (PB2/OC1B)? Which Arduino IDE version are you using? Is the second PWM output from you adjusting the potentiometer? How does this behave... int Pwm_output_pin_11 = 11;
void setup() { pinMode(Pwm_output_pin_11, OUTPUT); analogWrite(Pwm_output_pin_11, 128); }
void loop() { }
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 30
Arduino rocks
|
 |
« Reply #13 on: February 16, 2011, 09:58:17 am » |
Hi Coding Badly, Thanks for the input I appreciate it! I have tried pin 5, 6, 9 and 10 just now and it's the same problem for each pin. Then I tried your code on each of these pins as well, and indeed it's the same situation. The output goes high for a short moment, then low and after a small pause it is up again and running.
Yes the moving pwm in the video is me adjusting the potmeter.
Found something else... When you power the Arduino from a 9volt battery the problem is gone. It also seems like it boots multiple times faster that way. You plug in the power and a second later the thing is running, the short 'high' pwm problem is gone when run from battery.
So maybe the usb data connection initialization is causing the problem as well as the way slower boot time? I wonder how to solve this usb situation...
Booting powered from 9v battery = 2 seconds. (no brief output going high problems during boot) Booting from plugging in the usb cable = 7 seconds. (brief output going high problems during boot)
Thanks, Steven
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 116
Posts: 10134
|
 |
« Reply #14 on: February 16, 2011, 11:06:12 pm » |
Which Arduino IDE version are you using?
|
|
|
|
|
Logged
|
|
|
|
|
|