Bolton Astronomical Society

The life of Pi
Page 1 of 1

Author:  rwilkinson [ Wed Feb 25, 2015 9:51 pm ]
Post subject:  The life of Pi

I've just been experimenting with one of the new Raspberry Pi2 microcomputers, together with its custom camera board.

This camera uses the OV5647 5-megapixel CCD sensor and can support 1080p video at 30 fps, or up to 90 fps at VGA resolution. However the sensor is only 3.67 x 2.74 mm, and the pixels are just 1.4 x 1.4 um - but it could still be useful for planetary imaging with relatively short focal-length 'scopes?

Another interesting feature is that it can do long-exposures of up to 6-sec without any modifications. I was wondering how sensitive it would be in this mode, so I fitted it with the lens from an old webcam (only focussed approximately) and sat it on my window-sill, propped up looking out across the back garden and Queen's Park. I operated the Pi2 itself remotely, via WiFi from a VNC console on this computer.
File comment: Night-time view (9pm) from Raspberry Pi camera. Single 6-sec exposure at ISO 800 and EV = +10
rpi_lx1.jpg [ 241.68 KiB | Viewed 8972 times ]
the original image is 2592 x 1944 pixels, so I've re-sized its full frame to fit on this page.

I was quite surprised at how much detail it picked up in "darkness" (albeit with a lot of scattered light-pollution from the clouds above!) and how its built-in auto white-balance had produced sensible colours too (I've not made any adjustments to the image).
By the way, the diagonal stripe across my lawn is a shaft of light from a streetlamp across the road, and the circle of white light near to the right edge of the tree-line is the face of Bolton Town Hall clock!

Author:  rwilkinson [ Sun Mar 01, 2015 4:02 pm ]
Post subject:  Re: The life of Pi

I've just got my Raspberry Pi camera running via the video4linux2 driver, so that it will operate like a webcam on /dev/video0, and now I can use it with the qastrocam-g2 and linguider programs.

For convenience, I've attached it to the back of a telephoto lens for testing:
File comment: WiFi-linked Raspberry Pi camera fitted with SMC Pentax-M 135mm lens
picam_135.jpg [ 199.69 KiB | Viewed 8933 times ]
I'm running it remotely via a VNC WiFi link and I've now got a 50cm-long ribbon-cable to allow a greater separation between the camera and the Pi.

Author:  rwilkinson [ Sat Mar 07, 2015 9:43 pm ]
Post subject:  Ju<Pi>ter imaging

I've just been experimenting with the Raspberry Pi camera on the back of my StarWave 80ED 'scope:
File comment: Raspberry Pi2 mounted on the 'scope (using an old bootlace!) with its camera attached to the flip-mirror assembly
pi_mounted.jpg [ 194.78 KiB | Viewed 8898 times ]

The Pi was powered from the same 12V battery as the 'scope mount and it was connected through a nearby WiFi hub to the laptop which I was using to control it:
File comment: Wireless connection to the standalone (battery-powered) Raspi imaging system
remotepi.jpg [ 233.81 KiB | Viewed 8898 times ]

I was operating the camera with the qastrocam-g2 program, via the v4l2 driver. Once I'd got the image of Jupiter focused and centered the program allowed me to crop the middle quarter of the sensor's view:
File comment: VNC desktop display from the remote Pi2 on my laptop
picam_jupiter.jpg [ 155.64 KiB | Viewed 8898 times ]

This arrangement only yielded a slow video capture rate, but it was sufficient to prove the technique: even with a focal-length of just 555mm (and no Barlow lens) I was getting a reasonable resolution with the 1.4um pixels.

But the rate of the VNC screen update was slowed down by the dual wireless link, so I had to make very slow adjustments when aiming and focusing. However for local operation (i.e. standing beside the 'scope rather than running remote control from indoors) this could be improved by using a direct ethernet connection from the Pi to the laptop.

Author:  rwilkinson [ Sun Mar 08, 2015 11:04 pm ]
Post subject:  Re: The life of Pi

For this evening's test I'd connected the Pi to my laptop with a direct ethernet lead, and this proved better than the dual WiFi link of the previous evening: there was not so much delay in seeing my adjustments in aiming and focus.
I also tried the camera on my 8" SCT operating at f/10 - with a focal length of 2030mm Jupiter's disk almost filled the quarter-frame crop area on the sensor:
File comment: The Pi tied to the finder bracket on my SCT and linked to the laptop with the yellow ethernet lead
picamSCT 001.jpg
picamSCT 001.jpg [ 316.35 KiB | Viewed 8880 times ]
File comment: The quarter-frame cropped view of Jupiter appears in the VNC window on the laptop
picam_jupiter2.jpg [ 165.76 KiB | Viewed 8880 times ]

Some manual intervention was needed to keep the Jovian disk within the capture area of the sensor, and I had some difficulty setting the exposure through the v4l2 driver, but I did manage to record a 300-frame .AVI stream for stacking in RegiStax.
File comment: Jupiter on 8-Mar with Raspberry Pi camera. Stack of the best 250 frames using RegiStax 6.
Jupiter-2015.03.jpg [ 26.16 KiB | Viewed 8880 times ]

Author:  rwilkinson [ Thu Mar 12, 2015 9:46 am ]
Post subject:  Re: The life of Pi

Having seen the Pi camera's capability to do 6-sec "long" exposures, I've been wondering if it could capture any deep-sky objects, so the other night I fitted it with my Pentax 50mm lens and pointed it at M42.

I'd read that the camera can be set to export its raw sensor data (embedded within the EXIF field of each JPEG image!), so I also faced the challenge of extracting this and importing it into IRIS. Well, last night I finally worked out the process:
  1. first use a program called pi2dng to extract the raw data into .DNG files
  2. read each DNG file into IRIS and run the SIGNED command (to accomodate the 16-bit data)
  3. (perform offset, dark & flat calibration on these CFA files, if required)
  4. colour-convert the CFA files (but the Bayer matrix seemed to have got mixed up, so I then had to swap the R and G colour-planes)
  5. Process as usual (Register, Add a sequence, Gradient removal, etc.)

So here's the result of a stack of 13x 6-sec exposures (I'd not spent much time optimising the focus, so it's probably a little off):
File comment: Orion's sword using Raspberry Pi camera fitted with Pentax 50mm lens. 13x 6-sec, raw-frames stacked in IRIS
m42_pi.png [ 55.42 KiB | Viewed 8837 times ]
There's an obvious "amp-glow" on the right edge of the frame, but it's not so bad for a little camera which cost under £20! And I've not done any offsets, darks & flats yet, so this is just a stack of the raw frames (with some median filtering applied to take out the obvious hot-pixels) so it could be improved further with calibration.

It took a lot of work to get at the raw data from the sensor, but there's a very good reason for not using the standard JPEG output: it seems that the camera has a sort of flat-field process hard-coded into it, to compensate for the shortcomings of its "fixed" lens. Now since I'd removed this lens, the JPEG processing imposes a kind of spurious "anti-vignetting" onto its output, as can be seen from this stack:
File comment: Stack of the same 13x 6sec exposures from the JPEG files, stretched to illustrate the "anti-vignetting" effect
m42_jpeg.png [ 649.15 KiB | Viewed 8837 times ]

Author:  rwilkinson [ Fri Mar 13, 2015 9:19 pm ]
Post subject:  Re: The life of Pi - guiding lite!

Now that I've got my Pi camera fitted with an M12 adaptor, I can try it out in all the configurations where I've used my Philips webcams in the past - and one of these was as an auto-guider. :idea: Having seen its sensitivity from my previous deep-sky imaging test, I expected that the Pi camera would be well-suited to this application.

I'd been reading on some web-page about an experimental guiding system using a QHY camera and a Raspberry Pi, which included the observation that although Open PHD Guiding could be made to run on a Pi with INDI drivers, it was very slow compared to Lin-guider (which was designed expressly to run in Linux) - so I decided to give this latter program a go.
I was delighted to find that Lin-guider would accept the video stream from the Pi camera, although there didn't seem to be any way to control its exposure settings (I had to use v4l2-ctl command-lines or the qv4l2 GUI to do this). But the picture updated reliably every second, without any of the frequent missing frames which I suffered when using my LX webcams and PHD Guiding on a WinXP PC.

Now all the PC-based auto-guiders need to use either LPT or USB ports to comminicate their control signals back to the mount, whereas the Pi provides a host of GPIO pins which can be used for this purpose. But first I needed to use the WiringPi program to set up four of these pins as outputs, and then fiddle around with Lin-guider's configuration files to select the right ones.

Earlier this evening I conducted an initial proof-of-concept open-loop test, using a distant street-lamp as an "artificial star". I fitted the Pi camera with my Pentax 50mm lens and pointed it through the window, where it could see some distant lights through the gaps in the trees:
File comment: Setup for open-loop guider test with the Pi camera on the back of a 50mm lens and four LEDs connected to the guider output GPIO lines
openloopguider.jpg [ 172.19 KiB | Viewed 8817 times ]

Whilst operating the Pi from a VNC console on my laptop (connected via my home WiFi router), I trained the camera on an "artificial star" and turned on the guider:
File comment: VNC display showing Lin-guider running with a distant streetlamp as its target
linguider1.jpg [ 220.99 KiB | Viewed 8817 times ]
And then as I used the slow-motion controls on the tripod-head to sweep the lens either side of the target, the LED indicators on the "RA" and "Dec" outputs showed the control signals switching from the "+" to "-" senses. :D

So next I'll need to mount the Pi camera on the back of my guiding lens (an old Soligor 200mm telephoto) and build up an interface from the Pi's 3.3V logic to drive the "ST4" guide-port on my mount...

Author:  rwilkinson [ Wed Mar 25, 2015 9:55 am ]
Post subject:  Re: The life of Pi

Well, last night I had my prototype system auto-guiding on a real star! :D

I've made a simple interface to use four of the Pi's 3.3V GPIO pins to drive the "ST4" Guide-port inputs on my mount - it's one of the white cables in this picture:
File comment: Testing the Raspberry Pi2 camera with a 200mm lens as an auto-guider (the aluminium mount for my guiding lens is a Gerald Bramall special)
pi_guider.jpg [ 227.84 KiB | Viewed 8702 times ]
The other white cable is the 5V DC supply for the Pi, and the yellow one is the ethernet cable to my laptop (which will ultimately be replaced with a WiFi link). For this test, the Pi is simply tied onto the finder-scope bracket, and the StarWave OTA is only used as a mechanical support!

I used Alkaid (eta Ursae Majoris) as my guide-star: this was bright enough to help me initially focus the 200mm Soligor lens, and then to my great surprise still showed it on the display even when some clouds rolled in the way!

As with the PHD Guiding program, Lin-guider has an inital calibration phase where it slews the mount back and forth in both axes, and then it's ready to track. In this example, I ran it for 50-sec (two divisions on the graph) with the controls turned off (to show the unguided errors building in RA and Dec) and then enabled guiding on both axes:
File comment: Auto-guiding test on Alkaid
linguider2.png [ 297.77 KiB | Viewed 8702 times ]
This shows that the RA control-loop pulls in within a few seconds, whereas the Dec axis takes a little longer (due to the considerable backlash in my mount - in fact I had to set the Dec control-loop to average over 3-sec to prevent it from oscillating about the aim-point). Then from 20-sec of turning on the guiding, the tracking is maintained within a few arc-seconds (the vertical axis is 10" per division).

Author:  rwilkinson [ Mon Apr 27, 2015 9:29 am ]
Post subject:  Re: The life of Pi

The latest version of my Pi-Guider uses an old 135mm f/2.8 lens (a recent purchase from eBay). With the Pi camera attached, this can be clamped to the dovetail-bar on top of my refractor (or beneath my SCT) using the bracket which Gerald made for me, along with the Raspberry Pi itself:
File comment: Pi-Guider assembly with 135mm lens. The orange sleeve is a dew-heater and the white cable carries the four control signals to the guide-port of my mount.
guider135.jpg [ 231.12 KiB | Viewed 8590 times ]

So now with the Pi mounted on this bracket right next to the camera, I've been able to use a short ribbon-cable for the video feed, and have set up the Pi's wireless link to act as a local server (so that I can connect directly to it from my laptop or tablet without needing to go through a WiFi router). This remote display is only used for the initial set-up, after which the system can run stand-alone, needing only a 5V supply from a battery.

Last night I tried it guiding on a 7th-magnitude star. This screen shows it running first unguided for a couple of minutes (to illustrate the RA periodic errors and declination drift) before I turned on the guiding:
File comment: A VNC window on my laptop showing Lin-Guider running on the Raspberry Pi
linguider4.png [ 195.26 KiB | Viewed 8590 times ]

Whilst it was running, I was surprised to see that even though the tripod was set up on the lawn, as I walked past it on the path the vibrations were clearly visible on the error-signals.

Author:  rwilkinson [ Sat Jun 06, 2015 8:58 pm ]
Post subject:  Re: The life of Pi

My latest experiment was imaging Jupiter using the Pi camera on the back of my TS 70ED refractor. With a focal-length of just 420mm this is not ideal for high-magnification work, but the tiny pixels (just 1.4um) in the sensor help to alleviate this.
I was experimenting with the 'scope set up on just a lightweight Celestron LCM alt-az mount, and without the benefit of my usual flip-mirror - but in the qastrocam-g2 program I can see first the (scaled-down) view of the whole sensor, to help position the planet near its centre, before switching to cropped mode and capturing its central portion into a .AVI file.

Jupiter was only just visible above a neighbouring roof, from which the rising warm air made the seeing poor, but I captured a sequence of 200 frames, and made this image from the best 180 of them:
File comment: Jupiter (with Europa, Io & Ganymede) on 3-Jun-2015.
Imaged using Raspberry Pi camera on 70ED 'scope and processed in RegiStax 5.1

jupiter-2015-06-03.jpg [ 10.21 KiB | Viewed 8421 times ]

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group