Arduino analog read pin to frequency

Hi.
I am trying to convert the digital voltage (read from the analog pin on my arduino mega from an accelerometer) and perform FFT/Spectral analysis to convert it into a Magnitude vs. Frequency output waveform.
I am having some issues accomplishing this, with my output from the Arduino Read Pin Vi as a double 64-real 16 precision data, which I convert to a single waveform. The output from the FFT (RMS) from my spectral measurement via is a 1D cluster of 3 elements. When I wire this to a waveform graph it just changes the Y values (magnitude) but frequency is not updating the X axis at all.
Please help here is a screen shot of my setup so far:
[IMG]http://i.imgur.com/WrzbX.png[/IMG]
I also attached the VI below.
Solved!
Go to Solution.
Attachments:
arduino_test.vi ‏85 KB

Thanks Craig.
 I removed those build arrays functions as you suggested.
 The FFT seems to be working, but not as I expect it...I think this has to do with the limited bandwidth of 50Hz sampling that the accelerometer itself can handle.
 My new question is how can I control the While Loop with say an On/Off type button, which also will clear the values stored in that tunnel so I can use it simultaneously with the rest of my program? What I mean is that I'd like the accelerometer part of my program to have it reusable during the course of the program execution, without affecting the rest of my program which is controlling 8 DC motors. That is to say that while loop should be able to take new readings and data without stopping the rest of my program. 
 I've attached my VI to this reply. 
  Thanks a lot!!!
Attachments:
arduino_test.vi ‏123 KB

Similar Messages

  • Analog Read Pin VI for Arduino interface (LIFA)

    Hi all,
    I'm new to Labivew and Arduino but hoping to incorporate both into my classroom. The Uno I have is functional; I've had some success with it already in the sketch editor. I'm hitting a wall with the interface, though.
    I downloaded VISA but probably overlooked something in the setup. I can't get this Analog Read pin VI to work (from the examples). After setting up a constant on the Init.VI to specify the correct COM port, I hit Run and I can see the TX/RX lights flashing on the Uno. The data from the analog pin is not being read, however. The meter doesn't move.
    Hopefully it's something simple I'm overlooking. I'd really like to move forward and explore LIFA.
    Thanks
    Solved!
    Go to Solution.

    Hi SpuriousD,
    We actually have a specific community group dedicated to LabVIEW Interface for Arduino (LIFA) located at: www.ni.com/arduino. You would most likely get a better response if you posted your question on this board, and it also has some great resources.
    Bill E. | Applications Engineer | National Instruments

  • Read data from 3 arduino analog pins

    Hi, 
    My name is Jack. I have a question about how to read multiply data from arduino analog inputs in labview. I have tried to read data from 2 pins by using same way (continuous analog samples) and the system works well. However, I failed in reading data from one more pin, no matter I used the same way as to read continuous analog samples or the method to read analog voltage. 
    My idea is to read battery voltage from pin 0, and the transducer voltages from pin 1 and pin 2 and convert them to currents. Pin 1 and Pin 2's signals work well, but pin 0 does not that good.
    Another question is that how to plot data of pin 1 and pin 2 into one waveform chart. I have tried to bundle the two arrays; it didn't work, however.
     Attached is my VI. Thanks for help. 
    Attachments:
    final final project.vi ‏747 KB

    This article presents a procedure for reading the analog ports of Arduino UNO R3 board , on which a Joystick shield was installed. The analog data are related to the position of command and can be monitored from the front panel of our program , for which we use serial communication.
    https://decibel.ni.com/content/docs/DOC-33281
    Atom
    Certified LabVIEW Associate Developer
    Attachments:
    analog_JOYSTICK_ARDUINO.zip ‏1 KB
    cmd arduino JOYSTICK.vi ‏65 KB

  • How to enable 2 or more analog input pin in arduino uno labview simultaneo​usly for voltage analysis?

    Hi everyone,
    i am new to labview and using arduino uno board for measuring microwave analysis in my project. i want to measure the refflection coefficient by dividing two analog input received to arduino (Vref and Vin) to obtain so. problems come where i just can analyze only one analog input pin only. please, kindly helped to figure it out.i've try the others solution where i create two while loops for different analog pin. u can refer to my circuit in the attachment below.i really2 appreciate ur help, thank you.=)
    Attachments:
    reflection coefficient and Vswr.vi ‏665 KB
    front panel.PNG ‏66 KB
    block diagram.PNG ‏40 KB

    Try this if you have a POT around hook it up to the arduino than use the AnalogInSerial.pde and  load it to your arduino exit out of the arduino platform and  than try my VI see if this helps you.
    Harold Timmis
    [email protected]
    Orlando,Fl
    *Kudos always welcome
    Attachments:
    TalkToArduino.vi ‏28 KB

  • Starting analog read corrupts analog write waveform

    I have come across an odd condition that can occur if I am running a diagnostic routine on my system.  My diagnostic routine is basically four while loops, each containing code to control specific items in the system hardware. Two of the items are DIO's and always work no problem.
    (Am running LV 2013 on Win 7 with a PCI-6014 daq)
    Another contains an analog read using AI8 and the last contains an analog write on AO0.
    When I run the analog write task, I am feeding in a waveform that essentially pwm's the output.  By itself it works fine.  The only parameter I edit for the waveform generation is the total duration in seconds.  I set at two seconds and I get the modulated output for 2 seconds.
    The problem occurs when I try to do this and read the analog input (a simple voltage in from a pressure transducer) at the same time.
    If I start the read task while the write task is running, the modulation goes away and the signal goes high and stays there, not shutting off until I force it.   If I have the read task already running (in a loop remember so I can monitor pressure)  the write task acts even more wiggy.  When I start the task it runs for maybe 100-200 ms with the modulated signal and stops.  On about the fourth start, the signal goes straight to high again and stays there until forced off.
    So, is there some kind of limitation on this older hardware on reading and writing (at least a waveform) at the same time?
    The write task was orginally created in front of the loop and I tried creating it in daqmx and using that but it made no diffference.  I use a daqmx timing vi to set the sample clock rate based on the same waveform with a setting of finite samples.
    Any thoughts are appreciated.  This isn't stopping me from going forward but I would like to know why it's acting the way it is.
    Thanks....
    Doug
    "My only wish is that I am capable of learning each and every day until my last breath."
    Solved!
    Go to Solution.

    As I have not got this figured out yet, I am posting the guilty code in hopes someone might shed some light on what is causing the issue.  Code is pretty generic in nature with only one sub vi (also attached) and a couple simple tasks for reading the analog-in.
    This is on LV 2013 on a win-7 32 bit system using a PCI-6014 daq.  Analog read tasks are both on AI8. One task is configured to read the straight voltage from the transducer (0-10vdc) and the other uses a custom scale to convert to pressure.  Either one causes the conflict.
    Pressing the button to start the motor run works as intended by itself.  Default values for waveform are correct for my application though total pulse time (4 seconds) can be adjusted without consequence. (Note, waveform output controls an isolated SSR that contrls the higher level voltage)
    Running either option on the read pressure routine causes the analog out for the motor to wig out.  Stops pulsing and goes to a straight high condition.  If it is on first, starting the motor causes just a little blip of output for 4 - 5 clicks then eventually just sets the AO to high as well.  Continued clicking of the start eventually returns it to blip mode but not to the regular waveform that it is configured for.
    I have removed all un-related code from the routine that exhibits this behavior.  I returned the analog out to creating a task in the vi as was the original approach used. I had tried a preconfigured task in MAX but it made no difference.
    Small loop inside of motor state is to allow minor adjustments in power supply voltage while motor is running.  This has not even come into play at this point.
    If anyone can point out the error in my ways, I would much appreciate it.  I know the power supply vi is not the most robust and I will end up changing that to something better that uses the dll supplied by the mfg.  Current code is legacy material that I inherited.  Everything else though looks on the up and up from my persepctive.
    Thanks for any insight........
    (just had a thought, if the ground between the two drive voltages is made common, could that impact things ?  will have to see what the internal grounding connection on the daq is)
    Doug
    "My only wish is that I am capable of learning each and every day until my last breath."
    Attachments:
    Analog_Conflict_.vi ‏43 KB
    Serial Pwr Sply Driver.vi ‏68 KB

  • No reading on the frequency counter

    I'm not getting a reading on the frequency counter when I wired the clock signal onto it. There's just one input to the counter, so I wired a clock and try to get a reading. All I see are the dashes. Is there something else I need to do? thank you.

    Hi,
    You can configure some parameters in the pop-up window of the instrument. Trigger Level, sensitivity and AC or DC Coupling. You can try to set these based on your circuit.
    If you want us to take a look at it, please post the circuit.
    As an alternate, you can also see the freq in the measurement probe. Go to Simulate -> Instruments -> Measurement Probe and click on the net (wire) where you want to check the frequency.
    Hope this helps.
    Regards,
    Tayyab R,
    National Instruments.

  • How to structure the DMA buffer for PXie 6341 DAQ card for analog output with different frequencies on each channel

    I'm using the MHDDK for analog out/in with the PXIe 6341 DAQ card.
    The examples, e.g. aoex5, show a single Timer  (outTimerHelper::loadUI method), but the example shows DMA data loaded with the same vector size.
    There is a comment in the outTimerHelper:rogramUpdateCount call which implies that different buffer sizes per channel can be used.
       (the comment is: Switching between different buffer sizes will not be used)
    Does anyone know what the format of the DMA buffer should be for data for multiple channels with different frequencies ?
    For example, say we want a0 with a 1Khz Sine wave and a1 with a 1.5Khz sine wave.  What does the DMA buffer look like ?
    With the same frequency for each channel, the data is interleaved, e.g.  (ao0#0, ao1#0; ao0#1, ao1#1, ...), but when the frequencies for each channel is different, what does the buffer look like ?

    Hello Kenstern,
    The data is always interleaved because each card only has a single timing engine for each subsystem.
    For AO you must specify the number of samples that AO will output. You also specify the number of channels. Because there is only one timing engine for AO, each AO will channel will get updated at the same time tick of the update clock. The data will be arranged interleaved exactly as the example shows because each AO channel needs data to output at each tick of the update clock. The data itself can change based on the frequency you want to output.
    kenstern wrote:
    For example, say we want a0 with a 1Khz Sine wave and a1 with a 1.5Khz sine wave.  What does the DMA buffer look like ?
    With the same frequency for each channel, the data is interleaved, e.g.  (ao0#0, ao1#0; ao0#1, ao1#1, ...), but when the frequencies for each channel is different, what does the buffer look like ?
    In your example, you need to come up with an update rate that works for both waveforms (1 KHz and 1.5 KHz sine waves). To get a good representation of a sine wave, you need to update more than 10x as fast as your fastest frequency...I would recommend 100x if possible.
    Update Frequency: 150 KHz
    Channels: 2
    Then you create buffers that include full cycles of each waveform you want to output based on the update frequency. These buffers must also be the same size.
    Buffer 1: Contains data for the 1 KHz sine wave, 300 points, 2 sine wave cycles
    Buffer 2: Contains data for the 1.5 KHz sine wave, 300 points, 3 sine wave cycles
    You then interleave them as before. When the data is run through the ADC, they are outputting different sine waves even though the AO channels are updating at the same rate.

  • Arduino digital read

    Hi all
    I want to read the digital ports status and give one on the relative out (that i have assigned) if the input status is one, of my arduino using LIFA.
    i have made a VI but the status of all pin results 0 also if i give 5v like inputs on the board...
    help me pleale

    if it still does not solve your problem, there is a group in which topics of arduino arduino
    https://decibel.ni.com/content/groups/labview-inte​rface-for-arduino
    You can ask your questions
    Atom
    Certified LabVIEW Associate Developer

  • How to increase speed of analog read using PCI 6110 and LabView 7.1?

    Hi All,
    I'm a fairly novice user of LabView and I'm trying to figure out how to make my system as fast as possible. Basically, I'm reading in an analog signal (AI0) together with a trigger signal (PFI0) and I want to sample the analog signal on the falling edge of the trigger signal. What I'm finding, though, is that the acquisition rate of this system is excessively slow. My analog signals occur faster than 1 kHz, but the speed of my system is only about 100 Hz. A colleague of mine told me that the DAQmx Trigger.vi I was using was probably the culprit for the slow performance I was observing. Could this be right? If so, how could I resolve this issue?
    Another thought I had was to input the trigger signal into the external source input of the DAQmx Timing.vi. In this way I'd be using the trigger signal as an external clock. If operated in Continuous mode, then I think the Sample Clock would cause a sample to be read only when the trigger signal changes its state (from high to low). Could this work?
    Thanks for reading,
    Ben

    Hi Marni,
    Thank you so much for your post! I tried doing as you suggested, using the Cont Acq&Graph Voltage-Ext Clk-Dig Start.vi and I first set the trigger signal as the external clock source. It works beautifully! Now, with 1.6 kHz signal in, I'm reading in 1.6 kSa/s. This is a dramatic improvement from before. I also tried using the internal clock source option, but it didn't seem to trigger when I wanted it to. I didn't spend too much time debugging it, though, since the other method works so well. This brings up an interesting question. Is the DAQmx Trigger.vi really that slow? Previously, I could read in 100 kSa/s at best using the Trigger VI. Anyways, I'm a happy camper now:-)
    By the way, to answer your question about the DAQ device, I'm using the NI PCI 6110 Multifunction DAQ.
    Thanks again!
    Ben

  • What is the Reader X update frequency?

    I've noticed on various Windows machines that Reader X's (10.1+) update frequency is pretty leisurly--weeks can go by after an update is released. I have Reader set to update automatically in its preferences, but the update service is on manual and not started. When is checking done, when the program is run?
    I know in the case of Flash 11.2 (beta) that its update service is also on manual but that Adobe schedules a daily check for updates, triggering the service. Reader doesn't have any kind of scheduled checking that I've found.

    Please refer to the http://kb2.adobe.com/cps/837/cpsid_83709/attachments/Acrobat_Reader_Updater.pdf for details about the Acrobat And Reader Updater service (i.e. ARM).

  • Reading PIN value from install parameters

    Hi
    I have seen several examples in wich the SIM Toolkit applet reads the byte array passed into the install() method to find out the PIN code of the mobile phone.
    These examples read the input buffer pass the AID length to find the PIN code. As I'm new to SIM Toolkit, i don't quite understand what's going underneeth. Can somebody please explain the reason for this?
    Thank you.

    Hello asri,
    please take a look at the Java Card API specification in order to check out the structure of the data given to the applet. The interesting method is javacard.framework.applet.install(byte[], short, byte).
    "Installation parameters are supplied in the byte array parameter and must be in a format using length-value
    (LV) pairs as defined below:
    bArray[0] = length(Li) of instance AID, bArray[1..Li] = instance AID bytes,
    bArray[Li+1]= length(Lc) of control info, bArray[Li+2..Li+Lc+1] = control info,
    bArray[Li+Lc+2] = length(La) of applet data, bArray[Li+Lc+2..Li+Lc+La+1] = applet data"
    How the applet data are structured inside "applet data" and how the applet interprets them is up to the implementer of the applet. These data are also known as "applet specific installation parameters".
    Please note that the parameters given to the applet may differ in order and structure from the parameters in the INSTALL (for install) command.
    For more information on the INSTALL command, go to http://www.globalplatform.org and fetch the appropriate Card Specification (Version 2.0.1, 2.1.1 or 2.2) for your card.
    For more information on installation parameters for SIM applets look at something like
    ETSI, Technical Specification 102 226, "Remote APDU structure for UICC based applications (Release 6)", Version 6.11.0, 03/2005
    from http://www.etsi.org
    Please be careful to choose here also the correct specification version for your card, e.g. Release 4|5|6.
    So, coming back to your example, when there are PIN data in the installation parameters they are within the applet specific parameters and the installer and the applet developer agreed on their specific location.
    Have fun learning lots of things... :-)
    Salam,
    lionking

  • Read pin from my midlet

    Hola! Could be posible to read from my midlet application the code pin of the sim card when my application is running in a determinate mobile?
    Thanks/ Violeta

    Unless your specific phone SDK has an API to do this, then no. You usually don't get access to the inner workings of the phone because of the KVM security model.

  • Error when starting an analog read task with DAQmx 8.5 while 8.0 works

    I am programing a measurement application with Borland C++ Builder 6.
    Problem: Every time when I try to start an analog input task with the DAQmxStartTask() command of DAQmx 8.5 the program execution is interrupted and the error message "Invalid floating point operation" is given out. This problem does not occur with DAQmx 8.0 !

    Hello Johannes,
    the error occurs every time, when I try to start an analog voltage input task either with a simulated or a real device (PXI-4472). Changing any of the measurement parameters did not have any effect. I also tried one of the C-source code examples, which came with the original NI-documentation of the DAQmx 8.5 driver, resulting also in the same error.
    However, starting a counter task with a simulated PXI-6601 device worked without any problems !
    Do you have any ideas ?
    Regards,
    Thomas

  • Triggered, Multiple channel Analog Read: TIMEOUT

    Hello,
    I am trying to read multiple AI channels (differential), triggered with a DigitalStartLine. To trigger, I generate a Hi-Low pulse on the trigger line. My readanalogF64 function always returns a Timeout.
    I have used the same trigger to write multiple AO channels and have succeeded but not with the read operations. I have also found that if I don't use a triggered read, I am able to do the read perfectly.
    Following is the piece of code:
    DAQmxErrChk (DAQmxCreateTask("",&ADC_taskHandle));
    DAQmxErrChk (DAQmxCreateAIVoltageChan (ADC_taskHandle, "Dev1/ai0:7", "", DAQmx_Val_Diff, 0, 10, DAQmx_Val_Volts, NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming (ADC_taskHandle, "", 1000, DAQmx_Val_Falling, DAQmx_Val_FiniteSamps, 1000));
    DAQmxErrChk (DAQmxCfgDigEdgeStartTrig (ADC_taskHandle, "/Dev1/PFI1", DAQmx_Val_Falling));
    DAQmxErrChk (DAQmxStartTask (ADC_taskHandle));
    DAQmxErrChk (DAQmxReadAnalogF64 (ADC_taskHandle, 1000, 10, DAQmx_Val_GroupByChannel,ADC_Data, 8000, &read, NULL));
    DAQmxErrChk (DAQmxStopTask (ADC_taskHandle));
    // To generate the Trigger pulse
    for(i=1;i>=0;i--)
    if(i==1)
    singleBit_array[0]=1.0;
    else
    singleBit_array[0]=0.0;
    DAQmxErrChk (DAQmxCreateTask ("", &taskHandle));
    DAQmxErrChk (DAQmxCreateDOChan (taskHandle, "/Dev1/PFI0", "", DAQmx_Val_ChanPerLine));
    DAQmxErrChk (DAQmxStartTask (taskHandle));
    DAQmxErrChk (DAQmxWriteDigitalLines(taskHandle,1,0,10.0,DAQmx_​Val_GroupByChannel,singleBit_array,NULL,NULL));
    DAQmxErrChk (DAQmxStopTask (taskHandle));
    The ERROR I receive is:
    Function DAQmxReadAnalogF64: (return value == -200284 (0xfffcf1a4))
    Some or all of the samples requested have not yet been acquired.
    Property: DAQmx_Read_RelativeTo
    Corresponding Value: DAQmx_Val_CurrReadPos
    Property: DAQmx_Read_Offset
    Corresponding Value: 0
    Any suggestions would be a great help.
    regards,
    Dwivedi

    Dwivedi,
    Sorry it's taken me a while to get back to you, I've had a pretty hectic day here.  However I was able to sit down this afternoon and write a C program which accopmlishes what you were trying to do with AO.  I have NI-DAQmx 7.4 installed and was testing using a PCI-6259.  My program was able to run without error.  Here is my code:
    TaskHandle aoTask;
    int32 err = 0;
    float64 dataArray[8192];
    int32 sampsWritten = 0;
    for(int i=0; i<8192;i++)
    if((i%200) < 100)
    dataArray[i] = 6;
    else
    dataArray[i] = -6;
    err = DAQmxCreateTask("TestAOTask", &aoTask);
    if(err != 0)
    printf("Error Creating task... Error Code %d\n", err);
    return 0;
    err = DAQmxCreateAOVoltageChan(aoTask, "Dev1/ao0", "aoChan", -10.0, 10.0, DAQmx_Val_Volts, "");
    if(err != 0)
    printf("Error Creating channel... Error Code: %d\n", err);
    return 0;
    err = DAQmxCfgSampClkTiming(aoTask, "", 50000.0, DAQmx_Val_Falling, DAQmx_Val_ContSamps, 8192);
    if(err != 0)
    printf("Error configuring sample clock... Error code: %d\n", err);
    return 0;
    err = DAQmxCfgDigEdgeStartTrig (aoTask, "/Dev1/PFI0",DAQmx_Val_Falling);
    err = DAQmxWriteAnalogF64(aoTask, 8192, false, 10.0, DAQmx_Val_GroupByChannel, dataArray, &sampsWritten, NULL);
    if(err != 0)
    printf("Error durring write... Error Code: %d\n", err);
    return 0;
    err = DAQmxStartTask(aoTask);
    err = DAQmxStopTask(aoTask);
    err = DAQmxClearTask(aoTask);
    return 0;
    Sorry, the text editor for this forum seems to insert an extra newline for every time I hit enter.  About the only difference I found between your code an mine is that I wrote the data before starting the task (which is what I would recommend for AO.  This will ensure that there is data available for the DAC's once the task is started).  If you re-order your code in this way do you see a change of behavior?
    Sorry again it took me this long.  Please let me know how this works.
    Dan

  • Linx Arduino Uart Read

    Merhaba bitirme tezim için labview üzerinden arduino programlamam lazım. Öncelikle 2 arduino yu biri mega digeri uno olmak üzere unonun tx,rx uclarını meganın tx3, rx3 uclarına bagladım. Uno AI dan 0-5V arası değer okuyup port uzerınden mega yolluyor. Arduino labview arasını linx kullanarak yaptım fakat okunan değer anlamsız geliyor. Nasıl yapmam konusunda önerisi olan varmı ?
    //Arduino UNO 
    void setup() {
    Serial.begin(9600);
    void loop() {
    int sensorValue = analogRead(A0);
    Serial.print(sensorValue);
    Attachments:
    uart_read.vi ‏25 KB

    Thanks Craig.
     I removed those build arrays functions as you suggested.
     The FFT seems to be working, but not as I expect it...I think this has to do with the limited bandwidth of 50Hz sampling that the accelerometer itself can handle.
     My new question is how can I control the While Loop with say an On/Off type button, which also will clear the values stored in that tunnel so I can use it simultaneously with the rest of my program? What I mean is that I'd like the accelerometer part of my program to have it reusable during the course of the program execution, without affecting the rest of my program which is controlling 8 DC motors. That is to say that while loop should be able to take new readings and data without stopping the rest of my program. 
     I've attached my VI to this reply. 
      Thanks a lot!!!
    Attachments:
    arduino_test.vi ‏123 KB

Maybe you are looking for