Arduino and USB

Hi all,

I am connecting Arduino Uno to my usb port to plot data in real-time in the Arduino environment. I input a 1Hz square wave from function generator with a low mv range voltage to be read.

My laptop's usb ports all sample the waveform wrong with slightly different amplitudes, so the square waveform looks like a 10hz modulated signal, but when I use another laptop to do the same thing the signal is clean.

Does anyone know if this is a setting that I should set up on my laptop?

Thanks for your help!
Anna

Please post your full sketch.

If possible, you should always post code directly in the forum thread as text using code tags:

  • Do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code. This will make it easier for you to spot bugs and make it easier for us to read.
  • In the Arduino IDE or Arduino Web Editor, click on the window that contains your sketch code.
  • Press "Ctrl + A". This will select all the text.
  • Press "Ctrl + C". This will copy the selected text to the clipboard.
  • In a forum reply here, click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the sketch between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
  • Repeat the above process if your sketch has multiple tabs.

This will make it easy for anyone to look at it, which will increase the likelihood of you getting help.

If the sketch is longer than the 9000 characters maximum allowed by the forum, then it's OK to add it as an attachment. After clicking the "Reply" button, you will see an "Attachments and other settings" link.

When your code requires a library that's not included with the Arduino IDE please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manger (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.

hanna_hoj:
Hi all,

I am connecting Arduino Uno to my usb port to plot data in real-time in the Arduino environment. I input a 1Hz square wave from function generator with a low mv range voltage to be read.

My laptop's usb ports all sample the waveform wrong with slightly different amplitudes, so the square waveform looks like a 10hz modulated signal, but when I use another laptop to do the same thing the signal is clean.

Does anyone know if this is a setting that I should set up on my laptop?

Thanks for your help!
Anna

How large is the variation?

Could this be accounted for by ripple on the laptop's 5v supply? Do you have an oscilloscope that you can use to look at the 5v supplied by the laptop? By default ADC readings are referenced to Vcc, which is the 5v provided by the USB port in the configuration you seem to be describing, so if that's not steady, your readings won't be either.

Most laptops are factory set to use minimum power and even suspend USB ports.

Power saving modes and sleep or hibernate for other parts of the system can also have an effect on USB ports so match them too.
Check that both lappys are also set the same in the BIOS.
Use USB 2.0 ports on both machines so you don't get any mismatch on speeds.

Check the individual settings on the one that work against the one that does not and match them.

Also ensure both laptops are running off the power supply and not battery.

Bob.