Category Archives: University

IMG_20140227_153625 (2) thin

AberCam Upgrade 3 – Wind!

Got a wind speed sensor from Maplin’s Ebay shop for £2.50. Stuck it in a bit of polystyrene and used my computer’s case fans to blow air at it for testing purposes. I imagined there would be a little motor in there, and different (tiny) voltages would determine how fast it was spinning – nope that was wrong. What happens (I imagine with a magnet and reed switch, as I’ve found some use that) is that every half a revolution, it makes (or breaks, can’t remember) the circuit, so I just plugged this straight onto my breadboard where I had been testing push-to-make buttons with Python, Pi GPIO and interrupts (really easy to do, and eats 90% less CPU than just having the script whirl round in a while True: loop).

wind sensor

After a bit of maths to convert the RPM to mph (basically speed = distance/time, and time = 1/frequency(rpm)) I started to get some realistic values. Also after some research, most desk fans blow air at about 4mph if you are a foot or two away from it, so used one to test my results were feasible.

Next I got a bit of wood, drilled some holes in the end of it so the wind speed sensor and its wire could be secured, and stuck it out the window.

abercam looking at wind speed sensor

Other News

In other news, I was in some credits!

credits

Some of the footage taken by me of the Aberystwyth storms made it into the programme “The Storm That Stole Christmas” on Channel 4 (27th Feb, 9pm), so I was listed in the credits!

Matt

AberCam Upgrade 2 – Focus

Had the problem that AberCam’s webcam with its autofocus kept focusing on the dirty window that it was sat behind, so had a look to see if it was possible to stop the webcam autofocusing, and stumbled upon this great tool called uvcdynctrl. Downloadable here (or for the pi, use apt-get install uvcdynctrl), and there are some examples and a list of functions and explanations here.

With uvcdynctrl, you can stop the camera autofocusing (uvcdynctrl -d /dev/video0 [if its the only camera - video zero] -s [set] “Focus, Auto” [param] 0 [value - zero in this case].

A good idea is to -g [param] before you set it, so you know what the parameter was set to before you changed it. Also you can -S (capital S) and save a backup of the config file.

Another feature is being able to edit the zoom! e.g: uvcdynctrl -s “Focus (absolute)” 3 [try values 1-5 inclusive].

Also just found a great feature – uvcdynctrl -vc (verbose list of controls – tells you the bounds and step sizes for each param!)

Currently playing with the pan and tilt (e.g of a zoomed in image, my camera doesn’t physically move), managed to get them to each set once, but once attempted to be set, each defaults to the value 36000 and won’t move again. Looks like it could be to do with the webcam driver – oh well, not essential.

Looking at buying a little wind speed sensor to compliment AberCam’s temperature sensor!

AberCam’s focused view:

abercam view

Abercam Upgrade

Finally got around to adding the temperature sensor to Abercam. The temperature sensors I got (DS18B20 ones I believe) use the Dallas 1-Wire protocol to communicate with the Pi, meaning you can attach many temperature sensors in parallel, and the Pi can differentiate between them all and interrogate them individually, without having to use tons of GPIO pins, one for each sensor.

I dug out a 4.7k ohm resistor that I used for this Adafruit tutorial regarding temp sensing on the Pi, and used PHP from this YouTube video to get the temperature.

The PHP script simply opens the w1_slave files, finds and nicely formats the temperature. The HTML uses JQuery to request the .php file every 5 seconds and updates the HTML accordingly.

 

Hang about, I haven’t got PHP on my Pi

No problem, if you aren’t using a LAMP server – e.g I’m using lighttpd for my webserver, install php with the command:

sudo apt-get install php5-common php5-cgi php5

 

This guide I have refered to suggests installing the PHP MySQL libraries if you are using MySQL. Another good, similar, guide is here.

sudo apt-get install php5-mysql

 

After, enable the fastcgi-php module and reload the server:

sudo lighty-enable-mod fastcgi-php

sudo service lighttpd force-reload

Abercam with temp

That all works lovely on a local network, but when using my website to try and access the Pi to get the temperature, I ran into the problem of being stopped from accessing another server and displaying its information on my webpage due to the threat of cross-site scripting attacks. Ways to get round this are make an API or possibly use cURL. I also considered using FTP to upload a file every minute from the Pi containing the current temperature, which would be included in the webpage. Currently, I am using the below script, with a 20 second timeout, and the line “header(‘Access-Control-Allow-Origin: *’);” in the php file it is accessing.

This works really well now, with the page requesting an updated temperature every 20 seconds. Might have to revert to the FTP solution if getting the temp from the Pi is too slow or causes it too much extra traffic.

Matt

 

The Scripts

temp.php

<?php
//File to read
$file = ‘/sys/bus/w1/devices/28-000004abb89f/w1_slave’;

//Read the file line by line
$lines = file($file);

//Get the temp from second line
$temp = explode (‘=’, $lines[1]);

//Setup some nice formatting
$temp = number_format($temp[1] / 1000, 1, ‘.’, ”);

echo $temp;
?>

 

HTML

<html>
<head>
<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js” type=”text/javascript”></script>

<script type=”text/javascript”>
$(document).ready(function(){
refreshTemp();
});

function refreshTemp(){
$(‘#tempHolder’).load(‘temp.php’, function(){
setTimeout(refreshTemp, 5000);
});
}
</script>
</head>
<body>
<div id=”tempHolder”></div>
</body>
</html>

 

Abercam Viewers, Pi Rover, PiMS

Abercam

As we have been in the middle of a good storm here in Aberystwyth, Abercam has again been getting a good few hundred different people viewing it every day, and over 3000 page views this month. As well as streaming live images of Aberystwyth all over the world, I also tasked it with taking a snapshot every couple of seconds, which I have made into time lapses and stuck on YouTube here.

abercam shots

 

Pi Rover

Found this great YouTube video of a chap who has done many different random things such as making a little printer and milling machine using the Pi, but what interested me most was he has also built a Pi Car… And you can drive his little Pi Rover here: http://www.homofaciens.de/technics-robots-rover-control_en_navion.htm

 

PiMS

PiMS? Yes it has Pi in it. Its the topic I have chosen for my dissertation here in my final year at Aberystwyth. I will be creating a Raspberry Pi Management System that will manage engines such as those found in the Internal Fire Museum of Power in Cardigan. The system will monitor different temperatures, fluid levels (water/oil/fuel etc) and engine speed, notifying museum staff if any of these falls outside a set range.

 

Now back to work…

Matt

 

 

Course Representative

At the start of this year, the head of our Staff – Student Consultative  Committee asked for volunteers from our course to be course representatives. Course reps meet on a regular basis with staff to help improve things for students, and give feedback on academic issues such as lectures, practicals, assignments and whether they are working well or not.

Course Rep Hoody

Course Rep Hoody

I have enjoyed being a Course Rep this year, and will definitely aim to carry on when I return in my final year, so I can continue to help to give a positive impact on the department by improving academic issues with feedback given from the eyes of a student taking the course.

Matt

Air Ambulance Trip

Today, me and some of our first aid division did a trip up to Caernarfon to see the Air Ambulance, and the local ambulance station. Starting off from Aber at 7.40 (>.<) we trekked up to Caernarfon airport – a little air strip by the sea, very nice! As we got there, the Air Ambulance was just landing – and one of the gentlemen that flew in it very kindly showed us around the helicopter.

Me in the Air Ambulance

We saw that the space inside is actually very cramped, barely enough room to tend to a patient, despite having 2 sliding doors (one of which the stretcher slid out of and was held so a patient could be transferred to a bed outside) and a set of opening doors at the back too.

Air Ambulance

We also saw how the crew can easily work out the time it will roughly take them to get to an incident, using a very inventive magnet on a piece of string. You put the magnet/marker on the place to go, and the string draws a direct line from the air base – indicating the heading on a square compass. Above the map, the string continued passing through painting hanging loops, and along the straight top of the board were little markers for the number of miles the incident was away – and the marker was just a bit of red tape on the string. When the magnetic marker is pulled away from the base, the string travels along with it, and the red marker moves along the “miles” indicators. A very clever, but simple way of working out how far away things are, and on what heading!

Navigation Board

We then travelled to Caernarfon’s ambulance station – where Dewi (our trip’s organiser)’s Dad worked. We had a look round a couple of Mercedes Sprinter ambulances, as well as a new Land Rover Discovery.

The sick-bowls given to Miranda (suffering from travel sickness) appropriated as a hat

It was extremely interesting learning what they carried in their NHS ambulances, and how some of it worked. Whilst having a chat with one of the paramedics, I also learned the Merc ambulances contained 2.6 or 3 litre engines, could top 110mph, and weigh up to 5 ton.

Mercedes Ambulance

The ambulance was called out a couple of times whilst we were visiting, and I got a video of it leaving:



After – we visited Caernarfon’s town centre – and was not overly impressed by the absence of the sense of safety given by the violent behaviour from children and adults alike. We had a good look around the castle, and I had a great play with Liz’s Olympus metal SLR camera – having great fun with the wide-angle/fisheye lens, and managed to get some good shots (in my opinion, anyway).

Ambulances

A fantastic day out, and I really hope we can have another soon! Thank you so much to Dewi for organising the trip and driving the minibus, and thank you to Liz for some of the photos in this post, and for letting me borrow her SLR!

Matt

Interactive Web Programming – Ministar Galactica

Ministar Galactica is handed in and complete!

Since the last post, many things have been added including:

Powerups!

  • Health
  • Nuke
  • Super Laser
  • Shield
  • Ally
  • Stealth
These were great fun to think up, draw then implement. Really adds a bit of fun to the game.
Other things added:
  • Pause button / in-game help button that pauses the game and shows help to the user
  • Added some more hotkeys – “p” to pause, “o” to turn music off
  • Many fixes
  • Made the game get increasingly harder as the levels progress
  • A fading in and out “LEVEL X” indicator when a user goes up a level
  • High scores page
  • About page
  • End game stats such as powerups used, enemies killed, bullets fired, accuracy
  • New table “Accuracy” to the database, and it prints also to the high scores page
And much more. Anyway, if you want to go and play it, head over to: http://www.matthewrobbins.co.uk/ministar/ and post a high score!
Had great fun creating this assignment, and hope to work on it in the future!
Matt

Interactive Web Programming – HTML5 – Progress

Almost one week and over 1000 lines of code later, I have my little HTML5 (well JavaScript really) game in a presentable format. Features of my assignment now include:

  • Sign up feature to create an account
  • Log in feature (name and password) that checks if the user exists and the password is correct
  • High scores – the top 2 high scores are featured on the game page, along with the person that set them (got from their logged in account username)
  • Added the concept of levels and an increasing difficulty as the game went on
  • A mute button to mute the entire program
  • Volume fixes to make the sounds generally quieter and more consistent
  • Fixes to stop the enemies falling off the left edge so much
  • A website to contain the game
Its been tough, but fun at the same time – creating something that actually works and I can play with. All I have left to do is an “about” page and a couple of other small bits and bobs.
In other news, helped out with the ATC (Air Training Core) Cadets again a couple of times this week, had a great time helping teach them first aid with scenarios involving cars etc. Had a lot of talking about Weetabix allergies in their attempts to keep me concious, discussions of tea when a child’s teapot was found in the back of one of the cars, and the most memorable quote of the evening “I feel like treasure” said a girl who just had an “X” marked on her forehead to indicate an injury.
Matt

Interactive Web Programming Assignment – HTML5

I haven’t posted on this blog in a while, partly because the very interesting Human Computer Interaction assignment is complete and handed in, for which I was improving the Aber LINKS site, and many new assignments have now taken its place over Easter. One I am currently working on for a module called “Interactive Web Programming” involves making a game using HTML5 (and mainly the HTML5 canvas) with a lot of JavaScript.  After reading up on some of the new additions to HTML5, and following a couple of tutorials, I have been able to start making a game from scratch.

In my little game, you have control of a a little “Viper” spaceship, which can be moved around with the arrow keys. At the moment, you can just fire one type of bullet that will destroy the enemy Cylon Raiders, and in turn increase your score. There have been many challenges with this assignment, mainly just creating a 2d game in JavaScript – and learning how JavaScript does have a version of constructors, objects and methods for those objects. Other challenges have included getting the game to respond to 2/3 key inputs at once (e.g telling the spacecraft to go up and left, and shoot), having the enemy ships move around the screen randomly without falling off the sides, and only allowing so many bullets to be fired per second.

Space Game

Currently, I have a moveable spacecraft that can fire bullets to destroy enemy craft. The enemy spawn at the top of the screen and move down in a seemingly random fashion, with many random calculations, some deciding sets of movements so some enemies movements are much different to another’s. When a bullet hits an enemy, the enemy explodes (need to add sound clip) and is destroyed along with the bullet, whilst the player’s score is incremented.

I still have much I would like to do including adding more  guns/bullets, possibly getting the enemy to fire back, different levels with harder opponents, a help menu, and a high score leader board.

A fun week of JavaScript lies ahead!

Matt

Data Structures in the Java Class Libraries Analysis Using Reflection

For our module “Data Structures and Algorithms”, I had an assignment to find something interesting in the Java class libraries, and analyse it using Java reflection. This assignment was very challenging, and the results had to be presented in a special report format, but I was very happy with my end result of 88%.

This was my first time using reflection in any language, and I was very interested to see the Java language looking and collecting statistics from its own classes etc. Finding something “interesting” in the Java class libraries came as a bit of a challenge – as I wasn’t sure what to aim for.

Preview of Paper

I started off thinking about Data Structures – something we had learnt a lot about in this module. There is a definite noticeable difference between the speeds of different data structures in Java (especially with large data sets), and this caused me to hypothesise that maybe there would be a relation between the code complexity and the speed of the data structure. In my report I investigated this by building a Java program to collect statistics about the classes, classes referred to by those classes etc and print the results out to the terminal or to a CSV (comma seperated value) file.

You can find my paper here if you are interested, and if anyone was truly interested in the code, I am quite happy to give advice on that too where possible.

Matt