The Beeb Bodybuilding Course Part 129 By Mike Cook The Hamster Joins In In my house all members of the household are roped in to help with Body Build projects. Well this time it was the pet hamster's turn to help, which maybe explains why he choose to escape just as I was about to start my experiments. Nothing cruel you understand but I thought it might be a good idea to look at the ways we could use our computer to monitor the movements of small animals. This can make a fascinating school project or even the start of your own research. I know that in the past some of my interface projects have been used in animal behaviour research. One was used to monitor the hatching times of fruit flies and another to look at the daily movement cycle of edible snails. The idea here was that the researchers were looking for quiet times so that they could alter the biological clock making the snail think a day was much shorter. In that way they hoped to rear snails more quickly. Needless to say these was not for English consumption, on this occasion it was the Greeks. I had noticed that the nocturnal habits of "Shadow", our pet hamster, were quite strange. So much so that he had been passed from Graham to Alec because Shadow's cage-chewing habits kept Graham awake at night. I thought it might be interesting to see just what activity Shadow showed. However, the techniques are not confined to hamsters but can be modified to cope with anything from insects to small mammals. Computers are a godsend for those interested in monitoring animal activity, all that data can be taken slowly and steadily over long periods, dumped to disk and analysed. With the advent of a multi-tasking desk top you needn't loose the computer to this task. However, you must be careful not to use an application that will crash or cause the computer to reset or you will loose you data as well. You are not so much interested in detecting every movement of the creature, but rather the times of major activity. The trick here is to match your sensor to your subject and the question you want to answer. For example, does a goldfish take a nap, or how many miles can a hamster run in a week? Not only do you have to do this but you also have to make sure that your sensor does no harm to the subject and the subject does no harm to your sensor. Well let's look at the hamster problem first, a fairly simple sort of monitor could be made to detect the movements of the exercise wheel. This of course depends on whether you have a hamster that is partial to using it. The two we had before Shadow would never go near the thing and I was beginning to think they were just a con foisted on us by pet shop owners. However, Shadow really gave the exercise wheel some hammer, so much so that monitoring it's time of use or maximum speed might make a very interesting project. This is basically a tachometer problem, where we need to get the wheel to feed us a pulse at least once every revolution. I think this is best done by using a reflecting opto-switch with strips of foil glued on the outside of the wheel. However, these are designed to work at a distance of a few centimetres so this would mean mounting the electronics inside the cage. Now, if your hamster is anything like ours this means that it would get severely chewed, not much damage to the hamster but it could get expensive. Therefore I decided to adopt the direct approach and have an infra red beam across the cage. In that way all the electronics would be out of gnawing range. In order to make the wheel break the beam when it was turning I glued a small pieces of plastic on the outside of the wheel rather like figure I. The sensor and emitter were both placed in the end of long cardboard tubes. This was to shield the sensor from external light and to prevent the light from spilling out. As the distance between the emitter and sensor was a little long I had to resort to an amplifier at the sensor end. Note here that this is an AC coupled amplifier, this was because we are only really interested in movement and it also helped prevent any slowly changing background light interfering with the measurements. The electrical circuit can be seen in figure II. Note here all you need is a digital input to your computer to perform the monitoring. This could come from a User Port, IIC interface or even the BUSY line of any printer port. Monitoring a goldfish using the same technique could be done but it is a little more tricky. This is one area where I have not actually conducted any experiments but an initial idea might be to set up a beam across the tank. To cover more of the area you could arrange for mirrors, either inside the water or stuck on the outside of the tank to bounce the light around the tank, like figure III. This could be tricky to set up but would be quite effective. Remember however, that when light enters the water it is refracted, the water acts like a prism. This will need compensating for when you make your setup. However coming back to dry land I have found that the most effective movement monitoring is made by using conducting bedding. What is more, making the bedding is perhaps the only use you can make of those personal paper shredders that seem like such a good idea in a catalogue. The idea is that you get some paper and scribble heavily on both sides, make sure that you cover the paper thoroughly and leave no white showing. It is best to use a soft pencil for this, but nevertheless it is a bit of a messy business. Then take the paper and put it through a shredder, or failing that cut it up into long thin strips, and then scrunch it up. Now we have to put this on a piece of Veroboard that has been wired up as shown in figure IV, every alternate track is connected together. The idea is that the paper lies on top of the copper strips and some of the paper bending makes an electrical contact across the copper strips. If we monitor the resistance of this contact with our computer we can be quite sure that changes in resistance correspond to movement of our subject. In fact you only need a thin layer of this conducting bedding close to the Veroboard, the rest can be conventional straw and sawdust. The trick is not to have too much on top or the movement of our subject will not trigger any changes. This technique also works well, I believe, with insects. One long term problem is that the copper tends to corrode under the influence of certain wet substances. This can be prevented by placing a layer of cling film over the conducting bedding. One problem with measuring the resistance is that Analogue to digital converters always have noise causing the readings to change even in the absence of any resistance change. Fortunately this is easily coped with by software, the idea is that you take the difference between the current reading and the last one. Then to detect movement all you need to do is to see if that difference is above some threshold. Measuring resistance can be done easily using the circuit in figure V, however it could be that in your arrangement your subject is too light to make a measurable change. In that case you can always use the amplifier in figure II, again being AC coupled it should be almost self adjusting. The only snag with this type of monitoring is that you need an Analogue Input port, this could be the joystick port or the analogue input of an IIC device. One point about the software is that you have to consider what you want to measure. Normally you will need to take samples at a slow rate if you are not going to swamp yourself with data. Recording one floating point number every minute will give you about 12K of data per day. However, you don't just want to sample the circuit once a minute as you could easily miss something. Therefore what you want is two rates, one to record if any movement has been made it that period and the other to look at the sensors. There are many formats you can choose from but the one I have found most useful is to sample every second and count each time movement is detected. Then every minute record a byte of these counts. In case the computer does not let your program get a look-in every second, what you record is not the count but a normalised count. That is simply the number movements detected divided by the number of times you have looked. If you see movement every time this will be 1 otherwise it will be some decimal number less than 1. Another point about the timing is that you should not alter the value of the TIME variable in Basic, as this could upset other multi-tasking programs. What you should do is to make a copy of its value in your own variable, add a constant representing the time delay to this copy and then test it against the TIME variable to see if you should take a sample. Well there you have it your own animal behaviour laboratory, as someone once said "Behavioural science is just a matter of pulling habits out of rats", see you next month.