Category Archives: Uncategorized

Elite dangerous controller

Whilst ordering some new arts for a couple of projects, I came across the zero delay arcade by Reyann.

board

It is intended for raspberry pi etc. controls for creating arcade consoles and appears to be USB plug and play so I thought I’d give it a go and make some additional controls for elite:dangerous.

dscn4619

This prototype has been lovingly crafted for the cardboard box that my delivery arrived in. No setup required and it just plugged in and worked.

The kit comes with the wiring loom and usb cable so it’s just a case of slipping the buttons on to the wires and off you go. It connects perfectly with the arcade buttons but not so well with the smaller tactile ones which required some structural blu-tak – a couple of mins soldering would fix it but these buttons are only temporary.

dscn4610

Windows sees it as a generic controller and E:D responds in a similar way, so there is no issue in assigning the buttons to the massive list of controls available (copy and save your key binds though. They’re very fickle).

The arcade buttons themselves are made by Sanwa and are spot on arcade quality – you can roll your finger on them like a real arcade machine and they feel like they could go on forever.

The joystick too is a Sanwa item and just oozes quality.

The larger buttons are (I think) from Adafruit. They are a bit more clicky than the arcade ones but very tactile. The 100mm HAL special in the middle is impossible not to touch and brings out the father dougal in everyone.

lit

They also light up, I’ve not tried this yet but it looks to be pretty straightforward and some of the online pictures make them look very effective (e.g. the HAL 9000 replica on adafruit )

dscn4616

For a prototype it works perfectly and the next step is to work on the case and assemble the required buttons. This was pretty much thrown together to see if the board worked however having played for a bit today the HAL9000 / pacman mashup has really grown on me so I think I’ll keep it!

dscn4617

In summary:

Controller board

By Reyann. mod my pi link: https://www.modmypi.com/raspberry-pi/arcade/arcade-controllers/zero-delay-arcade-usb-encoder-and-wire-set/?search=arcade

Arcade buttons

 By Sanwa – mod my pi link : https://www.modmypi.com/raspberry-pi/arcade/arcade-buttons/official-sanwa-arcade-button-black/?search=sanwa%20arcade%20buttons

Arcade stick

By Sanwa Mod my i link : https://www.modmypi.com/raspberry-pi/arcade/arcade-joysticks/official-sanwa-8-way-arcade-joystick-jlf-tp-8yt/?search=sanwa

Illuminated buttons.

By Adafruit. Mod my pi link : https://www.modmypi.com/electronics/buttons-and-switches/massive-arcade-button-100mm-red/?search=arcade%20buttons

Trailcam – 8. updated

Other sections

  1. Introduction
  2. Basic setup & Power
  3. PIR sensor
  4. IR lamp
  5. IR filter
  6. Buttons
  7. Completed pics, improvements and parts list
  8. Updates

Pi

The first main alteration has been to swap out the pi model A for a pi zero, partly to save power and partly to save space.

inside, showing the massive tangle - hopefully soon a longer pi zero -> camera cable will be available.
inside, showing the massive tangle – hopefully soon a longer pi zero -> camera cable will be available.

The main board is set up for a 26 pin header and not the 40 pin of the pi zero, so for the time being I’ve chopped a section out of a spare 26pin connector so that it fits. I intend to convert the whole setup to 40 pins in time.

chopped down 26 pin connector. I also removed the top layer of the pimoroni case to get it to fit.
chopped down 26 pin connector. I also removed the top layer of the pimoroni case to get it to fit.

Detection code

The pyhon prog that controls the light is a massive mess so I’ve streamlined it a bit after some further reading form mod my pi. This is a lower resource bit of code and I’ve also incorporated the date time module so that it doesn’t waste battery power turning it on it the daylight.

Initial results weren’t too good so I’ve tinkered with it a bit and will continue to do so until it works as required.

#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import datetime

#setup date and time vars
now = datetime.datetime.now()
dusk="2130"
dawn="0500"

# Set pins to BCM
GPIO.setmode(GPIO.BCM)

#PIR setup
#set up PIR pin
PIR_PIN = 22
#set PIR pin as input
GPIO.setup(PIR_PIN, GPIO.IN)

#relay setup
# Set relay pin
GPIO_LIGHT_ON = 17
# Set relay pin as output
GPIO.setup(GPIO_LIGHT_ON,GPIO.OUT)



def MOTION(PIR_PIN):
 print "motion detected"
 if now.strftime("%H%M") > dusk or now.strftime("%H%M") < dawn:
 GPIO.output (GPIO_LIGHT_ON,1)
 print "light on"
 time.sleep(10)
 while GPIO.input(PIR_PIN)==1:
 time.sleep(10)
 GPIO.output (GPIO_LIGHT_ON,0) 
 print "Light off" 
 print "motion stopped"

print "PIR Module test press Ctrl+C to exit"
time.sleep(2)
print "ready"

try:
 GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION)
 while 1:
 time.sleep(100)
except KeyboardInterrupt:
 print "quit"
 GPIO.cleanup()

Lens glare

After fitting the lens in front of the filter I began to get lens glare. After a bit of experimenting I ended up turning the lens round so that the glass touched the end of the filter tube and the back end of the lens created a hood.

lens blu-tacked on upside down. If it works ok then I'll fix it properly and I've got a new IR filter switch coming which may change the arrangement.
lens blu-tacked on upside down. If it works ok then I’ll fix it properly and I’ve got a new IR filter switch coming which may change the arrangement.

Button(s)

Initially the pi had 3 buttons, temporarily fitted to a small breadboard. When the pi is setup outside it is put in position then the “reboot wifi” button is pressed to re-establish a link to the network.

In practice this soon became an issue as the buttons had to be forced in to the enclosure then the lid screwed on, resulting in lost screws and accidental shutdown by pressing a wrong button.

The box now sports a lovely maplin waterproof switch – this operates the wifi reboot and nothing else (the led to signal that it has worked is fitted in the box). Overall, much easier to use.

inside and outside pics of the button - apparently vandal proof but it remains to be seen if its squirrel proof
inside and outside pics of the button – apparently vandal proof but it remains to be seen if its squirrel proof

Lamp

The light from the lamp has been disappointing recently. It could be due to a variety of reasons including the angle (it is fitted to look downwards), battery voltage (it needs 12v but is getting 8.4v max from the rechargeable) & the settings within pikrellcam (e.g. white balance, night etc).

old lamp board, with the broken solder pads and bodge to get it to work
old lamp board, with the broken solder pads and bodge to get it to work

I had another kit so I’ve built it and swapped out the 220 ohm resistors for 100 ohm, based on information and calcs via ledcalc.net. Whist buiding the kit I took the opportunity to modify the way the lamp connects as the soldered joints were prone to detaching and multiple resolders have messed up the solder pads. Finally, I’ve changed the angle on it so that the downward angle is reduced.

It remains to be seen if this helps!

 

Edit:

it does – the video below was taken with the altered lamp and offers a significant improvement over the old. I just need to sort the white balance out (I’ve converted this to B&W to try and reduce the effect but it still “pulses”)

Trailcam – 2. Basic setup & power

Other sections

  1. Introduction
  2. Basic setup & Power
  3. PIR sensor
  4. IR lamp
  5. IR filter
  6. Buttons
  7. Completed pics, improvements and parts list
  8. Updates

 

Rpi basic setup

  • Raspbian o.s. on SD card*
  • Wi-Fi
  • Ssh
  • Pi noIR Camera

*: The pi runs the now superseded raspbian wheezy – I’ve had no issues with it so haven’t upgraded to Jessie on this particular pi.

The above is set up and confirmed working as described on the raspberry pi foundation website and numerous blogs and websites.

  • Video (pikrellcam)

This excellent piece of software is described in detail by its creator here: http://billw2.github.io/pikrellcam/pikrellcam.html where it can also be downloaded.

A further description & discussion is on the foundation website here:  https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=115583

Power

The first step is to provide power to the Rpi.

I’ve used a rechargeable battery from Amazon that is designed to provide emergency power to phones etc.

It’s a huge lump in terms of capacity, physical size and weight however it has performed flawlessly in the last couple of years. It takes a while to charge but holds it really well and lasts long enough to power the pi all night as well as for an hour or so to get the videos off of it in the morning.

It needs a pretty hefty power supply and I went with the recommended, branded one – this is also really handy for powering a pi2 with Wi-Fi when not charging the battery.

 

Trailcam – 7. Completion

Other sections

  1. Introduction
  2. Basic setup & Power
  3. PIR sensor
  4. IR lamp
  5. IR filter
  6. Buttons
  7. Completed pics, improvements and parts list
  8. Updates

 

Box / case

I’ve built the camera to be modular which helps when tinkering about with it but does take up a lot of space, hence the rather cramped appearance.

Camera in window cill mode
Camera in window cill mode
inside the camera
The tangly, wirey mess inside the trailcam. Generally, sensing on the front front piece, switches to the right of the main section and wi-fi on the left. 9v battery to the top with the switched tucked away from squirrely teeth.
inside front of camera
Inside of the front section with the IR lamp (top), camera and filter, PIR sensor. All held on with non committal bl-tak and gaffer tape! – it’s the future.
front view
Front (animal eye) view. I shall call him HAL and he shall sing nursery rhymes while he looses his mind.

Component list & suppliers

 

Item supplier Link
Battery – Easy Acc 1200mAh power bank. Amazon UK http://www.amazon.co.uk/gp/product/B008YRG5JQ?keywords=EasyAcc%2012000mAh%20Power%20Bank&qid=1452114498&ref_=sr_1_1&sr=8-1
Raspberry pi A RS Bought together but no longer available
Pi noIR camera RS
Wi-Fi adaptor Modmypi http://www.modmypi.com/raspberry-pi/accessories/wifi-dongles/wifi-dongle-ultra-long-range-high-gain-w-5dbi-antenna/?search=wifi
Relay Ciesco – now wirelessthings https://www.wirelessthings.net/3v-relay-board-supports-logic-level-kit
Lamp Maplin http://www.maplin.co.uk/p/infrared-spotlight-module-a23jn
IR filter eBay http://www.ebay.co.uk/itm/381270484479
Filter controller IC Modmypi http://www.modmypi.com/electronics/integrated-circuits-ics/l293dne-dual-h-bridge-ic-solenoid,-dc-and-stepper-motor-driver/?search=ADAS-807
Circuit board

Adafruit permaproto pi

Modmypi https://www.modmypi.com/search/?search=ADAS-1148
Circuit boards

Adafruit permaproto ½ size boards

Modmypi http://www.modmypi.com/raspberry-pi/breakout-boards/adafruit/adafruit-perma-proto-half-sized-breadboard-pcb-3-pack/?search=adafruit%20board
Buttons Modmypi http://www.modmypi.com/electronics/buttons-and-switches/colorful-tactile-button-switch-assortment-square-15-pack
PIR sensor Tandy  http://www.tandyonline.co.uk/pir-motion-sensor-module.html
Wires and other bits pimoroni https://shop.pimoroni.com/
Camera software pikrellcam http://billw2.github.io/pikrellcam/pikrellcam.html

GPIO Pin summary

Board

(physical)

BCM

(logic)

Use
12 18 Button 1 (green) – reboot
7 4 Button 2 (yellow) – restart wi-fi
26 7 Button 3 (red)
5 3 LED
16 23 Motor 1A
18 24 Motor 1B
22 25 Motor 1C
11 17 IR Lamp (connection to relay)
15 22 PIR sensor

Examples

Filmed through glass and saved as an mp4

Filmed outside running on batteries. Video has been cut down in length using windows movie maker so is saved as a wmv

 

Now using adobe elements and with the interesting vids cut together

Improvements

Now that the weather has given me the chance to run the project outside, there are a couple of areas that I’m not happy with:

  1. reflection – there looks to be a noticeable reflection from the light on the lens (not helped by the badger nosing it!. I need to find some way of keeping it waterproof whilst stopping the reflection – also might try and find a way to stop the IR filter cutting off the corners of the image.
  2. Brightness of image – the image is too dark and noticeably darker than the previous version. I think that this is partly due to the camera being set as “auto” (hence it brightening up after the bager nosed it) and partly due to the lamp
  3. Lamp connection – The hardware weak point is the connection to the lamp. At every opportunity the wires fall off to such an extent that the solder pads on the lamp have fallen apart.

Laptop charging issues

Here are a couple of photographs to show the power jack board:

1. Bottom of the power jack board showing where the power jack is soldered on. 1 connection to the central pin and 2 x connections for the outer.

bottomofboard

2. Power jack board in situ – top plate of the laptop has been unclipped and moved to one side without disconnecting the cables.

insitu

3. Power jack board out of the laptop.

topofboard

Nut Dispenser – 3B. Hardware(dispensing mechanism)

This has proved to be the trickiest part!

Initially i’d hoped to dispense standard, roasted monkey nuts as the squirrels love them! I’ve built many variations of the dispensing mechanism out of foam card however it was proving to be really tricky with the irregularly shaped nuts and their friction.

I’ve tried all sorts of mechanism from the simple opening and shutting of a spring loaded door to the moving of gravity fed nuts using a cut out like the board game downfall.

Downfall game – (image from skooldays.com)

The downfall was my favorite but very problematic with the monkey nuts so I changed to using shelled nuts which were much easier to dispense.

Above all the design needs to be reliable so I have constructed many prototypes with the most reliable by far being a simple trap door – I don’t mind it dispensing too many nuts at once however I don’t want it to clog up and this design proved to work well.

Prototypes - (clockwise from top left) the flapper, the hopper, the noisy cog and the downfall
Prototypes – (clockwise from top left) the flapper, the hopper, the noisy cog and the downfall!

The whole thing needed to be motorised and the foam card just wasn’t strong enough so I reverted to creating the mechanism from Lego at this stage. This was an easy decision as I have tons of it ahnging about with the only downfall ( 😉 ) being that I didn’t want to conform to the lego standard dimensions however for a prototype it would be fine.

 

 

 

Nut Dispenser – 3A. Hardware (electronic)

The hardware for the project can be broken down in to 2 main sections – the electronic control of the various sensors and the mechanism to dispense the nuts.

A) Electronic control.

Having played around a bit with breadboard I’ve worked out what I’d like to have for the various inputs and outputs:
1. Motor to drive the nut delivery system behind a reed switch or relay.
2. Microswitch to tell the pi where the motor is – to stop it chucking out tons of nuts or none at all!
3. Motion detector – I’ve bough one from Tandy which works pretty well .Not sure of the use for it yet but I:m going to add it in should it be necessary in the future.
4. Switch to trigger if the nuts are deployed. (possibly an IR breaker beam rather than a switch to avoid complex mechanical issues).
5. LED. A light that I can configure to show different colours. I’ve chosen a RGB LED so that it can be positioned in one place with the colours showing the status – I’d considered several different coloured ones but was concerned that the wildlife would notice the position of the light (i/e 3rd from left) rather than the colour = possibly a new experiment, though.

I wanted something that was easy to connect to the pi and so have come up with a veroboard circuit that connects to the pi via a ribbon cable.

This has the various connectors in place to make it fairly easy to connect up the swiitches etc and the ribbon cable to ensure that they are alwas connected to the correct pins on the pi.

The second piece of veroboard has the connection for the lego motor – these have special connectors and I decided to use an old battery box as a doner for the plug. I then soldered this on to some board and glued it down having worked out the pin arrangement from here: http://www.philohome.com/pf/pf.htm

It all works pretty well however the wires are inclined to come off the pins at the slightest vibration! Also I’ve had trouble passing 9v through the opto isolator as it sticks at anything over 3v – I’ve since got some relays that may prove better.

wildlife camera

I’ve had a bit of a break from the pi powered feeder over the past few weeks however I’ve been using it to work with our ip camera to record some night shots of the wildlife in the garden.
Over the past few evenings we’ve set the camera to look at the garden with the pi running “motion”. I’ve got hold of this inexpensive IR lamp from amazon and I’m using it with a cheap ip camera from here.
I’ve altered the camera a bit so that I have a switch to turn on & off the built in IR lamps – they’re really good however the camera is behind glass (on the windowcill) and they reflected off the glass. – basically I simply dismantled it and ran a switch over the LDR so that it could be bypassed.
After a bit of setting up from both the camera and motion I can leave the pi running all night silently creating videos of all motion. – the camera was pretty simple to set up having used the disc supplied and motion works excellently after reading the very extensive and detailed online documentation. – once its set up it can be accessed on the specified port (8080 in my case) to work through the options.
I’ve installed Apache on the pi so that it can be accessed from the local network and the videos are saved in a default way that organises them in to month/date.

The link below is for a video recored last week:

(Neither of these seem to work properly and I’m getting pissed off with trying to get videos to work on this blog! – so no more posting of videos)

deer (wmv)

deercam (avi)
This video is not the best quality as I’ve got it set up for night vision with high brightness but you can clearly see our visitor – a small deer which is quite special in such an urban, shared garden!

I’ve also got the CSI camera fitted to the pi which is significantly better in quality – I’ve got this working in a slightly different way and it’ll make a huge difference in picture quality when I intergrate it in to the whole system.

Nut Dispenser – setting up the pi part 1 – VNC

Having made the decisions about the design of the feeder I needed to begin getting the basics of the pi set up together.

AS I’m going to be using RISC OS there are a couple of hurdles to overcome that aren’t present in linux.

The shopping list for the pi setup is:
1 – Remote access for running the program (or monitoring if autonomous).
2 – Wireless networking.
3 – Sending or recording video.
4 – Get it working from battery power.

Before I get to running wirelessly I thought I’d begin with accessing the pi from a remote computer using its current remote connection – For this I used the VNC server by Adrian Lees – http://adrianl.drobe.co.uk/
He describes this as a shaky alpha release but, while a bit slow, it is perfect for running my basic program.

RISCOS for Pi running via VNC on my laptop
RISCOS for Pi running via VNC on my laptop

I accessed it from the laptop using tightVNC which provided a good & stable connection. The pi is set up to display on my tv using hdmi and I didn’t want to fiddle with the screen resolution, so I wasn’t surprised when it didn’t like running at 256 colours.

 

Nut dispenser – 1. Concept

With our squirrels and jays becoming a bit more used to our presence I though it would be fun to create an automatic feeder. Rather than simply dispense nuts the idea was to get them to work for it and to see what they see in terms of colours. Initially this consisted of a coloured l.e.d. that showed if a nut was present (e.g. red for none, green for present etc) with the nut being obscured so they could only tell via the colours.
I have grown this idea in my head to the point where I thought it would be fun to construct a dispenser that had several functions and then use them in a modular fashion to create various scenarios for the creatures to go through before they received the prize.

This idea was left for a while until my niece & nephew gave me a bird house for my birthday – unfortunately it is not possible to put up a permanent bird house in our communal gardens but the shape of it made me think that I could build my dispenser inside – so I did!

birdhouse
The birdhouse that will house the feeder

The following posts show how I am going through the design and build of this project.