LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

need some help! I am writing code for a force plate - FX,FY,FZ + moment X, moment Y and momentZ

Solved!
Go to solution

Hey Lucither

 

Thks again. I like this version best.

 

However, can you tell me how I can make one button to zero all channels (keep individual controls as well). Prof wants one button. I can do, do I add the code to the sub vi? Then how to get it to be a control in main vi window? I forget how to make things work between vi's?? I took labview in 2002-2004 (ver6 I think). Just started prgramming last spring again.

 

Also, I am fine with counting samples as a clock.

 

The biomechanics dude here wants to be able to collect data for a period of time. Let's say 10 seconds. He wants to be able to collect 1000 samples in say 10 seconds, but have the ability to collect maybe 2000+ samples etc....for the same period of time. I attached a pic of my main vi (I have not modified any code in subvi's). So when I run this vi, say at 2000hz-10000hz sampling rate, read 200-1000 samples, the prgram just counts slower. I do not get the extra samples. He cannot tell how fast we are gathering data from the the samples read control.

 

The noise control is awesome. I learned quite a bit from your coding techniques. Graphs are cool and everything else. Thanks man!!

 

Really - thks I never dealt with a Matrix before!! 

 

 

Download All
0 Kudos
Message 11 of 33
(2,334 Views)

Hi Ned,

 

Will have a look at the All Zero button.

 

I think the problem you may be seeing with the sample rate is because you have left the timing function (set to 60ms) on the vi. I only had this as i dont have the DAQmx vi so need to insert a pause into my loop. I dont think that you need that in yours. Try it without and see how you get on.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 12 of 33
(2,315 Views)

Hi Ned,

 

Added a 'Zero All' button for you.

 

As i said before, try your code by removing the timing function. I only used that for my testing. If you still have problems after this let me know.

 

This file has some extra subvi's in. Same thing as last time, you may want to just get rid of the other stuff and use all of this folder.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 13 of 33
(2,312 Views)

Hey Lucither!

 

I didn't see the msec timer there. The prgram is awesome. Zero works really well. Excel file is perfect. My same problem:

 

The Prof here needs to be able to have a control for frequency.

 

Another control for time.

 

 

So hypothetically, he wants to be able to collect for say :

 

5 seconds at 1000Hz-->result-->writes 5000 samples to excel file.

5 seconds at 2000Hz-->result-->writes 10000 samples to excel file.

10 seconds at 1000Hz-->result-->writes 10000 samples to excel file.

10 seconds at 2000Hz-->result->writes 20000samples to excel file.

 

etc............

 

The setup now is not sufficient for his purposes. He needs to be able to change the sampling frequency and thus number of records so he can capture certain frequencies depending on what action is being tested. The frequency he chooses will depend on what action the test subject will perform. He has done a shitload of testing for Adidas, Nike etc..so he knows what he needs.

 

I am not sure how to approach this. If I set sample rate (program running speed) from 1000Hz to say 10 000Hz and read 100 to 1000 samples, the prgram does not slow down at all - it pounds out whatever number of samples in the same allotted time. It returns (writes to excel) whatever number of samples read (your control) that was entered when the prgram started.

 

0 Kudos
Message 14 of 33
(2,299 Views)

Hi Ned,

 

I think there must be a bit of a time difference between us as im just on my way to bed. What you want does not seem too difficult. As i have previously said i do not have any of the DAQmx vi's and have never used them but from what you are saying it seems to me that you need to be able to change in the loop the sampling rate. Just to clarify, would you like me to alter the vi so that you can change the sampling rate within the loop and then also give you a time variable instead of the samples variable. Basically so you can choose a sampling rate and an amount of time to sample. This is not a problem as long as the DAQmx vi allows you to dynamically change sampling rates on the fly?? That will be something for you to check. 

 

In the morning i will quickly modify the vi for you. Would have a go now but have had a bottle of wine so don't fancy how it would turn out Smiley Tongue

 

Let me know if this is exactly what you want.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 15 of 33
(2,291 Views)

Hey Lucither

 

I live on the East Coast of Canada - Nova Scotia.

 

Yes. Scott does not like the # sample variable. A timer would be better. So what he wants is whatever sample rate he sets on the control, say a 1000Hz for 5 min, he wants 5000 samples written to excel. Say 5000Hz for 5 min, he wants 25000 samples written to excel. Say 2000Hz for 10 seconds, he wants 20000 samples written to the excel file....etc...

 

I really appreciate this help. Then that's it. The program is awesome.

 

I work at Acadia University. Electronic design eng - but have been away from Labview. I need to get a better understanding of sub vi's and how to use them for the future. You code is a great learning tool!

 

 

0 Kudos
Message 16 of 33
(2,274 Views)

Hey Ned,

 

Nova Scotia, well i dont think we could live further apart if we tried.

 

I will have a look at the vi for you tomorrow afternoon. I was actually going to sort it out for you the other day, i was going to download the DAQmx files so i could fully understand what needed to be done but my computer kept on crashingSmiley Mad

 

Just a little bit of info i need to continue. If i want to change the sample rate can i simply immediately write to the DAQmx vi where i can see you set the sample rate or would i need to first 'Stop', then re-enter the sample rate and then re-start. If i have to stop then i will need to implement some code that triggers when i change the sample rate, closes the DAQ session, changes the sample rate and then re-starts. If i dont have to do this then i can just change the sample rate on a change of input.

 

If you can find this out for me will be a help and then i can get you over the final (hopefully) version.

 

I am going to continue trying to download the DAQ vi's anyway, then i can simulate it better. Is >1G though and the Thai internet isnt the fastest.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 17 of 33
(2,268 Views)

Hey

 

Thailand - that is far!

 

Warmer there - winter here Lucither - if ya like snow we have lots to share!

 

Anyway, we have a system to gather electromyography data on the subject. Accelerometers all over the lower body. When that program is stabilised, it sends a pulse (not sure if a one shot (on then off) or stays on for a period of time) wirelessly to the Force plate Labview program.

 

So we need it to capture data when this pulse happens.

 

From what I understand of the DMX part of Labview (see attached pic), is the 1000hz is the overall speed of the running of the program, samples per channel is the buffer created by Labview per channel and the samples to read is the number of data points pulled out each time the while loop is called??

 

Now the prof (he is a biomechanist/Mech Eng/PHd in Physics) wants to be able to set a timer for each trial at some sampling rate/frequency. So if he sets the prgrm to 5000 hz for 10 seconds he wants 50000 records written to excel. 1000Hz hz for 10 seconds he wants 10000 records written to excel.

 

As for your question.

 

Each trial with a subject will begin the same way.

The DelSys program (NI compatible software) must stabilise (this software deals with the accelerometers on subject), when it's ready it will send a wireless pulse to Forceplate prgrm to begin trial, then data will be captured and written to excel according to frequency on a control and time period set on a timer control. Time is just arbitrary. It can be anything to accomodate capturing the trial. The frequency is another matter. Scott may need to increase frequency to see certain aspects of a cutting move, plant and jump on the force plate. More resolution depending on the frequency of the action being captured.

 

The Labview force plate prgram now lets us increase # samples to read to whatever, counts that number accurately, then writes to the excel file. If I increase samples to read/write to excel now, from 10000 to 20000 samples to read (and leave prgrm sample rate at 1000Hz and samples read to 100), the prgram takes 20 seconds to write the samples instead of 10 seconds. We need to be able to jam whatever sampling frequency into the prgram and have it write the records in one time period reqardless of frequency. If it is 10000 hz in 10 seconds, 20000hz in 10 seconds, or 50000hz in 10 seconds.

 

 

Thks for the help!

 

I hope life is good for you in Thailand!

 

Have a great weekend

 

 

Download All
0 Kudos
Message 18 of 33
(2,262 Views)

The Labview force plate prgram now lets us increase # samples to read to whatever, counts that number accurately, then writes to the excel file. If I increase samples to read/write to excel now, from 10000 to 20000 samples to read (and leave prgrm sample rate at 1000Hz and samples read to 100), the prgram takes 20 seconds to write the samples instead of 10 seconds. We need to be able to jam whatever sampling frequency into the prgram and have it write the records in one time period reqardless of frequency. If it is 10000 hz in 10 seconds, 20000hz in 10 seconds, or 50000hz in 10 seconds.


 Hi Ned,

 

 

Im a bit confused as what i believe you are asking for is just a conversion from Time to samples. If for example like you stated above you keep the sample rate at 1000hz and you ask for 10,000 samples then it will take 10 seconds, if you then want to take 20,000 samples within 10 seconds then you will have to change the sampling rate to Samples/Time, in this case 2000hz. If as you say all you want to do is input a sample rate and then log data for 10 seconds then all you would have to do is enter (Sample rate * 10) into the #samples control to get the amount of samples you need to get within 10 seconds?? Is this correct, is this all you now need.

 

If this is all you want and you don't need to change the sampling rate of the hardware whilst the vi is running then the attached will work. All i have done is calculated the amount of samples you need to obtain based on the time you want to test and the input sample rate. Currently if you need to change the sample rate you will have to stop the vi, enter the new sample rate and then start again. If you can get the information to me that i asked you for the other day, specifically whether you can dynamically change the sample rate using the DAQmx vi or whether you need to stop the current operation, change the sample rate and then start again then i can see about adjusting the vi so you can change the sample rate whilst its running. I am currently still trying to download the DAQmx vi's from NI so i can find out for myself but keep on having computer trouble.

 

I will attach the folder below. The new vi you need is called 'Force Simulator Time based'. I have left the previous version in there as well just in case this is not what you was trying to explain.

 

Should be pretty self explanatory what you need to do but if you get stuck just ask.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 19 of 33
(2,246 Views)

Hi Ned,

 

Finally managed to download the DAQmx library. Found the answer to my question. Quickly updated the code with the DAQmx vi's so you can now alter the sample rate whilst running. Also have a time input for your test.

 

This should be it up and running now. Let me know how you get on.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 20 of 33
(2,221 Views)