1 / 33

Introducing Handyboard/Interface and Set-up Continuation of Programming Skills

The George Washington University Department of ECE ECE 1010 Intro: Electrical & Computer Engineering. Introducing Handyboard/Interface and Set-up Continuation of Programming Skills Connecting Handyboard Making sure connections are fine Introduction to analog sensors Dr. S. Ahmadi Week 2.

beck-patel
Download Presentation

Introducing Handyboard/Interface and Set-up Continuation of Programming Skills

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The George Washington University Department of ECE ECE 1010Intro: Electrical & Computer Engineering • Introducing Handyboard/Interface and Set-up • Continuation of Programming Skills • Connecting Handyboard • Making sure connections are fine • Introduction to analog sensors Dr. S. Ahmadi Week 2

  2. Outline • PART I • Programming Exercises • Connecting Handyboard • Hands-on Programming • Starting IC Program (Downloading Firmware) • Running Programs • PART II • Introduction to Analog Sensors • Project Description

  3. PART I: Handyboard

  4. Hardware Components Handyboard (Interface to motors) RJ-11 Cable (Connection btwn Handyboard & Serial Port Interface) Serial Port Interface (Interface between Handyboard & PC) AC Adapter (Provides power to Serial Port Interface & Handyboard) Serial Port Cable (25pin to 9pin) (Connects “Serial Port Interface Board” to back of PC)

  5. Handyboard Layout LCD Screen (for output from your ROBOT) ON/OFF Button I LOVE ECE001! Download Connector (Connect Serial Port Interface Board to Handy-board here) Ports 0,1,2,3 for MOTORs (Connect a wire from Port 1 to your LEFT motor And another wire from Port 3 to your RIGHT motor)

  6. Connecting the Handyboard • Connect RJ-11 Cord (Phone Cord) to the “Serial Port Interface” and Handy Board. • Connect “Serial Port Interface” to PC via Serial Cord • Start “Interactive C” on PC

  7. Running Interactive C: • Start Menu >> Programs >> Interactive C 4.0

  8. Initially on running the program, you have to choose the hardware you’re going to be working with. Click on the “Handyboard” option.

  9. * Depending on how you connected the Serial Port Interface, choose either com1 or com2, and then “Connect Now”

  10. Overview of Interaction Window Download program to Controller. Stop program currently being run. Run program that is currently in the Controller’s Memory. Single Instruction Entry (Interaction Area)

  11. BASIC HANDYBOARD HOOKUP PROCEDURE • Connect Handy-board to computer. • Turn the Handy-board on. • Open your Interactive C software. Make sure the computer is talking to the controller. • After connecting handy-board, type “beep();” in the interactive window. • If you hear a ‘beep’, your connections are correct.

  12. This is just a simple test, to make sure your connections are correct. • In the single instruction entry, simply type “beep();”. • The command should then be displayed in the History area, and the “Handy-board”should emit a beep.

  13. Start a new File by pressing the “New” button at the top left hand corner of the screen.

  14. Running the same program as the previous example in a new file. • Any program that is written in a new file has to be encapsulated by a main function, as shown, so that the controller knows what to run first. • Inside the actual Main, type the set of commands you wish to run, in this case, “beep();”. • Save the program, and then press the download button. • “Run Main” -> if nothing went wrong, your “Handyboard” should beep. • Note that unlike writing a single command in the Interaction window, programs written in a new file must first be downloaded to the controller’s memory.

  15. If the IC Software does not detect any errors in your program, it should download without any problems. If there is an error, it will not download, but should tell you where the error occurred.

  16. Sample Beeping Program /* Program to beep 20 times continuously. */ void main() { int count=0; while(count<=20) { beep(); count=count+1; // Incrementing counter } } • Extra: Wait half a second between beeps.

  17. Motor control commands • DC motor control commands • fd (n);Rotate motor ‘n’ forward • bk(n); Rotate motor ‘n’ backwards. • motor(n, s); move motor ‘n’ at speed ‘s’ • ‘s’ range: -100 ~ +100 • ‘s’>0 forward • ‘s’<0 reverse • off(n); turn off motor ‘n’ • ao(); turn off all motors

  18. Motor Exercise Procedure • Attach the two motors to the connector wires. Next, attach the wire plugs to Handyboard ports. • Turn the Handyboard on. • Open your Interactive C software. Make sure the computer is talking to the controller. • In interactive window, type “fd(1);” • After making sure motor connected correctly, type “off(1);” • Turn on motor 1 using the motor(n,x) command. • Make motor 1 alternate between a forward and backward direction. • You can change the speed of your motors. For example motor(1,100) means motor 1 is turning at 100 or full speed.

  19. Motor Control: Exercise #1 • Exercise #1: Motor speed control • write IC program to run one motor in three different speeds. • Turn motor #1 on • drive in slow speed for 3 seconds • drive in medium speed for 5 seconds • drive in high speed for 3 seconds • Stop motor

  20. Sample Motor Program (Exercise #2) void main() {printf("Press START to test motors\n"); while(start_button() == 0); //wait until start button is pressedfd(1); // Motor in port 1 go forward sleep(2.0); // Sleep for 2 seconds.bk(1); // Motor in port 1 go backward sleep(2.0);off(1); //turn motor in port 1 off fd(3); // Motor in port 3 go forward sleep(2.0);bk(3); // Motor in port 3 go backward sleep(2.0);off(3); }

  21. Charging The Handyboard • Charging the Handyboard takes 14 hours, after which it can be left in the power indefinitely. • Zapping the Handyboard fully charges it in 4 hours, but it must not be left in power after charging is complete. • Note: Students will be responsible for charging their groups Handyboard.

  22. SUMMARY of Main Functions from Week 2 • fd (n); Rotate motor ‘n’ forward • bk(n); Rotate motor ‘n’ backwards. • motor(n, s); move motor ‘n’ at speed ‘s’ • ‘s’ range: -100 ~ +100 • ‘s’ > 0 – motor moves forward • ‘s’ < 0 – motor reverses/moves backward • off(n); turn off motor ‘n’ • ao(); turn off all motors • sleep(x); // Delays execution of next statement for ‘x’ secs. • msleep(x); // Delays execution of next statement for ‘x’ millisecs. • beep(); // Causes the handy-board to Beep.

  23. PART II: INTRO TO SENSORS

  24. Analog Sensors • Outputs a range of integer values. • Range depends on the signal being sensed. • The main analog ports are ports 2 – 6, and ports 20 – 23. • Actual ports that should be used will depend on the sensor being used. • The three main analog sensors that we will be using are the Light Sensor, the Optical Rangefinder Sensor and the Ultrasonic Sensor (aka Sonar). • In today’s project, only the light sensor will be utilized.

  25. Analog Sensor 1: Light Sensor • The light sensor included in the kit, can “sense” lightness and darkness. • Connect to analog ports 2-6 or 20-23 • Access with function analog(port#) • Analog values range from 0 - 255. • A low value indicates bright light or close proximity to a light source • A high value indicates dark light or far proximity from a light source Enlarged Light Sensor

  26. Analog Sensor 2: IR Reflectance Sensor “Top Hat” • The IR sensor included in the kit, can also “sense” lightness and darkness like the light sensor • Connect to analog ports 2-6 or 20-23 • Access with function analog(port#) • Low values indicate bright light, light color, or close proximity • High values indicate low light, dark color, or distance of several inches • Sensor has a reflectance range of about 3 inches Enlarged IR Sensor

  27. Light Sensor Sample Code /* Program that measures the reads from the light sensor and displays its output values continuously. */ void main() { int color=0; printf(“\n Light Sensor Sample Program"); while(!start_button()); // Press Start Button while(1) // Continue infinitely { sleep(0.5); color = analog(6); // Read “lower deck” analog port 6 printf(“\n Color is %d”, color); // if near 0 – WHITE // if near 255 - BLACK } }

  28. Project 1 Overview

  29. Project Description • The aim of this project is to design a robot that moves along a given path, from the Start point, towards the Finish line. • The thick black line acts as the guide for the robot to follow. • As an optional element to the project, after reaching the finish line, the robot should turn around, and go back along the path it came to the starting point. • Robot will be judged on smoothness of journey, and robot design. • It is the students’ responsibility to make sure that the Handy Board is fully charged • Each group will have one chance to demonstrate their project to the judges. Therefore, fully test your project before demonstration.

  30. Project #1 - Route 2m 2m Finish Start 2m 2m

More Related