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

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

 

So I have a 6x6 calibration matrix for my force plate

 

I am acquiring data continuously but my program will wait for a wireless pulse from a Delsys electromyography program, then collect and write to a lvm file for 5-10 seconds. My question, for all 6 channels or columns in my lvm file seem to display a cyclical pattern. I do not think I am getting the numbers I want.

 

I will attach vi

 

I have captured 5 seconds of data standing on the plate; the values for Fz are in the 3rd column (FZ).

Lvm format Fx,Fy,Fz, torqueX, torqueY, torqueZ

Download All
0 Kudos
Message 1 of 33
(4,830 Views)
Solution
Accepted by Ned_Kelleher

Hi Ned,

 

I'm a bit confused why you are only writing the data every time that you click the button. Do you want to capture all the data? If you notice in your excel file, the larger numbers will correspond to how many times you click the EMG sim button. Also, if you put an indicator from the array wire prior to entering that case structure, you'll see the data that you're supposed to be getting. These numbers correspond to the larger numbers in your excel sheet. So essentially, the data in between each of these larger numbers is data that isn't representative of your signal. Therefore, you should alter your code to write in a better fashion if you want to view the data as a whole rather than each time you click it. I hope this makes sense, let me know if you have any other questions.

 

Paul M

National Instruments | Applications Engineer | www.ni.com/support
Message 2 of 33
(4,777 Views)

The button is simulating the eloctromyography pulse from (DelSys-NI compatible) accelerometers all over subject. I am not sure yet if it is a pulse or dc level. I have a latching vi for that. Then the latched value will stay high (after detecting hi to low transition) and drive this part of my code. So the way I have it set up now is just leave switch on until timer done. Then stop.

 

Should I use a For loop? A While loop? instead of the case-while still needing to drive it with emg pulse?

 

I thought I was getting something funny from the case.

 

Thanks for your analysis. Very helpful.

 

This is all I need to do. Zero signals, acquire pulse to start trial (write data/start timer), acquire 6 signals via matrix, run/stop timer, export it to excel. The students will manipulate data in Excel.

 

Thanks again for your help.

 

I will post any changes made to vi

 

 

0 Kudos
Message 3 of 33
(4,756 Views)

Hi Ned,

 

To be honest i dont think your solution is solved just yet?

 

I think the problem you are having is that the data in excel is input wrong. I am on my way out so cannot give a full explanation with code etc... but i can give you a quick example. Tomorrow, if needed, i will go over in detail. For example, your 'X force' Column, the first 6 entries (row 2 - 7) is actually the data that should be in row 2 (columns B-G) (the same for all columns). Your data seems to be transposed incorrectly, This is why it is cyclicle, every 6 rows its repeating the only difference being the factor you are multiplying by. I believe that your column data should be your row data. 

 

Sorry, hope this makes enough sense for you to understand. Im in a major rush (and slightly drunk!!). As i said, when i have time i will explain in more detail if needed.

 

Rgs,

 

Lucither.

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

 

 

Hi Ned,

 

I've had time to have a look at your vi again. I really dont believe that your problem lies with how you are capturing the data to a file. If what you want to do is write to a file for x amount of seconds then the method you are using isnt the absolute right or best way but it will work. I believe the problem Paul was seeing was maybe due to the fact that he may of not entered a value into the 'Set time' control. I have tested and if for example i enter a 5, your vi will log for 5 seconds and then stop.

 

I believe that you have a problem in the rest of your code, to me it doesn't feel as though you have coded what you want to capture. As i dont know exactly what you have tried to do i have re-done your vi showing exactly what you are doing. Take a look and let me know if this is what you are trying to achieve, if i am right and it is not let me know exactly what you are trying to do and then we can start from there. Have a look at the following snippet:

 

Zero channel operation.png

 

What makes me beleive that you are not doing what you are intending is the fact that only the first row of you matrix is actually being used, the rest is redundant. What you are doing in your code is:

 

1: Seperate read data into seperate channel data

2: Add 0 offset to each channel

3: Get last read value from 1D channel data array.

4: Multiply this value to whole of matrix

5: Index the first row of matrix (Done for each channel)\

6: Get subset from 0 to length (Does nothing, returns what you put in?)

7: Build Array.

 

This is the same for all 6 channels, you only ever get the first row of the matrix muliplied by the last value read from that channel. Is this what you are after?

 

I have added at the bottom a much simpler version to better illustrate the steps you are taking.

 

Have a look and let me know your thoughts. Just another point, you may want to mark this problem as un-solved if it isn't yet solved. There are most probably people on here who actually know about Bertec calibration and are in a better position to help you. As such they may not even look as you have marked it as solved.

 

Rgs,

 

Lucither.

 

 

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 5 of 33
(4,730 Views)

Hi Ned,

 

Had some spare time so i googled bertec calibration matrix. From what i gather the diagonal data is your calibration values and the rest is cross-talk values. From this i summized what i believe you are trying to achieve.:

 

Force plate 1.png

 

If what you want to do is read the last value from each channel and then multiply this by its corresponding calibration value and then save this array as a row of data then the above should achieve this (I have assumed that the channels 0 - 5 line up with the corrosponding rows in the matrix).

 

I am not sure why you only are getting the last value, im guessing that in fact it would be better for you to get all the reads but you found this method easier. If this is the case then use the simplified version in the snippet below:

 

Force plate 2.png

 

Point to note for the different methods. If you use the first method of only getting the last value read from each channel you will only get a single 1D array to save, 1 element of data for each channel. If you use the 2nd method you will have a 2D array, multiple 1D arrays corresponding to the amount of times the hardware has been read between iterations. For the different cases you will need to configure the 'Convert to dynamic data' vi differently:

 

Write to file conv.png

 

Above shows explains how it needs to be configured for the different methods. I have quickly tested this and using your original method of capturing the data for x amount of seconds and then exporting gives you the data in excel correctly, this is for both methods.

 

Rgs,

 

Lucither

 

 

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 6 of 33
(4,717 Views)

็Hi Ned,

 

In testing your vi i had practically written a routine that would do what i think you are after. I have spent just a little time putting it all together so you can use it. As i dont have any of the DAQmx vi's i tested it using a DAQ simulator i placed in the vi. For you to use it just add your DAQmx vi's and replace my simulator. I will attach it below.

 

I have slightly changed a part of it. Rather then store data for x amount of seconds, i changed this to x amount of samples. This allowed me to easily allocate a buffer to store the data in. You can easily pre-calculate how many samples = how many seconds from your sample rate. Unlike your original attempt i also read all data that the DAQ outputs.

 

Hope it helps, if you have any questions just ask.

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 7 of 33
(4,706 Views)

Hey Ned and Lucither,

 

I just want to make you aware of our on-line Biomedical User Community over at www.ni.com/biomedusers - there's quite a bit of EMG discussion going on over there and I think this force plate stuff would be a nice addition once it is worked out.  Also - note that we have a free Biomedical Starter Kit download with some example applications (ECG signal processing, data logging, etc.) and lots of very useful signal processing VI's for ECG, EMG, as well as great file conversion utilities.

 

Steve

Message 8 of 33
(4,663 Views)

Hey

 

Oh my thanks for the help people!! I see what I was doing wrong.

 

Lucither thanks for the help. Man I didn't expect that level of help.

 

Steve:

I just want to make you aware of our on-line Biomedical User Community over at www.ni.com/biomedusers - there's quite a bit of EMG discussion going on over there and I think this force plate stuff would be a nice addition once it is worked out.  Also - note that we have a free Biomedical Starter Kit download with some example applications (ECG signal processing, data logging, etc.) and lots of very useful signal processing VI's for ECG, EMG, as well as great file conversion utilities.

 

 I have made a note of this. We are building a new motor behaviour/biomechanics lab. Much more of that type of data logging goin' on in the future.

 

 

Lucither - I am going to use your code. I added my input channels. The vi does all I need it to do. I have one question. When I zero the channels, they get noisier. Especially FZ. I attached my vi.

 

My question:

 

Can I split the signals up (Index/Array), then fire them through their own individual Mean/Negate (to get rid of noise on each channel). Then bring the signals back together to send to the Bertec Calibration vi?

 

Other than the noise, the vi is fine the way it is.

 

Thanks again for all the help. I am impressed.

0 Kudos
Message 9 of 33
(4,648 Views)

Hi Ned,

 

You where right, there was a bug in the zeroing. I was zeroing correctly but applying it to the transposed array, basically sharing all zero data across all channels. I didn't like how it was done previously anyway so took the time to do it tidier. I have also implemented it so that you can toggle on/off zeroing per channel, will also display the zero offset value for you.

 

I have attached the updated zip file below. The best thing for you to do is completely get rid of the version i sent you before. In the new zip file i have made changes to several of the vi's that i previously sent you that have the same names. Dont want you accidentally trying to use a different version of the same named vi. Better to just dispose of what i previously sent you and use this.

 

Again, if you have any questions or you want to make some changes but dont know the best way to go just ask. Fortunately for you (and unfortunately for me) i dont have anything better to do Smiley SadSmiley Very Happy

 

Rgs,

 

Lucither.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 10 of 33
(4,629 Views)