The george washington university department of ece ece 001 intro electrical computer engineering
This presentation is the property of its rightful owner.
Sponsored Links
1 / 14

Intro to the Robotics Introducing the IC Discuss motor control using IC Hands-on programming PowerPoint PPT Presentation


  • 63 Views
  • Uploaded on
  • Presentation posted in: General

The George Washington University Department of ECE ECE 001 - Intro: Electrical & Computer Engineering. Intro to the Robotics Introducing the IC Discuss motor control using IC Hands-on programming Dr. S. Ahmadi Class 1 Slides obtained from Botball Kit Documentation. Class Outline .

Download Presentation

Intro to the Robotics Introducing the IC Discuss motor control using IC Hands-on programming

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


The george washington university department of ece ece 001 intro electrical computer engineering

The George Washington University Department of ECE ECE 001 - Intro: Electrical & Computer Engineering

Intro to the Robotics

Introducing the IC

Discuss motor control using IC

Hands-on programming

Dr. S. Ahmadi

Class 1

Slides obtained from Botball Kit Documentation


Class outline

Class Outline

Policy and Safety

Basic IC programming

Download

Display

Function commands

Botball Part list

http://www.seas.gwu.edu/~ece001/partlist.doc

• Overview of Motors


How to write a simple interactive c ic computer program

How to Write a SIMPLE Interactive C (IC) Computer Program

  • IC is a hybrid of C designed to run on small, self-contained robot controllers

    void main()

    {

    }

    • Making decisions

      • If ( ) { statement }

      • Else( ) { statement }

    • Making repeated decisions

      • While( ) { statement }


How to write a simple interactive c ic computer program1

How to Write a SIMPLE Interactive C (IC) Computer Program

  • IC is a hybrid of C designed to run on small, self-contained robot controllers

    • void main()

      {

      // This is a comment

      int my_variable; // “my_variable” is of type: integer

      my_variable = 2; // assinging a variable

      motor(1, my_variable); // a function call, turns on motor

      float my_second_variable;// “my_second_variable” is of type: float

      my_second_variable = 2+(3/6)^5; // mathematical expression using C

      my_second_variable = sqrt((a^2)+(b^2));

      }

    • Important: All statements end with a semicolon (;).

    • Making decisions

      • If ( ) { statement }

      • Else( ) { statement }

    • Making repeated decisions

      • While( ) { statement }


Variable types

Variable Types

  • What is a variable?

    • It holds information, for example: a number

  • Two types of variables we will use in ECE001

    • int (16 bit integer number in IC)

      +/-32,767 (largest # it can hold)

    • float (32 bit floating point number)

      e.g. 3.1416


Useful function

Useful Function:

  • Sleep(seconds);

  • sleep() delays the function’s execution for an amount of time equal to the number of seconds (expressed as a float) given as an argument


C function printf

C Function:printf();

  • Takes a quoted string and prints it out

    – %d is used for an integer

    – %f is used for a float

    – \n starts next character back at upper left corner (or new line on terminal)

    – commas separate all arguments after the quoted string

    • printf(“I’m printing\n”);


Handyboard functions

Handyboard Functions

  • start_button();

  • stop_button();

  • beep();

  • fd(x);// makes motor “x” go forward

  • bk(x);// makes motor “x” go backward

  • ao();// turns all motors off --- “all off”


Sample program

Sample Program

  • When a program is run, the control moves from one statement to the next

  • Calculate j2 + 1 when j = 3

    void main()

    {

    int r,j; /* declare r and j */

    j = 3; /* assign a value to j */

    r = j*j + 1; /* calculate and assign */

    printf(“result is %d\n”,r);

    }


Making decision using if else condition

Making decision Using if-else condition

void main()

{

if ( start_button()==1)

{fd(1); fd(2); }

else

{ ao(); }

}


Repeating execution loops

Repeating Execution: Loops

  • Loops are used when you want to do the same thing multiple times

  • E.g., beep 20 times

  • You could type beep(); 20 times, but there is a better way: a loop


Repetition using while

Repetition Using while

  • Syntax: while (<test>) {statements}

  • Beep 20 times

    void main()

    {

    int num; /* declare counter */

    num = 1; /* initialize counter */

    while (num <= 20)/* loop while num is <=20*/

    {

    beep(); /* beep once */

    num = num + 1; /* add one to the counter */

    }

    }


Get started with ic environment

Get Started with IC Environment

  • Start the IC application

  • Click on the picture of the Handy Board

  • Click on the Connect Later button

  • Click on the New button (upper left corner)

  • Type in the program that prints out a text string

  • Save the file using the Save button (name it

  • whatever you want -- just remember where you put it).


Important information

Important Information

  • How to learn IC programming

    • http://www.kipr.org/curriculum/programming.html

  • Check class website for Handy board documentation

  • Check IC command functions

  • Check the handy board diagram

  • Return the Kit release form after you check all parts in the Kit

  • Homework is to be done individually


  • Login