Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

USB 6525 6501 digital output to step motor driver

Solved!
Go to solution

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. 

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 31 of 41
(2,698 Views)

Hi Aaron,

Hope you had a great weekend!

 

I am using Digital>>Single Channel>>Single Sample>>Boolean (1 line) for ENA and DIR and they work well now. And I put PWM in a different port, it also works well. The problem now  is how to let the 'PWM' (USB6501, control stepping motor) and 'Load cell'(NI-9172, NI-9237, data acquisition from load cell)  start together and stop together.
1)Should I put all four 'DAQmx Start Task' from four parts inside one 'flat sequence' frame to let them start together?  
2) I input a number to the for loop in the CLK(PWM) part which control how many steps the motor will run. The 'PWM' will stop when finish the preset number, my question is how to automatically stop the load cell part when the motor stops?
3) the 'load cell' part will reset the offset null(begin from zero) each time I rerun the VI.  I do not want to reset the reference(offset null) when I repeat the PWM, so I need just ''pause" the load cell reading  when the motor stops. How to  implement 'pause' in the software rather than click the PAUSE button in the LabView?  I do need a restart button in the front panel to reactivate the PWM letting motor run the  preset number again without loadcell null again. I guess during the whole process the RUN button in the labview is also on then I can avoid the load cell offset null.
4) the issue of software timed and hardware timed. Is that because of the USB 6501 is software timed(doesn't have sample clock), so I actually can not synchronize USB 6501 with NI 9237?  I try to let two devices(USb 6501-motor; NI9237-load cell) start at the same time.
5) I want to also write step number( from PWM)  into the same file of load cell data acquisition. How to implement that ?
Attached is my VI. Please have a look. Thanks!
Melody
0 Kudos
Message 32 of 41
(2,682 Views)

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? 

 


Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 33 of 41
(2,668 Views)

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

0 Kudos
Message 34 of 41
(2,664 Views)

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.

Aaron W.
National Instruments
CLA, CTA and CPI
0 Kudos
Message 35 of 41
(2,650 Views)

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

 

0 Kudos
Message 36 of 41
(2,623 Views)

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. 

Aaron W.
National Instruments
CLA, CTA and CPI
Download All
0 Kudos
Message 37 of 41
(2,610 Views)

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 

0 Kudos
Message 38 of 41
(2,507 Views)

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.

 

Doug Farrell
Solutions Marketing - Automotive
National Instruments

National Instruments Automotive Solutions
0 Kudos
Message 39 of 41
(2,492 Views)

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

0 Kudos
Message 40 of 41
(2,467 Views)