Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced EasyC Jim Cline July 20-21, 2017.

Similar presentations


Presentation on theme: "Advanced EasyC Jim Cline July 20-21, 2017."— Presentation transcript:

1 Advanced EasyC Jim Cline July 20-21, 2017

2 Advanced EasyC Variables Custom Functions Defines

3 Advanced EasyC Variables
Variables can be used for many different purposes. Controlling the master loop Analog and digital inputs Speed controls Custom functions

4 Emergency Shutdown When first setting up a robot there can many times in which the robot can end up in state that needs to be shut down to prevent damage to the robot or other things. Motor and servo stalls, unresponsive controller. To do this we create a function that will shutdown all functions and create a variable that will drop out of the main loop and enter the shutdown function. Note: Robot will not function again until robot is restarted.

5 Emergency Shutdown Before doing anything make sure the Controller Configuration is set up with motors and servos in the correct spots.

6 Emergency Shutdown Add a variable that will hold the main loop control. Also add a Shutdown button pushed variable.

7 Emergency Shutdown Add a while loop and set the loop to run as long as the trigger is true

8 Emergency Shutdown Add a new custom function to shut down the motors and move servos to safe locations

9 Emergency Shutdown Set the motors to zero and move the servos to a safe location (0 may not be safe)

10 Emergency Shutdown Add the Robot_Shutdown function after the loop.

11 Emergency Shutdown Add a Get Joystick Digital function that gets the status of the button that will be used for shutdown

12 Emergency Shutdown Add an if statement that detects when the shutdown button is pushed.

13 Emergency Shutdown Add an assignment function inside the if statement that will set the trigger to false

14 Emergency Shutdown

15 Advanced EasyC So now we have a button that will shut the
robot down if a button is pushed. What happens if they accidently press that button during the competition? The robot stops functioning and will not work until restarted. NOT GOOD So how do we fix that?

16 Defines Defines are in the same dialog as variables
Set a define called TESTING Defines are typically all upper case to identify they are defines Set the define to 1 (true) to say that we are testing

17 Defines

18 Emergency Shutdown Add an if statement with the define TESTIN as the test. Put the shutdown code into the new if.

19 Defines Doesn’t a variable do the same thing?
Sort-of. A variable can be changed, a define can’t. A variable is set at run-time the define at compile time.

20 Q and A Questions?


Download ppt "Advanced EasyC Jim Cline July 20-21, 2017."

Similar presentations


Ads by Google