Code runs different with external power supply

Hello Folks, I wrote some code and have it running all well and good as long as I use the USB for power. When I use an external power supply of 9VDC, my millis()counts are like twice as long. This screws up my program big time. I tried two separate power supplies. I checked the waveforms with a scope and the voltage looks clean.

Can you tell me why millis() would have different values when using either the USB or a Wall Wart for power? Thanks very much for your input!

Can you measure the 5V pin and confirm you get 5V in both cases?

How do you know the millis() counts are out? What is the external manifestation of this?

Can you tell me why millis() would have different values when using either the USB or a Wall Wart for power? Thanks very much for your input!

There is no linkage between millis() behavior on USB Vs external power. However I would want to look at the external power voltage carefully, with a o-scope, while it's powering the arduino. There is always a logical explanation once the root cause is found.

Lefty

I'm using millis() for a delay count. My calculated time is right on when I use the USB power. It's way off (more than twice as long) with either of two wall warts.

As I said in my first post, I'm looking at it with a scope and it looks clean. Voltage is 4.97 VDC using either supply.

Can you post the code for us to take a look at?

OK, let me put it a different way. Can you post your code please?

(Edit) ninja'd!

I don't have the code right now, it's on a different box. But trust me, the only difference is the power supply. I change nothing but the power and the count goes off.

What count? You haven't answered my question about how you know that millis() is returning different values.

This is the programming questions part of the forum. You are supposed to post your program, and then ask a question about it.

hypercode: Can you tell me why millis() would have different values when using either the USB or a Wall Wart for power? Thanks very much for your input!

It wouldn't. But it would be easy to have a power supply / loading problem and sketch design that produced similar symptoms for other reasons. What's the voltage/current rating of the power supply, what's connected to the Arduino, and [u]what sketch are you running[/u]?

It's a 200mA 9v pretty-well regulated wall wart. The output is one LED each at two PWMs at ~15mA each. Two analog inputs, A0 & A1. When I use an external pulse trigger on pin 8 for counting, my counts are accurate using the wall wart. When I use millis() to count, the timing is way off using the wall wart. With USB power, my counts are consistently good with millis() or pulse input.

Can you post the code for us to take a look at?

OK, let me put it a different way. Can you post your code please?

You are supposed to post your program, and then ask a question about it.

what sketch are you running?

What is your aversion to posting your sketch? The people here want to help, but you seem determined to stop them.

I have an idea! How about posting the circuit too!

When I use an external pulse trigger on pin 8 for counting ...

What are you counting?

Oh, and what Arduino are you using?

Or are we going to keep playing 20 questions?

Read this:

http://www.catb.org/~esr/faqs/smart-questions.html

Some important points:

  • Describe the problem's symptoms, not your guesses
  • Be precise and informative about your problem

Regarding the second point, we are getting tired of grovelling at your feet to get you to post your code. Or describe in detail what you have connected to where.

... my counts are accurate using the wall wart ...

What counts?

When I use millis() to count ...

Show us how you are using millis(). (in your code)

... the timing is way off ...

How do you know that?

With USB power, my counts are consistently good ...

How do you know this?

The output is one LED each at two PWMs at ~15mA each ...

What output? Connected to where? What resistors are you using?

Two analog inputs, A0 & A1 ...

What is connected to them? With what resistors? What capacitors? What length wires?