www.cavefischer.at/Sharp Pocket Computer
// Print to Sharp CE-120P
const int OUT_XOUT = 3; // Pin D3, XOUT, pin 7 CE-120P
const int IN_ACK = 14; // Pin D14, ACK, pin 9 CE-120P
const int OUT_Dout = 8; // Pin D8, Dout, pin 5 CE-120P
const int OUT_Busy = 9; // Pin D9, Busy, pin 4 CE-120P
const int InfoLED = 13;
byte myChars[] = {1,2,3,4,5,6,7,9,11,12,0};
void setup() {
pinMode(IN_ACK, INPUT);
pinMode(OUT_Dout, OUTPUT);
pinMode(OUT_Busy, OUTPUT);
pinMode(OUT_XOUT, OUTPUT);
pinMode(InfoLED, OUTPUT);
digitalWrite(InfoLED, HIGH);
delay(1000);
printLine("Hallo Welt");
printLine(myChars); // Zeichensatz 1,2,3,4,5,6,7,9,11,12 drucken
for(int x=0; x<10; x++){ // Zeichensatz von 16 bis 255 drucken
selectPrinter();
for(int y=1; y<25; y++){
printByte(24*x+y+15, false);
}
printByte(13, false);
delay(1500);
printByte(15, false);
}
printLine("Ende");
digitalWrite(InfoLED, LOW);
}
void loop() {
} // End loop
void selectPrinter() {
digitalWrite(OUT_XOUT, HIGH);
printByte(32, true);
digitalWrite(OUT_XOUT, LOW);
delay(30);
} // End selectPrinter
void printLine(char x[]) {
int i = 0;
selectPrinter();
do {
printByte(x[i], false);
i++;
} while (x[i] != 0);
for (int y=0; y<(24-i); i++) {
printByte(32, false);
}
printByte(13, false);
delay(1500);
printByte(15, false);
} // End printLine
void printByte(byte aDataByte, boolean deviceSelect) {
byte i = 0;
do {
boolean DataBit = aDataByte & (1 << i);
digitalWrite(OUT_Dout, DataBit);
if (deviceSelect) {
waitforACK(LOW);
digitalWrite(OUT_Busy, HIGH);
waitforACK(HIGH);
digitalWrite(OUT_Busy, LOW);
}
else {
digitalWrite(OUT_Busy, HIGH);
waitforACK(LOW);
digitalWrite(OUT_Busy, LOW);
waitforACK(HIGH);
}
delayMicroseconds(100);
i++;
} while (i < 8);
delay(2);
} // End printByte
void waitforACK (boolean state) {
boolean ACK;
long Timeout = millis();
do {
ACK = digitalRead(IN_ACK);
if (millis() - Timeout > 50) break;
} while ((ACK==state));
delayMicroseconds(100);
} // End waitforACK
Signalverlauf bei 3 gedruckten Zeilen: |
Signalverlauf Device-Select für 1. Zeile: |
Signalverlauf Device-Select für weitere Zeilen: |
Beispielausdruck den das Programm erzeugt: |
Pinbelegung | ||
---|---|---|
Arduino UNO Pin | Name | Sharp CE-120P 11-pol. Schnittstelle |
GND | GND | Pin 3 |
D3 (Output) | Xout | Pin 7 |
D14 (Input, mit 470k pull-down Widerstand) | ACK | Pin 9 |
D8 (Output) | Dout | Pin 5 |
D9 (Output) | Busy | Pin 4 |