ADVANCED BRAIN Training

Slides:



Advertisements
Similar presentations
Teacher/Mentor Institute Using the Cortex Chuck Powell.
Advertisements

Variables and Functions ROBOTC Software. Variables A variable is a space in your robots memory where data can be stored, including whole numbers, decimal.
Getting started with LEGO NXT Mindstorms software This is intended to be a short introduction to the LEGO Mindstorms software and programming the LEGO.
Add and Use a Sensor & Autonomous For FIRST Robotics
Photos and Sensor Instructions
Using the NXT Light Sensor. 2 Connect One Light Sensor – 1 From My Files use Left / Right NXT buttons and get to View menu and push Orange button. From.
V EX C OACHES ' T RAINING October 12, Agenda for Today 9 – 10 AM : Tina Reeves and the Engineering Notebook 10 – Noon : Finish Building, Basic Robot.
What is RobotC?!?! Team 2425 Hydra. Overview What is RobotC What is RobotC used for What you need to program a robot How a robot program works Framework.
ROBOTC for VEX Online Professional Development
1 iSee Player Tutorial Using the Forest Biomass Accumulation Model as an Example ( Tutorial Developed by: (
Weston Schreiber & Joshua Gabrielse Robotics Summer Training Programming #1: EasyC Basics.
Teacher/Mentor Institute Using easyC Joel Kirkland July 30-31, 2015.
EV3 Workshop Oct 3, 2015 Instructor: Chris Cartwright
Default_Routine(); - PWM Mapping /******************************************************************** * FUNCTION NAME: Default_Routine * PURPOSE: Performs.
Motors and Sound Troubleshooting Tips. © H-CCS Problem 1 Why can’t I download my program to the RCX?
FRC Robot Programming 1.PID Continued 2.Downloading and Deploying Code 3.Program a 2012 Robot from Spec Basic code For FIRST Robotics.
Wall Encounter By Made easy by Dwayne Abuel.
Copyright © 2008 BEST Robotics, Inc. All rights reserved. 1 BEST Robotics Advanced Instruction Node Team Training Really Using Your BRAIN (Advanced Applications)
Photos and Sensor Instructions
Brain Software. Things you need Administrator Rights Know how to open a folder Know how to unzip a file??? Know any special changes your IT department.
Variables and Functions ROBOTC Software © 2012 Project Lead The Way, Inc.Principles of Engineering.
RobotC Remote Control. Learning Objectives: Focusing on Virtual World with Physical Examples Understand Real-Time Joystick Mapping Understand how to use.
Automation and Robotics.  First you select the platform type so that you can use Natural Language PLTW.
Casne.ncl.ac.uk Taking care of the CrumbleBot Please do NOT stress the robot's motors 1.Do NOT push the robot 2.Do NOT hold the.
Teacher/Mentor Institute Intro to easyC Programming Scott McEwen July 21-22, 2016.
ROBOTC for CORTEX Teacher Training © 2011 Project Lead The Way, Inc. Automation and Robotics VEX.
Harpeth Hall Jan 2016 Introduction to Arduino Prepared for Harpeth Hall Winterim January 2016.
Using a SparkFun™ serial LCD with an Arduino
Introduction to Programming in RobotC
Making a 24hr Timer.
Arduino Setup & Flexing the ExBow
OpModes in FTC Eric Golde.
ROBOTC for VEX Online Professional Development
ROBOTC for VEX Online Professional Development
ROBOTC for VEX On-Site Professional Development
Introduction to Handshaking Communication with SSC-32U
Stop Light Lab 7 Winter Quarter.
Really Using Your BRAIN (Advanced Applications)‏
Arduino Uno and sensors
Programming Scratch to Control a K’NEX Fairground Ride
Automation and Robotics
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
fischertechnik® RoboPro Software for Gateway To Technology® RoboPro
Basics for Robotics Programming
Schedule 8:00-11:00 Workshop: Arduino Fundamentals
Music by Touch Music by Touch Presentation > TeachEngineering.org
Automation and Robotics
Sasha Popov November 16, 2018 iRobot Create.
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Controlling your quadcopter
An Introduction to VEX IQ Programming with Modkit
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
While Loops and If-Else Structures
Searching.
The programming page of the Brick
Photos and Sensor Instructions
Remote Control For this activity we will use the Squarebot
REACH Computer Resource Center
While Loops and If-Else Structures
CodePainter Revolution Trainer Course
Compiled from various Internet sources Presented by Mr. Hatfield
While Loops and If-Else Structures
Creating a Simple Game in Scratch
Programming Concepts (Part B) ENGR 10 Introduction to Engineering
While Loops And If-Else Structures
Getting started with LEGO EV3 Mindstorms software
Introduction to Programing the Cortex for BEST
Presentation transcript:

ADVANCED BRAIN Training Presented by: Matt Lapolla matthew@mattandsuz.com

Topics for this class Example Why program your BRAIN? Vocabulary Useful References: BRAIN Software Rev 3.pdf IR Communications More functionality than just 4 channels Selection Stick State Machines Readjusting the driving joystick Debugging LED’s Serial Communication Example Topics for this class

Make Things Simpler for the driver and designers Automate operations Use the BRAIN to its maximum potential Have better control of your robot Why program your BRAIN?

Why program your BRAIN Don’t Over complicate the controls Your drivers have understand the controls Can’t put stickers, tape, etc on transmitter Why program your BRAIN

String vs. Number Integer Number Real Number Proportional Vocabulary

Vocabulary How you see the number 13 13 How the computer sees the number 13 1101 <- this is a number How the computer displays the number 13 Character(49) and Character(51) 1 and 3 13 <-this is a string of 2 characters Vocabulary

Integers : 1, 54, 742, 34532 Real : 1.233, .3532, 33453.22. 1.00 Vocabulary

Vocabulary Proportional is the same as variable Think of a dimmer switch in your house Non-Proportional is On or Off Think of a normal light switch in your house Vocabulary

IR Communications The IR transmitter (on your robot) Is optional – But can help the points Sends commands to the game field Uses a modified servo port You will not be able to verify until mall day or game day. ALWAYS bring your most current program with you to mall day and game day! Laptop Thumb drive CD IR Communications

To use the IR transmitter you need to change the way the servo port operates. The code looks like this: Declare Variables and Initialize our port unsigned short now; ... int main( void ){ InitBrain(); // initialize the BRAIN now=getClock(0); // Give 1/5 sec while(getClock(now)<10); // delay for CP setServoRange(0,180); //if 0 is IR port IR Communications

IR Communications Now we need to use our IR commands Commands are numbers sent to our IR port Read the rules on page 21 To send the command 300 to the IR port setServo(0,300); // if 0 is our IR port To send the command 900 to the IR port setServo(0,900); // if 0 is our IR port IR Communications

More functionality than 4 More functionality than just 4 channels? More functionality than 4

The Transmitter has 4 proportional channels Selection stick

Channel 0 Selection stick

Channel 1 Selection stick

Channel 2 Selection stick

Channel 3 Selection stick

So you should only be able to control 4 things with our transmitter. Is it possible to control 5 things with proportional channels? Selection stick

YES Instead of using channel 2 as a proportional control of a motor or servo, we use it as a selection switch. It will select what the right joystick (channel 0 and 1) control. Selection stick

For example: If the left joystick is up, then the right joystick controls the drive motors Selection stick

For example: If the left joystick is DOWN, then the right joystick controls the robotic arm Selection stick

So now we have 5 proportional controls with only 4 channels 4 on the right stick (depending on the up/down position of the left stick) And one more: left stick side to side. A total of 5! Selection stick

Selection stick The code for this looks something like this: if(getRcValue(2,DEADBAND,125)<512){ // Do this if the stick is in the Upper half }else{ // Do this if the stick is in the Lower half } Left Stick Up and down Selection stick

Selection stick If we use the entire left stick (channels 2 and 3) … We can easily create 9 sensitive areas. Selection stick

Separate the left stick in to a 3x3 grid Selection stick

The vertical and horizontal limits of the joystick are 0 to 1023 1023 1023 Selection stick

If we integer divide the vertical and horizontal limits of the joystick by 342 we will get a range of 0, 1, and 2 1 2 2 1 Selection stick

Now we combine the row and column into one number Now we combine the row and column into one number. 00, 01, 02, 10, 11, 12, 20, 21 or 22 Row*10+Column 1 2 2 1 0 (00) 1 (01) 2 (02) 10 11 12 20 21 22 Selection stick

The code to make 9 sensitive areas looks like this: Selection stick

//Get and determine Vertical cell of Left joystick Row = getRcValue(2,8,125)/342; //determine Horizontal cell of left Joystick. Column = getRcValue(3,8,125)/342; Cell = Row*10 + Column; // Combine the cell // Determine what to do in each cell of the left joystick switch (Cell){ case 0: // Left Joystick in the Upper Left corner // Put your code here break; case 1: // Left Joystick in the Upper Center Corner case 2: // Left Joystick in the upper Right corner case 10: // Left Joystick in the Center Left case 11: // Left Joystick in the Center Center case 12: // Left Joystick in the Center Right case 20: // Left Joystick in the Lower Left case 21: // Left Joystick in the Lower Center case 22: // Left Joystick in the Lower Center }

With this arrangement we could have 18 proportional channels or….. Selection stick

Any combination of Proportional channels and other functions… Selection stick

State Machines What other functions? Non-proportional channels* For Example: Open the hand*, close the hand* Open Hand Close Hand State Machines

State Machines What other functions? State Machines Close Hand then Lower Arm Tip Bucket Etc... State Machines

State machines State Machines execute a series of actions They can be time based Turn on Motor 0, wait 3 seconds Then, Set servo 3 to 800 and wait for 4 seconds Then... Or they can use some feed back (input) Turn on motor 0 until switch 1 is pushed Then turn on motor 1 until switch 2 is pushed State machines

A timed state machine code looks like this: State machines

//To turn on your sequence: Seq1 = 0; //Set the first sequence number DelaySeq1 = 0; //Enable the timer . //To turn off your sequence DelaySeq1 = 65535; //This is the highest clock value //See if time for next sequence if(getClock(LastClockSeq1) > DelaySeq1){ LastClockSeq1 = getClock(0); //Reset Timer for next sequence switch(Seq1){ //Choose next sequence case 0: // Put your code here DelaySeq1 = 150; // set delay 50 = 1 second Seq1 = 1; // Set Next Sequence to execute break; case 1: Seq1 = 2; // Set Next Sequence case 2: Seq1 = 3; // Set Next Sequence case 3: DelaySeq1 = 250; // set delay 50 = 1 second Seq1 = 4; // Set Next Sequence case 4: DelaySeq1 = DelayOff; // This stops the timer Seq1 = 0; // Reset Sequence Number }

A feedback state machine code looks like this: State machines

// To turn on the state machine then… // Start Sequence ArmSeq = 1;// Enable Sequence Seq2 = 0; // Pick an initial condition movement ----------------------------------------------------------------- // To turn off the sequence ArmSeq = 0; // Stop Sequence //Check to see if the Arm Sequence is being used. If so then.... if (ArmSeq == 1){ // Check to see if at any limit switches. If so switch direction if(getSwitch(0)==1){ Seq2 = 0; } if(getSwitch(1)==1){ Seq2 = 1; // Select the direction based on Sequence switch(Seq2){ case 0: ArmMotor = 430; break; case 1: ArmMotor = 594;

Readjusting the drive joystick When is forward not forward? When you don’t use your BRAIN Readjusting the drive joystick

Readjusting the drive joystick Normally to drive forward you need the left motor and right motor at full power. Readjusting the drive joystick

Readjusting the drive joystick But this is not very intuitive. There is a better way! Readjusting the drive joystick

Readjusting the drive joystick By creating a simple function that you call, it will adjust your steering for you. You pass it the steer value (usually channel 0) And the Speed Value (usually channel 1) It will return to you the adjusted motor values for the right and left motors Readjusting the drive joystick

Readjusting the drive joystick void remapDrive(unsigned int steerValue, unsigned int speedValue, unsigned int *rightMotor, unsigned int *leftMotor) { int xInput, yInput; // declare some signed integers int rightValue,leftValue; xInput=steerValue-RCIDLEVAL; // grab the input values yInput=speedValue-RCIDLEVAL; // and make into delta leftValue=yInput+xInput; // combine the input to create rightValue=yInput-xInput; // output delta values // bound the delta values (remember RCIDLEVAL is half RCMAXVAL) if (leftValue>RCIDLEVAL) leftValue=RCIDLEVAL; // becomes RCMAXVAL if (leftValue<-RCIDLEVAL) leftValue=-RCIDLEVAL; // becomes zero if (rightValue>RCIDLEVAL) rightValue=RCIDLEVAL; if (rightValue<-RCIDLEVAL) rightValue=-RCIDLEVAL; // output the values and include the idle offset *leftMotor=leftValue+RCIDLEVAL; *rightMotor=rightValue+RCIDLEVAL; } Readjusting the drive joystick

What happens when my program does not operate correctly? Debugging

Debugging This is called Debugging. The BRAIN has 2 useful debugging tools. The first are 8 LEDs that you can turn on with your program. I will use this to help me determine where the program is going. Debugging

Debugging Here is a sample code for turning LEDs on setSingleLED(0); // Turn on 1st LED setSingleLED(1); // Turn on 2nd LED setSingleLED(2); // Turn on 3rd LED setSingleLED(3); // Turn on 4th LED setSingleLED(4); // Turn on 5th LED setSingleLED(5); // Turn on 6th LED setSingleLED(6); // Turn on 7th LED setSingleLED(7); // Turn on 8th LED writeLED(255); // Turn on all LEDs Debugging

Debugging Here is a sample code for turning LEDs off clearSingleLED(0); //Turn off 1st LED clearSingleLED(1); //Turn off 2nd LED clearSingleLED(2); //Turn off 3rd LED clearSingleLED(3); //Turn off 4th LED clearSingleLED(4); //Turn off 5th LED clearSingleLED(5); //Turn off 6th LED clearSingleLED(6); //Turn off 7th LED clearSingleLED(7); //Turn off 8th LED writeLED(0); //Turn off all LEDs Debugging

Debugging: USB There is also a more advance debugging tool. The BRAIN can display information on a PC. You simply build up a “string” that you want to send to the PC then call the outHostsz procedure. Debugging: USB

Debugging: USB // Declare 2 strings for your USB message //buf1 is a temporary string for converting numbers char buf1[10]; // outbuf is string to be transmitted to the host PC char outbuf[70]; // max of 70 characters, or change num // just after the main while(1) loop // Clear out the display string before each loop outbuf[0] = '\0'; // To add a message with out variables strcat(outbuf,“My Message"); // Add words to message // To add a variable Cell to the message itoa(Cell,buf1); // Convert the var Cell to text strcat(outbuf,buf1); // Add new text to buffer Debugging: USB

//Lastly you need to send out your completed message strcat(outbuf,"\r\n"); // add carriage return & line feed outHostsz(outbuf); // send outbuf to the USB port You will need a program on the PC to receive your message. Have IAR workbench installed on the PC (included on DVD) Use Realterm (included on your DVD) Settings: Display Tab ansi Port Tab BAUD is 9600 Port is (that varies from computer to computer, Try the largest number you have listed) OPEN button is pressed in Pins Tab DTR Press Clear Button RTS Press Clear Button Debugging: USB

Example Here is an example program that I came up with. The program in its entirety will not be helpful to you, but some of the examples used may help you get started planning your own program. Example

The start to every program you need to decide what you want it to do. So let me outline what my program does. The Right Joystick controls the drive motors Note: I don’t have any drive motors hooked up The Right Joystick controls the arm. The left joystick was separated in to 9 sensitive areas Example

I control the drive wheels If the left stick is in the upper 3rd Then the right stick is used for drive wheels I control the drive wheels Example

Example If the left joystick is in the Center 3rd Then the right joystick up and down, controls the arm I control the arm Example

I control the arm with parabolic_scale If the left stick is in the Bottom 3rd Then the right up and down controls the arm with parabolic_scale I control the arm with parabolic_scale Example

Example If the stick is in the top right then… Raise Red, Yellow, Green and Blue Flags Example of a switch Example

Example If the stick is in the top left then… Lower Red, Yellow, Green and Blue Flags Example of a Switch Example

Example If the stick is in the center left then… Start a timed state machine First raise the Red flag then wait 3 seconds Then raise the Yellow flag then wait 3 seconds Then raise the Green flag then wait 3 seconds Then raise the Blue flag then wait 5 seconds Then lower all flags Example of a timed state machine Example

Example If the stick is in the Lower Left then… Slowly rotate arm until limit switch Change direction until limit switch Repeat Example of a State Machine with feedback Example

Example If the stick is in the Lower Right then… Stop the arm State Machine Example

Look at the code Look at the code

QUESTIONS? What did we miss?