Eeep! Not much since last update… a week ago. I had to clear something off my ToDoList. Well at least I can say I got the driver connected and talking to the Arduino.
Part 1 : Arduino Code
– This code will blink the onboard LED (pin13) however many times the length of the command string that is being read on Serial, whose command string is terminated by a ‘#’ character
String temp; void setup() { // put your setup code here, to run once: Serial.begin(19200); pinMode(13, OUTPUT); digitalWrite(13,LOW); } void loop() { // put your main code here, to run repeatedly: if (Serial.available()) { //readStringUntil will consume the '#' character temp = Serial.readStringUntil('#'); for (int i = 0; i < temp.length(); i++) { digitalWrite(13,HIGH); delay(200); digitalWrite(13,LOW); delay(100); } delay(1); } delay(100); }
Part 2 : Telescope Driver Code
– This code snippet belongs to the Connected member object, which includes get() and set() functions. The get() just returns whether or not the driver already established a connection to the hardware. The set() checks if we’re already connected, and if not, then we establish a serial connection to the Arduino over the ASCOM.Utilities.Serial Library. Common serial parameters I use are port 26 and baud 19200. It also sends a text message to the Arduino to confirm that it’s established a connection. The next step would be to have the Arduino send back an acknowledgement text message.
private ASCOM.Utilities.Serial objSerial; public bool Connected { get { tl.LogMessage("Connected Get", IsConnected.ToString()); return IsConnected; } set { tl.LogMessage("Connected Set", value.ToString()); if (value == IsConnected) return; if (value) { connectedState = true; tl.LogMessage("Connected Set", "Connecting to port " + comPort); // TODO connect to the device objSerial = new ASCOM.Utilities.Serial(); objSerial.Port = 26; objSerial.Speed = SerialSpeed.ps19200; objSerial.Connected = true; objSerial.Transmit("Hello Arduino#"); } else { connectedState = false; tl.LogMessage("Connected Set", "Disconnecting from port " + comPort); // TODO disconnect from the device objSerial.Connected = false; } } }
Soo yeah. That’s all I’ve accomplished for now. I’m considering writing the MoveAxis method, and the SlewToAltAz method. Eventually, I’ll be able to move the telescope by sending it a text command, such as “SlewToAltAz(123.45678, 98.76543)#” or “MoveAxis(0,0.01234)#”, with each command ending in ‘#’ character. I’m not sure how to invoke those functions through the driver test app yet, but I might have to make a form in Visual Studio. I’m thinking something like a simple CNC manual Jog feature interface.
After I can get those two functions working, then we’ll figure out how to translate between the telescope’s machine coordinates and the coordinate based on planet earth…
I’ll leave you with one of my favorite comic strips:
Until next time
-david