void processController(){

  if(data_received){
     
     switch(received_command){
        case 0x01:
             write_line_enable = 1;
        break;
        
        // home y axis
        case 0x02:
        
          home_y_axis();
          acknowledge();
         
        break;
        
        // home z axis
        case 0x03:

          home_z_axis();
          acknowledge();
       
        break;
        
        // turn laser on
        case 0x04: 
          laser_on();
          acknowledge();
        break;
        
        // turn laser off
        case 0x05:
         laser_off();
         acknowledge();
        break;
        
        // next layer
        case 0x06:
          // moveToNextLayer here!
          moveToNextLayer();
          toggle_y_Direction();
          acknowledge();
        break;
        
        case 0x07:
          moveToNextLayer();
          acknowledge();
        break;
        
        case 0x08:
          move_z_to_end_position();
          acknowledge();
        break;
        
        case 0x09:
          set_exposing_cycles();
          acknowledge();
        break;
        
        case 0x0a:
         move_z_relative();
         acknowledge();
        break;
    }

  }
 
  if (exposing_done){
    
                moveToNextLine();
                data_table[0] = 0;
                write_line_enable = 0;
                exposing_done = 0;
                acknowledge();

  }
  
}
Beispiel #2
0
/**
 * Read the input buffer and find any recognized commands.  One G or M command per line.
 */
void processCommand() {
  // blank lines
  if(buffer[0]==';') return;
  
  long cmd;

  // is there a line number?
  cmd=parsenumber('N',-1);
  if(cmd!=-1 && buffer[0]=='N') {  // line number must appear first on the line
    if( cmd != line_number ) {
      // wrong line number error
      Serial.print(F("BADLINENUM "));
      Serial.println(line_number);
      return;
    }
  
    // is there a checksum?
    if(strchr(buffer,'*')!=0) {
      // yes.  is it valid?
      char checksum=0;
      int c=0;
      while(buffer[c]!='*') checksum ^= buffer[c++];
      c++; // skip *
      int against = strtod(buffer+c,NULL);
      if( checksum != against ) {
        Serial.print(F("BADCHECKSUM "));
        Serial.println(line_number);
        return;
      } 
    } else {
      Serial.print(F("NOCHECKSUM "));
      Serial.println(line_number);
      return;
    }
    
    line_number++;
  }

  cmd = parsenumber('G',-1);
  switch(cmd) {
  case  0: // move linear
  case  1: // move linear
      // Move Linear here
      do_move(parsenumber('Y',0), parsenumber('Z',0), parsenumber('F',30000));
    break;
  case 3:
     delay(parsenumber('D',0));
  break;
  case  4:  
      set_exposing_cycles(parsenumber('E',0));
    break;  // dwell
  case 5:
      fill_laser_buffer(parsedistance('D',0));
    break;
  case 6:
      delay(20);
      expose_line(parsenumber('E',1000));
    break;
  case 7:
       create_test_pattern();
       expose_line(parsenumber('E',50000));
     break;  
  case 29:
      //home z- axis
     home_z_axis();
     break;
  case 30:
     home_y_axis();
     break;
   
  case 28:
      // home all axis
      break;  
  
  case 90:  mode_abs=1;  break;  // absolute mode
  case 91:  mode_abs=0;  break;  // relative mode
  case 92:  // set logical position
      // set position to 0 here
    break;
  default:  break;
  }
  
  // M Code section 
  cmd = parsenumber('M',-1);
  switch(cmd) {
  case 18:  // disable motors
    motors_release();
    break;
  case 19:
     laser_on(); 
    break;
  case 20:
     laser_off();
    break;
  case 21:
    vat_down();
    break;
  case 22:
    vat_up();
    break;
       
    
  case 100:  help();  break;
  case 110:  line_number = parsenumber('N',line_number);  break;
  case 114:  
    // print position here  
  break;
  default:  break;
  }
}