PROGRAM WORKSHEET 41: Plotting a rectangle

Projected outcome: The pupils will develop an understanding of how machines make decisions in the workplace.

What it does: This program counts the number of times the touch sensors are pressed and uses the data to enable the plotter draw a rectangle on a sheet of paper. Motor A raises and lowers the pen; Motor B drives the paper feeder and Motor C drives the pen horizontally, so by moving the paper in and out we get vertical lines and by moving the pen we get horizontal lines on the sheet of paper. (If a remote control is available, use it to test the various motors and watch the touch sensors counting.)

Equipment: Plotter can be built using Ultimate Builders Kit (Lego 3800) and programmed using Lego Mindstorms V.2. (Note: Search the 'net for other plotter designs.)

 

Plotter from materials in Ultimate Builders Kit (Lego 3800)

 

Plotter movie

(Starts on mouseover)Download directly

Program to draw a rectangle on the plotter

 

 

All plotters work from reference points. For example, an inkjet printer always starts with the print heads docked on one side of the rail on which the print heads travel, and uses this location as its reference point.

Part 1: Setting up the pen's reference point

In our program we make sure the pen is raised (On A for 3 seconds) and we proceed to dock the pen close to the RCX using the Repeat While Touch 1 is released command. Touch Sensor 1 is located at the end of the rail on which the pen module travels.

 

 

Part 2: Setting up the pen's starting position on the page

The pen has to be moved from its docked position to the point where we wish to begin to draw the rectangle.

1.  Sometimes it can be useful to insert a comment before a stack of instructions (as computer programmers do) for debugging purposes, and where pupils are working as a team. Click the tag on the comment brick to view what the next lines of the program do, and the information appears in its own pop-up window.

2. The variable verticalposition is set to 0, Motor B is turned on until the vertical position variable reaches 10. Each time Motor B turns, Sensor 3, which is located close to a cam on its axle,  adds 1 to the value of verticalposition.

3. The variable horizontalposition is used to set the horizontal position of the pen in the same fashion, using Motor C.

 

 

 

Part 3: Placing the pen on the page

1. Reverse the direction of Motor A, as last time it was used to raise the pen.

2. Turn on Motor A for 4 seconds.

3. Return the status of Motor A to normal forward.

 

Note: It was decided to use line segments as basic shape-builders and, by combining line segments, it would be possible to build shapes easily.

Part 4: Setting up the program for horizontal line segments

1. Motor C is used for horizontal movement and the counter in this block of the program ensures a line segment length of 10 motor revolutions. By combining segments we can build a continuous horizontal line.

 

Part 5: Setting up the program for the vertical line segments

1. Motor B is used for vertical movement and the counter in this block of the program ensures a line segment length of 10 motor revolutions. By combining segments we can build a continuous vertical line.

 

Notes

1. The rectangle is built by combining line segments (SEGVERT, SEGHOR) and the Set Direction bricks to ensure the line is drawn correctly.

2. DOCK is added in after the program is complete.

3. The PENUP block (not shown, as it's inside the RECTANGLE block) is similar to PENDOWN but with the motor direction reversed.

4. One of the tests of a properly written program for a plotter is whether it does the same thing each time it runs.

Download Program

Cam on axle from Motor B with touch sensor used to count motor revolutions of paper feeder.

 

 

Cam on axle from Motor C with touch sensor used to count motor revolutions of pen module crossing page horizontally.

Note that time could also be used to measure horizontal and vertical movement but counting axle rotations is more accurate.

Plotter Game

(Click image to zoom)

Challenge 1: How fast can you guide the pen around the track using the remote control. Four second penalty for "crashing" into fence. Kevin holds the record for this track at 73 seconds.

Challenge 2: Class to do track as a relay race

Challenge 3: Give a commentary

Detail showing pneumatic pump

(Click image to zoom)

Pump is connected to inlet of a pneumatic valve chamber which has a lever to switch air-flow between the two outlets. A single motor drives the pump and the lever which switches the air-flow, and the white clutch gear "slips" when the switch is at either of its limits.

 

Plotter in the workplace

The pupils of the school visited Carrabine Joinery in Ballina and Daniel demonstrated how a computer-controlled plotter works to produce carved images on wood.

 

Figure of angel in image library on computer

Router takes image data from computer and carves image on sheet of wood

(Video starts on mouseover)

(Download)

Figure of angel carved on sheet of wood by router