Sensors and Control II

Sensors and Control II - Control Using Simple Feedback II...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style 10/15/10 Control Using Simple Feedback II Lab1 – A Wall Following System
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10/15/10 Feedback - 13 import lejos.nxt.*; public class SimpleWallF { static UltrasonicSensor mySensor = new UltrasonicSensor(SensorPort.S1); public static final int WALLDIST = 20; /* standoff distance */ public static final int DEADBAND = 2; /* deadband */ public static final int FWDSPEED = 300; /* default speed */ public static final int DELTA = 150; /* BANG-BANG constant */ public static void main(String[] args) { boolean traveling=true; int distance=0; int status=0; int error=0; LCD.clear(); /* Set up display */ LCD.drawString("Simple Wall F",0,0,false); LCD.drawString("Distance: ",0,32,false); Motor.B.forward(); /* Start motor thread */ Motor.C.forward(); Motor.B.setSpeed(FWDSPEED); /* Set default speed */ Motor.C.setSpeed(FWDSPEED);
Background image of page 2
10/15/10 Feedback - 14 Simple WallFollower cont’d. while (traveling) { status=Button.readButtons(); if (status==8){ NXT.exit(0); /* Return to monitor */ } mySensor.ping(); /* Initiate scan */ distance=mySensor.getDistance(); /* Get data */ LCD.drawInt(distance,4,11,4); error = distance-WALLDIST; if (Math.abs(error) <= DEADBAND) { /* Within tolerance */ Motor.C.setSpeed(FWDSPEED); /* 0 bias */ } else if (error < 0) { /* Too close */ Motor.C.setSpeed(FWDSPEED-DELTA); /* -ve bias */ } else { /* Too far */ Motor.C.setSpeed(FWDSPEED+DELTA); /* +ve bias */ } } } }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10/15/10 Feedback - 15 OK – so we can control by accelerating or decelerating one wheel… Maybe this can be improved by affecting both wheels… So – to increase the distance, decrease the speed on the right wheel and speed up the left wheel To decrease the distance do the
Background image of page 4
10/15/10 Feedback - 16 Improving the Simple Wall Follower
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/14/2010 for the course ECSE 211 taught by Professor Davidalisterlowther during the Fall '09 term at McGill.

Page1 / 15

Sensors and Control II - Control Using Simple Feedback II...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online