![]() |
Running a Relay for a Set Time
I need to run a relay for a set amount of time while still being able to run the rest of the robot's functions. When I use the tried and true Wait() function from the Watchdog, it (as expected) halts the rest of robot operations. I have looked into separating out this function in a Task/Semaphore formation, but I'm not sure if it will solve this or exactly where to start with this (I have looked through this tutorial, but I'm still not sure where to start). What is the best way to run a function for a set amount of time while still running drive/other schmazz? :)
|
Re: Running a Relay for a Set Time
One of our programmers got it with a separate task, but what I'd suggest is starting a Timer, polling it in your loop, and as soon as the timer exceeds some length of time, turn the relay off.
|
Re: Running a Relay for a Set Time
This is a C++ example. Its a state machine that starts with a trigger on a joystick. It even includes the 2 second lockout before the kicker can be fired again.
Code:
enum Kicker_State { |
Re: Running a Relay for a Set Time
I'd recommend using the Notifier class. It automatically calls a callback function after a given amount of time, and works on an interrupt level so it doens't block other code until it runs.
|
| All times are GMT -5. The time now is 13:54. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi