The Lego Programming Assignment - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

The Lego Programming Assignment

Description:

The Lego Programming Assignment. Programmable microcomputer (Hitatchi H8/3932) ... int main(int argc, char **argv) { cputs('hello'); sleep(1); cputs('world'); sleep(1) ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 11
Provided by: andrease
Category:

less

Transcript and Presenter's Notes

Title: The Lego Programming Assignment


1
The Lego Programming Assignment
  • Programmable microcomputer (Hitatchi H8/3932)
  • Sensors and actuators
  • Battery driven
  • IR-transceiver

2
LegOS
  • Small OS to be downloaded on the RCX unit
  • Runs on Linux and Windows 95/98/NT
  • Source code is freely available
  • Not a hard real-time operating system
  • LegOS supports
  • Preemptive multitasking
  • Dynamic memory management
  • POSIX semaphores
  • LegOS gives access to
  • LCD-display
  • Buttons
  • IR communication
  • Motors
  • Sensors

3
LegOS System Calls
  • LCD-display (5 chars)
  • void lcd_int (int i)
  • void cputs (char s)
  • Memory management
  • free(void ptr)
  • malloc(size_t size)
  • strcmp(char s1, char s2)
  • strlen(const char s1)
  • LNP LegOS Networking Protocol
  • lnp_integrity_send(data,length)
  • lnp_integrity_set_handler(func)
  • lnp_logical_range(int)
  • Semaphores
  • sem_wait()
  • sem_post()
  • RCX Button Input
  • getchar()
  • wakeup_t dkey_pressed()
  • Sound
  • void sound_system(SOUND)
  • void dsound_play(const note_t )
  • Motor control
  • motor_a_dir(enum MotorDir)
  • motor_b_speed(int speed)

4
LegOS System Calls
  • Sensors
  • TOUCH_1, TOUCH_2, TOUCH_3
  • LIGHT_1, LIGHT_2, LIGHT_3
  • ROTATION_1, ROTATION_2, ..
  • void ds_activate (SENSOR)
  • BATTERY
  • Task Management
  • int execi(PROCESS_NAME, int argc, char argv,
    priority_t prio, size_t
    stack_size)
  • exit(int code)
  • kill(int PID)
  • yield()
  • wakeup_t wait_event(wakeup_t(wakeup)(wakeup_t),
    wakeup_t data)
  • Miscellaneous
  • sleep(int sec)
  • msleep(int msec)
  • random()
  • srandom(int seed)
  • long int sys_time

5
Programming Example
  • include ltconio.hgt
  • include ltunistd.hgt
  • int main(int argc, char argv)
  • cputs("hello")
  • sleep(1)
  • cputs("world")
  • sleep(1)
  • cls(" ")
  • return 0

6
Programming Example
  • int main(int argc, char argv)
  • ds_active(LIGHTSENS)
  • locate_line()
  • follow_line()
  • return 0

static void locate_line() motor_a_speed(NORMAL
_SPEED) motor_c_speed(NORMAL_SPEED)
motor_a_dir(fwd) motor_c_dir(fwd)
wait_event(dark_found,DARK_THRESH)
static wakeup_t dark_found(wakeup_t data)
return LIGHT(LIGHTSENS)lt(unsigned short)data
7
Assignments
  • Assignment 1, Light detector Make a Geiger
    counter for light
  • Assignment 2, Static Cyclic Schedule Construct
    a vehicle. Run a single thread that calls
    procedures corresponding to tasks in your system.
    The procedures should be called at regular time
    intervals. Tasks are engine_control,
    forward_run, direction_change and
    obstacle_handling

8
Assignments
  • Assignment 3, Watch dog Add a task to you
    static schedule that checks that no procedure are
    going over its time budget.
  • Assignment 4, Multi-threading - Implement the
    tasks in your system as concurrent execution
    threads scheduled by LegOS. Add task
    border_handling

9
Assignments
  • Assignment 5, Game playing Let the vehicles
    communicate using the LegOS Network Protocol.
  • The vehicle should be able to play
  • tag when a vehicle hits another vehicle, it
    gets a point and the the other vehicle must be
    idle for a while
  • catch one vehicle has the tag. When it succeeds
    to hit another vehicle the tag will be
    transferred to this vehicle.

10
Notes
  • Labs are scheduled in rooms 1312 and 1313 on
    Thursday. The rooms are booked both Thursday and
    Friday.
  • Come by room 1221 on Wednesday 4/4 to get the
    Lego Mindstorms Kit and to sign receipt.
  • Assignment deadline 16 May 2001
Write a Comment
User Comments (0)
About PowerShow.com