Jump to content

SkySurveyBanner.jpg.21855908fce40597655603b6c9af720d.jpg

USB relay for roll-off roof winch


Rallemikken

Recommended Posts

My roof is operated by a slightly modded 220V two-way winch, and I'm planning to let Ekos pull the roof over the rig when the nights schedules are finished. I've mounted stop switches in both ends, so it's just a matter of  setting on current for a limited time, once it reach the end it switches off itself.

I've taken a look at these:    https://www.kmtronic.com/usb-relays.html

Looks like these can be operated by a single bash-script (I'm on linux). I might opt for the boxed four channel, maybe the eight. Might come handy later. Am I missing something? Anyone else tried these?

Link to comment
Share on other sites

  • 2 weeks later...

Short update: Opted for the boxed 4-way USB relay, installed and tested. Some remarks, all this is done on Linux Mint 20.3:

* This version does not need any power supply, but be sure your USB-port delivers enough current. With all relays closed, it pulls some amps. I've plugged it into a USB-hub with it's own supply.

* It might conflict with any other equipment connected with a USB-to-serial plug, my HEQ5 for my part; it's connected with a EQDirRJ45 cable. To fix this, we must give the box it's own shortcut in /dev. This is done by writing a udev-rule, and reboot. Just like in Windoze.

* This box and my EQDir-cable uses the same chipset. [removed word]. Yours might not, but better safe than sorry. Unplug everything, apart from the box from KMTronic, and reboot.

* Run this in the shell:
udevadm info -a -n /dev/ttyUSB0 | grep '{serial}' | head -n1
You maybe get this response:
    ATTRS{serial}=="AB0LB2GY"

* Then we write our udev-rule. Make a file named /lib/udev/rules.d/99-observatory.rules This must be done as root, or via sudo.
This is how mine turned out in the end:

Line 1: # KMTronic box for takmotor (roofmotor)
Line 2: # SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AB0LB2GY", MODE="0666", SYMLINK+="takmotor"
Line 3: # SUBSYSTEMS=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AB0LB2GY", MODE="0666", SYMLINK+="takmotor"
Line 4: SUBSYSTEM=="tty", ACTION=="add", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{serial}=="AB0LB2GY", MODE="0666", KERNEL=="ttyUSB*", SYMLINK="takmotor"

As you can see, I've fiddled a bit. The first three lines are commented out, line #2 and 3 are pure failures. The last line (line 4) did the trick. I suspect it was the last "S" in "SUBSYSTEMS", but we'll never know....   The  ACTION=="add" and KERNEL=="ttyUSB*" might play a role, anyway, putting them in don't seem to do any damage....

* So to the bash-file that is called after finished schedule in Ekos:

#!/bin/bash
#
#  1    FF 01 01    HEX     Turn ON relay 1
#  2    FF 02 01    HEX     Turn ON relay 2
#  3    FF 03 01    HEX     Turn ON relay 3
#  4    FF 04 01    HEX     Turn ON relay 4
#  9    FF 01 00    HEX     Turn OFF relay 1
# 10    FF 02 00    HEX     Turn OFF relay 2
# 11    FF 03 00    HEX     Turn OFF relay 3
# 12    FF 04 00    HEX     Turn OFF relay 4
#
echo -e "\xFF\x01\x01" > /dev/takmotor
echo -e "\xFF\x02\x01" > /dev/takmotor
sleep 30
echo -e "\xFF\x01\x00" > /dev/takmotor
echo -e "\xFF\x02\x00" > /dev/takmotor
sleep 3
exit

The 'sleep 30' gives the motor time to pull the roof all the way, it has a stop switch at the end of travel, timing is not cruzial for my part. The next two lines turns the relays back to their default, open configuration. I have a manual switch to OPEN the roof, and I don't want my USB-box to conflict with my manual switch in case I don't turn off my computer. The 'sleep 3' is just a precausion to let the computer finish the talk with the box. Next is 'init 0', but that's another story....

 

Edited by Rallemikken
Line numbering in "/lib/udev/rules.d/99-observatory.rules"
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.