|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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: Quote:
Here's the relay code that causes the problem: Thanks for your help. |
|
#2
|
|||||
|
|||||
|
Re: Error While Making Relay Work For Certain Time
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:
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/at...chmentid=13775 Last edited by Mark McLeod : 10-02-2013 at 23:14. |
|
#3
|
|||||
|
|||||
|
Re: Error While Making Relay Work For Certain Time
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. |
|
#4
|
|||
|
|||
|
Re: Error While Making Relay Work For Certain Time
Quote:
In your example, after Button 1, there is an arrow with an asterix underneath it. How do I make that? Thanks again! |
|
#5
|
|||
|
|||
|
Re: Error While Making Relay Work For Certain Time
Quote:
|
|
#6
|
|||||
|
|||||
|
Re: Error While Making Relay Work For Certain Time
Quote:
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. Last edited by Mark McLeod : 11-02-2013 at 08:16. |
|
#7
|
|||
|
|||
|
Re: Error While Making Relay Work For Certain Time
How are you wiring the feedback node? When I attempt to use one it faces the opposite direction.
|
|
#8
|
|||||
|
|||||
|
Re: Error While Making Relay Work For Certain Time
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.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|