Pwm output is high on bootup?

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

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);
}

Hi Coding Badly,
Thanks for the code.
I tried it and here are the results:
home.planet.nl/~sintt000/Arduino2.wmv

The 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

Is the glitch also present on digital pin 3 (PD3/OC2B)?

Yes the result is the same.

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()
{
}

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

Which Arduino IDE version are you using?

Whoops sorry about that,
Version 0021

This is probably an Uno/Optiboot 'feature' - optiboot does less initialization, probably not reseting pins to input mode. Power-up reset does this but subsequent resets don't?

probably not reseting pins to input mode.

No that happens automatically as a result of the reset pin being hit. It is a hardware thing.

Grumpy_Mike:

probably not reseting pins to input mode.

No that happens automatically as a result of the reset pin being hit. It is a hardware thing.

I'm not so sure, the Uno/Optiboot 'features' and the new 8u2 usb converter chip sure made for a rather rocky introduction to the latest board offerings from Arduino, with more bugs then any other new board offerings I can recall. And also requiring two IDE releases in very short order.

In hind site they would probably been better off just introducing the 8u2 feature and put off changing from their more proven bootloader code. That or they need a better beta process before rushing new boards to market.

My money 2 cents is that this symptom uncovered in this posting will be at least related to the new bootloader if not directly caused by it. No proof, just shooting from the hip. :wink:

nali2001:
Whoops sorry about that,

No problem.

Version 0021

I cannot find anything in 0021 that would cause this sort of problem. I cannot find anything going from 0021 to 0022 that would effect PWM.

But, just in case I missed something, I suggest upgrading to 0022 and rerunning the tests.

Hi all,
I tried this code on version 0022:

int Pwm_output_pin_10 = 10;

void setup()
{
  pinMode(Pwm_output_pin_10, OUTPUT);
  analogWrite(Pwm_output_pin_10, 128);
}

void loop()
{
}

Same result. Output still goes high for a short moment. Just to check I also tried it all on an other Arduino board and the problem is still there.

I have two new video's.
You see it with a led instead of the scope.
I plug in the cable and you see the process. It goes high for a little while, then nothing and after that high again and it's ready for use. I also later on press reset and you see it now does 'reboot' nicely without the 'going high' problem.

First video:
http://home.planet.nl/~sintt000/Arduino3.wmv

Second video:
Here you see the boot process when powered from a battery.
This works fast and without the problem.

http://home.planet.nl/~sintt000/Arduino4.wmv

Thanks.

The processor that's on that board ... where did you get it? Is it the processor that came with the board?

Is that the same board you were using earlier with the oscilloscope testing?

Just to confirm ... the LED is on pin 10?

Do you have an ICSP? Another Arduino?

I tried this code:
So no Arduino native PWM but a digitalWrite and Delay combo on pin 8.
Problem is the same.

int LedTest1 = 8;

void setup() {
  pinMode (LedTest1, OUTPUT);
}

void loop() {
  digitalWrite(LedTest1, HIGH);
  delay(25);
  digitalWrite(LedTest1, LOW);
  delay(25);
}

Please see the video:
http://home.planet.nl/~sintt000/Arduino5.wmv

Hi,
Yes the board came ready to use so including the chip.
I'm not really sure where we got them, probably a local Dutch electronics store. My boss bought them (we have 2 boards)

Yes the same board as used in the scope video.

Yes pwm pin 10.

I have two boards and both behave the same.
I have no ICSP

Thanks!

Using the "Arduino Duemilanove or Nano w/ ATmega328" board option (ATmegaBOOT_168_atmega328.hex bootloader) I cannot reproduce the problem. Everything works as expected.

I have not been able to test with the "Arduino Uno" (optiboot_atmega328.hex bootloader)...

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.

Would someone with an Uno (or someone who can get Optiboot working) mind trying to reproduce this problem. All that's needed are a few LEDs + resistors and one of the Sketches above.

Thanks for trying,
Odd that you don't see this issue, I tried two broads and the problem is the same.
That is, only when powered from usb cable, powered from battery solves the problem.

Looks like the usb communication interrupts the operation of the board when cable is just plugged in.

So if anyone wants to verify this problem, this is what you need:
470ohm resistor and a led.

And this code:

int Pwm_output_pin_10 = 10;

void setup()
{
  pinMode(Pwm_output_pin_10, OUTPUT);
  analogWrite(Pwm_output_pin_10, 128);
}

void loop()
{
}

Power it from usb and see if the led goes on for a short moment, then off, and after a while on again.

Thanks!

Hey,

Is this problem solved of getting pulse when booting up arduino??

I am facing same problem.