|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
How to program a toggle switch to stop a motor from spinning..?
Simple task, right?
I need a switch program that, when the PVC pipe hits the switch, it will stop powering the motor and prevent power in the same direction until the switch is depressed. I also need to know how to wire the switch properly so it will function. |
|
#2
|
|||
|
|||
|
Re: How to program a toggle switch to stop a motor from spinning..?
The programming is simple. The idea is that a switch will return either a true value or a false value corresponding to whether the switch is being pressed at the moment.
You want the motor to operate normally when the switch is returning false (is not being pressed), and to be allowed to move only backward when the switch is returning true (is being pressed). I would implement this knowledge as follows: Code:
if ( ![switch name here].Get() )
{
/* control the motor normally */
}
else
{
if ( [motor name here].Get() > 0 ) // or < 0; test to figure out!
{
[motor name here].Set(0); // necessary: otherwise motor will continue
// at whatever speed you left it at
}
}
I can't help you with the wiring, since I don't know too much about that stuff. |
|
#3
|
|||||
|
|||||
|
Re: How to program a toggle switch to stop a motor from spinning..?
Here are two LabVIEW examples.
They are just two different styles, pick what you are most comfortable with. When the limit switch is wired Normally Open (NO) it reads in the code as false when pressed. Wired Normally Closed it reads in the code as true when pressed. Wire to Ground (GND) and pick only one of the other two NC or NO. If you look at the side of the limit switch, most of them have a diagram labeled GND, NO, and NC to show where the wires go. If there is no label, then use a multimeter to figure out which is the ground and which is NC or NO. ![]() ![]() Last edited by Mark McLeod : 17-02-2014 at 20:33. |
|
#4
|
|||
|
|||
|
Re: How to program a toggle switch to stop a motor from spinning..?
Where would the switch wire into? The PD board or the Digital Sidecar?
|
|
#5
|
|||||
|
|||||
|
Re: How to program a toggle switch to stop a motor from spinning..?
Limit switches get wired to a Digital Input on the Digital Sidecar. Signal and ground pins only (NOT the +5v power pin).
|
|
#6
|
|||
|
|||
|
Re: How to program a toggle switch to stop a motor from spinning..?
Alright I'll do that very soon, thanks.
|
|
#7
|
|||
|
|||
|
Re: How to program a toggle switch to stop a motor from spinning..?
I don't think either of those examples would work with what I'm trytrying trying to do. Pretty much we have a pvc pipe that is extending and descending. While descending, I'd like a piece of metal to hit the switch to prevent the motor from pulling the pvc down further.
|
|
#8
|
|||||
|
|||||
|
Re: How to program a toggle switch to stop a motor from spinning..?
A team I'm mentoring is also moving a pvc pipe up and down, stopping the motor at both the top and the bottom with limit switches.
The right example is good for that. I don't know what is complicating what you are doing differently. |
|
#9
|
|||
|
|||
|
Re: How to program a toggle switch to stop a motor from spinning..?
I think the main complication is how im using 2 true-false statements attached to two separate button.
I can't upload a picture because the photo exceeds size, but buttons 4 & 6 both connect into a true-false triangle. The true of 4 is -1 and the false is connected to the output of button 6. Button 6 has true 1 false 0. The output of the two connects to set motor output |
|
#10
|
|||||
|
|||||
|
Re: How to program a toggle switch to stop a motor from spinning..?
Your button 4 Select output would replace "axis 2 (y)" in the example on the right.
|
|
#11
|
|||
|
|||
|
Re: How to program a toggle switch to stop a motor from spinning..?
And leave button 6 as is?
|
|
#12
|
|||||
|
|||||
|
Re: How to program a toggle switch to stop a motor from spinning..?
The result of the Button 6 Select feeds the Button 4 Select.
|
|
#13
|
|||
|
|||
|
Re: How to program a toggle switch to stop a motor from spinning..?
So now onto the wiring. We have switches similar to the one pictured above. But as for wiring into the DS and what wire is nrrdrd I dont know what to do
|
|
#14
|
|||||
|
|||||
|
Re: How to program a toggle switch to stop a motor from spinning..?
If you have a spare PWM cable, that could be used by cutting off the male end.
|
|
#15
|
|||
|
|||
|
Re: How to program a toggle switch to stop a motor from spinning..?
Thank you for this info. During our post-build season I'll wire up a mock where we can test the code and wiring. Thanks for your help!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|