![]() |
Need help with logic
1 Attachment(s)
I'm trying to make a program that will make three motors turn until the lifts they are controlling hit the limit switch we have at the bottom of the lifts. I need the lifts to go in order from the lowest to the highest lift (we have encoders) As of currently I've been putting logic into periodic tasks but I can't seem to get it to work. Anyone have any ideas?
I posted the code that I'm currently using, this is a vi I made that is inside of periodic tasks |
Re: Need help with logic
A loop does not produce an output until it ends. Your VI will execute until the limit switch is activated, then end and output a value of zero.
I don't understand the description of what you want to do. Can you give some more detail, and maybe include a picture or diagram of what you're controlling? |
Re: Need help with logic
1 Attachment(s)
Quote:
|
Re: Need help with logic
I'm not quite sure what the picture is supposed to show me, but I'll take a guess. Is each lift a lead screw driven by a belt from a motor?
Are all three lifts independent, or do they need to coordinate with each other somehow? I will assume that each lift works on its own. Once the button is pressed, do you want the lift motor to continue running until the limit switch is activated, or do you want the motor to stop when the button is released? I will assume that you want the button to start the motor, and only the limit switch will stop it. (That's dangerous, but it sounds like what you asked for.) The simple way to do it is to use a flat sequence inside a neverending while loop in Periodic Tasks. The first frame of the sequence waits for the joystick button to be pressed. The second frame sets the motor to run the lift downward. The third frame waits for the limit switch to be activated. The fourth frame stops the motor. If that's not enough of a hint, ask for more help about what you don't understand. There should also be a failsafe in the part that waits for the limit switch. I suggest an "abort" button on the joystick that stops the lift motor on command, and also a timer that stops it if too much time has elapsed. You could also stop driving the motor if the encoder indicates that the lift has moved too far, or if it has stopped. |
Re: Need help with logic
All your assumptions are correct. The only problem is that I've never used flat sequences outside of auto so how exactly does one flat sequence?
|
Re: Need help with logic
Just put the flat sequence inside a while loop in Periodic Tasks. Right-click on the edge and add frames as needed.
Each of the "wait until" steps should be implemented as a while loop inside one of the frames. Put the code to read a joystick button or limit switch inside the loop, with the logic set up to stop the loop when the desired condition occurs. Also add a 5-20 millisecond Wait inside the loop, to keep it from running as fast as possible and starving other tasks of CPU time. |
Re: Need help with logic
That's really simple thanks! :]
|
Re: Need help with logic
1 Attachment(s)
Quote:
|
Re: Need help with logic
Quote:
You need to put the Joystick Get and the Switch Get Value functions inside their respective loops, so that you're repeatedly reading their current value. |
Re: Need help with logic
1 Attachment(s)
Quote:
|
Re: Need help with logic
I would suggest combining the first frames of your program, just to clean it up. It doesn't change any thing, but makes it neater. By once, do you mean it runs until it hits the limit switch?
|
Re: Need help with logic
Quote:
|
Re: Need help with logic
Well since the limit switch is pressed, the loop will continue seeing true. What you need to do is to create a case structure that checks the button being pressed and when the limit is pressed. I suggest creating a truth table as you have 2 Boolean elements. There is a Boolean array to number express vi that will change the default case structure into a numeric structure. I have an examination to how to do this in a guide I made. Here's the link to it. This guide does not cover any new vis or changes made to LabVIEW for this season. LabVIEW's mechanics have not changed significantly and the examples shown will work. If you want to pursue this path, be attentive to the changes you made. Be aware of the states of your sensors before, during and after the action your robot will make after the button is pressed.
|
Re: Need help with logic
Quote:
If your lifts are truly independent, put the code for each of them in its own While loop. |
Re: Need help with logic
Thanks for the help! I got it to work after putting the flat sequence inside of a case structure that executes whenever the button is pressed
|
| All times are GMT -5. The time now is 10:27. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi