I’l try to make it short.
I have around 15 loops which everyone uses a motor object.
I want to make an emergency break button, If I use a joystick button I’l have to make a reference in each loop. it’s a lot so I think it’s kind of lame way to make it.
Do you have any other options\ideas?
(Besides making one function for it).
I assume this is not an emergency type of stop. Because the space bar on the key board will stop ALL motors.
Reading the joy stick button in each loop is not a bad way to go. What ever way you go, you are still going to have to “read” this “other option” and have a reference to it in each loop. Plus you will have create code to constantly update this “other option” to check if the button has changed.
This is duplicating what the Get Joy Stick already does.
When you read the joy stick all you are doing is reading from stored values that have been previously stored. In this case stored in a shift register. The get joy stick function does not read from the joystick, but from this storage location on the cRIO. Anything else you do would just be duplicating the stored values.
Create a sub VI that gets the joy stick button state and returns it. Then drop copies of this sub VI into each loop and wire the Boolean output as needed.
But you could create your own copy the stored joy stick button data in your own global, but you would have to constantly copy the data from one stored location to the other stored location. Each loop could then read the copy of the data.
You could use a LabVIEW notifier. But again it will require you to create code to copy the data and send out the notifier.
is this for teleop? And if so why do you have 15 loops? I would use case structures with a true false toggle/latch on a button to send zero to the motors.
Hmm It’s kind of an Emegency stop button.
I want to stop everything so it wont stuck… For example. Im running in a loop and any other code wont work because I’m in a loop.
I want to exit the loop and stop every action with a single press.
As I described it’s still some sort of duplication… anyhow I’l need to put it in 15 loops which is kind of silly.
I’m not an amatuer programmer and I know about duplication code and every bad habit of coding. I know about our drawbacks of coding. If I was the lead programmer I would change everything. Because of the time and waste of other’s time I don’t want to do that.
So how do I make a stop button for everything without stucking the robot with running code?
It isn’t clear to me if you want to stop the code and loops, or stop the motors.
It is best to leave the motors being updated in a single place. Anytime you try to coordinate loops to share a motor, it gets unpredictable. So if you want to build a motor override functionality, I’d make a subVI that goes in front of, or even wraps the various calls to update the motor. Pass in the requested motor speed, and in the subVI, check the global override and choose between the requested speed and 0.0. Pass that value to the motor.
If you wish to actually stop the code, I’d look at the Abort or Exit. Not the cleanest, nor what I think you are asking for, but it exists.
Then use the space bar. That will stop ALL motors!
I want to stop everything so it wont stuck… For example. Im running in a loop and any other code wont work because I’m in a loop.
Then get rid of the loops.
THERE SHOULD BE NO LOOPS IN YOUR TELEOP.
I want to exit the loop and stop every action with a single press…?
The space bar will do that.
As I described it’s still some sort of duplication… anyhow I’l need to put it in 15 loops which is kind of silly.
Either rework your architecture to get rid of the time grabbing loops or put a Joy Stick Get in each loop to kill the loops.
I’m not an amatuer programmer and I know about duplication code and every bad habit of coding. I know about our drawbacks of coding. If I was the lead programmer I would change everything. Because of the time and waste of other’s time I don’t want to do that.?
No comment.
So how do I make a stop button for everything without stucking the robot with running code?
I do not understand this question. I do not know how to add a stop button without adding or “stucking the robot with running code”. We do not have some magic trick for you without adding “running code” to your code.
A “professional” programmer would have planed out the correct architecture before wiring the first node on the block diagram and avoided endless loops that block the rest of the code from running.
Fixed it with a SubVi.
We have been told that FIRST as some sort of an override to the robot. So we don’t really need an emergency stop button.
Critizing me is easy… It’s my first time using LabView. It was an hard time just to get use to the D&D.
I’ve fixed it with a subVI I programed.
The loops are used to put a delay so we’l have a timed controlled actions.
Some other question:
How can I run the motors without a loop(I need to run a controlled by time motor action).
2)I have some values to put in the dashboard. How can I send the values to the dashboard?
How can I run another thread?(I want an multi threading system which the shooter wont interrupt the driver).
How can I run the motors without a loop(I need to run a controlled by time motor action).
2)I have some values to put in the dashboard. How can I send the values to the dashboard?
How can I run another thread?(I want an multi threading system which the shooter wont interrupt the driver).
I think you are describing a sequence of motor speeds. To perform this, I’d suggest putting it into the Periodic Tasks VI. The loop is generally used just to keep the code armed and checking for a trigger. When triggered, it can run your timed sequence and arm again checking the trigger. The sequence is often easiest to perform using a sequence structure, the frames of film object next to the loops in the palette.
SmartDashboard is there for this purpose. In the lower right of the palette you can write the value into a named variable that is replicated on other clients. On the dashboard, you can read with the same name or simply put the display indicator on the panel in the Operation tab and name it the same as the variable.
LV does parallelism using threads, but without you needing to manage them. Each parallel loop you draw will multitask, and each branch of code will multitask. The system will have a pool of threads that take turns running the code based on a priority queue. By default there are four threads per CPU.