Friday 25 May 2018

EV3 Banner Printer

We have developed an EV3 Banner Printer based on the instructions given here. We developed a Java (LeJOS) program to make it operate according to our requirements. Below is a small clip which will demonstrate the printing of various characters. We have also posted the gist of Java program which we developed. This Java program has an array called "myString" which stores the entire set of characters that we want to print. 

Let me give you a brief introduction of this array. The main objective of the program was to operate with the help of a Infrared beacon (For Example: Print "P" when beacon is on mode-3 and button-4). However, testing frequently with the help of beacon was quite time consuming. Hence we have put the entire list of beacon characters in "myString" array. 

NOTE: Below is the gist of how "myString" array looks like
myString[0][0] = 2;  // This is the mode number of the first character
myString[0][1] = 4;  // This is the button number of the first character
myString[1][0] = 2;  // This is the mode number of the second character
myString[1][1] = 1;  // This is the button number of the second character
and so on ... 

Once the string is stored inside the array, we can iterate it over the while loop and start printing the characters one by one. The job of printing any characters is very simple. Rotate the three motors as per requirements. In our case, Large Motor C is doing the job of moving paper as the characters get printed. Large Motor A is doing the job of moving the pen up and down. Medium motor is doing the job of moving the pen from bottom to top of the paper and vice-versa. 

Some key points to remember:
  • Each character is printed 180 degrees apart from each other horizontally, where 180 degrees is the rotation of large motor C. The motor C is responsible for the horizontal movement along the paper's length
  • Each character is printed within 90 degrees to 270 degrees rotation of medium motor D. The medium motor D is responsible for the vertical movement of the pen along the paper's breadth. Here, motor's rotation to 90 degrees correspond to bottom most position along the paper's breadth and 270 degrees correspond to topmost position along the paper's breadth 
  • When the large motor A is rotated through 160 degrees, the pen touches the paper and the character starts printing. And when the motor is rotated through 360 degrees, the pen is lifted up and the printing gets disabled  
Now let me explain the way we print the letter A as an example:
  • The character begins at the position begin = (character - 1) x 180 degrees. The motor C is rotated to this position with the statement ev3lmotorC.rotateTo(begin)
  • Medium motor D is placed at its lowest position on the paper by rotating the medium motor through 90 degrees. This is achieved by the statement ev3mMotorD.rotateTo(90)
  • Large motor A is rotated through 160 degrees by the statement ev3lmotorA.rotateTo(160). This brings us to position A of the character A (based on the below figure)
  • Then comes the drawing of slanting edges of the letter A. The drawing of slanting edge is achieved by incremental movement of motors C and D which move the pen horizontally and vertically respectively. As a result, if you closely observe, the letter A looks like in the below image

 
  • There are total 10 increments through which the motors move and draw the edges. The motor D is moved through increments of 18 degrees vertically, that helps it reach the maximum of 270 degrees of character height in 10 increments. While motor C is moved through increments of 5 degrees that will help it reach 45 degrees horizontally, when it is at the character height. A similar principle is applied when the downward slanting edge is drawn. This exercise brings us from point A to B to C   
  • Now it is the time to draw the horizontal middle line of the letter A. But before jumping into drawing the line, we have to know where we are, with respect to the entire drawing of letter A. We are at point C. At this point we have to lift the pen, by rotating the motor through 360 degrees. We lift the pen so that nothing gets printed unless we want it
  • We then bring the pen at the position M, by rotating the motor C horizontally through an angle begin + 90 - 68. Also we need to rotate the motor D vertically by 180 to reach the point M
  • Now rotate the motor A through 160 degrees, to get the pen in contact with the paper. Then rotate the motor C horizontally through an angle begin + 90 - 23. This will bring the pen at position N. 
  • The next steps are to wrap up the printing of the character, by brining the pen from position N to position C.  
    • Lift the pen up by rotating the motor A through 360 degrees
    • Rotate the motor C through begin + 90 degrees and motor D through 90 degrees to reach the point C. With respect to point C, the next character will be drawn. 
For us, it was a lot of joy to work on this printer. Hope you will also enjoy reading the article and also building it. 


Monday 7 May 2018

Our Pet Spik3r

Below is a story of our pet Spik3r, which we have captured in the form of a small video clip. Our Spik3r was moving on as usual and we were about to give it some food (the bug). However, our Spik3r sensed some danger at that point of time and shot the bug. It started running backwards and stopped after some time. Enjoy the visual. (The Java program is also shared along with the visual).

Based on the mechanical assembly of the Spik3r, the large motor D is used to drive the robot forward. Another large motor A, is used to implement the sting. While the medium motor is used to implement the claw to catch the food (the bugs). The IR sensor is mounted on the front part of the robot in order to sense the existence of any danger. 

The program to drive the robot Spik3r consists of a single class, Spik3r2. It has a main method, which initializes all the three motors and the IR sensor in Distance mode. When the ESCAPE button is un-pressed and the IR Sensor does not find any object (danger) in front of it in a range of 20 cm, the robot keeps moving forward with the large motor D (which rotates with a speed of 400 degrees per seconds) and it also keeps moving its claw to catch the bug. The claw movement is done by rotating the medium motor through 220 to -220 degrees. The IR Sensor distance samples are fetched continuously while moving forward.  

If the robot locates a danger (our hand which is placing the bug in front of the robot) in less than 20 cm distance, it starts running backwards with a speed of 990 degrees per seconds. While running backwards, it stings the dangerous object (in the case of Spiker, it shoots a ball towards the dangerous object). The sting is caused by setting the large motor A at a speed of 640 degrees per second and rotating it through 600 degrees. The IR Sensor keeps fetching the Distance samples and as soon as the dangerous object goes out of sight, the robot starts moving forward again (unfortunately this forward movement at a later stage has not gotten captured in the video).