www.cavefischer.at/Sharp Pocket Computer


Drucken am SHARP Thermodrucker CE-125 mit Arduino UNO


Dieses Arduino Programm druckt mit einem Arduino UNO am Sharp Thermodrucker CE-125.


Pinbelegung
Arduino UNO Pin Name Sharp CE-125
11-pol. Stecker
GND GND Pin 3
D9 (Output) Busy (FO1) Pin 4
D8 (Output) Dout (FO2) Pin 5
D4 (Input) ACK  (IB7) Pin 9
D3 (Output) SEL2 (IB6) Pin 10
D2 (Output) SEL1 (IB5) Pin 11


// Print to Sharp CE-125

const int OUT_SEL1 = 2; // Pin D2, SEL1, pin 11 CE-125
const int OUT_SEL2 = 3; // Pin D3, SEL2, pin 10 CE-125
const int IN_ACK   = 4; // Pin D4, ACK,  pin  9 CE-125
const int OUT_Dout = 8; // Pin D8, Dout, pin  5 CE-125
const int OUT_Busy = 9; // Pin D9, Busy, pin  4 CE-125
const int InfoLED = 13;
boolean ACK;
int DataBit;
long Timeout;
int i;
byte SharpString[] = {byte('H'),  //  1
                      byte('E'),  //  2
                      byte('L'),  //  3
                      byte('L'),  //  4
                      byte('O'),  //  5
                      byte(' '),  //  6
                      byte('W'),  //  7
                      byte('O'),  //  8
                      byte('R'),  //  9
                      byte('L'),  // 10
                      byte('D'),  // 11
                      byte(' '),  // 12
                      byte(' '),  // 13
                      byte(' '),  // 14
                      byte(' '),  // 15
                      byte(' '),  // 16
                      byte(' '),  // 17
                      byte(' '),  // 18
                      byte(' '),  // 19
                      byte(' '),  // 20
                      byte(' '),  // 21
                      byte(' '),  // 22
                      byte(' '),  // 23
                      byte('*')}; // 24


void setup() {
  pinMode(IN_ACK, INPUT);
  pinMode(OUT_Dout, OUTPUT);
  pinMode(OUT_Busy, OUTPUT);
  pinMode(OUT_SEL1, OUTPUT);
  pinMode(OUT_SEL2, OUTPUT);
  pinMode(InfoLED, OUTPUT);
  // Example 1, The array must always contain 24 bytes!
  printLine(SharpString);
  // Example 2
  printLine("ABCDEFGHIJKLMNOPQRSTUVWX");
  // Example 3
  strcpy(SharpString, "This are twentyfour byte");
  printLine(SharpString);
} // End setup


void loop() {
} // End loop


void printLine(char aLineStr[]) {
  digitalWrite(InfoLED, HIGH);
  selectPrinter();
  delayMicroseconds(5000);
  digitalWrite(OUT_SEL2, HIGH);
  for(int y=0; y<24; y++){
    printByte(aLineStr[y]);
  }
  printByte(13);
  delayMicroseconds(1000);
  digitalWrite(OUT_SEL2, LOW);
  delay(500);
  digitalWrite(InfoLED, LOW);
  delay(500);
} // End printLine


void printByte(int aDataByte) {
  i = 0;
  do {
    DataBit = aDataByte & (1 << i);
    digitalWrite(OUT_Dout, DataBit);
    digitalWrite(OUT_Busy, HIGH);
    Timeout = millis();
    do {
      ACK = digitalRead(IN_ACK);
      if (millis() - Timeout > 50) break;
    } while (!ACK);
    delayMicroseconds(500);
    digitalWrite(OUT_Busy, LOW);
    Timeout = millis();
    do {
      ACK = digitalRead(IN_ACK);
      if (millis() - Timeout > 50) break;
    } while (ACK);
    delayMicroseconds(500);
    i++;
  } while (i < 8);
} // End printByte


void selectPrinter() {
  digitalWrite(OUT_SEL1, HIGH);
  digitalWrite(OUT_SEL2, HIGH);
  delayMicroseconds(1000);
  digitalWrite(OUT_SEL1, LOW);
  Timeout = millis();
  do {
    ACK = digitalRead(IN_ACK);
    if (millis() - Timeout > 50) break;
  } while (!ACK);
  Timeout = millis();
  do {
    ACK = digitalRead(IN_ACK);
    if (millis() - Timeout > 50) break;
  } while (ACK);
  delayMicroseconds(1000);
  digitalWrite(OUT_SEL2, LOW);
} // End selectPrinter


zum Seitenanfang

© 2018-2020: Walter Fischer