AndyMark Arduino Tutorial

Similar documents
Arduino 101 AN INTRODUCTION TO ARDUINO BY WOMEN IN ENGINEERING FT T I NA A ND AW E S O ME ME NTO R S

The Arduino Briefing. The Arduino Briefing

RoastLogger Arduino/TC4 driver installation for Windows 9/10/13 By John Hannon (JackH) at Homeroasters.org

Arduino Programming and Interfacing

RedBoard Hookup Guide

ROBOTLINKING THE POWER SUPPLY LEARNING KIT TUTORIAL

CORTEX Microcontroller and Joystick User Guide

Prototyping & Engineering Electronics Kits Basic Kit Guide

Note. The above image and many others are courtesy of - this is a wonderful resource for designing circuits.

1 Introduction. 1.1 Overview. 1.2 Supported Hardware. 1.3 Recommended Hardware. 1.4 Installation

Objectives: Learn how to input and output analogue values Be able to see what the Arduino is thinking by sending numbers to the screen

2009 FRC Control System. Published by Team 103

Tutorial 1: Software Setup

This is the Arduino Uno: This is the Arduino motor shield: Digital pins (0-13) Ground Rail

Robotics Adventure Book Scouter manual STEM 1

Create moving images in forward and reverse with your Arduino when you connect a motor to an H-bridge and some still images BATTERY POTENTIOMETER

How to use the Zduino LEE Module with the Trainer Board

AT42QT1010 Capacitive Touch Breakout Hookup Guide

VEX ARM Cortex -based Microcontroller and VEXnet Joystick User Guide

Building an Arduino-powered underwater ROV

Lab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process

TA0139 USER MANUAL ARDUINO 2 WHEEL DRIVE WIRELESS BLUETOOTH ROBOT KIT

Software Setup Instructions for the Foster Control System used in the Explora Dome Observatories

Digital Pins and Constants

INTRODUCTION TABLE OF CONTENTS 1 INTRODUCTION WELCOME TO THE 2009 FRC CONTROL SYSTEM Suggestions for Getting Started 2

AT42QT101X Capacitive Touch Breakout Hookup Guide

This is an inspection failure, not meeting the requirement of >10k Ohm between either PD battery post and chassis.

Quickstart CHAPTER 1. Powering Up. Installing the Software

StenBOT Robot Kit. Stensat Group LLC, Copyright 2018

Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Counter & LED (LED Blink)

Make your own secret locking mechanism to keep unwanted guests out of your space!

Freeduino USB 1.0. Arduino Compatible Development Board Starter Guide. 1. Overview

Lab 2.2 Ohm s Law and Introduction to Arduinos

Thumb Joystick Retail. Tools and parts you'll need. Things you'll want to know. How does it work? Skill Level: Beginner. by MikeGrusin March 22, 2011

CNC Controller Quick Start Guide

Elektor Uno R4 Installation & Test

Robotics Jumpstart Training II. EasyC: Software & Firmware Updates

HUB-ee BMD-S Arduino Proto Shield V1.0

The Robodox Guide to Multiple Cameras in FRC

In this activity you will create a tool to allow you to play games such as Red Light/Green Light. To create the game, follow the steps below.

Go-Baby-Go Senior Capstone Project

The "Hello world" of FRC robot programming

Make a Simple Weather Station Using Arduino

Arduino Prof. Dr. Magdy M. Abdelhameed

Innovation First, Inc Full-Size Robot Controller Reference Guide

Step 1: Connect the Cortex to your PC

Introduction To Arduino

Instruction Manual. Model RBA18

Arduino IDE The Developer Kit library The JeeLib library for RFM12 transceivers

Instructions for Installing FlashUpdate and Downloading Updates for Super Buddy Satellite Meter

keyestudio Keyestudio MEGA 2560 R3 Board

Copyright White Box Robotics Inc. and Frontline Robotics Inc

Chapter 1: Getting Started

ZENSOL CIRCUIT BREAKER PERFORMANCE ANALYZER

Pulsed Frequency TM. Joint PEMF Software Download, Installation and User Guide

VP- X Pro & VP- X Sport

These instructions were adapted from Arduino: Installing Standard Firmata which is licensed under Attribution- NonCommercial-ShareAlike 2.

Physics 120/220. Microcontrollers Extras. Prof. Anyes Taffard

The reasons for this problem might be: some special settings in the router itself or the switch might not be working properly.

Docking Station Operational Description

Halloween Pumpkinusing. Wednesday, October 17, 12

Rotorgeeks SSD Flight Controller Manual

Module 003: Introduction to the Arduino/RedBoard

ROBOLAB Tutorial MAE 1170, Fall 2009

Arduino IDE Friday, 26 October 2018

GUIDE TO SP STARTER SHIELD (V3.0)

Stand Alone HDMI Kit. Tutorial

Overview. Connect the Flight Control Board and Receiver

VEX Robot Remote Control Set-Up

University of Hull Department of Computer Science C4DI Interfacing with Arduinos

Arduino Panel Meter Clock. By Russ Hughes

Using a Stepper Motor Like a Servo Controlled by a Potentiometer (G Payne 2017)

Documentation for Wifi-Enabled Data Logging - System Control By: Jesse Jenkins

Create your own wireless motion sensor with

Advanced Debugging I. Equipment Required. Preliminary Discussion. Basic System Bring-up. Hardware Bring-up, Section Plan

How-To #3: Make and Use a Motor Controller Shield

USER MANUAL ARDUINO I/O EXPANSION SHIELD

ARDUINO UNO R3 BASED 20A ROBOT CONTROL BOARD [RKI-1580] Page 1

Reading ps2 mouse output with an Arduino

KNOCK LOCK MAKE YOUR OWN SECRET LOCKING MECHANISM TO KEEP UNWANTED GUESTS OUT OF YOUR SPACE! Discover: input with a piezo, writing your own functions

FRC Driver Station Powered by NI LabVIEW

Metro Minimalist Clock

HUB-ee BMD-S Arduino Proto Shield V1.1

Sten-SLATE ESP Kit. Description and Programming

XM360 X-Tractor Troubleshooting

New APIs and Hacks. Servo API. Chapter 4. The Theory versus Practice

Project 16 Using an L293D Motor Driver IC

Arduino 05: Digital I/O. Jeffrey A. Meunier University of Connecticut

Pulsed Frequency TM. MR7 Software Download, Installation and User Guide

Arduino Lesson 15. DC Motor Reversing

VEX Startup and Configuration Procedures

Controlling the Robotic Arm using the BBC micro:bit

Rover 5. Explorer kit

Station Automation --W3SZ

RC Tractor Guy Controller V2.1 Assembly Guide

Share Drobo on a Network: Apple Airport Extreme

SeeMeCNC Guides. Step 5: Installing the Firmware. This guide will show you how to install the firmware on your Rostock MAX v3 3D printer.

Blinking an LED 1 PARTS: Circuit 2 LED. Wire. 330Ω Resistor

Procedure: Determine the polarity of the LED. Use the following image to help:

Transcription:

AndyMark Arduino Tutorial Tank Drive June 2014 Required: Required Software List: - Kit Arduino IDE - Robot Power Cable Kit (am-0975) RobotOpen Arduino Shield Software - Battery Base Package (am-0477) RobotOpen Driver Station - D-Link DAP-1522 Radio (am-0839) - Logitech Gamepad F310 (am-2064) - MK ES17-12, 12 Volt, 17 Amp-Hour Sealed Lead Acid Battery (half of am-0844) - Battery Cable (am-0009) - Ethernet Arduino and Peasy Breakout Board Combo (am-2734) - Or an Arduino with a Breadboard and 13 Jumpers - Programmer Cable (am-2416) - 6-30 Amp Snap Action Breakers (am-0290) - Ethernet Cable (am-0499) - Assembled Robot - Windows XP OR Newer 1

Table of Contents Section Page # Setting Up the Software 3 Wiring the Arduino 4-6 Programing the Robot 7-10 Configuring the Driver Station 11 Connecting the Robot and Driver Station 12 Troubleshooting 13-15 Appendix A: PWM 16-17 Appendix B: The Driver Station 18 Appendix C: Motor Bias 19-2 2

Setting Up the Software Arduino IDE : Once you have downloaded Arduino IDE Double Click on Arduino You may need to right-click and select Run as Administrator Install to a known location. Setting up the RobotOpen Software Once you have downloaded RobotOpen Arduino Shield Software: Open the RobotOpen-Shield-Library-master zip file Find and right-click on the RobotOpen file folder Select copy Open the Arduino folder The default location for this file is in your Program Files My filepath was: C:\Program Files (x86)\arduino Paste the RobotOpen folder into the Libraries folder Wiring the Arduino 3

Place your Arduino on a desk so it doesn t short out. FTDI Port (Programming Port) Plug in your USB-to-FTDI Cable (am-2416) into an open USB Port on your computer Rotate the Arduino so the FTDI Port is facing your computer Plug the other end of the cable into your Arduino s FTDI Port Ethernet Port Plug one end of your ethernet cable (am-0499) into the ethernet port on your computer Plug the other end of your ethernet cable into the Arduino s Ethernet Port Note: If your computer does not have a ethernet port you will need to read the tutorial on the Arduino Wireless. Note: You now will need to place your robot on blocks, so that it s wheel are off the ground. Place your Arduino on the robot while keeping everything plugged into the computer The Peasy Board (am-2734) plugs directly into the Arduino like so: Once plugged into the Peasy Board: Plug PWM wires from the speed controller into the peasy board using the following configuration: 4

Front Left = Digital Pin 9 Rear Left = Digital Pin 3 Front Right = Digital Pin 6 Rear Left = Digital Pin 5 The yellow wire should insert into the headers that are labeled sig. Note: Make sure all of your speed controllers are off. Alternatively : You can use a breadboard. This will be less convenient than the Peasy Board, but it will still work. To match our example programs, you may want to wire the Arduino to the breadboard this way: 5

Programming the Arduino The Program Open up the Arduino IDE You may need to right-click and select run as administrator At the menu bar select Tools > Board > Arduino Ethernet At the menu bar select Tools > Serial Port > Select Communication Port To find communication (com) port, unplug your usb cord, re-iterate the above steps, find which COM is missing. The missing COM is the port to select. Insert this code below into your sketch. CODE: #include <SPI.h> #include <Ethernet.h> #include <Servo.h> #include <EEPROM.h> #include <RobotOpen.h> #define NEUTRAL 127 #define FORWARD 255 #define REVERSE 0 #define FORWARD_MS 2000 #define REVERSE_MS 1000 #define NEUTRAL_MS 1500 //Declaring which joystick we are using ROJoystick usb1(1); //Declaring that we have two Servos Servo leftrear; Servo leftfront; Servo rightrear; Servo rightfront; //Delay time for calibration int d = 250; //IP Address of the Arduino IPAddress ip (,,, ); //<=== Make your own IP Address void setup() { //Identify which digital pins the servos are using rightrear.attach(5); rightfront.attach(6); leftrear.attach(3); 6

leftfront.attach(9); //This function makes sure the speed controller and the Arduino understand each other. calibrate(); //Communicates with the RobotOpen Driver Station RobotOpen.setIP(ip); //Begins the RobotOpen tasks RobotOpen.begin(&enabled, &disabled, &timedtasks); void enabled() { //Records the value of the left analog stick on our selected joystick. //The motors move slightly slower when moving in reverse than when moving forward. The bias() function takes care of this problem. //Adjustmants may be needed depending on your setup. int vall = bias(usb1.lefty()); int valr = bias(usb1.righty()); //Maps vall and valr on a scale of 1000-2000. //The first two numbers are your high and low for the former scale and the last two are the high and low for the new scale. int spdl = map (vall, 0, 255, 1000, 2000); int spdr = map (valr, 0, 255, 1000, 2000); //The value becomes our wheel speeds leftfront.writemicroseconds(spdl); leftrear.writemicroseconds(spdl); rightfront.writemicroseconds(spdr); rightrear.writemicroseconds(spdr); void disabled() { // safety code leftrear.writemicroseconds(neutral_ms); leftfront.writemicroseconds(neutral_ms); rightrear.writemicroseconds(neutral_ms); rightfront.writemicroseconds(neutral_ms); void timedtasks() { //Publishing the values of the analog sticks to the RobotOpenDS RODashboard.publish("usb1.leftY()", usb1.lefty()); RODashboard.publish("usb1.leftX()", usb1.leftx()); 7

RODashboard.publish("usb1.rightY()", usb1.righty()); RODashboard.publish("usb1.rightX()", usb1.rightx()); RODashboard.publish("Uptime Seconds", ROStatus.uptimeSeconds()); void calibrate() { //Calibrating the Contorllers. See Appendix A in the Arduino Tutorial for more info leftrear.writemicroseconds(neutral_ms); leftfront.writemicroseconds(neutral_ms); rightrear.writemicroseconds(neutral_ms); rightfront.writemicroseconds(neutral_ms); delay(d); leftrear.writemicroseconds(foward_ms); leftfront.writemicroseconds(foward_ms); rightrear.writemicroseconds(foward_ms); rightfront.writemicroseconds(foward_ms); delay(d); leftrear.writemicroseconds(reverse_ms); leftfront.writemicroseconds(reverse_ms); rightrear.writemicroseconds(reverse_ms); rightfront.writemicroseconds(reverse_ms); delay(d); leftrear.writemicroseconds(neutral_ms); leftfront.writemicroseconds(neutral_ms); rightrear.writemicroseconds(neutral_ms); rightfront.writemicroseconds(neutral_ms); //We declare that we have a function that is going to take an integer int bias (int motor){ //The motors move around 15% slower when in reverse. float reversebias =.85; //If the motor is moving forward we want to slow it down by 15% if(motor>neutral){ //Maps a new scale that will match the speed of the motors running in reverse //SEE APPENDIX C IN THE TUTORIAL FOR MORE INFO return map(motor, REVERSE, FORWARD, (FORWARD*(1.0- reversebias)), (FORWARD*reverseBias)); else { //Maps a new scale that will match the speed of the motors running in reverse return motor; 8

void loop() { //Continually communicates with the Robot Open Driver Station RobotOpen.syncDS(); Upload your code by pressing the arrow at the top of your sketch If an error occurs, check the Arduino Forums for help If no errors appear, proceed Unplug your Arduino from the computer Note: You will need to change the IP Address to fit your computer. For help with this see the Troubleshooting section. Configuring the Driver Station The Driver Station Open up the RobotOpenDS (https://chrome.google.com/webstore/detail/robotopends/bhpgaibglpbnkhlkmpjhfmlpfbolgkme?hl=en-us) Go to: Setup > Robot > Type in the IP Address you made for the Arduino. The number for Port should be 22211 Plug in your Logitech Gamepad F310 (am-2046) Press any button on the Controller. The Joy #1 tab at the top of your Driver Station should be highlighted green. If not see the Troubleshooting section. Connecting the Robot and Driver Station Note: Check that your ethernet cable (am-0499) is plugged into your computer or router (am- 0839). Calibrating the Speed Controllers Hold the Arduino s reset button While holding the button, switch all of the speed controllers on Let go of the reset button Using the Controller Open up the RobotOpen Driver Station Make sure your controller (am-2064) is plugged into the computer Click the connect button in the top right corner of the Driver Station Click the enable robot button in the top right corner of the Driver Station Move your analog sticks. Your left analog corresponding to your left wheels & your right analog corresponding to your right wheels 9

Troubleshooting My program won t load onto my Arduino. OR I keep getting the error message: avrdude: stk500_getsync(): not in sync: resp=0x00? Check that you have the right com port. To do this: Unplug your FTDI cable from the computer Open the serial port menu Find which com port is missing Plug your FTDI cable back into the computer Re-open the serial port menu Select the new com port Check that your FTDI cable is correctly plugged into your Arduino: Completely unplug the FTDI cable from your Arduino Make sure that the golden crimps are facing down Fit the FTDI cable into the Arduino s FTDI Port Push the cable up until the silver pins are covered. Note: It may feel like the pins will break, but push the cable all the way. This ensures that you will achieve a good connection. Joy #1 on the Driver Station does not highlight when the controller is plugged in? Make sure the Driver Station window is open and Selected. If it still does not work, move to the next step. Re-connect the controller: Close the Driver Station App Unplug your controller from the computer Re-open the Driver Station App Plug your controller into the computer Press any button on your controller Repeat the process once more if it does not work the first time. 10

The Driver Station won t connect to the Arduino? OR The Driver Station only connects to the Arduino for a short time? Check to see if your Arduino IP Address is correct: Make sure you the code from Programming the Arduino section is loaded on to the Arduino, your Arduino is plugged in to your network and you have changed the IP Address to fit the subnet your computer is on. (Same first three numbers) Open start menu > search for cmd > select cmd.exe > type in: ping IPADDRESS -n 15 >Press Enter If it says Destination host unreachable you need to either: Change your IP Address Check the way you setup your software To find a correct IP Address: Open start menu > search for cmd > select cmd.exe > type in: ipconfig In the line that says "IPv4 Address" there should be a number You want your IP Address for your Arduino to have the same first three numbers of your IPv4 Address but a different last number For example: Your IPv4-192.168.1.15 Arduino IP - 192.168.1.25 or 192.168.1.XX Re-install the software: Close all Arduino sketches Open up task manager and make sure no Arduino programs are running The application will be called Arduino 1.0.5-r2 Open up the start menu > Control Panel > Programs and Features > Right-Click on Arduino > Select uninstall Open up your Downloads folder and delete your all of the downloaded files for Arduino and RobotOpen EXCEPT for your Driver Station Once everything is uninstalled and deleted, re-download the Arduino IDE & the RobotOpen Arduino Shield Software Open up your Downloads folder > Open RobotOpen-Shield-Library-master zip file > Open RobotOpen-Shield-Library-master file > Open libraries file > Right-Click on the RobotOpen file > Select Copy 11

Open up the start menu > Select Computer > Open Local Disk (C:) > Open up either Program Files (x64) or Program Files (x86) > Open Arduino > Open libraries > Right- Click in an open area > Select paste If you selected to install it to a custom area, you will go there instead of Program Files. Follow the steps from the Programming the Arduino section until the end 12

Appendix A: PWM A PWM is a message that allows your Arduino to talk to your speed controller which then controls your motor. This "message" is, in short, pulses of electricity every few milliseconds. Let's look at a theoretical analogy. Assume there is an army back before they had radio or any other type of speedy communication, and the army is split into two different sections. These two sections need a way to communicate but they are too far away for messengers, so they decide to use a flag. To make sure the two groups understand each other, they decide that every twenty minutes they will raise the flag with a message. The flag is raised for a minimum of one minute so the other section knows a message is coming. If the flag is lowered right after that first minute, that means retreat. If the flag is kept up for thirty seconds after that minute, that means don't move. If the flag is kept up for one minute after the first minute, that means to go forward. In this analogy, the period of the message is twenty minutes. After the message, the flag will go down until the next period starts. If we were to graph this, it would look something like this: How does this relate to your Arduino and Motors? Well think of your Arduino as the side sending the message and your speed controller as the other group receiving the message. Once your speed controller reads the message it controls the motor to do whatever the message said. The only difference between a PWM and the flag raising method is that a PWM uses electricity instead of a flag, and instead of minutes it uses milliseconds. 13

This is a variation to some of the code from above: //Adds Servo library to the compiler list #include <Servo.h> //Create a motor object to talk to Servo myservo; int d = 233; void setup() { //Tell the motor object to connect to myservo.attach(9); myservo.writemicroseconds(1500); delay(d); myservo.writemicroseconds(1000); delay(d); myservo.writemicroseconds(2000); delay(d); myservo.writemicroseconds(1500); void loop() { Most of this is straightforward except for the myservo.writemicroseconds() function. The myservo is the specific Servo Object we want to modify. The writemicroseconds() is the specific task we want to to with this object. The first part myservo just says that we are doing something with the servo that we call myservo. The second part writemicroseconds() is doing all the real work. writemicroseconds() takes the number we put in and uses that number to send the PWM. The number is the amount of time the pulse should be sent. You may have noticed the number we put in is in microseconds and not milliseconds like a PWM, but it doesn t make a difference. Now that you know all of this you should know: myservo.writemicroseconds(1500); says the motor is neutral. myservo.writemicroseconds(1000); says the motor is full reverse. myservo.writemicroseconds(2000); says the motor is full forward. myservo.writemicroseconds(1500); says the motor is back to neutral. The delay function just stops the motor from changing positions to quickly. Note : DO NOT change the value of "d" this number should be constant. The purpose of the above code is to perform a calibration, a type of "handshake." The speed controller does not really know the exact scale that your Arduino would send out pulses so it must find out the midpoint then the low and high point. It must also have enough time to register these values, hence the delay. The set delay time of 233 is the minimum amount of time the controller needs to register the values and that is why the number should not be changed. 14

The Driver Station 15

Appendix C: Motor Bias What is motor bias? Look at the picture below: The arrow is the way the wheel would move if in forward or reverse. Yet, what happens to a motor on the opposite side? Motors on opposite sides are the same kind of motor; one is just flipped 180 degrees. So, if we flip the above motor we get this: If you want both sides of your robot to run forward, the motors will be moving in opposite directions. So, to move your robot forward, the left side runs forward(100%) and the right side runs in reverse (-100%). The only problem is that when a motor runs in reverse (-100%), it does not always move as fast as a motor running forward. This is called a motor bias. So, to counter this you must slow down the motors moving forward to match the motors that are moving in reverse. To help you with this, we have created the bias() function in the program to help you. EXAMPLE: //We declare that we have a function that is going to take an integer int bias_ms (int motor){ //The motors move around 15% slower when in reverse. float reversebias =.85; //If the motor is moving forward we want to slow it down by 15% if(motor>neutral){ //Maps a new scale that will match the speed of the motors running in reverse return map(motor, REVERSE, FORWARD, (FORWARD_MS*(1.0- reversebias)+1000), (FORWARD_MS*reverseBias)); else { //Maps a new scale that will match the speed of the motors running in reverse 16

return map(motor, REVERSE, FORWARD, REVERSE_MS, FORWARD_MS); 17