02-13-2009 01:44 PM
Melody -
I will combine Points 2 and 3, cause they are related to the same issue. For The PWM signal you need to have that signal set for 'one channel for all lines' and it will need to be on its own port (i.e. Port0). Now for ENA and DIR you can have those set to 'one channel for each line' (as they are capable of being on the same port) you will also need to change the DAQmx Write functions for ENA and DIR to Digital>>Single Channel>>Single Sample>>Boolean (1 line), and when you set the physical channel you must have it set to a specific pin for each input. (Example: ENA = 'Dev1/Port1/line0' and DIR = 'Dev1/Port1/line1'). This will write only to that one line on your board. Also for the ENA pin there is no need to have the DAQmx Write function in a while loop if the value will never be changing. You could just get rid of the while loop and make sure it doesn't execute the DAQmx Clear Task until after you have decided to stop your program.
As for point 4, you could use a For loop instead of a while loop and then have a control on your Front Panel that would set the number of iterations that the For loop would execute. Then once the For Loop had finished executing you would just have to run the VI again to run the motor.
It seems to me as you are making pretty good progress with the program. Let me know any other questions that arise.
02-15-2009 09:49 PM
Hi Aaron,
Hope you had a great weekend!
02-16-2009 05:11 PM
Melody,
I hope you had a good weekend as well, I feel that an extra day on the weekends would be great and am trying to find a way to make that happen.
How exact do you need to Load Cell and the PWM signal to start with each other? Are we talking within the same second, or are we talking milliseconds? Lets take a step back and talk about the overall needs of the program as a whole. This is what I understand so far:
- You need to be able to output a software timed PWM signal.
- While you are outputting a PWM signal you need to be taking data from the load cell.
- You need to be able to control the ENA and DIR lines while all of this is taking place.
- You need to be able to save the Load Cell data to a file while all of this is taking place.
- You also need to be able to write what step count the measurement was taken into the file.
This is a fairly in-depth program and I just wanted to make sure I know exactly what you need to do to get the program up and running. As it stands right now the code you are using does not have a good data flow because there are essentially 4 parts of the program operating independently from one another. If you could give me more of an overview of what the program needs to do overall, it would help greatly.
You also mentioned about being able to run the PWM over again and still be able to take load cell data continuously, are you wanting to append the data to the file you are saving so you can have a consistent log of data from when the PWM signal is being run?
02-16-2009 09:57 PM
Hey Aaron,
I know some companies do take off today. I'm sorry you didn't. Me either.
Here is the big picture of my application.
Overall is an loading and unloading test. Stepping motor( drived by 3rd party board which requires D I/O from USB-6501)is used to generate motion while NI-9237 recording the load cell data. Set up the steps numbers , frequency for the stepping motor, then start motor motion and load cell data acquisition together. When the motor finishes the preset number, motor motion and load cell data acquisition stops together. After 5 to 10 minutes, restart the motor drive and load cell data acquisition without the offset nulling calibration again, say let the load cell stay in 'pause' not 'stop' status during the hold period(I can rerun th VI as long as the load cell doesn't change offset). Then after several runs , I will change the direction of motor and do the unloading. I would like to save all the load cell data according to time and motor step number in one file including each run.
All the points you list is correct 🙂
- I need to be able to output a software timed PWM signal control the frequency and steps of motor.
- While I'm outputting a PWM signal I need to be taking data from the load cell.
- I need to be able to keep the ENA on while all of this is taking place. I need to control DIR during this is taking place or between run.
- I need to be able to save the Load Cell data to a file while all of this is taking place.
- I also need to be able to write what step count the measurement was taken into the file.
1) I do want to append the data to the file I am saving for each run. So the PWM and load cell should be both on or both off.
2) I try to use' local variables' to stop the load cell when the PWM stops. So I added a local variables(stop 2 which can stop load cell reading) to the PWM status, but it popped up an error: Boolean 'stop 2' latch action is incompatible with local variables. If a Boolean control has associated local variables, it cannot use latch mechanical action. The first local variable to read a Boolean control with latch action would reset its value to the default.
I would appreciate if you can do some correction for this in my VI. I am confused about how this 'local variables' works
3) The load cell recording should begin from 0. I tried to keep offset nulling on the first run, and then turn off offset nulling before I rerun the VI, but the reading totally changed from -2 to 0.8. I still need suggestion for this step.
4) My concern about putting steps from PWM to load cell file is the different data frequency and compatibility.
Appreciate your time and effort!
Melody
02-17-2009 04:03 PM
Melody,
I see that you had been talking to John P on another forum linked here. John actually sits by to me and we have been talking about this issue. The last iteration of the program that he gave you was a very good program that should work well for you. As I am sure you have figured out LabVIEW is very powerful/flexible software and there are often many ways to write the same functionality. If you can tell us what isn't working with the current version of the code we will help you debug from there.
02-22-2009 11:18 PM
Hi Aaron,
Thank you for both of your efforts !
One more question: How to reduce the data saved while keep the high sampling rate. The rate I set is 500 and samples per channel is 50. But that cause too much data in the file and I can't enve open the file with excel. could you please help in saving, say 1/10 (5) of the total data(50) each time ?
Thanks!
Melody
02-23-2009 08:24 AM
Melody,
One simple way to reduce the amount of data that is written to the file is to use a quotient/remainder function and a case structure. You can use the iteration count of the while loop wired to the 'X' Input and then a constant of 10 to the 'Y' Input and then wire the output of the remainder to a case structure. In the zero case of the case structure you can place the write to file VI. In the 1 case place nothing and make the 1 case the default. This will cause the data to only be written to file on every 10th iteration. I have attached pictures to show you how to set this up.
03-19-2009 10:13 PM
Hi Aaron,
How are you doing?
I'm still working on the VI we were discussed. Now I 'm focusing on some detailed feature about the load cell.
1) I would like to get the average value as the output each time the 'DAQmx Read' get the readings( each time about 50 readings which I can change@ rate 1006.92 Hz the minimum)
2) I try to use the shunt calibration, but it reports the error(please refer to load_cell_null_off_shuntcal.vi
Error -200077 occurred at DAQmx Perform Shunt Calibration (Bridge).vi:1
Possible reason(s):
Measurements: Requested value is not a supported value for this property.
Property: AI.Bridge.ShuntCal.GainAdjust
You Have Requested: -756.494860
Valid Values Begin with: 500.0e-3
Valid Values End with: 1.500000
Channel Name: cDAQ1Mod1/ai0
Task Name: _unnamedTask<28>
3) There are three items I need to fill out about the shunt calibration: Load cell bridge resistance: 350 ; 9237 Internal shunt resistance(ohms) :350 Shunt element location : R4.
I did try to change the numberof resistance from 0.5 to very big, but it still does not work. Please help.
4) Do I need to calibrate the load cell separately and get the slope which I can input to somewhere to get the correct reading ? I believe the shunt calibration can do that, am I right?
Many thanks!
Melody
03-20-2009 02:44 PM
Hey melody,
1. You can use the mean vi to average the number of samples coming out of your DAQmx read. It takes in an array and outputs one value. You may have to break your waveform out into its Y components and dt and t0 depending on what you are reading from your DAQmx read.
2. I would imagine this is because you have set the internal resistance to 300 ohms, this resistance is related to a resistor inside of the 9237 and should be set at 100 killiohms. Setting it so 300 probably made the driver think the 9237 was way out of calibration and tried to compensate with a gain that is not possible for the device, hence the overrange error.
4. The shunt should handle this for you, you are correct.
03-25-2009 11:30 AM
Hi Doug,
Here are some details about my load cell calibration.
The hardware are NI9237, Chasis NI cNAQ-9172.
The load cell has four wires: Green(+signal) connected to Pin 2(AI+), white(Signal ) to 3(AI-), Red (+excitation) to 6(EX+), Black (Excitation) to 7(EX-).
I use the MAX, Create task-- Acquire signal--Analog input--Strain--Select channel ai0--strain calibration--enable offset nulling and shunt calibration-value 100K and location R3. Then the reported error is 515.37% and 603.25% after shunt calibration.
Then I run the example VI load_cell_null_off_shuntcal.vi and give the rang of 500 grams. The reading is way out of the rang and goes to 10323 and goes down to -2000 without any loading. We do have a load stem on top of the load cell. Does that affect the reading so much ?
Appreciate your help!
Melody