Jump to: navigation, search

Talk:RepRap Mendel i2

Revision as of 18:40, 14 December 2012 by Zeptomoon (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Talk:RepRap Mendel i2

This is the test software, that I used on the Gen7 1.4 electronics. It worked well when uploading with the parallel port ISP adapter. Maybe we can open a repository at code.labaki.gr? Otherwise I will ask Traumflug, if he wants to add it to his trunk.

/*****************************************************************************
  Gen7 1.4 test

  Reacts to simple serial port commands at 57600 bps.
 
  Type:
  1 -> Blink LED on pin D13 (LED on most Arduinos)
  2 -> Blink hot bed heater for 1 second. (!This needs 12V!)
  3 -> Blink extruder tip heater for 1 second. (!This needs 12V!)
  4 -> Turn on ATX PSU 12V supply.
  5 -> Turn off ATX PSU 12V supply. (Leaves only 5V standby.)

                  +--------\/--------+
 INT8 (D 0) PB0  1|> Xmin  Temp_Bed {|40 PA0 (AI 8 / D31)
 INT1 (D 1) PB1  2|> Ymin  Temp_Ext {|39 PA1 (AI 1 / D30)
 INT2 (D 2) PB2  3|> Zmin     Xstep >|38 PA2 (AI 2 / D29)
  PWM (D 3) PB3  4|< Heat_Bed Xdir  >|37 PA3 (AI 3 / D28)
  PWM (D 4) PB4  5|< Heat_Ext Ystep >|36 PA4 (AI 4 / D27)
 MOSI (D 5) PB5  6|           Ydir  >|35 PA5 (AI 5 / D26)
 MIS0 (D 6) PB6  7|           MotEn >|34 PA6 (AI 6 / D25)
  SCK (D 7) PB7  8|                  |33 PA7 (AI 7 / D24)
            RST  9|                  |32 AREF
            VCC 10|                  |31 GND
            GND 11|                  |30 AVCC
          XTAL2 12|           Zstep >|29 PC7 (D 23)
          XTAL1 13|           Zdir  >|28 PC6 (D 22)
 RX0 (D 8)  PD0 14|                  |27 PC5 (D 21) TDI
 TX0 (D 9)  PD1 15|                  |26 PC4 (D 20) TDO
 RX1 (D 10) PD2 16|           Estep >|25 PC3 (D 19) TMS
 TX1 (D 11) PD3 17|           Edir  >|24 PC2 (D 18) TCK
 PWM (D 12) PD4 18|                  |23 PC1 (D 17) SDA
 PWM (D 13) PD5 19|                  |22 PC0 (D 16) SCL
 PWM (D 14) PD6 20|           PwrEn >|21 PD7 (D 15) PWM
                  +------------------+

*****************************************************************************/


// Pin 13 has a LED connected on most Arduino boards.
int LED   = 13;
int HtXtr = 14;
int PwrEn = 15;
int HtBed = 3;
int HtTip = 4;
int inByte;

void waitForInput() {
 Serial.print("Waiting...");   // send text
 while (Serial.available() <= 0) {
   Serial.print('.');   // send a dots
   delay(300);
 }
}

// the setup routine runs once when you press reset:
void setup() {
  // initialize the digital pin as an output.
  pinMode(LED, OUTPUT);       //  D 13 LED
  pinMode(HtXtr, OUTPUT);     // HtXtr Extra heater
  pinMode(HtBed, OUTPUT);     // HtBed Hot bed heater
  pinMode(HtTip, OUTPUT);     // HtTip Extruder tip heater
  pinMode(PwrEn, OUTPUT);     // PwrEn PSU
  digitalWrite(PwrEn, HIGH);  // turn the PSU *off* (low-active)
  Serial.begin(57600);        // start using RX/TX at 57.6kbps 
}

// the loop routine runs over and over again forever:
void loop() {
  waitForInput();
  if (Serial.available() > 0) {
    // get incoming byte:
    inByte = Serial.read();
    Serial.println(inByte);

    if (inByte == 49) { // received '1'  -> blink led
      Serial.println("BLINK");
      digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);               // wait for a second
      digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    } // endif

    if (inByte == 50) { // received '2'  -> blink hot bed
      Serial.println("Hot bed");
      digitalWrite(HtBed, HIGH);
      delay(1000);               // wait for a second
      digitalWrite(HtBed, LOW);
    } // endif

    if (inByte == 51) { // received '3'  -> blink extruder heater
      Serial.println("Extruder");
      digitalWrite(HtTip, HIGH);
      delay(1000);               // wait for a second
      digitalWrite(HtTip, LOW);
    } // endif

    if (inByte == 52) { // received '4'  -> turn on power supply
      Serial.println("PSU on");
      digitalWrite(15, LOW);   // turn the PSU *ON* (LOW is the voltage level / low-active!)
    } // endif

    if (inByte == 53) { // received '5'  -> turn OFF power supply
      Serial.println("PSU off");
      digitalWrite(15, HIGH);   // turn the PSU *off*
    } // endif

  } // endif Serial.available()

  if (Serial.available() > 0) {
    inByte = Serial.read();     // clear read buffer
  }

} // end main loop