RoPlot -LOGI3

Click picture to see the movie.

This project is the answer to many e-mails we got around LOGI2. We got some inspiration from Benjamin ERWIN, Creative Projects with Lego Mindstorms, USA, 2001, ISBN 0-201-70895-7 . But building instructions for a performing plotter was not available. After some internet-surfing however we found a very interesting site called brickshelf, with a marvelous original Cartesian-plotter from LEGO No.8094. This design had of course to be transformed to fit for the RCX-purpose.

For instance we added the geared 9V motors instead of the ungeared to the main mobile body. Two LEGO rotation sensors were connected to the motor-power. The transmission was slightely changed by adding the Technic gear-box LEGO part. No. 9918. This part makes sure the worm-gear does not move back and forth every time the motor-direction is changed. Two touch-sensors were added for zero-point fixing. Because there was only one sensor-input left on the RCX, we used Mike Gasperi's input-expander. Finally an ungeared motor was fixed to the head in order to allow pen-up pen-down movements. Note that the 8094 building instructions may be followed up to No. 20. Here some details.

 

 

  click to see the video

The RO-PLOT may be programmed by LOGI3.

Download the program and the Delphi source files.

Here a screen-shot of the program.

Some advice for the use of LOGI3:

1) With the aid of LOGI3 you may drive the RO-PLOT with the following instruction-set:

FORWARD x
LEFT y
RIGHT y
DIRECTION z
PEN v
REPEAT w [ Instructions ]
*

whereas:

x - integer number between 0 and 32767 (mm); negative numbers
don't cause any error, but RO-PLOT ignores the sign. ATTENTION: The allowed RO-PLOT area corresponds
to the screen-dimension of about 10 x 9 cm.

y - angle between -180 and 180 degrees; angles out of this range
will automatically be adjusted to this interval. Notice: LEFT -60
makes the robot-head move to the right during the next FORWARD instruction!

z - absolute angle between 0 and 360 degrees clockwise. You may
enter the compass-directions; for example DIRECTION NW will cause the
robot-head move 45 degrees from the 0-position during the next FORWARD command.

v - UP, DOWN.

w - positive number between 0 und 255. REPEAT 0 [ Instructions ] causes a continuous loop.

Do not forget the brakets!

Your program should end with a sole *

2) Choose INSTALL / PLOTTER-program to transmit the main
program to the RCX at slot1. You may choose another slot by
clicking INSTALL / SLOTS. You may test your robot with the initial
program. Simply press run on the RCX.

3) The short initial program should execute the following instructions:

DIRECTION 30
FORWARD 10
*

4) You may save and load your plot-programs. If you want to print
them, use a simple text-editor.

5) One line comments must be introduced by a / .

6) Test your LOGi3-program on-screen by clicking TEST. You'll see that if the compiler is in 
PEN-UP condition, the test-picture will be drawn with gray lines. At PEN-DOWN condition,
the lines are blue. NOTE: Then PEN up -down instructions cause the program to draw a ball
at the location.

7) Download your program to the RCX by clicking the DOWNLOAD-button. 

Version 3.0 07/06/2001
Author Claude Baumann


=====================================================================
Appendix

A) You may write your own routines with LeROBOT for example. Put
attention to the following conditions:

1. LOGI addresses the subroutines:

FORWARD --> 0
LEFT --> 1
RIGHT --> 2
PEN --> 3
DIRECTION --> 4

2. Respect the variable 0

argument = variable 0

3. The main procedure for plotting should be task 1.
example:

PEN DOWN
REPEAT 5 
[
LEFT 72
FORWARD 20
]
*

will be transmitted as:

BeginOfTask(1)
SetVar(0,2,0)
Gosub(3)

Loop(2,5)
SetVar(0,2,72)
Gosub(1)
SetVar(0,2,20)
Gosub(0)
EndLoop()
EndOfTask()

Variable 0 transports the plotting-argument.


4. The main programtask should look like

BeginOfTask(0)
/Initialisation of the variables
/Output-power
/Sensorsettings
/Start of some tasks
/in any case:
Starttask(1)
EndOfTask()

Some explanations to the RCX-procedures which are incorporated into the LOGI3-body. First of all, the RO-PLOT has to recognize its zero-point. The main task orders the x-motor and the y-motor to bring the plotter-head back home. Then it waits for the t_event variable to be set to 1, e.a. both switches are pressed. The following task manages the input expander. You have to put attention to adjust the values if necessary. Check if the switches are well connected to the exander. The sensor-input must be set to No_TYPE. Use the on-board VIEW-button to check the values.

beginoftask(touch_event);
setsensortype(sensor_2,no_type); //touch_sensor multiplexer used
   setvar(t_event,con,0); //clear t_event
   setvar(x_touch,con,0); //clear x_touch event
   setvar(y_touch,con,0); //clear y_touch event
   loop(con,forever); //wait until both events happened
      setvar(x_touch,con,0);
      setvar(y_touch,con,0);
      while_(senval,sensor_2,GT,con,990); //wait until touch_event
      endwhile();
      wait(con,10); //wait transition time
      if_(senval,sensor_2,GT,con,860); //y_touch pressed
         setvar(x_touch,con,0);
         setvar(y_touch,con,1);
      else_();
         if_(senval,sensor_2,GT,con,825); //only x_touch pressed
           setvar(x_touch,con,1);
           setvar(y_touch,con,0);
        else_();
           setvar(x_touch,con,1); //both pressed
           setvar(y_touch,con,1);
        endif();
     endif();
     setvar(t_temp,var_iable,x_touch); //store temporary because of operation
     mulvar(t_temp,var_iable,y_touch);
     setvar(t_event,var_iable,t_temp);
 endloop();

endoftask();

The motion of a Cartesian plotter is very interesting. If both motors move the head positively, the plotter draws a 45° line. If only one motor is powered, either a 0° (180°) line or a 90° (270°) are drawn.

Quadrant x-motor y-motor
I + +
II - +
III - -
IV + -

To draw lines at any angle, the head-position must be devided in 4 quadrants. At case 1 the y-motor moves quicker than the x-motor. At case 2 the inverse is true. To handle, the program first checks the quadrant, then the case. The tangens of the angle j  always represents the speed-ratio of the motors. To make things simple, we used a trick to power the motors precisely without timing the motor through a wait or timer command, nor calculating the tangens of angles.

it is possible to choose small integer values a and b, so that :

So, during the whole line-drawing period P = n . (a + b) , x-motor turns for the time n . a, and y-motor for the time n . b. We have:

For example: j = 21° --> a good approximation for LEGO-purpose is: a=3, b=8

//motor-control ***********************************************
beginoftask(motor_x_control);
loop(con,forever);
     if_(var_iable,phi,eq,con,0);
        if_(var_iable,case_,eq,con,2);
            on_(x_motor);
        endif();
     else_();
        if_(var_iable,phi,eq,con,45);
            on_(x_motor);
       else_();
          loop(var_iable,motor_on); // is a in the explanation-text
                on_(x_motor);
         endloop();
         loop(var_iable,motor_off); //is b in the explanation-text
              off(x_motor);
        endloop();
      endif();
   endif();

endloop();
endoftask();

The whole drawing period is determined by the readings of the rotation-sensors. The plotter is ready if the forward-argument :

argument  = L =

Note that this RoPlot could easily work without rotation-sensor. The programs would only have to count the dx and dy values as n . a, resp. n . b . In this case you would not need the input expander. The precision could be improved, if another program-variant were able to cound a and b from the rotation-sensor readings, although the actual design is well calibrated.


RetourMain Page