Friday, May 23, 2014

Simple Modbus Slave

The idea behind thid project was to experiment a little with the serial bus, to have more than one device on s single serial line, aka multi-dropping.

There are several ways of doing this, but one very common way is using the Modbus protocol. The protocol doesn't specify the eletrical interface. I'm going to use RS485. For processing, I'm going to use an ATMEGA8, since it has hardware USART and I2C. The I2C I'm going to use to interface with the sensor, a LM75 temperature sensor. Other hardware bits are LM7805 linear regulator with a Vmax of 30V and a MAX485 for the serial interface. All components except the block connector are surface mount.

The board was laid out in EagleCAD, which was a first for me. I wanted to learn how to use EagleCAD, since so many other hobbyists do. The board came out nicely, I even added a little silk screen art to the bottom in form of a QR code.


The board outline is 5cmx3.5cm, and double sided. I opted for a 1.6mm PCB thickness for rigidity, and green PCB, white silk-screen and HASL for my wallet. I sent away the design to a PCB prototyping service.

A stack of PCBs arrived at the post office a couple of weeks later. By then I had sourced all the components needed to build the ten boards. Well, there was one component I couldn't source, and that was a the one-way SMT DIP switch. If I make another revision of the board, I will make that one through-hole.

I took me a while to hand solder, as I don't have the equipment to reflow solder. Perhaps it is time to invest in one. Anyway, I think the board turned out well.

As you can see, the 1-way DIP switch is unpopulated. If I make another board revision, that would be one of the things I would change. The QR-code works well thought!

Next up is the code...

Saturday, May 17, 2014

DIY EQ-Dir


It is possible and fairly easy to control Synta telescope mounts (Skywatcher, Celestron, Skytech, and more) from a computer. The most common reason for doing this is to autoguide, which was also my motivation.

The mount interface is a standard serial device, but with TTL levels.  TTL is an abbreviation for Transistor Transistor Levels, and means that a logical 1 = 5 volts and a logical 0 = 0 volts.
Normal serial devices usually work with something like logical 1 = -10 volts and logical 0 = +10 volts, thought there isn't a set standard. (Note: standard serial has inverted logic, on a hardware level a negativ value is logical 1.) If you fed your telescope with these levels you would probably damage the mount controller box, so we need a device that can convert between standard serial levels and TTL levels. This is what An EQ-Dir does, if you've heard that name before.

There are sites that sell these devices ready made, for bluetooth, USB, or a standard serial port, but they are very easy to make yourself, and cheap.

Since none of my current computers have a serial port, I had to find another way interface with my mount. I had two options here: a USB to serial adapter with a sort of TTL converter on the serial end, or a direct USB to TTL adapter. The USB to TTL is actually simpler to make, since the former would require a power supply to drive the TTL adapter.

You can a USB to TTL adapter from ebay, dx.com, or similar. Buy one with a chip from FTDI or Prolific, as these work well for this application. They cost as little as a US dollar including shipping.



The next, and only other, thing you'll need is an ethernet cable you can sacrifice. Cut it to desired length, and strip of a length of the outer insulation.

Only three wires are needed, one each for TX, RX, and signal ground. These are the minimum number of connections for a two-way serial interface. (Note:While researching the solution I came across a few posts that claim you also need to connect the RTS/CTS/DTR/DSR lines, but my mount worked happily without them. I almost never see these lines in use, and I suspect they can be left out on all Synta mounts.)


On the ethernet cable, it is the midle pins that are in use (4,5 & 6).


Connect as marked on the adapter, where 4 goes to  GND, 5 to TX, and 6 to RX. The colours on the wires in the ethernet cable are normally blue (4), blue/white (5), and green (6).

That's it. The rest is all software.