How to Fix “Glitchy” Servo Code

Slides:



Advertisements
Similar presentations
The Important Thing About By. The Important Thing About ******** The important thing about ***** is *****. It is true s/he can *****, *****, and *****.
Advertisements

Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
EMS1EP Lecture 8 Pulse Width Modulation (PWM)
PHYS707: Special Topics C++ Lectures Lecture 2. Summary of Today’s lecture: 1.More data types 2.Flow control (if-else, while, do-while, for) 3.Brief introduction.
All of the pucks feel a force to the right. A. True B. False
Chapter 16 Exception Handling. What is Exception Handling? A method of handling errors that informs the user of the problem and prevents the program from.
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
CIS 725 Data Link Layer. Physical Layer Figure 3-1 B. Forouzan, TCP/IP Protocol Suite.
Selection Control Structures Chapter 5: Selection Asserting Java © Rick Mercer.
MANUFACTURER WISE PRODUCT CODE SETUP SOFTWARES MAIN SCREEN. FOR PRODUCT CODE SETUP PRESS ENTER ON “SETUP” MENU.
Problem: Given an array of positive integers, find a pair of integers in the array that adds up to 10 (or indicate none exist). Your code should be as.
Copyright © 2002 Bolton Institute Joysticks Andrew Williams
Games at Bolton Joysticks Andrew Williams
If Statements Sections 1.25, Control Structures o All code thus far executes every line of code sequentially o We want to be able to repeat,
The If/Else Statement, Boolean Flags, and Menus Page 180
The Insertion Sort Mr. Dave Clausen La Cañada High School.
Week 3 C For Win Lecture :.  Mouse Message  Keyboard Message.
Keyboard In computing, a keyboard is an input device, partially modeled after the typewriter keyboard, which uses an arrangement of buttons or keys, to.
COMPUTER PROGRAMMING 2 Timers. Game Idea: Mob Reaction Timer Use a timer variable to keep track of time and a variable for each player to measure the.
HFOOAD Chapter 2 Requirements. We create software for a reason. We create software fro people. We need to know what the people want in the software we.
What can you make happen? Acknowledging materials from Lego Education which contributed to this lesson sequence.
Rob Miles. Creating a Working MoodLight We know that colours in XNA are stored as values which represent the amount of red, blue, green and transparency.
Java Programming The Ponytail Posse - FTC #8808 9/12/15.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
The world of Constructs Control Structures. The three Structures Sequence Selection Loop Entry Exit.
Computing with C# and the.NET Framework Chapter 3 Software Engineering with Control Structures.
CHAPTER 2 The Game Loop - Variables, Types, Classes and Objects in XNA XNA Game Studio 4.0.
private void Application_Launching(object sender, LaunchingEventArgs e) { } private void Application_Activated(object.
A: A: double “4” A: “34” 4.
CheckBox i Option Button. Private Sub Command1_Click() Check1 = 1 If Check1 = 1 Then Text1.FontBold = True Else Text1.FontBold = False End If Check2 =
11 Adding Vibration Effects Session Session Overview  Describe how the vibration feature of the gamepad works  Show how an XNA program can control.
1 Working with Controls at Run Time. 2 Objectives You will be able to Add controls to a Windows form at run time. Modify controls at run time.
T/F  The following code will compile without error. int x = 3, y = 4, z = 5; double k = 3.4; cout
PROGRAMMING FTC ROBOTS WITH ANDROID STUDIO EAGLE ROBOTICS TEAM 7373 JORDAN MOSS AND BRIAN BAARS.
COMP 50 Game Design LESSON #11: Digital Playtesting & Introduction to Character Animation with Mecanim.
OpModes in FTC Eric Golde.
Complex Conditionals Human languages are ambiguous
FTC Driver Station Setup and Operation Mike Zook 20-Sep-2016.
Programming and File Management Part 2
Section 3 Review Mr. Crone.
Chapter 2 Elementary Programming
Advanced EasyC Jim Cline July 20-21, 2017.
Introduction To Programming with LEGO NXT 0
FTC Driver Station Setup and Operation Mike Zook 20-Sep-2016.
Programming FTC Robots with Android Studio
C# and the .NET Framework
Webroot Antivirus offers a hassle-free scan option and helps which prevent your important data and system from the virus and malware attack.
STAAR – R2 Force, Motion & Energy
STAAR – R2 Force, Motion & Energy
Controlling Data within the System
Complex Conditionals Human languages are ambiguous
Chapter 5 Servomotor.
Selection CSCE 121 J. Michael Moore.
Simple Windows Applications
C# Basics These slides are designed for Game Design Class
Logical assertions assertion: A statement that is either true or false. Examples: Java was created in The sky is purple. 23 is a prime number. 10.
Flow Control Statements
CheckBox i Option Button
Introduction to Software Planning and Design
2. Second Step for Learning C++ Programming • Data Type • Char • Float
ECE 103 Engineering Programming Chapter 8 Data Types and Constants
Understanding Conditions
Nate Brunelle Today: Conditional Decision Statements
DGMD E-70 Principles of Game Design
Controlling Data within the System
Creating Controls Dynamically in C#
SEQUENCE Start Initial situation Step 1 Step 2 Step 3 End
How to allow the program to know when to stop a loop.
Mr. Dave Clausen La Cañada High School
Presentation transcript:

How to Fix . . . “Glitchy” Servo Code Mike Zook 05-Sep-2016

Original Code //Partially working method to experiment with the servo, works but is very glitchy public void servoTest2(){ if (gamepad1.a) { if(buttonAPushed) servo1.setPosition(1); buttonAPushed = false; } else if(!buttonAPushed) servo1.setPosition(0); buttonAPushed = true;

Original Code Sequence

The Glitch The servo position is continuously toggling between 0% and 100% while the Gamepad <A> button is pressed. The Fix Toggle servo position one time per button press.

Alternative Sequence

Alternative Code public void servoTogglePosition(Servo servo, double dLastServoCommand, bool bGamepadPB, bool bPBPressed) // This method toggles the position of a servo. The servo's range of motion is 0% to 100%. { if (bGamepadPB) if(!bPBPressed) // If true, this is the first scan where gamepad button is pressed. bPBPressed = 1; // Acknowledge gamepad button pressed // Toggle servo position if (dLastServoCommand = 0.0) dLastServoCommand = 1.0; else dLastServoCommand = 0.0; servo.setPosition(dLastServoCommand); } else bPBPressed = 1; // Unacknowledge gamepad button pressed when button released.

Something to Think About How would you change the sequence (and code) to slowly toggle the servo to prevent damage to the servo gears?