Actions

Difference between revisions of "WiFi telescope and camera control"

From Just in Time

Line 22: Line 22:
 
== Software ==
 
== Software ==
 
The software receives UDP packets and sends their contents verbatim to the serial port and vice versa. When receiving UDP data, the firmware will first examine the contents to see if any switch on/off instructions are being sent. If so, the package is intercepted and the switches are operated accordingly. Any other data is forwarded.
 
The software receives UDP packets and sends their contents verbatim to the serial port and vice versa. When receiving UDP data, the firmware will first examine the contents to see if any switch on/off instructions are being sent. If so, the package is intercepted and the switches are operated accordingly. Any other data is forwarded.
 +
 +
In other words, expressed in the universal language of "Arduino":<syntaxhighlight lang="c++">
 +
void loop()
 +
{
 +
FromUdpToSerial();
 +
FromSerialToUdp();
 +
}
 +
</syntaxhighlight>
 +
 +
 +
And:<syntaxhighlight lang="c++">
 +
    /**
 +
    * Forward data that is received from the UDP port to the
 +
    * serial device.
 +
    */
 +
    bool FromUdpToSerial()
 +
    {
 +
        auto packetSize = udp.parsePacket();
 +
        if (packetSize > 0)
 +
        {
 +
            packetSize = std::min( packetSize, bufferSize);
 +
            remoteIp = udp.remoteIP();
 +
            remoteUdpPort = udp.remotePort();
 +
 +
            udp.read( bufferFromUdp, bufferSize);
 +
 +
            if (not HandleLocally( bufferFromUdp, packetSize))
 +
            {
 +
                serial.write( bufferFromUdp, packetSize);
 +
            }
 +
 +
            return true;
 +
        }
 +
 +
        return false;
 +
    }
 +
</syntaxhighlight>
  
 
In order to examine the communication between the SynScan app and this device, a python script was written that implements a simplified version of the motor-controller side of the protocol. This is just enough to get the SynScan app to connect to either the python script directly over UDP or through the Wemos D1 over an USB connection with the device.
 
In order to examine the communication between the SynScan app and this device, a python script was written that implements a simplified version of the motor-controller side of the protocol. This is just enough to get the SynScan app to connect to either the python script directly over UDP or through the Wemos D1 over an USB connection with the device.
  
 
Sources are available on [https://github.com/DannyHavenith/Partem/blob/master/src/Partem.cpp github].
 
Sources are available on [https://github.com/DannyHavenith/Partem/blob/master/src/Partem.cpp github].

Revision as of 15:00, 14 November 2020

I'm so happy with my new telescope! This Skywatcher 150mm telescope (150P-DS) came with a decent motor-controlled mount with go-to capability (EQM-35 Pro). Out of the box, it comes with a SynScan hand controller, which is fine, if somewhat tedious to use. However, when using this mounts go-to capabilities with a WiFi bridge (instead of the hand controller) and the SynScan Pro app this telescope is a pure joy to use.

The app also has a function to control a camera attached to the mount controller. Unfortunately, the EQM-35 Pro is not equipped with a SNAP port, the port to which a camera can be connected, so with a regular WiFi adapter, you can't use that functionality.

It would be nice to have a WiFi-to-serial bridge that could also implement the camera controls sent by SynScan Pro app. And luckily, with cheap WiFi enabled microcontrollers available, this is relatively easy to do!

Telescope and camera
Telescope and camera

System overview

The system consists of a Wemos D1 mini, two BS170 N channel Mosfets, used as switches and a mini DC-DC buck converter. This connects to the RJ-45 socket on the EQM-35 mount, where it takes 12V power and connects to the 3.3v serial Rx and Tx lines.

Two of the D1's GPIO pins control the mosfets while the D1's serial port lines can be connected directly to the serial port of the mount. Just to be sure, I've added 100R resistors on the serial lines.

Overal, the schematic is so simple that this could be implemented on stripboard.

To finish it off, the board is fitted into a 3D-printed enclosure. Because I like to reuse whatever parts I have lying around, I used an old RJ-12 (telephone) socket for the connection to the camera.

Partem electronics in enclosure.png

Software

The software receives UDP packets and sends their contents verbatim to the serial port and vice versa. When receiving UDP data, the firmware will first examine the contents to see if any switch on/off instructions are being sent. If so, the package is intercepted and the switches are operated accordingly. Any other data is forwarded.

In other words, expressed in the universal language of "Arduino":

void loop()
{
	FromUdpToSerial();
	FromSerialToUdp();
}


And:

/**
     * Forward data that is received from the UDP port to the
     * serial device.
     */
    bool FromUdpToSerial()
    {
        auto packetSize = udp.parsePacket();
        if (packetSize > 0)
        {
            packetSize = std::min( packetSize, bufferSize);
            remoteIp = udp.remoteIP();
            remoteUdpPort = udp.remotePort();

            udp.read( bufferFromUdp, bufferSize);

            if (not HandleLocally( bufferFromUdp, packetSize))
            {
                serial.write( bufferFromUdp, packetSize);
            }

            return true;
        }

        return false;
    }

In order to examine the communication between the SynScan app and this device, a python script was written that implements a simplified version of the motor-controller side of the protocol. This is just enough to get the SynScan app to connect to either the python script directly over UDP or through the Wemos D1 over an USB connection with the device.

Sources are available on github.