05-28-2016 01:25 AM
Hmm, I try to "decode" what you show in this schematic. As I see what you have is a kind of hardware components to build up a PID controller, at the left you have the P,I,D terms, in the middle something is called a limiter, at the right the myDAQ.
Ok, as I see you connected wires to the two analogue inputs and one analogue output single-ended, using a common ground pin. I am not 100% sure this is ok in this case, but lets assume now it is.
Regarding to the channels, as I see you want to drive the PID elements' inputs from the AO CH0, and also read back the created signal using AI CH0, correct? Finally you want to measure the output signal of the PID using AI CH1.
If the above wiring is correct and usable, you need to plan what to do on the software side. Based on your wirings, you want to create a kind of stimulation signal, an analogue voltage. What are you requirements for this stimulus? In the last VI which you attached, you use a white noise simulator VI creating 128 data points. This is the signal what you want to send to the PID controller? If so, you need an AO DAQmx task and wiring this data array to it. The update rate you need is 1kHz based on your VI? If you want to measure the created AO signal with your AI CH0, then you need in total two DAQmx tasks:
05-28-2016 02:51 AM - edited 05-28-2016 02:51 AM
Could you try the attached VI? Please others also comment on the code, whether is it optimal for this actual case?
05-28-2016 03:11 AM - edited 05-28-2016 03:40 AM
I think a possible problem here with my VI is that, myDAQ cannot use RSE pin config for the AI channels, only for the AO, regarding to the spec doc:
www.ni.com/pdf/manuals/373060f.pdf
If this is right, then you need to wire the AI0 and 1 in differential.
Actually what is the reason you cannot use the ELVISmx Bode Analyzer? http://www.ni.com/tutorial/11504/en/
Here is a video even showing wiring (input channels wired differential): https://www.youtube.com/watch?v=Hey53nsKLKs
edit: in your picture where you show your actual wiring, the AI channels wired differential, so try to use Differential pin config for the DAQmx function for input channels:
05-28-2016 03:45 AM - edited 05-28-2016 03:46 AM
Ok, with this Differential setting my VI works, at least with a simulated myDAQ...
I would also put a CASE structure around the System Identification functions, so when you stop the top loop, the bottom loop will not generate error due to the empty arrays:
05-28-2016 04:17 AM
I made a new vi. It works well, the MyDAQ gives signal.
Missing only the Bode plot, but I don't know would be the right one. I'm not sure that is working properly what I used for the previous one.
05-28-2016 04:24 AM
Again wrong approach. You need to understand what signals you want to measure, and what to generate. Regarding to the Bode analysis, you need to generate a voltage signal, this will be your Analogue Output task (AO). Beside, you need to acqusitie TWO channels, one is the generated signal, and the other is the response from the PID circuit (Analogue Input task, with two channels: AI0, AI1).
In the VI which you attached, you just generate a single voltage output changed by a knob (in your previous example you wanted to use a White Noise signal generator, no???), and measure a SINGLE analogue input channel. This is not reflecting your physical wiring... Also, do not use Express VIs, they are not optimal in a While loop.
Did you actually try my example VI shown above???
05-28-2016 05:27 AM
Yes, I tried your example. It shows the same error as before.
05-28-2016 05:49 AM
I changed the data type of wire to 64 bit. But still not works.
05-28-2016 06:48 AM - edited 05-28-2016 07:06 AM
You do not understand how that error is created. Did you read the error information? Do not change the data type for the ID functions, what for?
The original error is coming from the DAQmx functions (3.jpg). The error from the Identification functions (1.jpg & 2.jpg) are only due to the fact, that a zero sized array is sent to the consumer loop. So all we need is to fix the DAQmx error. Looks like what works with a simulated myDAQ, not necessarily works with a real device.
I am not sure but probably this is a hardware timing limitation of the myDAQ device.
Could you try the VI below, so we can see which DAQmx task creates the error?
edit: another change is that, I explicitly specified the number of samples for the AO task's Sample Clock function...lets see...
edit2: actually after reading the help for the DAQmx Timing, I realised in Contin. mode this function uses a 10k sized buffer in case of a 1k Hz rate, even if I connected the value 128 to it...so this is not the source of the recent problem i guess...
05-28-2016 07:32 AM - edited 05-28-2016 07:33 AM
Based on this info: http://digital.ni.com/public.nsf/allkb/EC1968728E660B288625780700570D06 ,
could you try the following modified VI?