Visar inlägg med etikett Raspberry Pi. Visa alla inlägg
Visar inlägg med etikett Raspberry Pi. Visa alla inlägg

måndag 27 februari 2017

Raspberry Pi DSLR trigger

Here's a small, simple project, a remote trigger for a DSLR.
I control my telescope mount through INDI, but unfortunately I can't control my old DSLR that way. The only way I can do "automated" exposures is if I connect an intervallometer to the camera. The problem with intervallometers is however, that they only run on small batteries, and will stop working when it's cold.
Another problem is, that it's impossible to use dithering with an intervallometer and simultaneous guiding.
Here's a partial solution to these problems. I wrote a simple Python script that will run on the Raspberry Pi, The script sends exposure signals through the RPi's GPIO bus to the remote port of my camera.
To connect the Raspberry Pi to the camera, I made a small optocoupler circuit, that will isolate the camera electronics from the RPi.
The input (left) will connect to a GPIO pin (pin 18, GPIO 24) and ground (pin 20), while the ouput (right) connects to the remote port of the camera.
Here's the code.
_____________________________

#!/usr/bin/python

import RPi.GPIO as GPIO
import time
import sys

NrExposures = 1
ExposureTime = 30
TimeBetweenExposures = 6
print ' '
print 'Make sure that the camera remote port is connected to pins 18 (signal) and 20 (ground).'
print ' '
if len(sys.argv) == 1 :
   print 'No arguments provided. Will use single 30 sec exposure.'
elif len(sys.argv) == 2 :
   ExposureTime = int(sys.argv[1], 10)
   print 'Single', ExposureTime, 'seconds exposure.'
elif len(sys.argv) == 3 :
   ExposureTime = int(sys.argv[1], 10)
   NrExposures = int(sys.argv[2], 10)
   print NrExposures, 'x', ExposureTime, 'seconds exposures.'
else :
   ExposureTime = int(sys.argv[1], 10)
   NrExposures = int(sys.argv[2], 10)
   TimeBetweenExposures = int(sys.argv[3], 10)
   print NrExposures, 'x', ExposureTime, 'seconds exposures, with', TimeBetweenExposures, 'seconds delay.'

TriggerPin = 24  # Broadcom pin 24 (P1 pin 18)

GPIO.setmode(GPIO.BCM)  # Broadcom pin-numbering scheme
GPIO.setup(TriggerPin, GPIO.OUT)  # trigger pin as output

GPIO.output (TriggerPin, GPIO.LOW)
time.sleep(1)

counter = NrExposures
print ' '
print 'Start : %s' % time.ctime()
while (counter > 0):
   print '  Exposure nr', counter, 'started'
   GPIO.output(TriggerPin, GPIO.HIGH)
   time.sleep(ExposureTime)
   GPIO.output(TriggerPin, GPIO.LOW)
   print '  Exposure nr', counter, 'ended'
   counter = counter - 1
   time.sleep(TimeBetweenExposures)
   print ' '

print 'End :  %s' % time.ctime()
GPIO.output(TriggerPin, GPIO.LOW)
GPIO.cleanup()
print ' '
print 'Goodbye.'
______________________________

The script is saved as Trigger.py and is made executable:

chmod +x Trigger.py

The script takes up to three command line arguments. The first argument is the single frame exposure time in seconds. The second argument is the number of exposures to take, and the third argument is the wait time between exposures, also in seconds.
For example

./Trigger.py 1 2 3

will take 2 exposures of 1 second each with a 3 seconds wait time after each exposure. The script will take 8 seconds to run.

If only two arguments are given, the wait time will be set to a default value of 6 seconds.
If only one argument is given, this is interpreted as exposure time. Only one exposure will be taken.
If no arguments are given, the script will do a single 30 seconds exposure.

Eventually, I may try to rewrite the INDI CCD driver to control my camera, as this will give me the possibility to dither between exposures. But for now this simple script will do the job.


söndag 20 november 2016

First steps in guiding

Finally I have taken the plunge and invested in a guiding setup. I decided for the SkyWatcher ST80 scope with ZWO ASI120MM camera. The camera is the older USB2 version.
As I don't want to take my laptop out in the field, I intend to use a RaspberryPi as a guiding computer.
The last couple of days and nights, I have been trying to get this to work. My configuration at the moment is this:
ASI120MM connected to RaspberryPi, running Ubuntu Mate as an operating system.
The Pi also holds an INDI server and the lin_guider software. The camera connects to the Pi and receives guiding pulses which it sends on to the mount (SW AZ-EQ6 GT) via the ST4 port.
Installation was quite straightforward, despite warnings that the camera driver may not be stable. Setting the exposure time to 1 sec in Lin_guider seems to work fine though.
Last night, despite partial cloud cover, I was able to test the guiding, and it worked fine.
Lin_guider connected to the camera, and frames started to flow in. Focussing was a bit of a hassle. I had to take my laptop out (despite the dew), and because there is no live view, it took a while to get focus right. In the end I had my setup guiding on Vega (which was grossly overexposed at any gain setting), and later on a nearby much fainter star. This worked fine until the stars disappeared behind my neighbour's trees and clouds rolled in.
I haven't tried imaging yet, and I still have to figure out the best settings for PID gain, but so far so good.

lördag 13 augusti 2016

First experience with INDI on Raspberry Pi - part 2

Last week , when I tried to control my mount through indi on a Raspberry Pi, I managed to install the server and connect from my laptop to the indi server on the RPi. However, the mount didn't respond. It turned out that the USB serial cable didn't work anymore.
Yesterday I received an EQDIR cable from FLO, and connected it to the mount. After some adjustment of the parameters in linux and the Indi client, it all worked perfectly.
Now I can control my mount from PixInsight or any client that can run the indi protocol.
The next step will be to install and test servers.
Short recap of the installation so far.
  1. Install an Ubuntu Mate image on a SD card for the RPi
  2. Connect the RPi to the home Wifi network and set parameters to connect to PuTTY
  3. Connect to the indi repository, download and install the indi server
  4. Set $USER for dialout permission
  5. Create a permanent USB entry for the connector
  6. Start the server
  7. Start the client and connect to the server
  8. Configure the site and the mount in the client
So far PixInsight can connect to the mount and send goto commands. With the search capability, I can just search for say, M27 and the mount will slew to it.
Of course, this assumes that the mount is aligned, and so far PixInsight can't do a 2-star alignment.
I just hope that this will be implemented soon.
For the time being, my intended workflow is as follows.
  1. Haul out the mount and set up
  2. Level mount
  3. Start mount with SynScan
  4. Do a polar and a 3-star alignment
  5. Park the mount and power off
  6. Disconnect the SynScan
  7. Connect the RPi and boot
  8. Connect the client
Further testing is delayed by clouds :-(

onsdag 3 augusti 2016

first experiences with INDI on Raspberry Pi

Now that I have invested in a proper mount, I'm also looking into remote (15 meters) operation of it.
I don't want to drag my laptop out into the garden just to have it covered with dew, and I like the size of Raspberry Pi. This, and the fact that PixInsight is moving into the direction of hardware control through the INDI protocol, made me decide to look into the INDI solution, rather than EQMOD.
So, last weekend I erased my Pi memory card and installed Ubuntu Mate. This OS was recommended on the INDI website (indilib.org ).
Now, I have very little experience with linux, and for most of the things I do, I need to follow a tutorial or google my way around. The following is probably not the best way to do it, but these are my experiences.

Installing the OS wasn't much of a problem; download and extract the image. Then use Win32DiskImager to write the OS image onto the memory card.
Started the OS, and managed to connect it to PuTTY, but in the beginning I mainly used the desktop and a terminal window in the desktop.
Installing the INDI library took some time. For some reason I couldn't register or connect to the INDI repository (mutlaqja ppa), and the desktop on several occasions reported an internal error. Finally (don't aks me how) I managed to connect to the repository and install INDI. To get this far took quite a while so I read the OS image back to windows. I figured that if I ever need to go back and reinstall the OS, at least I won't need to do it from scratch.
I managed to get INDI server up and running, and decided to rename the USB port for permanent reference. Some googling gave the answer, and some more tapping away on my keyboard (now I don't use Mate anymore, but am connected through PuTTY and WiFi).
I then connected the mount through Synscan's serial cable and a serial/usb interface.
I managed to connect from PixInsights INDI client, but the program crashed a few times. Again, don't ask me why. I have never been able to crash PixInsight, but during the past few days I managed it twice. (Mind you, I have managed to bring it to it's knees by integrating some 200+ 14 Mpixels drizzled images. But that's a different story.)
It seems that there isn't a "hello world" application that lets you test a partial setup. There isn't even a proper tutorial that covers a complete setup. It takes some googling and looking around the INDI website to get ideas and suggestions for solutions.
Anyway, I also tried connecting through Stellarium, which didn't protest and connected to the server.
Both the PI and Stellarium connections worked fine, as the server kept responding to slew requests. However, the mount didn't budge an arcsecond.
After a long time installing, uninstalling and reinstalling various things and starting and stopping the server, rebooting the RPi, etc, etc, I finally called it a night, not having moved the mount remotely at all.
I dismantled the RPi, cables, and the mount (I'm doing this more or less in the family living room), and just as I was about to disconnect the serial cable, I noticed that neither of the LEDs was lighting or blinking.
It appears that my serial/USB connecter isn't working anymore. So now I'm waiting for the HITECH EQDIR Synscan/USB interface to arrive from Firstlightoptics.
Since everything else worked fine, just plugging in the connector should make the remote setup work. Something tells me though, that it will not work from the start, even with a new cable.

The setup sofar:
RPi 2 with Ubuntu Mate, connected to PuTTY on Windows.
sudo apt-add-repository ppa:mutlaqja/ppa (works after a few tries and reboots)
sudo apt-get install indi-full
sudo adduser $USER dialout (so I don't have to be root user to use indi)
create a rules file to rename the mounts usb port, using udevadm
indiserver -m 100 -v indi_eqmod_telescope
several reboots along the way.

To do next:
Make sure that the new connector works (without the Synscan)
Make sure that the setup works (mount connected to RPi without the Synscan inbetween; indisverver controlled by Stellarium on Windows machine)
Make sure that indiserver starts up automatically after booting the RPi.
Find and install a client that lets me control the mount and will replace the Synscan.

To be continued, I guess.