From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
12-02-2008 01:32 PM
Hi,
I am a new user of LabView, and I need some help on writing the code.
I am using a USB 6009 to control a gearmotor through a relay. I need to write code to turn the motor on/off, change direction, and control the RPM from the digital output.
Also, I need to use the analog input to acquire signal from LVDT and load cell.
Moreover, I need to write code to control the Lever switch (microswitch). The application is when the shaft touches the switch, then the motor goes off. However, I don't know how to program it. Can anybody help me on this?
I attached a template to turn on/off of the motor and acquire signal from LVDT and load cell. If anything needs to change or any suggestion, please let me know.
Here's the gearmotor and lever switch:
http://www.radioshack.com/product/index.jsp?productId=2049719
http://www.grainger.com/Grainger/items/6Z077
Thanks,
Pak
12-02-2008 01:54 PM
Pak,
You do not need to write the digital motor on/off control on every iteration of the loop. Write only when the value of the button changes. Use an event structure or compare the current value to the previous value with a shift register.
You do not need the 5 ms Wait because the Analog Read will take 1 second to acquire 1000 samples at 1000 samples per second. A Wait is usually a good idea in a loop, but in this case the Read provides the wait function.
I recommend that you wire the lever switch directly to the motor. If you wish to monitor it from software as well that is fine, but do not rely on the software to stop the motor on time. Especially since the loop takes about 1 second per iteration.
You do not show how you intend to control direction and speed. We cannot help without knowing more about how your system will work.
You might be better off with two parallel loops, one for output and one for input.
Lynn
12-02-2008 04:48 PM
Hi Lynn,
Thanks for the reply.
My application is to control a gearmotor to drive a piston up and down. Since the movement is required at very low speed and the gearmotor is rated at 16 RMP (ideally, want to control at 10 RMP), so I want to write the code to control the RPM. Also, I want to control the gearmotor to move up and down (i.e. CW and CCW).
For the lever switch, I'd like to use LabView to control it and monitor it since the motor's speed is slow. I tried to find examples on the web, but I could not find any, so would you please show me how to write the code?
I also attached the code, and since I am just a beginner, so would you please modify the code if needed.
Thanks,
Pak
12-02-2008 08:18 PM
We need to know more about your application.
How do you plan on controlling the speed of the motor? Usually, AC motors require a variable frequency drive in order to vary the speed from the base speed.
How do you change direction with the motor? The information you linked to says it is a single phase motor, and it is reversible, but doesn't indicate how it reverses. Does it have two different input windings, one for each direction?
12-02-2008 09:10 PM
Hi,
For my application, I am going to connect one end to digital output of the USB 6009, and connect the other end to a relay. Then connect one end to the relay and connect the end to the motor.
I want to write the labview code so that when the signal (for example, 5V) is sent to the coil of the relay, then the contact of the relay is closed and the motor will turn, and vice versa if the contact is opened.
In order to make the motor runs in other direction, I think I will use the negative voltage. I am not sure if this will work, please correct me if I am wrong.
For the lever switch, I need to write the labview code so that when the switch is closed, it will cut the loop of the motor and the motor will stop.
I hope this information is more clear.
Thanks,
Pak
12-02-2008 11:41 PM
You can definitely use LabVIEW to read digital inputs and write digital outputs. Look in the example finder for DAQmx code to do that. One thing you'll have to be sure of is whether the USB6009 can output enough current to drive your relay.
If your motor is truly a DC motor like you say in the title of your VI, then yes you should be able to reverse the polarity of the wiring to get it to run in the opposite direction. A double pole double throw relay would allow you to do that.
However, the link you gave pointed to an AC motor. There is no such thing as a negative voltage when it comes to AC.
12-04-2008 09:29 AM
12-04-2008 10:33 AM
The relay coil current is 90mA, while the 6009 can output only ~9mA. You will need a transistor or relay driver chip connected between the 6009 and the relay to boost the current up. Also put a reverse biased diode (1N400x series) directly across the relay coil to prevent voltage spikes from damaging your electronics when power is removed from the coil.
PS- did you get the run capacitor for the motor too?
-AK2DM
12-04-2008 11:00 AM
Hi,
Are you saying that the digital ouput can provide +5V but only has 9 mA current. If so, I can add a buffer between the output and relay.
I got the capacitor for the motor.
Also, since I am just a beginner user of LabView, would you please take a look at my template that I attached before and modify if needed. I am still have difficulties to add the microswitch on the template. Would you please help me on that, too?
My application is to have two microswitched attached on the shaft, upper limit and lower limit, to monitor the position. If the microswitch on the upper limit is touched, then the motor will stop.
Thanks,
Pak
12-05-2008 12:05 PM - edited 12-05-2008 12:07 PM
Hi Pak,
You are correct that the USB 6009 is specced to output up to 8.5 mA on a Digital Output channel--to output up to 90mA you will have to use a transistor or op-amp as a voltage follower.
The attached vi should give you a simple example of how to incorporate a switch to stop your motor in software. Keep in mind that this dependant on your loop rate, so if you need to stop the motor more abruptly you should use the switch to directly shut off the relay.
-John