Go Down

Topic: Arduino and NI usb DAQ (Read 1 time) previous topic - next topic

Alright, this may be a dumb question but here goes:

I have a quadrature encoder that read an angle.  I have this part working.  I need to write this number out to a pin, which will be read by a USB National Instruments USB DAQ.  I was trying to analogWrite to a pin, and wanted to verify it was sending the right information so I wanted to do an analog read and get the value to serial.print. Basically, how do i output a number from one pin and read it in on another?

PaulS

Quote
I need to write this number out to a pin

How are you doing this? How does the device expect this number to be "written to a pin"?

Quote
which will be read by a USB National Instruments USB DAQ

No idea what a USB DAQ is, but is seems unlikely that National Instruments makes only one.

Quote
I was trying to analogWrite to a pin

Is that what the device expects? Hardly seems likely.

Quote
and wanted to verify it was sending the right information so I wanted to do an analog read

analogWrite() and analogRead() operate on pins on opposite sides of the board. Do you have the appropriate pins connected?

Quote
and get the value to serial.print

Well, that part, at least, is trivial.

Quote
Basically, how do i output a number from one pin and read it in on another?

First, let's make sure that this even makes sense. Post a link to the device that you are trying to talk to, and explain this number that you are trying to output. Byte, int, float, unsigned long? uint64_t?

madworm

Assuming your usb data acquisition hardware reads analog values, you need to add a suitable low-pass filter to the PWM pin of the arduino. I think the PWM frequency is around 500Hz. In case of doubt use a scope to make sure the voltage is reasonably steady.
• Upload doesn't work? Do a loop-back test.
• There's absolutely NO excuse for not having an ISP!
• Your AVR needs a brain surgery? Use the online FUSE calculator.
My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...
• Microsoft is not the answer. It is the question, and the answer is NO!

RoyK

I think the problem is Arduino's differing use of the word 'analog' for input and output pins.

An 'analog' input expects a voltage input over the nominal range of 0-5v (or other if the reference pin is tied to some other voltage).

An 'analog' output is PWM - that is an approximately 500hz oscillation who's duty cycle depends on the value being output.

RoyK

Oh, and if you are using NI Daq equipment I assume you're likely a LabVIEW programmer. You might want to check this out if you haven't already done so.

https://decibel.ni.com/content/groups/labview-interface-for-arduino


RoyK
Thank you!
Yes I am a labview programmer and did not know this existed.  This is the perfect solution to my problem.  I can read a value from arduino using a quad encoder assign that value to a variable and have it interact with my daq.  Thank you so much!

RoyK

You're welcome (from a now retired LabVIEW programmer).

Go Up