EasyC. Programming Tips



Similar documents
Programming the VEX Robot

CONTENTS. What is ROBOTC? Section I: The Basics

ROBOTC Software Inspection Guide with Additional Help Documentation

New Technology Introduction: Android Studio with PushBot

STEELSERIES FREE MOBILE WIRELESS CONTROLLER USER GUIDE

Best Robotics Sample Program Quick Start

Using the VEX Cortex with ROBOTC

Downloading a Sample Program over USB

Testing Robots Using the VEXnet Upgrade

Creating a Project with PSoC Designer

Dr Robot C# Advance Sputnik Demo Program

ROBOTC Programming Competition Templates

D-MAX WEB GUIDE CONTROLLER WITH OPERATOR INTERFACE PANEL QUICK START SETUP MANUAL

STEP 7 MICRO/WIN TUTORIAL. Step-1: How to open Step 7 Micro/WIN

Option nv, Gaston Geenslaan 14, B-3001 Leuven Tel Fax Page 1 of 14

FRC WPI Robotics Library Overview

Six-servo Robot Arm. DAGU Hi-Tech Electronic Co., LTD Six-servo Robot Arm

Quick Start Guide. TWR-MECH Mechatronics Board TOWER SYSTEM

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

Work with Arduino Hardware

QUICK START GUIDE. SG2 Client - Programming Software SG2 Series Programmable Logic Relay

EMBEDDED C USING CODEWARRIOR Getting Started Manual

Install MS SQL Server 2012 Express Edition

Section 5: Installing the Print Driver

Using Flow Control with the HEAD Recorder

Homeguard Wireless Home Camera Quick Start Guide

Guarding Expert (Android Tablet) Mobile Client Software User Manual (V3.1)

TestManager Administration Guide

FUNDAMENTALS OF ROBOTICS

INF-USB2 and SI-USB Quick Start Guide


Building an Embedded Processor System on a Xilinx Zync FPGA (Profiling): A Tutorial

TESTBOX SHAKE TABLE USER MANUAL

How to read this guide

Modern Robotics, Inc Core Device Discovery Utility. Modern Robotics Inc, 2015

What is OneDrive for Business at University of Greenwich? Accessing OneDrive from Office 365

WinCC. Configuration Manual. Manual Volume 2

X-Trade Brokers Dom Maklerski S.A. XTB Expert Builder. Tutorial. Michał Zabielski

Example Connection between USB Host and Android

INTRODUCTION TO SERIAL ARM

For Introduction to Java Programming, 5E By Y. Daniel Liang

Installing S500 Power Monitor Software and LabVIEW Run-time Engine

Board also Supports MicroBridge

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Programming with the Dev C++ IDE

Capacitive Touch Lab. Renesas Capacitive Touch Lab R8C/36T-A Family

T-BOXN12R. First steps with T-BOXN12R. You can make it wireless. Date: Version 1.0

How To Use First Robot With Labview

vtcommander Installing and Starting vtcommander

TREND series H.264 DVR Central Management System Quick User Guide

OSM 2007 MONITORING SOFTWARE

MICROSOFT OUTLOOK 2010 WORK WITH CONTACTS

Generating lesson plans with. Adobe Acrobat

WA Manager Alarming System Management Software Windows 98, NT, XP, 2000 User Guide

ERC-to-MRC JOB TRANSLATOR MANUAL

Getting Started Manual

Quick Start Using DASYLab with your Measurement Computing USB device

5nine Hyper-V Commander

Kinect Interface to Play Computer Games with Movement

Arena Tutorial 1. Installation STUDENT 2. Overall Features of Arena

Audacity is a free, totally free, audio editing program. Get it here:

Table of Contents. 1. Overview Materials Required System Requirements User Mode Installation Instructions..

iridium for KNX/EIB Fast Start: Connection Setting Manual for KNX/EIB equipment

BLE Series. Data setting software MEXE02 OPERATING MANUAL. Tabel of contents 1 Synchronization with the driver Monitor function...

Help. Contents Back >>

Part Number Revision A, January Monitoring System Rack Configuration and Utilities Guide

STIM202 Evaluation Kit

WAVES. MultiRack SETUP GUIDE V9.80

Setting up Wireless ipad Control of your DEWETRON Computer-based System

Copley Camming User Guide

Gephi Tutorial Visualization

Transmitter Interface Program

AXIS Camera Station Quick Installation Guide

iridium for Weinzierl KNX IP BAOS

Avigilon Control Center Web Client User Guide

Tutorial for Programming the LEGO MINDSTORMS NXT

Industrial Automation Training Academy. PLC, HMI & Drives Training Programs Duration: 6 Months (180 ~ 240 Hours)

Remote Support. User Guide 7.23

Quick Start Guide NVR DS-7104NI-SL/W NVR. First Choice For Security Professionals

CATIA V5 Tutorials. Mechanism Design & Animation. Release 18. Nader G. Zamani. University of Windsor. Jonathan M. Weaver. University of Detroit Mercy

Raptor-CAN User Manual

How To Run A Factory I/O On A Microsoft Gpu 2.5 (Sdk) On A Computer Or Microsoft Powerbook 2.3 (Powerpoint) On An Android Computer Or Macbook 2 (Powerstation) On

DSP Laboratory: Analog to Digital and Digital to Analog Conversion

Plesk 8.1 for Windows Counter-Strike Game Server

IGSS. Interactive Graphical SCADA System. Quick Start Guide

1 Introduction. 2 Project Browser. 3 FlowStone Editor

5. Tutorial. Starting FlashCut CNC

RGK60 RGK50 RGAM10 RGAM20 RGAM4 Generator set control units

Downloading Driver Files

Clustering ExtremeZ-IP 4.1

NVMS User Manual

Getting Started with the LabVIEW Mobile Module

Using Microsoft Visual Studio API Reference

Installing the Gerber P2C Plotter USB Driver

SYMETRIX SOLUTIONS: TECH TIP May 2014

HOW TO TRANSFER FILES BETWEEN EEN IDL7000 PVR AND USB2 DEVICE

TRILOGI 5.3 PLC Ladder Diagram Programmer and Simulator. A tutorial prepared for IE 575 by Dr. T.C. Chang. Use On-Line Help

e-gate USB Smart Card Driver Install Notes (Windows 98/98SE/Me)

After: bmotorreflected[port2]= 1; //Flip port2 s direction

Event counters in NOVA

Transcription:

EasyC Programming Tips

PART 1: EASYC PROGRAMMING ENVIRONMENT The EasyC package is an integrated development environment for creating C Programs and loading them to run on the Vex Control System. Its Opening Screen has five sections as shown in the following figure. 1. The Tool Bar: This provides a quick access to commonly used commands. It has some of the standard Windows commands and several EasyC specific commands. 2. The Programming Window: This is the place where the user writes the programs; it starts with the Start Page window, which provides quick access to several commonly used EasyC features. You can write several programs in the same window, each program will have its own tab. 3. Function Block Panel: 4. The Project Explorer Panel: 5. The Output Panel: You can customize the relative arrangement of these sections on screen to fit your taste.

A: COMPONENTS OF THE TOOL BAR The tool bar provides a quick access to commonly used commands. It has some of the standard Windows commands and several EasyC specific commands as shown in the following figure. Details of these commands are provided in the Tutorial section of the Start Page screen in the Programming window. A snapshot of these details is shown in the following figure.

B: COMPONENTS OF THE PROGRAMMING WINDOW The programming window is the place where the user writes the programs; it starts with the Start Page window as shown in the following figure. The Start Page provides a quick access to several commonly used features of easyc. There are four screens in the Start Page as follows: a. Projects Screen: A normal C Program is composed of several variables and subprograms (functions) which can be in several files. Project is a name given to the collection of all of the variables, subprograms, and files that together form a single program. The Projects screen provides an easy access to tools for creation and modification of projects; it has four tabs for: i. Listing Recently Opened Projects: This provides an easy access to all recently opened projects by listing them up to six projects. ii. Creation of Standalone Projects: These are projects that drive the robot in one of the two possible modes: teleoperation or autonomous to be discussed later. iii. Creation of Competition Projects: These projects drive the robot using both the autonomous mode and the teleoperation mode in a timed competition. These projects will not be necessary in BEST robotics applications; only the standalone projects will be sufficient. iv. Opening an Existing Project from the hard disk: Use this tab to open and possibly modify an existing project

b. Tools Screen: This screen provides an access to tools for communicating with the Vex hardware; it has four utilities as shown in the following figure. Each of these tools activates the Intelitek loader, which must be configured properly in order to successfully complete the communication between the user and Vex hardware. Use the online Help to learn how to set up the Intelitek loader. A snapshot on the main functions of these tools is as follows: 1. The Download tool provides an easy means for downloading a new program into the Vex Controller. Use the Download window to download your program to the controller and view the status of the download process. The progress bar displays the status of the download process. It moves to the left to indicate the loader is erasing any previous programs from the controller, and moves to the right to indicate the loader is downloading the new program to the controller. 2. The Terminal tool is used as a feedback mechanism showing a list of actions carried out by the Vex controller. A Typical Terminal window will be as illustrated in the following figure.

3. The Graphic Display is an extension of the Intelitek loader that displays the feedback data from the Vexnet hardware by printing on screen. It typical appearance of the Graphic Display Screen is as shown in the following figure. 4. The On Line tool is for manually testing and controlling a robot directly from the EasyC software. This tool is used only after the program has been uploaded into the Vex Controller. By using the computer cursor keys, the user can control the robot using this tool; a typical On line window is as shown in the following figure.

5. The Competition Switch tool emulates the physical VEXnet competition switch, which allows two players to load new programs to the robot wirelessly and compete; it is enabled only when working with Competition Projects, otherwise it is disabled. It is expected that BEST robotics teams won t have to use this facility. c. The Help Screen: The help screen has three sections as shown in the following figure. Probably, the most important section is the Contents section, which allows the user to search information about any topic.

d. The Tutorials Screen: The EasyC package comes loaded with 14 tutorial sessions on how to navigate the EasyC programming environment, writing a Vex control program, debugging and loading it into the Vex controller hardware. Make use of these tutorials to equip yourself with the necessary skills on writing good and winning programs for your robots. C: THE FUNCTION BLOCKS AND THE PROJECT EXPLORER PANELS: On starting any new program as will be shown later, the Function Blocks and the Project Explorer panels will also open. The Function Block panel shows all available EasyC built in functions. The user can click and drag any of these functions into the program followed by filling in with appropriate values for the function arguments. The Project Explorer controls the details of the project and is the access point for the text editor and other features; it displays the overall structure of the project. As the program builds up, and so does the project explorer expand. A normal user will probably do nothing in the project explorer panel. The following figure shows both the basic contents of the function blocks and the project explorer panels.

D: THE OUTPUT PANEL: The Output Panel displays the outputs of the compiler about the correctness of the program. It has three tabs: Build, Output and Find Results as shown in the figure below. 1. The Build tab displays the output of the compiler, and lets the user know what files are being processed during long compilations. 2. If the compiler finds errors in the program, a list of these errors will automatically be generated and displayed in the Output tab. You can highlight the line of the code in blue in the C programming window by selecting the error line from this list. 3. The Find Results tab lists all results obtained after running a search using Find in Project Files command under the Edit pull down menu in the main menu bar.

PART 2: WHAT YOU NEED TO KNOW ON CREATING A VEX PROGRAM A: VEX ROBOT PROJECTS There are two modes of driving any robot; either by teleoperation using a human driver, or autonomously by the robot following a sequence of preprogrammed events. In line with these modes, there are two types of Vex projects: the Standalone project and the Competition project. A Standalone project allows only one mode of driving the robot, while the competition project allows both modes to compete on a single robot. All BEST robotics projects will use teleoperation mode, therefore they will be Standalone projects. To create a new project for a teleoperated robot, use the Projects Screen and click New Standalone project. A dialog window will open asking you to choose whether you want to create a Standalone project for Teleoperation (Joystick Project (wifi)) or you want an Autonomous only standalone project as shown below. Choose Joystick Project The Function blocks panel fills with all function needed for your project. The project explorer panel and the programming window will automatically be filled with the basic information that you will need to complete your program. In general you will see a screen similar to one shown below

Programming your robot will involve reading the joystick control signals and translating them to motor or servo drive signals. A clear understanding of the functions for reading the joystick commands and the functions for sending control signals to motors, and servo motors is neede. Let us start by examining the contents of the Function blocks panel. This panel has several standard functions needed by the robot project; we will focus on the joystick functions and the output functions only. B.JOYSTICK FUNCTIONS The joystick functions manage how the Vex controller gets control commands from the Joystick. There a total of 17 joystick functions as shown in the following figure, probably the important functions for our projects will be ten only as described below. 1. Arcade 2 Motor: This command allows you to control two motors simultaneously using the x and y joystick movements of one joystick only; the motor speed is proportional to the joystick position from the center. Basically, the joystick sends same commands to two Motor channels, as specified in the command. When using the arcade 2 command, you must specify the followings: a. The intended joystick. VEX Controller can be controlled by using two joysticks numbered 1 and 2. In BEST competitions, we will use only one joystick, number 1. b. The joystick channel assignment for forward reverse motions : Channels 1 or 3 for the x motion and Channel 2 or 4 for the y and x motion. You would be better off using channels 1 and 2 on one stick. c. The Joystick channel assignment for left right turns (Channels 1 or 2 for the x and y motion of left stick and channels 3 or 4 for the y and x motions for the right stick.) d. The motor channels controlled by the joystick ( any motor channel from 1 to 10 is possible); you have to specify two motor channels

2. Arcade 4 Motor: This function is similar to the Arcade 2 Motor, but it can simultaneously control a total of four motor channels instead only two. Other parameters are same but the motor channel specification requires four motors to be specified as shown in the following figure instead of only two as seen before

3. Tank 2 Motor: This function allows one analog x y stick on the joystick to control two motors for the forward and reverse motions only, it does not allow left and right turns; the motor speed is proportional to the joystick position from the center. To use this function, the user must specify: a. The intended joystick ( 1 for one joystick mode) b. The motor motion assignments. Each stick motion will control one motor on one side of the robot (left or right); therefore, if the x motion of the tick is controlling the left motor, then the y motion of the same stick will control the right motor. The stick channels range from 1 to 4 with channels 1 and 2 attached to the x and y motions of the right stick, while channels 3 and 4 are attached to the x and y motions of the left stick. c. The motor channels controlled by this joystick; any channel between 1 and 10 is possible; you have to specify two motor channels. 4. Tank 4 Motor: This is an extension of the Tank 2 Motor function with the ability to control up to 4 motors: two on the left hand side of the robot and two on the right hand side. It has the same features as the Tank 2 Motor function as shown in the next figure.

5. Joystick to Motor: The Joystick to Motor function uses one channel of the analog x y joystick to control one motor only; the motor speed is proportional to the joystick position from the center. Therefore, each joystick can be assigned to two motors using two Joystick to Motor functions. In setting up the joystick to motor function, you must specify: a. The intended joystick:1 b. The intended channel ( 1 to 4), c. The controlled motor channel (1 to 10).

6. Joystick to Motor and Limit Switch: This function is similar to the Joystick to Motor function, except that it also allows limit switches to be used as emergency stops for the motor. One limit switch stops the motor from the forward direction and another switch stops the motor from the reverse direction. Limit switches will be connected to any of the digital input channels 1 to 12. If limit switches are disabled by selecting Channel 0, then the function behaves just like the Joystick to Motor function. 7. Joystick to Servo: The Joystick to Servo function uses the analog x y joysticks to control the servos. It is similar to the Joystick to Motor function, except that the motor is replaced by a servo. 8. Joystick Digital to Motor: This is the digital equivalent of the Joystick to Motor. It behaves just like the Joystick to Motor but the motor has only two speeds, zero and the maximum set speed in either direction. The digital joystick is labeled 7 and 8 at the top of the analog x y joysticks.

To use these digital joysticks, you must specify the joystick channel, joystick displacement direction, the channel of the controlled motor and the digital value corresponding to the maximum motor speed, which ranges from 127 corresponding to full reverse motor speed to +127 corresponding to the maximum forward full motor speed. Half forward speed will be 64, and quarter will be 32 etc. Motors will be connected to the PWM Motor terminal block (numbered 1 10 not 1 12 as shown in its dialog window). 9. Joystick Digital to Motor and Limit Switch: This is the digital equivalent of the Joystick to Motor and Limit Switch. 10. Joystick Digital to Servo: This is the digital equivalent of the Joystick to Servo. D. OUTPUT FUNCTIONS Output functions control how the Vex controller sends control signals to the output devices. There are three output functions as shown in the following figure and discussed next. 1. The Motor Module: This function block sends control signals to the motors connected at the Motor PWM terminal block at analog channels 1 10. The user must specify the motor

channel, and the motor speed. The motor full speed is specified by a digital value 127 in one direction and 127 in the opposite direction. A digital value of 64 corresponds to the half speed, and a value of 32 corresponds to the quarter speed and so on. 2. Servo Module: The Servo Module controls a specified servo connected at the PWM motor terminal block at channels 1 10. It is similar to the Motor Module although servos have a limited range of motion (about 120 degrees). The command value specifies a position within that range of motion for the servo motor to move to and hold. A value of 127 will result in a full turn while a value of 64 will result in a half turn etc. 3. Digital Output: The Digital Output function block is for controlling the state of a Digital Output. You can use the Digital Output to turn ON or OFF a device such as an LED or a solenoid.

To set up a digital output, you must specify: a. The digital output channel # that corresponds with the port where the device is plugged into on the controller. The output digital channels range from 1 to 12. b. Set a predefined output value in the "Set" field; the valid values are 1 for ON and 0 for OFF. By default, all the digital outputs are set to 0 (or low) by default. C: PROGRAM FLOW CONTROL As in any computer programming project, there must be a logical flow of instructions in order to achieve the intended objective. There are several program flow control function blocks as shown in the following figure. In most of BEST robotics projects, the most important instruction will be the While Loop; this allows the program to repeat the specified code sequence for as long as certain conditions hold, stopping only when those condition cease to be valid. By using the While Loop, the code for reading the joysticks placing control signals to output devices, i.e. motors and servomotors, the robot runs continuously until the power is turned off or the robot is reset. To use the While Loop you must specify the condition that will remain true for as long as the robot is running; the following figure illustrates one way to make a valid WHILE loop, it is valid as 1 equals to 1:

PART 3: CREATING A ROBOT PROGRAM The following steps outline a systematic procedure for creating a simple but sufficient robot program. Before writing any robot program, you have to clearly understand the controlled devices that are connected to your controller. Recall that the Vex Control System has two power banks, each distributed to five motor ports: the first power unit is distributed to port 1 through 5, and the second power unit is distributed to port 6 through 10. Additionally, ports 1 and 10 have internal motor controllers while the rest need an external controller. This year we will use four external controllers only, so port 1 and 10 will not be used. Balance your load between the two power units by proper assignment of ports. Hardware Assumptions: In this example, we will assume that: We will assume further that all drive motors and servos are connected at the motor terminal block, not at the digital block.. The motors and servos will not be protected by limit switches. There are four motors and four servos consistent with the BEST robotics return kit. Two motors are connected to motor ports 2 and 9 for driving the robot, another two motors are connected to ports 3 and 8 are for actuating the robot arm: The servos connected to ports 4 through 7; two for are activating the robot fingers, and two for activating the robot arm. Program Plan: The control program will be implemented as follows: There will be only one joystick, i.e. joystick #1; and the motor channels 1 and 10 will not be used. The two drive motors on ports 2 and 9 will be driven simultaneously by the using channels 1 and 2 of the joystick in Arcade mode. The other two motors on ports 3 and 8 will be controlled independently using channels 3 and 4 respectively. The servos on ports 4 through 7 will be controlled by using digital channels 5 through 8. Program Development: 1. Start a Standalone project for teleoperation mode using one of the following approaches: a. Main Menu: File > New Standalone Project b. The Start Page: Projects > New Standalone Project After the following dialog window opens, choose Joystick Project (WiFi)

The programming window will open with the Main block diagram as shown in the following figure: 2. Configure the hardware connections by clicking the Config block. This will open the hardware configuration window as shown in the following figure: Assign the motor ports in the motor description space as illustrated in the following figure, and press OK to close the configuration window.

3. In the Function Blocks panel, open the Program Flow group, and select the While Loop block. Click and drag the While loop block to the line between the Variables block and the End block in the Main block diagram as shown below.

The While Loop dialog window will open asking you to state the logical condition under the loop will be valid; any integer number greater 0 as indicated in the following figure will set the loop to be valid for ever, as long as the robot is running. Press OK, close the While Loop dialog window, a loop will be created in the Main Block diagram as illustrated below. 5. In the Function Blocks panel, open the Joystick group and select the Arcade 2 motor block. Click and drag the Arcade 2 motor block to the line between the { block and the } block in the While loop in Block diagram as shown below. This is for reading joystick commands and controlling the drive motors on ports 1 and 10 on the Vex hardware.

A dialog window will open for configuring the Arcade 2 motor command. Set the parameters as shown in the following figure. a. Joystick # 1 defines the only one joystick used by this system. It is possible to use two joysticks. b. The transmitter channels indicate the functions of the joystick movements: The forward and reverse motions of the robot will be controlled by joystick channel 2, which is the y axis motion of the joystick, and the left right turns of the robot will be controlled by channel 1, which is the x axis motion of the joystick. c. The left and right drive motors of the robot will be from ports 2 and 9 respectively as indicated below. Press OK to close the Arcade 2 motor dialog window. 6. Now you want to control the two motors for the robot arm. Select the Joystick to Motor block from the Function Blocks panel, and place it in the While Loop of the Main block diagram under the Arcade 2 motor block as shown in the following figure. In the dialog window that opens, specify the motor channel and the joystick channel that will be involved. For example, the following dialog window sets channel 3 (the y axis) of

the left joystick to control the robot arm motor connected on Channel 3 of the Vex hardware; the Vex motor port and joystick channel do not have to be of the same number. Click OK, to close the dialog window. Repeat the above process for the robot arm motor in port 8 to be controlled by Channel 4 (the x axis) of the left joystick. 7. Having controlled all four motors, now it is a time to set up the controls for the three servos. Since all analog joystick channels have been assigned to motors, the servos will be controlled using the digital joystick channels, which start from channel 5 through 8. In the Function Blocks panel, click and drag the Joystick Digital to Servo block into the While Loop as illustrate in the following figure. In the dialog window that opens, set the channel 5 of the digital Joystick # 1 to control the hand servo connected in port 4 of the Vex hardware. Button 1 (D) of the joystick will

provide a forward motion of the servo at a full range of 127, and button 2 (U) will reverse the motion at a full range of 127. You can change the range by descresing these values. Click OK to close the Joystick Digital to Servo dialog window. Repeat the process above two more times for the servos in ports 6 and 7. Port 6 will be controlled by channel 7 of the second joystick, and port 8 will be controlled by channel 8. Unfortunately, there is no function to hold the servo in one position. If required, you can program it using combinations of If then commands. Those who will need this feature can directly contact Dr. Selekwa for help at majura.selekwa@ndsu.edu, 8. The block diagram appearance of your final program will appear as shown in the following figure.

You can view the generated C program either by opening the C programming window from the main menu: Window > C Programming or by opening the main.c file from the project explorer panel. The C program for this project will be as shown in the following figure. Unless one is good at C programming, most BEST robotics users will find it not important to access the C program. 9. Save your program at any convenient location on the hard disk, using any name of your choice. 10. After creating the program, the next task is to compile and upload it into the Vex system ready for running your robot. There are two options, either to compile vthe program without uploading or compile and upload. The tools for performing these operations are shown in the following figure.

To compile the program without uploading it, use Build and Download > Compile Project from the main menu, and to compile and upload, use Build and Download > Build and Download as shown below. On compiling the project, you can see the compilation results in the Output Panel as shown in the following figure. Programming errors also will be listed here, and by highlighting and clicking the error, the C file opens with the cursor placed at the line that contains the error.