2. Agenda
• Use Robot Global Data as debug tool
• Minimize watchdog timer errors
• D/S message to track prog version
• Scan all sensors in Periodic Tasks
• Reusable templates ‘debugged ‘
• State machines - build two
jimc2550@gmail.com
4. We want our bunny bot design to
have..
– Arcade control during teleop
– Tank drive for Autonomous
– Grip/Release solenoid control in teleop & auto
using a state machine
– Robot Global Data optimized for debug
– Use a template for reuse with common functions
– All sensors and controls driven through Periodic
Tasks.vi, minimize watchdog timer problems
– Use D/S message block for program version
notation
jimc2550@gmail.com
5. Basic Template to start
• Rather than have to start with a fresh 2012 FRC
Robot Project every time…. Build a re-usable
template with the basic sensors we know for
sure….
• joysticks read into Robot Global Data
• Two Drive motors, one solenoid, compressor,
encoder
• In Teleop, put name is d/s message block
• BUNNYBOT 2012 template
• Then SAVE AS special name for program
jimc2550@gmail.com
6. Advanced Program Design Topics
• State Machines
– Often used in control programs to improve stability… ie limit weird
unexpected outputs
• Robot Global Variable
– Useful temp storage for LabVIEW program variable data which is accessible by
all project Vis
• Watchdog timer
– Used to detect if program has gotten lost!
– Timer must be “updated” at a specific frequency so that HOST OS knows the
margin of safety is ok
– Used in Robot Project Drive Motors to ensure robot motion is always under
positive control must refresh every 100 ms
• USER Message to ID program in cRIO
• Video image processing use global data to debug
• Autonomous system controls . . Use periodic tasks to combine controls
into global data
jimc2550@gmail.com
7. FRC 2012 Robot Project
• Start by looking at Robot Main. Vi in our
template
• Then put joystick scan and solenoid state
machine in template
ENUM GRIP SOLENOID STATE CHART
STATE OUTPUT TRIG to CASE NEXT STATE
START SOL = REV NONE REVERSE
REVERSE SOL= REV GRIP GRIP
GRIP SOL = FORW REL REVERSE
jimc2550@gmail.com
8. In autonomous we want to…
• Reset ENCODER, RELEASE GRIP
• Drive forward 10 feet
• Reset encoder
• Close gripper
• Back 5 feet
• Reset encoder
• Turn left 90 degrees
• Reset encoder
• Go forward 5 feet
• Stop and open gripper
• (note, we need a 5 sec delay to build pressure?)
jimc2550@gmail.com
9. State Machine chart for Autonomous
STATE OUTPUTS TRIGGER NEXT STATE NOTES
1 START R=L=0, G=F, NONE FORW10
ENCRS=REL=T
2 FORW10 R=L=-.4 ENC=10 RSENC1
ENCRS=REL=F
3 RSENC1 R=L=0; ENCRS=T 1025 MS CLOSEGRP
4 CLOSEGRP R=L=0; ENCRS=F; 1025 MS BACK5
GRP=T
5 BACK5 R=L=.34; GRP = F ENC = 5 RSENC2
6 RSENC2 R=L=0;ENCRS=T 1025 MS TURN LEFT
7 TURN LEFT ENCRS=F; R=-.34 ENC = .03 RSENC3
8 RSENC3 R=L=0; ENCRS=T; 1025 MS FORW5
9 FORW5 R=L=-.35;ENCRS=F ENC = 5 STP&REL
10 STP&REL R=L=0; REL=T 1025 MS END
11 END R=L=0, REL=GRP=F NONE END
jimc2550@gmail.com
10. Create and debug
• Build state machine in autonomous
• Watch Robot Global Data during execution
• Use ‘highlight execution’ to debug
• WATCH DIAGNOSTIC WINDOW IN DS
IMPROVEMENTS?
jimc2550@gmail.com
11. First fare notes
• First fare template.lvproj
– Robot main.vi
• Robot mode state machine
• Global variables
• Put AUTO ENABLE in Robot Global
– Teleop.vi
• Disable drive
• Put messages into driver station
– Periodic tasks.vi
• Autoencoder reset create and put in global
• Gripper state machine
– Output to solenoide
– Input from grip/release
– Enum
– Enum indicator put on robot global data
– Run Template with driver station
jimc2550@gmail.com
12. First fare notes 2
• First fare bunnybot
– Teleop put in message
– Autonomous
• Put message in driver station
• Show state machine chart
• Go through each step in state machine
– Finds errors
– Run with driver station
– Run in highlight execution mode
jimc2550@gmail.com