Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Simultaneous acquisition, output and binary write file query

Hello

 

I am using a PCI-6221 card. I have a bread board to access all of the IPs and OPs on the card. I have a NANO 17 force/torque sensor from ATI Ltd. I can acquire data from the sensor from the PCI card using the program “ForceSensor.vi” attached.

 

I can acquire data and drive the stepper motor with a constant pulse train sent out from the card whose direction is determined from the data acquired, using the program “AI_feedback.vi”.

 

I can acquire data and convert to binary form using the program “AI,vi”.

 

The project is to measure the load on an aerofoil using the load sensor. A disturbance will be introduced into the flow. The idea is to measure the load acting on the aerofoil and to use a trailing-edge flap (driven by the stepper motor) to reduce the loading by applying proportional, PI, PID and an LQG controller using values obtained computationally.

 

So what I would like to do is to sample at around 1000Hz and drive the stepper motor with individual pulses at a maximum pulse rate of 150Hz. I have attached the three programs and I was wondering if it would be possible to give me any guidance/advice on how to synchronise the timing of them programs together.

 

Many Thanks

 

Mark

0 Kudos
Message 1 of 14
(4,875 Views)
 
Download All
0 Kudos
Message 2 of 14
(4,872 Views)

Dear Mark,

 

Wow, it sounds like you are involved with a very exciting project.  If you don’t mind me asking, where are you working? I have some good news and bad news for you.

 

Firstly, the bad news...

After a brief look at your code, and I fear that there is a bigger issue than the synching problem.

 

The good news...

Spending the time to remedy your existing code may be all that is required to provide the requisite synchronisation.

 

The main problem with your code is that you are trying to control 1 sample clock with 3 separate vi’s. The PCI-6221 has a single clock controlling its 8-off analogue input channels. Even though the sampling rates of the 3 vi’s are identical (10kHz), the multiple DAQmx timing functions will battle for resources.

 

The best way to remedy this would be to meld all 3 of your VI’s into a single VI, and share the timing function between them.  As you will see in the attached file, I have done this for you. Please look at the the new block diagram – it includes all 3 of your VIs. Notifiers are used to move data between the loops.

 

Notifiers, if you are yet to be introduced to them, are ideal for this application. They not only inform  the separate loops that data has become available, but they also send the required the data. Fantastic little functions!

 

…Continued to next post…

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 3 of 14
(4,837 Views)

A few other smaller changes have also been made...

 

1.   DAQmxRead, in the AI_feedbackloop, is reading 1000 samples from a single channel. Therefore its  properties were altered to reflect this (Analogue 1D DBL 1Chan NSamp).

2.   There was originally no method of stopping the AI-feedback loop. This is bad programming practice – the only way to stop the loop was to halt the entire application. If you do this, you will never receive potential error messages.  The front panel stop control will now now produce a notifier error, which will effectively terminate loops.

3.   Now, all DAQmx tasks are stopped when the loops are terminated, and any errors are merged and displayed to the user.

 

The only downside to what we have accomplished today is that the back and front panels are now quite intimidating and unwieldy. Another viable solution, depending on your budget, would have been to buy another 2 DAQ boards – thus giving you 3 analogue input timers, which you could have manipulated individually.

 

I have taken this program as far as I can, without alot more information and the missing sub-Vis. Hopefully this program will now synchronise effectively, but it will likely take some further tweaking from yourself.

 

 

…Continued to next post…

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 4 of 14
(4,836 Views)

If you are interested in furthering your understanding of any of the concepts raised in this reply, please visit the National Instruments website. As I am sure you are aware we run some excellent training courses which may help to speed up your development processes. Further information on all our courses may be found at www.ni.com\uk\training.

 

Alternatively, send an email to... info.uk@ni.com, and include information about the kind of training you would like to receive. If I could be so bold, I would suggest the Data Acquisition and Signal Conditioning course, which covers DAQ hardware, signal conditioning, analogue input, signal processing and synchronization. I have recently completed it myself, and would recommend it wholeheartedly.

 

I apologise for the rather epic length of my reply. This is my first ever forum reply, and so my enthusiasm is through the roof!

 

Best wishes for your project, and feel free to get back in touch if you have any further questions.

 

Richard Roberts

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 5 of 14
(4,835 Views)

Dear Richard

I'm sorry that I haven't replied sooner, but I have been away for a few days. Now that I'm back, I cannot thank you enough for your phenomenal reply!!! I was not expecting anything as thorough as that! I have always been very impressed with National Instruments products and services etc. and have mouthed this off to anyone and everyone (from your reply, I am assuming that you also work for NI) but this is a whole new level!!!

Not at all - I'm working at Imperial College London and this project is for my PhD, which, hopefully (!), I will finish at the end of the year.

I do have a small problem [ 🙂 ] in that I can't actually read the program that you have posted in reply, because my current version of LabVIEW is 8.0 and that is from a more recent version. This was extremely frustrating as once I had read through the reply I was very excited indeed!!! How can I upgrade in order to see your reply program?

Many thanks indeed

Mark

0 Kudos
Message 6 of 14
(4,778 Views)

Hello Mark,

Thank you very much for your kind words. You are correct in you assessment... I have indeed recently joined National Instruments, and I am rather happy about it!

I am pleased to inform you that upgrading your current software should be fairly easy. Imperial College has a full "site licence" with National Instruments, which means you are entitled to all the latest versions of all our software.

Our “Key Contact” at Imperial, and the chap you need to get intouch with, is Kevin hale, who is based in the IT department. He will be able to supply you with, either...

1.       CD installers of our latest upgrades

2.       The NI licence number, which will allow you to download and install software via our website. (www.ni.com)

If you have any more questions about the upgrade, feel free to reply to this post. Although, it may be a more efficient use of your time to call our office on 01635 523545.

Good luck with this Mark. Although the upgrades should be easy for you to aquire, if you do hit any hurdles please get back to me and I will re-write the code in LV8.0.

Best wishes,
Richard

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 7 of 14
(4,758 Views)

Dear Richard,

Got it all working and learned about notifiers...yes, very useful! Thanks again for all that.

I do have one last question, which is that I need to acquire data (as I am doing) and drive the stepper (as I am doing), not with a controlled feedback though, but instead a standalone series of pulses. For example, to take measurements while the stepper moves through 50 steps and then stops whilst still taking measurements. This is a finite pulse train and isn't a problem.

However, I want to deflect the flap sinusoidally through, say, 0 to 45 degrees, periodically. As each step is 1.8 degrees, this requires a series of steps that are not regularly spaced in time (although the series itself is periodically repeated). Would you happen to know the easiest way to go about this please?

Many Thanks

Mark

0 Kudos
Message 8 of 14
(4,720 Views)

Hello again Mark,

I am pleased that your original vi is now working as intended. I have only recently been introduced to the glory of the notifier, and I was delighted to have the opportunity to pass on the knowledge J If you are interested, perhaps you could also have a look at “queues”. They work in a very similar fashion, but have associated FIFO buffers, which will prevent data loss.

Anyway... onto more pressing matters! Please have a look at the attached code. I have commented the block diagram, so hopefully it will be easy to follow. It generates a sine wave, which oscillates between 0 and 45. This is converted into a series of +ve and –ve steps, which hopefully you will be able to use to control your motor.

There is a graph which directly compares the original sine wave with the stepped version. But, more pertinent to your requirements, is the numeric indicator which displays how many steps the motor needs to make at a given instance.

I hope this will be of some use to you.

Have a fantastic weekend!

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 9 of 14
(4,696 Views)

Hello Mark, was the "steps" code I wrote any use to you?

I hope that all is well,

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 10 of 14
(4,632 Views)