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?
How are you doing this? How does the device expect this number to be "written to a pin"?
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.
I was trying to analogWrite to a pin
Is that what the device expects? Hardly seems likely.
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?
and get the value to serial.print
Well, that part, at least, is trivial.
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?
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.
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.
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!