×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Re:Controlling camera shutter with SkyWatcher SNAP port

  • Posts: 32
  • Thank you received: 13
I feel like I'm somewhat different in how I am using Astroberry. I want to share some things about my setup and how I use it. This first topic will be about how I control the shutter on my camera.

I have a Fujifilm X-T20. It is not possible to control the shutter and download images at the same time. More expensive Fujifilm cameras support tethered shooting, but not the X-T20. It is possible to use external intervalometers, but this makes it nearly impossible to dither. Controlling the shutter from an INDI client (I use CCD Ciel) while also dithering in PHD2 was my ultimate goal.

I also have a Sky-Watcher EQ6-R Pro. Many Sky-Watcher mounts have "snap" ports that can be used to control cameras in the same way intervalometers can control cameras. The snap port on my Sky-Watcher mount controls my X-T20 using a simple 2.5mm to 3.5mm stereo audio cable. If I use the mount's hand controller, I can access a menu that works just like an intervalometer would.

I don't use a hand controller though. Instead I connect the Raspberry PI directly to the mount using a USB cable. I then use the EQMod Mount INDI driver. Recent versions of this driver include INDI parameters for controlling the snap ports on Sky-Watcher mounts. The parameters to look for are "EQMod Mount.SNAPPORT1.SNAPPORT1_ON" and "EQMod Mount.SNAPPORT1.SNAPPORT1_OFF". Note: The driver looks at a mount identifier to determine if the parameters should be enabled. If you have a mount with a snap port, but the parameters do not exist, the EQMod driver developer might only need to add a mount identifier to the code to enable support.

This means we can control the shutter from a shell prompt with the following command.
indi_setprop "EQMod Mount.SNAPPORT1.SNAPPORT1_ON=On"
And similarly, this command will close the shutter.
indi_setprop "EQMod Mount.SNAPPORT1.SNAPPORT1_OFF=On"

So now we have a way to control the shutter from the command line, but in order to use an INDI client, we need something that looks like an INDI camera. The secret to making all of this work, is to enable the "CCD Simulator" driver. This is a fake camera in INDI. We setup our INDI client to use the CCD Simulator camera as the main camera. When the client tells the camera to take a picture, it sets the "CCD Simulator.CCD_EXPOSURE.CCD_EXPOSURE_VALUE" to the length of the exposure needed.

The next trick is to watch that CCD_EXPOSURE_VALUE parameter from a shell script, catch the new exposure length when it increases in value, and then open the shutter for the specified number of seconds. Ok, I admit that sounds a little complicated, so I've included my script that does just that. The snap_port_listener script (attached with a txt extension) uses an indi_eval command to wait for the exposure value to change. To use this script, just open a shell window and start the script before using the camera in your favorite client. The script will keep track of the cumulative exposure time as well as the total number of exposures. When you're done capturing, just issue a Ctrl-C in the window running the listener, and the script will stop. If you kill it while an exposure is taking place, it will close the shutter.

File Attachment:

File Name: snap_port_...ener.txt
File Size:2 KB


This script can be easily edited if you have a different way to control your shutter from the command line. I actually use a similar script that controls my shutter using an optoisolator circuit and the GPIO pins on the Raspberry PI. The only thing that needs to change in the script to use a different shutter control method is the exposeSensor and closeShutter functions.

It is also worth noting that if the INDI client cancels an exposure, the script will not see it. In that case, you would want to kill the script, or wait for the exposure to finish, before starting a new set of exposures using the client.

You may need to check the values of the parameters on the CCD Simulator driver to ensure the exposure is set to zero before starting the script. Also, the CCD Simulator creates simulated image files. You will want to note where these get saved so you can purge them later, or block them from being written all together. I actually tell CCD Ciel to write the files to a directory that I have set with 000 permissions. It happily fails to write them and continues with exposures anyway... which is handy in my case. I also configure the CCD Simulator to use a smaller resolution (600x400) and scale the pixel size so the field of view actually matches my camera. This is not necessary, but results in less IO for the simulator driver, and any client that uses the sensor for field of view estimates will draw the correct sized box.

I hope someone finds this script helpful. I'm sure there are many other ways to do this, and many different ways to write this, but this is working well for me. Feel free to use it as a starting point for your own script.
The following user(s) said Thank You: Tom, Andres Rossi, Ricardo Serpell
Last edit: 3 years 6 months ago by Kristopher. Reason: previous edit messed up code markup and italics... :(
3 years 6 months ago #59901
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 32
  • Thank you received: 13
I've been asked about how I'm using the GPIO pins to control the shutter.

A good tutorial on how to wire optoisolators can be found here. For astrophotography we don't usually need to control focus, but if you do, there are units available with two optoisolators built in. I'm actually using this board , but I don't recommend it. I was required to use power from the camera (by leaving the focus pin powered) in order for the transistors on the board to work. The method in the first link is easier and better.

You can then use the /sys/class/gpio interface to control the pins. For example, I'm using pin 23 for the shutter. The following code will control the pins and includes the needed exposeSensor and closeShutter functions needed in the script I posted earlier.

# Set GPIO path
GPIO_PATH="/sys/class/gpio"
 
# Define Pins
SHUTTER=23
FOCUS=24
 
# This is backwards because of the board I'm using.  
# You likely want to swap values here.
ON=0
OFF=1
 
 
# Function to export a pin if not already exported
exportPin() {
  if [[ ! -e $GPIO_PATH/gpio$1 ]]
  then
    gpio export "$1" out
  fi
}
 
# Function to change state of a pin
setState() {
  echo $2 > $GPIO_PATH/gpio$1/value
}
 
# Function to expose for for a given number of seconds.
exposeSensor() {
  setState $SHUTTER $ON
  sleep $1
  setState $SHUTTER $OFF
}
 
# Function to close the shutter.
closeShutter() {
  setState $SHUTTER $OFF
}
 
 
# Export pins and set initial state.
exportPin $SHUTTER
setState $SHUTTER $OFF
 
exportPin $FOCUS
setState $FOCUS $OFF

By the way, audio header cables used on old CDROM drives have the right pin spacing for the raspberry PI. :)
Last edit: 3 years 6 months ago by Kristopher. Reason: changed "off" to "powered" to make it a little more clear.
3 years 6 months ago #60681

Please Log in or Create an account to join the conversation.

  • Posts: 32
  • Thank you received: 13
My scripts make use of the bc command. The most recent Raspbian updates to Astroberry took this away.

It's simple enough to get back though.

sudo apt install bc


I'm not sure if I'm using other stuff that isn't installed by default. I'm glad I had internet access when I found out last night. :)
3 years 5 months ago #61446

Please Log in or Create an account to join the conversation.

  • Posts: 41
  • Thank you received: 4
Wow! This is a great solution!! Thanks a lot dude!
3 years 2 weeks ago #68381

Please Log in or Create an account to join the conversation.

  • Posts: 269
  • Thank you received: 53
To control GPIO pins you can also try the indi-asi-power driver.
Latest version uses GPIO 21 for DSLR shutter control but is not yet in the nightly builds. check out indilib.org/forum/ccds-dslrs/8982-issue-....html?start=12#68327
If you want to build from source note that I have moved it to branch asidslr2
it would be fairly simple to convert it to use different pins
The following user(s) said Thank You: Kristopher
3 years 2 weeks ago #68439

Please Log in or Create an account to join the conversation.

  • Posts: 1
  • Thank you received: 0
Sorry for the Newbie question. I have a Fuji X-T3. I am also getting an ASIAIR pro which is based on a raspberry pi I think. Using the ASIAIR, would I still be able to control camera using the snap port on my EQ6R pro?


Sent from my iPhone using Tapatalk
2 years 11 months ago #70159

Please Log in or Create an account to join the conversation.

  • Posts: 238
  • Thank you received: 15
Hi Kristopher,

Regarding controlling camera shutter with SkyWatcher SNAP port, I have this modified wireless remote that uses on DSLR that without shutter release port.

www.pentaxforums.com/forums/62-do-yourse...entax-ir-camera.html

But when I connect this modified wireless remote to the SNAP port, it doesn't seem to open the shutter. I can confirm that it is working with another remote timer.

Is something missing from the script?

Hope you can take a look at this matter.

Regards,
Tom
2 years 8 months ago #73485

Please Log in or Create an account to join the conversation.

  • Posts: 32
  • Thank you received: 13
A previous Astroberry release included a slightly broken indi_setprop command. The workaround is to specify the INDI server host. To test if this is your issue, bypass the script and just use the following command line tools.  (note the -h 127.0.0.1 part)
indi_setprop -h 127.0.0.1 "EQMod Mount.SNAPPORT1.SNAPPORT1_ON=On"
indi_setprop -h 127.0.0.1 "EQMod Mount.SNAPPORT1.SNAPPORT1_OFF=On"

If that works, you can set a temporary alias in the script or just hardcode the host on all indi_setprop and indi_getprop commands.

Something like this at the top of any bash scripts that use these commands will work around the issue for now.
# Temporary aliases to work around localhost issue.
shopt -s expand_aliases
alias indi_getprop="indi_getprop -h 127.0.0.1"
alias indi_setprop="indi_setprop -h 127.0.0.1"
alias indi_eval="indi_eval -h 127.0.0.1"
The following user(s) said Thank You: Tom
Last edit: 2 years 8 months ago by Kristopher. Reason: This is fixed in the latest release. Hopefully this workaround won't be needed again.
2 years 8 months ago #73489

Please Log in or Create an account to join the conversation.

  • Posts: 238
  • Thank you received: 15
Will try it by tomorrow. But do these changes only apply to astroberry only? How about Stellarmate or another system?

Regards,
Tom
2 years 8 months ago #73490

Please Log in or Create an account to join the conversation.

  • Posts: 32
  • Thank you received: 13
My script was written on an Astroberry. I do not know what is included on Stellarmate. Sorry.
2 years 8 months ago #73491

Please Log in or Create an account to join the conversation.

  • Posts: 238
  • Thank you received: 15
Hi Kristopher,

The script still does not work with the modified wireless remote. But if the SNAP port cable directly plugs into the camera shutter release port, it works.

Thanks.
Tom
2 years 8 months ago #73512

Please Log in or Create an account to join the conversation.

  • Posts: 32
  • Thank you received: 13
If it works connected directly, then it's not my script... sounds like a compatibility issue with your IR shutter cable. I can't help... but I think it's cool you're messing with it. :)

Out of curiosity, What are you trying to solve using the IR remote if you can already control the shutter with a cable? If your answer is "fun thing to try" I'd totally understand.
The following user(s) said Thank You: Tom
2 years 8 months ago #73546

Please Log in or Create an account to join the conversation.

Moderators: Radek Kaczorek
Time to create page: 1.105 seconds