View Full Version : Error While Making Relay Work For Certain Time
piguy123
10-02-2013, 22:35
Hello!
I'm trying to make a relay work for a specified amount of time (not necessarily 500ms as in my screenshot). I couldn't find very good relay examples online, but from what I gathered through various forum searches, I determined that in order to make a relay work, you need to run it continuously in something like a while loop.
I did that, but I'm still receiving errors which state that I'm not running my loop fast enough. Any idea how I can get my code to work?
Here's the full error message:
ERROR <Code> -44061 occurred at "Left and Right Motors" in the VI path: Robot Main.vi
<time>02:07:27 01/01/1970
FRC: The loop that contains RobotDrive is not running fast enough. This error can occur if the loop contains too much code, or if one or more other loops are starving the RobotDrive loop.
Could someone also clarify what this message actually means?
Here's the relay code that causes the problem:
13921
Thanks for your help.
Mark McLeod
10-02-2013, 22:56
That message means that your code is too slow to handle the command packets received from the Driver Station 50 times a second.
For instance, if you tried to run this code in Teleop.vi, because Teleop handles the Driver packets directly and subsequently cannot take longer than 20ms to execute.
Code that is allowed to run just as fast as it possibly can (like your example) will also suck all the life out of the cRIO CPU and prevent other code from running in a timely manner.
So, two points:
A delay sequence like this belongs in Periodic Tasks.vi where it won't slow down Teleop
Every loop you use must have a Wait built into it to slow it down, and Waits act to release the CPU for use by other tasks, like Teleop.The code as written will never end.
Relay's do not have to be in wait loops.
Here's an example of a Relay sequence, a double sequence really, but just ignore the second one for your purposes.
http://www.chiefdelphi.com/forums/attachment.php?attachmentid=13775
Alan Anderson
10-02-2013, 23:00
If you put a delay inside Teleop, you will break things. The way the system works, Teleop gets called once every time a communication packet from the Driver Station arrives. It needs to finish very quickly so it can process the next packet.
Move your relay code into a While loop in Periodic Tasks. You'll have to make some adjustments to the way you're handling your delays before it will work right, though.
piguy123
10-02-2013, 23:25
That message means that your code is too slow to handle the command packets received from the Driver Station 50 times a second.
For instance, if you tried to run this code in Teleop.vi, because Teleop handles the Driver packets directly and subsequently cannot take longer than 20ms to execute.
Code that is allowed to run just as fast as it possibly can (like your example) will also suck all the life out of the cRIO CPU and prevent other code from running in a timely manner.
So, two points:
A delay sequence like this belongs in Periodic Tasks.vi where it won't slow down Teleop
Every loop you use must have a Wait built into it to slow it down, and Waits act to release the CPU for use by other tasks, like Teleop.The code as written will never end.
Relay's do not have to be in wait loops.
Here's an example of a Relay sequence, a double sequence really, but just ignore the second one for your purposes.
http://www.chiefdelphi.com/forums/attachment.php?attachmentid=13775
Thanks for the awesome reply! I'll try that out!
In your example, after Button 1, there is an arrow with an asterix underneath it. How do I make that?
Thanks again!
piguy123
10-02-2013, 23:26
If you put a delay inside Teleop, you will break things. The way the system works, Teleop gets called once every time a communication packet from the Driver Station arrives. It needs to finish very quickly so it can process the next packet.
Move your relay code into a While loop in Periodic Tasks. You'll have to make some adjustments to the way you're handling your delays before it will work right, though.
Thanks!
Mark McLeod
11-02-2013, 08:12
In your example, after Button 1, there is an arrow with an asterix underneath it. How do I make that?
That's called a Feedback Node and it's used to remember the value from the last time through.
What that little test does is only go True the first time the button is pressed. Holding the button down will get you False everytime after the first. You must release and press the button again before it'll be True again and run the sequence. So if the sequence or action after the button press is fast, it won't rapid fire do it over and over again 50 times a second until you have time to release the button.
It's on the Programming -> Structures palette.
chrissevigey
11-02-2013, 10:14
How are you wiring the feedback node? When I attempt to use one it faces the opposite direction.
Alan Anderson
11-02-2013, 10:27
You can right-click a feedback node and tell it to face the other direction, so the input is on the left and the output is on the right. That's just a cosmetic thing; it doesn't change its behavior.
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.