Memorial day is 05/25/2015 – Orders will ship out on May 26th. There will not be any deliveries or shipping on Monday. Any order placed after 11am ET on Friday May 22nd will not start to ship out until Tuesday May 26th.

Arduino Mega ADK+Ethernet Shield+CNC Machine!!
Moderators: adafruit_support_bill, adafruit

Arduino Mega ADK+Ethernet Shield+CNC Machine!!

by faysalkahen on Thu Jan 24, 2013 5:10 am

Hello fellows.

I'm really having a problem controlling 3D of a CNC machine through arduino ethernet shield. I wrote a simple program to control it without any webserver/webclient coding and shown below and all went smoothly:

[Edit - moderator - please use the 'code' button when submitting code]

Code: Select all | TOGGLE FULL SIZE
int ms2pin1 = 26;
 int enablepin1 = 27;
 int ms1pin1 = 24;
 int sleeppin1 = 25;
 int steppin1 = 22;
 int dirpin1 = 23;
 int dirpin2 = 32;
 int steppin2 = 33;
 int ms2pin2 = 30;
 int enablepin2 = 31;
 int ms1pin2 = 29;
 int sleeppin2 = 28;
 int dirpin3 = 34;
 int steppin3 = 35;
 int ms2pin3 = 39;
 int enablepin3 = 38;
 int ms1pin3 = 36;
 int sleeppin3 = 37;
 void setup() {
 Serial.begin(9600);
 
 pinMode(dirpin1, OUTPUT);
 pinMode(steppin1, OUTPUT);
 pinMode(ms2pin1, OUTPUT);
 pinMode(enablepin1, OUTPUT);
 pinMode(ms1pin1, OUTPUT);
 pinMode(sleeppin1, OUTPUT);
 pinMode(dirpin2, OUTPUT);
 pinMode(steppin2, OUTPUT);
 pinMode(ms2pin2, OUTPUT);
 pinMode(enablepin2, OUTPUT);
 pinMode(ms1pin2, OUTPUT);
 pinMode(sleeppin2, OUTPUT);
  pinMode(dirpin3, OUTPUT);
 pinMode(steppin3, OUTPUT);
 pinMode(ms2pin3, OUTPUT);
 pinMode(enablepin3, OUTPUT);
 pinMode(ms1pin3, OUTPUT);
 pinMode(sleeppin3, OUTPUT);
 
 digitalWrite(enablepin1, LOW);    // enable easy driver
 digitalWrite(sleeppin1, HIGH);    // easy driver operating
 digitalWrite(ms1pin1, HIGH);    // microstepping disabled
 digitalWrite(ms2pin1, HIGH);    // microstepping disabled
 digitalWrite(enablepin2, LOW);    // enable easy driver
 digitalWrite(sleeppin2, HIGH);    // easy driver operating
 digitalWrite(ms1pin2, HIGH);    // microstepping disabled
 digitalWrite(ms2pin2, HIGH);    // microstepping disabled
  digitalWrite(enablepin3, LOW);    // enable easy driver
 digitalWrite(sleeppin3, HIGH);    // easy driver operating
 digitalWrite(ms1pin3, HIGH);    // microstepping disabled
 digitalWrite(ms2pin3, HIGH);    // microstepping disabled
 }
 
 void loop ()
 {
   int i;
   
 digitalWrite(dirpin1,LOW);
   delay(1000);
   
   Serial.println("Forward");
   for (i=0; i<10000; i++)
   {
   digitalWrite(steppin1, HIGH);
   delayMicroseconds(500);
   digitalWrite(steppin1, LOW);
   delayMicroseconds(500);
   }
digitalWrite(dirpin3,LOW);
   delay(1000);
   
   Serial.println("Forward");
   for (i=0; i<5000; i++)
   {
   digitalWrite(steppin3, HIGH);
   delayMicroseconds(500);
   digitalWrite(steppin3, LOW);
   delayMicroseconds(500);
   
 }
 digitalWrite(dirpin2,HIGH);
   delay(1000);
   
   Serial.println("Down");
   for (i=0; i<15000; i++)
   {
   digitalWrite(steppin2, HIGH);
   delayMicroseconds(500);
   digitalWrite(steppin2, LOW);
   delayMicroseconds(500);
   
 }
 digitalWrite(dirpin1,LOW);
  digitalWrite(dirpin2,LOW);
  digitalWrite(dirpin3,LOW);
   delay(1000);
   
   Serial.println("Forward & Upp");
   for (i=0; i<10000; i++)
   {
   digitalWrite(steppin1, HIGH);
   delayMicroseconds(500);
    digitalWrite(steppin2, HIGH);
   delayMicroseconds(500);
      digitalWrite(steppin3, HIGH);
   delayMicroseconds(500);
   digitalWrite(steppin1, LOW);
   delayMicroseconds(500);
    digitalWrite(steppin2, LOW);
   delayMicroseconds(500);
      digitalWrite(steppin3, HIGH);
   delayMicroseconds(500);
   }
   digitalWrite(dirpin1,HIGH);
   delay(1000);
   
   Serial.println("Reverse");
   for (i=0; i<10000; i++)
   {
   digitalWrite(steppin1, HIGH);
   delayMicroseconds(500);
   digitalWrite(steppin1, LOW);
   delayMicroseconds(500);
   }
     digitalWrite(dirpin3,HIGH);
   delay(1000);
   
   Serial.println("Reverse");
   for (i=0; i<10000; i++)
   {
   digitalWrite(steppin3, HIGH);
   delayMicroseconds(500);
   digitalWrite(steppin3, LOW);
   delayMicroseconds(500);
   }
   digitalWrite(dirpin2,HIGH);
   delay(1000);
   
   Serial.println("Down");
   for (i=0; i<10000; i++)
   {
   digitalWrite(steppin2, HIGH);
   delayMicroseconds(500);
   digitalWrite(steppin2, LOW);
   delayMicroseconds(500); 
 }
 digitalWrite(dirpin1,HIGH);
   delay(1000);
   
   Serial.println("Reverse");
   for (i=0; i<10000; i++)
   {
   digitalWrite(steppin1, HIGH);
   delayMicroseconds(500);
   digitalWrite(steppin1, LOW);
   delayMicroseconds(500);
   }
 }


but when it comes to adding webserver coding to this one in order to controll it online..i'm having a big problem... So could someone suggest some help/guidance. Thanks
faysalkahen
 
Posts: 1
Joined: Thu Jan 24, 2013 5:02 am