How to make homework machine for students

How to make homework machine for students

 

homework machine is a Computerized Numerical Control(CNC) machine which can run through G-code.
G-code is a programming language for CNC that instructs machines where and how to move.
The G-code is based on image file, you can put a image file in Inkscape software and convert it to CNC language.
If you are using a complicate image file then you must draw an outline with the image and put it to the Inkscape.
The machine also writes the latter but only in g-code, you have to convert the latter into G-code.

Required Materials

Arduino Nano 328p
L293D IC
Servo Motor 9g

2X DVD Drive

Male & Female headers

Power supply Connector

Wire

Pen etc.

PROCEDURE

STEP1

Making

 

First of all you need two Standard PC OLD DVD DRIVE, The DVD drive must has 4 wire stepper motor(you can’t do this with normal DVD drive which has two wire DC motor)

Now Unscrew the DVD drive and pick out the lens slider, slider rod and Stepper motor.

Now you need to check the stepper motor is working or not, it’s an easy method , mainly stepper motor has two coils and one coil has two ends so respectively two wire has four ends so the upper side of stepper motor has 4 connection point and it connects to the two coils internally. Now you have to point out your A1B1A2B2 connections by following this image

Now you need to take your multi-meter in continuity point and check 4 wire point if stepper motor coil is in good condition then the multi-meter will buzzing two wires.

 

 

Now you have to cut the lens mount for make the slider more compact for this project, you can super glue the both cutting pars and put slider rods in the hole.

 

 

Now you cut the 2mm ACP(Aluminum Composite panel) sheet or 3mm acrylic sheet by follow the Stepper motor and Slider rod size.

 

 

You have to attach the stepper motor on the ACP sheet and screw or glue it.

 

 

Now you glue the DIY compact slider on this frame then your X-Axis Slider is ready, Now you have to do this same procedure for Y-Axis with second DVD drive.

When both axis is ready you can attach the Y-axis over the X-axis and align the axis 90 degree.

 

 

STEP2

Making Pen Mechanism

It’s most revolutionary mechanism ever,
Required Materials-
Normal DVD drive ROD
One Lens Mount
One Pen
Copper Wire

Take the 3mm Rod and spiral the copper wire to make it like a spring or you can use a pen spring, now insert the rod in the cutting Lens mount and Screw the cutting pen Cap and add a enlightenment part (I made it through ACP sheet) because it hold the pen in one position, Now you can attach the servo motor

 

 

Now you have to glue the pen mechanism to the Y-axis

 

 

STEP3

Making Circuit

 

Now you Make the circuit by Following the Circuit Diagram

 

 

Warning– You have to the circuit by following the circuit diagram wiring connection using your multi-meter in continuity Mode.

 

 

Now attach you circuit on the machine and make connections(X-axis,Y-axis,Servo)

 

 

STEP4

Programming

 

Connect your Arduino to your computer and Open Arduino IDE,

 

 

First You have to choose the Board type Arduino Nano
Select communication port,Select Processor-> Atmega328P and Upload this Arduino nano

 

 

*If you are facing any issue with com_port or problem uploading to board

SOLUTIONS –
*You must have Windows10 for better driver Support(com_port issue) or update your USB driver through Device Manager
*Choose processor type Atmega328p t0 Atmega328p old boot-loader
*Remove your Arduino from the circuit and upload the code (L293D driver make create issue during uploading the code so remove the Arduino and upload)

 

 

#include <Servo.h>
#include <Stepper.h>

#define LINE_BUFFER_LENGTH 512

const int penZUp = 80;
const int penZDown = 40;

const int penServoPin = 6;

const int stepsPerRevolution = 20; 

Servo penServo;  

Stepper myStepperY(stepsPerRevolution, 2,3,4,5);            
Stepper myStepperX(stepsPerRevolution, 8,9,10,11);  

struct point { 
  float x; 
  float y; 
  float z; 
};

struct point actuatorPos;

float StepInc = 1;
int StepDelay = 0;
int LineDelay = 50;
int penDelay = 50;

float StepsPerMillimeterX = 6.0;
float StepsPerMillimeterY = 6.0;

float Xmin = 0;
float Xmax = 40;
float Ymin = 0;
float Ymax = 40;
float Zmin = 0;
float Zmax = 1;

float Xpos = Xmin;
float Ypos = Ymin;
float Zpos = Zmax; 

boolean verbose = false;

void setup() {
  Serial.begin( 9600 );
  
  penServo.attach(penServoPin);
  penServo.write(penZUp);
  delay(200);

  myStepperX.setSpeed(250);
  myStepperY.setSpeed(250);  

  Serial.println("Mini CNC Plotter alive and kicking!");
  Serial.print("X range is from "); 
  Serial.print(Xmin); 
  Serial.print(" to "); 
  Serial.print(Xmax); 
  Serial.println(" mm."); 
  Serial.print("Y range is from "); 
  Serial.print(Ymin); 
  Serial.print(" to "); 
  Serial.print(Ymax); 
  Serial.println(" mm."); 
}

void loop() 
{
  delay(200);
  char line[ LINE_BUFFER_LENGTH ];
  char c;
  int lineIndex;
  bool lineIsComment, lineSemiColon;

  lineIndex = 0;
  lineSemiColon = false;
  lineIsComment = false;

  while (1) {

    while ( Serial.available()>0 ) {
      c = Serial.read();
      if (( c == '\n') || (c == '\r') ) {             
        if ( lineIndex > 0 ) {                        
          line[ lineIndex ] = '\0';                   
          if (verbose) { 
            Serial.print( "Received : "); 
            Serial.println( line ); 
          }
          processIncomingLine( line, lineIndex );
          lineIndex = 0;
        } 
        else { 
          
        }
        lineIsComment = false;
        lineSemiColon = false;
        Serial.println("ok");    
      } 
      else {
        if ( (lineIsComment) || (lineSemiColon) ) {   // Throw away all comment characters
          if ( c == ')' )  lineIsComment = false;     // End of comment. Resume line.
        } 
        else {
          if ( c <= ' ' ) {                           // Throw away whitepace and control characters
          } 
          else if ( c == '/' ) {                    // Block delete not supported. Ignore character.
          } 
          else if ( c == '(' ) {                    // Enable comments flag and ignore all characters until ')' or EOL.
            lineIsComment = true;
          } 
          else if ( c == ';' ) {
            lineSemiColon = true;
          } 
          else if ( lineIndex >= LINE_BUFFER_LENGTH-1 ) {
            Serial.println( "ERROR - lineBuffer overflow" );
            lineIsComment = false;
            lineSemiColon = false;
          } 
          else if ( c >= 'a' && c <= 'z' ) {        // Upcase lowercase
            line[ lineIndex++ ] = c-'a'+'A';
          } 
          else {
            line[ lineIndex++ ] = c;
          }
        }
      }
    }
  }
}

void processIncomingLine( char* line, int charNB ) {
  int currentIndex = 0;
  char buffer[ 64 ];                                 // Hope that 64 is enough for 1 parameter
  struct point newPos;

  newPos.x = 0.0;
  newPos.y = 0.0;

  //  Needs to interpret 
  //  G1 for moving
  //  G4 P300 (wait 150ms)
  //  G1 X60 Y30
  //  G1 X30 Y50
  //  M300 S30 (pen down)
  //  M300 S50 (pen up)
  //  Discard anything with a (
  //  Discard any other command!

  while( currentIndex < charNB ) {
    switch ( line[ currentIndex++ ] ) {              // Select command, if any
    case 'U':
      penUp(); 
      break;
    case 'D':
      penDown(); 
      break;
    case 'G':
      buffer[0] = line[ currentIndex++ ];          // /!\ Dirty - Only works with 2 digit commands
      //      buffer[1] = line[ currentIndex++ ];
      //      buffer[2] = '\0';
      buffer[1] = '\0';

      switch ( atoi( buffer ) ){                   // Select G command
      case 0:                                   // G00 & G01 - Movement or fast movement. Same here
      case 1:
        // /!\ Dirty - Suppose that X is before Y
        char* indexX = strchr( line+currentIndex, 'X' );  // Get X/Y position in the string (if any)
        char* indexY = strchr( line+currentIndex, 'Y' );
        if ( indexY <= 0 ) {
          newPos.x = atof( indexX + 1); 
          newPos.y = actuatorPos.y;
        } 
        else if ( indexX <= 0 ) {
          newPos.y = atof( indexY + 1);
          newPos.x = actuatorPos.x;
        } 
        else {
          newPos.y = atof( indexY + 1);
          indexY = '\0';
          newPos.x = atof( indexX + 1);
        }
        drawLine(newPos.x, newPos.y );
        //        Serial.println("ok");
        actuatorPos.x = newPos.x;
        actuatorPos.y = newPos.y;
        break;
      }
      break;
    case 'M':
      buffer[0] = line[ currentIndex++ ];        // /!\ Dirty - Only works with 3 digit commands
      buffer[1] = line[ currentIndex++ ];
      buffer[2] = line[ currentIndex++ ];
      buffer[3] = '\0';
      switch ( atoi( buffer ) ){
      case 300:
        {
          char* indexS = strchr( line+currentIndex, 'S' );
          float Spos = atof( indexS + 1);
          //          Serial.println("ok");
          if (Spos == 30) { 
            penDown(); 
          }
          if (Spos == 50) { 
            penUp(); 
          }
          break;
        }
      case 114:                                // M114 - Repport position
        Serial.print( "Absolute position : X = " );
        Serial.print( actuatorPos.x );
        Serial.print( "  -  Y = " );
        Serial.println( actuatorPos.y );
        break;
      default:
        Serial.print( "Command not recognized : M");
        Serial.println( buffer );
      }
    }
  }



}



void drawLine(float x1, float y1) {

  if (verbose)
  {
    Serial.print("fx1, fy1: ");
    Serial.print(x1);
    Serial.print(",");
    Serial.print(y1);
    Serial.println("");
  }  

  
  if (x1 >= Xmax) { 
    x1 = Xmax; 
  }
  if (x1 <= Xmin) { 
    x1 = Xmin; 
  }
  if (y1 >= Ymax) { 
    y1 = Ymax; 
  }
  if (y1 <= Ymin) { 
    y1 = Ymin; 
  }

  if (verbose)
  {
    Serial.print("Xpos, Ypos: ");
    Serial.print(Xpos);
    Serial.print(",");
    Serial.print(Ypos);
    Serial.println("");
  }

  if (verbose)
  {
    Serial.print("x1, y1: ");
    Serial.print(x1);
    Serial.print(",");
    Serial.print(y1);
    Serial.println("");
  }

  //  Convert coordinates to steps
  x1 = (int)(x1*StepsPerMillimeterX);
  y1 = (int)(y1*StepsPerMillimeterY);
  float x0 = Xpos;
  float y0 = Ypos;

  //  Let's find out the change for the coordinates
  long dx = abs(x1-x0);
  long dy = abs(y1-y0);
  int sx = x0<x1 ? StepInc : -StepInc;
  int sy = y0<y1 ? StepInc : -StepInc;

  long i;
  long over = 0;

  if (dx > dy) {
    for (i=0; i<dx; ++i) {
      myStepperX.step(sx);
      over+=dy;
      if (over>=dx) {
        over-=dx;
        myStepperY.step(sy);
      }
      delay(StepDelay);
    }
  }
  else {
    for (i=0; i<dy; ++i) {
      myStepperY.step(sy);
      over+=dx;
      if (over>=dy) {
        over-=dy;
        myStepperX.step(sx);
      }
      delay(StepDelay);
    }    
  }

  if (verbose)
  {
    Serial.print("dx, dy:");
    Serial.print(dx);
    Serial.print(",");
    Serial.print(dy);
    Serial.println("");
  }

  if (verbose)
  {
    Serial.print("Going to (");
    Serial.print(x0);
    Serial.print(",");
    Serial.print(y0);
    Serial.println(")");
  }

  
  delay(LineDelay);
  
  Xpos = x1;
  Ypos = y1;
}


void penUp() { 
  penServo.write(penZUp); 
  delay(LineDelay); 
  Zpos=Zmax; 
  if (verbose) { 
    Serial.println("Pen up!"); 
  } 
}
void penDown() { 
  penServo.write(penZDown); 
  delay(LineDelay); 
  Zpos=Zmin; 
  if (verbose) { 
    Serial.println("Pen down."); 
  } 
}

 

 

 

STEP5

Run Your Machine

 

External power supply- you have to give 5V @ 0.5amp to the circuit board for proper work.

 

Open Processing and copy paste the code from here, Now Run the Code, it will popup a window for all controls

 

Processing Software

 

 

Copy paste the code from here

 

import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;
import processing.serial.*;

Serial port = null;

// select and modify the appropriate line for your operating system
// leave as null to use interactive port (press 'p' in the program)
String portname = null;
//String portname = Serial.list()[0]; // Mac OS X
//String portname = "/dev/ttyUSB0"; // Linux
//String portname = "COM6"; // Windows

boolean streaming = false;
float speed = 0.001;
String[] gcode;
int i = 0;

void openSerialPort()
{
  if (portname == null) return;
  if (port != null) port.stop();
  
  port = new Serial(this, portname, 9600);
  
  port.bufferUntil('\n');
}

void selectSerialPort()
{
  String result = (String) JOptionPane.showInputDialog(frame,
    "Select the serial port that corresponds to your Arduino board.",
    "Select serial port",
    JOptionPane.QUESTION_MESSAGE,
    null,
    Serial.list(),
    0);
    
  if (result != null) {
    portname = result;
    openSerialPort();
  }
}

void setup()
{
  size(600, 400);
  openSerialPort();
}

void draw()
{
  background(155);  
  fill(0);
  int y = 24, dy = 12;
  text("INSTRUCTIONS", 12, y); y += dy;
  text("p: select serial port", 12, y); y += dy;
  text("1: set speed to 0.001 inches (1 mil) per jog", 12, y); y += dy;
  text("2: set speed to 0.010 inches (10 mil) per jog", 12, y); y += dy;
  text("3: set speed to 0.100 inches (100 mil) per jog", 12, y); y += dy;
  text("arrow keys: jog in x-y plane", 12, y); y += dy;
  text("page up & page down: jog in z axis", 12, y); y += dy;
  text("$: display grbl settings", 12, y); y+= dy;
  text("h: go home", 12, y); y += dy;
  text("0: zero machine (set home to the current location)", 12, y); y += dy;
  text("g: stream a g-code file", 12, y); y += dy;
  text("x: stop streaming g-code (this is NOT immediate)", 12, y); y += dy;
  y = height - dy;
  text("current jog speed: " + speed + " inches per step", 12, y); y -= dy;
  text("current serial port: " + portname, 12, y); y -= dy;
}

void keyPressed()
{
  if (key == '1') speed = 0.001;
  if (key == '2') speed = 0.01;
  if (key == '3') speed = 0.1;
  
  if (!streaming) {
    if (keyCode == LEFT) port.write("G91\nG20\nG00 X-" + speed + " Y0.000 Z0.000\n");
    if (keyCode == RIGHT) port.write("G91\nG20\nG00 X" + speed + " Y0.000 Z0.000\n");
    if (keyCode == UP) port.write("G91\nG20\nG00 X0.000 Y" + speed + " Z0.000\n");
    if (keyCode == DOWN) port.write("G91\nG20\nG00 X0.000 Y-" + speed + " Z0.000\n");
    if (keyCode == KeyEvent.VK_PAGE_UP) port.write("G91\nG20\nG00 X0.000 Y0.000 Z" + speed + "\n");
    if (keyCode == KeyEvent.VK_PAGE_DOWN) port.write("G91\nG20\nG00 X0.000 Y0.000 Z-" + speed + "\n");
    if (key == 'h') port.write("G90\nG20\nG00 X0.000 Y0.000 Z0.000\n");
    if (key == 'v') port.write("$0=75\n$1=74\n$2=75\n");
    //if (key == 'v') port.write("$0=100\n$1=74\n$2=75\n");
    if (key == 's') port.write("$3=10\n");
    if (key == 'e') port.write("$16=1\n");
    if (key == 'd') port.write("$16=0\n");
    if (key == '0') openSerialPort();
    if (key == 'p') selectSerialPort();
    if (key == '

 

 

 

p:select serial port
1:set speed to 0.001 inches
2:set speed to 0.010 inches
3:set speed to 0.100 inches
$:display grbl settings
h:go home
0:set home to the current location
g:stream a g-code file
x:stop streaming g-code

 

 

 

Now type p

select com_port

Now type g to select g-code file by browsing your file and press enter

 

 

 

Congratulations you made an awesome project.

If you face any problem then comment below.....

 

Thank you so much for watching.....

 

Follow me on

Instagram
Telegram
Facebook

) port.write("$\n"); } if (!streaming && key == 'g') { gcode = null; i = 0; File file = null; println("Loading file..."); selectInput("Select a file to process:", "fileSelected", file); } if (key == 'x') streaming = false; } void fileSelected(File selection) { if (selection == null) { println("Window was closed or the user hit cancel."); } else { println("User selected " + selection.getAbsolutePath()); gcode = loadStrings(selection.getAbsolutePath()); if (gcode == null) return; streaming = true; stream(); } } void stream() { if (!streaming) return; while (true) { if (i == gcode.length) { streaming = false; return; } if (gcode[i].trim().length() == 0) i++; else break; } println(gcode[i]); port.write(gcode[i] + '\n'); i++; } void serialEvent(Serial p) { String s = p.readStringUntil('\n'); println(s.trim()); if (s.trim().startsWith("ok")) stream(); if (s.trim().startsWith("error")) stream(); // XXX: really? }

 

 

 

p:select serial port
1:set speed to 0.001 inches
2:set speed to 0.010 inches
3:set speed to 0.100 inches
$:display grbl settings
h:go home
0:set home to the current location
g:stream a g-code file
x:stop streaming g-code

 

 

 

Now type p

select com_port

Now type g to select g-code file by browsing your file and press enter

 

 

 

Congratulations you made an awesome project.

If you face any problem then comment below…..

 

Thank you so much for watching…..

 

Follow me on

Instagram
Telegram
Facebook

47 Comments

  1. I was curious if you ever thought of changing the page layout of your site?
    Its very well written; I love what youve
    got to say. But maybe you could a little more in the way of content so people could connect with
    it better. Youve got an awful lot of text for only having one or two pictures.
    Maybe you could space it out better?

  2. certainly like your web-site however you have to check the spelling on quite a few of your posts.
    Many of them are rife with spelling problems and I
    in finding it very bothersome to inform the reality
    however I’ll certainly come again again.

  3. You really make it seem so easy with your presentation but I find this topic
    to be really something that I think I would never understand.
    It seems too complicated and very broad for me. I am looking forward for your next post, I’ll try
    to get the hang of it!

  4. You can definitely see your skills in the article you write.

    The world hopes for even more passionate writers such as you who are not afraid to mention how they believe.
    All the time follow your heart.

  5. Hmm is anyone else having problems with the images on this blog loading?
    I’m trying to find out if its a problem on my end or if it’s the blog.
    Any feedback would be greatly appreciated.

  6. First off I would like to say awesome blog! I had a quick question which I’d like to ask if
    you do not mind. I was interested to know how you center yourself and clear your head
    before writing. I have had a tough time clearing my mind in getting my thoughts
    out there. I truly do enjoy writing but it just seems like the first 10
    to 15 minutes are generally lost simply just trying to figure out how to begin. Any suggestions
    or hints? Thank you!

  7. I am extremely impressed together with your writing abilities as neatly as with
    the format in your weblog. Is that this a paid theme or
    did you customize it your self? Either way keep
    up the nice high quality writing, it’s rare to look a great weblog like this one nowadays..

  8. It’s appropriate time to make a few plans for the longer term and it’s time to be happy.
    I have read this publish and if I could I desire to counsel you few attention-grabbing issues or advice.
    Perhaps you could write subsequent articles regarding this article.
    I desire to learn more issues approximately it!

  9. Superb website you have here but I was wanting to know if you knew of any discussion boards that cover the same topics talked about
    in this article? I’d really love to be a part of community
    where I can get suggestions from other knowledgeable individuals that share the same interest.

    If you have any suggestions, please let me
    know. Cheers!

  10. I’m truly enjoying the design and layout of your site. It’s a very easy on the eyes which makes it
    much more pleasant for me to come here and visit more often. Did you hire out a developer to create your theme?
    Excellent work!

  11. I all the time used to study article in news papers
    but now as I am a user of internet thus from now I am using net for articles or reviews, thanks to
    web.

  12. That is very attention-grabbing, You’re an excessively professional blogger.
    I’ve joined your rss feed and sit up for searching for extra
    of your magnificent post. Also, I’ve shared your site in my
    social networks

  13. Can I simply just say what a comfort to find an individual who actually understands what they’re
    talking about on the net. You definitely realize
    how to bring a problem to light and make it important.
    More people ought to read this and understand this side of the story.
    I was surprised that you aren’t more popular since you most certainly possess the gift.

  14. Someone essentially lend a hand to make seriously posts I
    would state. This is the very first time I frequented your web
    page and up to now? I amazed with the research you made to make this actual submit amazing.
    Magnificent task!

  15. On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment so blinded by desire. Excepteur sint occaecat cupidatat non proident. Giralda Hagan Zasuwa

  16. I don’t know whether it’s just me or if everyone else encountering issues
    with your site. It appears as though some of the text in your content are running off the screen. Can somebody else please comment and let me
    know if this is happening to them as well? This may be a issue with my web browser because I’ve had this happen before.
    Thank you

  17. Hi I am so glad I found your webpage, I really found you by accident, while I
    was looking on Askjeeve for something else, Regardless I am here now and would just like to say kudos for a
    tremendous post and a all round enjoyable blog (I also love the theme/design),
    I don’t have time to look over it all at the moment but I have
    bookmarked it and also added your RSS feeds, so when I have time I will be back
    to read a great deal more, Please do keep up the excellent b.

Leave a reply

Please enter your comment!
Please enter your name here

Related Articles