teleskop_steuerung_fuer_c8
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende ÜberarbeitungNächste ÜberarbeitungBeide Seiten der Revision | ||
teleskop_steuerung_fuer_c8 [2019/06/24 09:34] – torsten.roehl | teleskop_steuerung_fuer_c8 [2019/06/24 10:28] – [Bau und Inbetriebnahme der Steuerung] torsten.roehl | ||
---|---|---|---|
Zeile 43: | Zeile 43: | ||
==== Bau und Inbetriebnahme der Steuerung ==== | ==== Bau und Inbetriebnahme der Steuerung ==== | ||
- | === Simulation mit Java === | + | Zuerst wird ein virtuelles |
- | Die grundsätzliche Arbeitsweise kann man auch ohne Elektronik (& | + | Dieses |
- | 1. Virtuelle serielle Schnittstelle erzeugen | ||
- | socat -d -d PTY, | ||
- | 2.Rechte setzen | + | [[virtuelles Java-Teleskop]] |
- | + | ||
- | # chmod 777 / | + | |
- | + | ||
- | 3. Testen | + | |
- | + | ||
- | i) Konsole | + | |
- | + | ||
- | echo ": | + | |
- | + | ||
- | Simulator.java sollte Nachricht anzeigen! | + | |
- | + | ||
- | ii) Stellarium | + | |
- | + | ||
- | lx200 Teleskop einrichten mit / | + | |
- | + | ||
- | + | ||
- | Die Schnittstelle muss häufig neu eingerichtet werden (schritte 1 + 2 ). | + | |
- | + | ||
- | < | + | |
- | package test; | + | |
- | + | ||
- | import com.fazecast.jSerialComm.SerialPort; | + | |
- | + | ||
- | public class Test01 { | + | |
- | + | ||
- | public static void main(String[] args) { | + | |
- | SerialPort comPort = SerialPort.getCommPorts()[2]; | + | |
- | comPort.openPort(); | + | |
- | comPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_SEMI_BLOCKING, | + | |
- | try { | + | |
- | while (true) { | + | |
- | byte[] readBuffer = new byte[1024]; | + | |
- | int numRead = comPort.readBytes(readBuffer, | + | |
- | + | ||
- | if (numRead > 0) { | + | |
- | plot(numRead, | + | |
- | + | ||
- | if(getRADEC(numRead, | + | |
- | System.out.println(" | + | |
- | writeRADEC(comPort); | + | |
- | } | + | |
- | if (isGetRA(numRead, | + | |
- | System.out.println(" | + | |
- | writeRa(comPort); | + | |
- | } | + | |
- | if (isGetDec(numRead, | + | |
- | System.out.println(" | + | |
- | writeDec(comPort); | + | |
- | } | + | |
- | // | + | |
- | } | + | |
- | Thread.sleep(100); | + | |
- | + | ||
- | } | + | |
- | } catch (Exception e) { | + | |
- | e.printStackTrace(); | + | |
- | } | + | |
- | comPort.closePort(); | + | |
- | + | ||
- | } | + | |
- | + | ||
- | static void plot(int numRead, byte[] readBuffer) { | + | |
- | System.out.println(" | + | |
- | + | ||
- | for (int i = 0; i < numRead; i++) { | + | |
- | char c = (char) readBuffer[i]; | + | |
- | System.out.print(c); | + | |
- | } | + | |
- | System.out.println("" | + | |
- | } | + | |
- | static boolean getRADEC(int num, byte[] readBuffer) { | + | |
- | char c[] = new char[num]; | + | |
- | if (readBuffer.length < 1) | + | |
- | return false; | + | |
- | + | ||
- | for (int i = 0; i < num; i++) { | + | |
- | c[i] = (char) readBuffer[i]; | + | |
- | + | ||
- | } | + | |
- | + | ||
- | if (c[0] == ' | + | |
- | return true; | + | |
- | } | + | |
- | + | ||
- | return false; | + | |
- | } | + | |
- | + | ||
- | static void writeRADEC(SerialPort p) { | + | |
- | + | ||
- | String str = " | + | |
- | byte[] buffer = new byte[18]; | + | |
- | byte[] byte_str = str.getBytes(); | + | |
- | for (int i = 0; i < 18; i++) | + | |
- | buffer[i] = byte_str[i]; | + | |
- | + | ||
- | // | + | |
- | // | + | |
- | + | ||
- | p.writeBytes(buffer, | + | |
- | } | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | static boolean isGetRA(int num, byte[] readBuffer) { | + | |
- | char c[] = new char[num]; | + | |
- | if (readBuffer.length < 4) | + | |
- | return false; | + | |
- | + | ||
- | for (int i = 0; i < num; i++) { | + | |
- | c[i] = (char) readBuffer[i]; | + | |
- | + | ||
- | } | + | |
- | + | ||
- | if (c[0] == '#' | + | |
- | return true; | + | |
- | } | + | |
- | + | ||
- | return false; | + | |
- | } | + | |
- | + | ||
- | static boolean isGetDec(int num, byte[] readBuffer) { | + | |
- | char c[] = new char[num]; | + | |
- | if (readBuffer.length < 4) | + | |
- | return false; | + | |
- | + | ||
- | for (int i = 0; i < num; i++) { | + | |
- | c[i] = (char) readBuffer[i]; | + | |
- | + | ||
- | } | + | |
- | + | ||
- | if (c[0] == '#' | + | |
- | return true; | + | |
- | } | + | |
- | + | ||
- | return false; | + | |
- | } | + | |
- | + | ||
- | static void writeRa(SerialPort p) { | + | |
- | + | ||
- | String str = " | + | |
- | byte[] buffer = new byte[9]; | + | |
- | byte[] byte_str = str.getBytes(); | + | |
- | for (int i = 0; i < 9; i++) | + | |
- | buffer[i] = byte_str[i]; | + | |
- | + | ||
- | // | + | |
- | // | + | |
- | + | ||
- | p.writeBytes(buffer, | + | |
- | } | + | |
- | + | ||
- | static void writeDec(SerialPort p) { | + | |
- | String str = " | + | |
- | //" | + | |
- | byte[] buffer = new byte[7]; | + | |
- | byte[] byte_str = str.getBytes(); | + | |
- | for (int i = 0; i < 7; i++) | + | |
- | buffer[i] = byte_str[i]; | + | |
- | // | + | |
- | // | + | |
- | // | + | |
- | + | ||
- | p.writeBytes(buffer, | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | + | ||
- | </ | + | |
+ | [[virtuelles Arduino-Teleskop]] | ||
[[DIY Teleskop-Steuerung]] | [[DIY Teleskop-Steuerung]] |
teleskop_steuerung_fuer_c8.txt · Zuletzt geändert: 2020/11/22 16:19 von 127.0.0.1