Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Messuhren mit dem PC auslesen

Absolute-System mit RB6-Datenausgang.
(Genauigkeit 2 um, Ablesung 0,001 mm).
Digitale Messuhren ( Messschieber, Dickenmessgeräte …) haben häufig eine Datenschnittstelle. Diese Datenschnittstelle wird entweder an extra dafür vorgesehene externe Hardware angeschlossen, um Messwerte auszulesen oder mit einem Datenkabel und entsprechender Software (meist nur für Windows verfügbar) mit dem PC verbunden. Diese Lösungen sind einerseits recht teuer (80€-300€), und anderseits für die eigentliche Weiterverarbeitung äußerst unpraktisch, so dass sich meist der Kauf dieser Extrakomponenten für Hobbyisten nicht lohnt. Hier zeigen wir, wie Hardwarekomponenten, die nur wenige Euro kosten, mit Messuhren, die über eine serielle Schnittstelle (Digimatic Protokoll) verfügen, kommunizieren können. Praktisch setzen wir das in unserer CNC-Fräse ein, die mit LINUXCNC gesteuert wird. Es wären aber auch Roboterprojekte denkbar, in denen mit wenig Aufwand genaue Messungen durchgeführt werden könnten.
Übersicht
Hardware
Software
Details
Hardware
Schaltplan
Arduino Prototyp Entwicklung
Arduino mit Messadapter
Fertiges Elektronikgehäuse
Software
Digimatic-Protokoll
Arduino Testprogramm
Messsoftware
- | Arduino
/* minimal solution - reading gauge indicator (here a device from Absolute-System) @author torsten roehl */ /* ADJUST AREA START */ /* pin configuration */ int pinREQ = 5; int pinDATA = 2; int pinCLK = 3; /* baudrate */ int bd = 9600; /* ADJUST AREA END */ /* Keep FIXED! - data protocol format */ byte digits[13]; /* serial communication protocol */ byte cmd; const byte PROTOCOL_REQ = 55; void setup() { /* SERIAL_8N1 (the default) */ Serial.begin(bd); pinMode(pinREQ, OUTPUT); pinMode(pinCLK, INPUT_PULLUP); pinMode(pinDATA, INPUT_PULLUP); digitalWrite(pinREQ, LOW); // set request at high } void loop() { if (Serial.available() > 0) { cmd = Serial.read(); switch (cmd) { case PROTOCOL_REQ: readDialGauge(); send(); break; } } } /* Read the dial gauge. After a call to this function the array digits[13] contains all data according to the data protocol. For normal data reading the first four digits should be all 'F', the function returns false, if this is not the case. */ boolean readDialGauge() { /** Generate request by making REQ active (low level)! */ digitalWrite(pinREQ, HIGH); // generate set request /* read 13 nibble (52 bit) */ for (int i = 0; i < 13; i++ ) { int digit = 0; for (int j = 0; j < 4; j++) { while ( digitalRead(pinCLK) == LOW) {}/* Wait for CLOCK=HIGH */ while ( digitalRead(pinCLK) == HIGH) {} /* Wait for CLOCK=LOW */ bitWrite(digit, j /*pos*/, (digitalRead(pinDATA) & 0x1)); } digits[i] = digit; } digitalWrite(pinREQ, LOW); /* d1-d4 should be all oxF */ int header = digits[0] + digits[1] + digits[2] + digits[3]; return header == 60 ? true : false; } /* This function sends 13 bytes via the serial interface. The method sends the whole digimatic protocol for client side processing purposes. */ void send() { for (int i = 0; i < 13; i++ ) { Serial.write(digits[i] ); } }