FUN WITH FOAM The Beeb Bodybuild Course Exercise 43 By Mike Cook Most Body Build exercises involve the use of high technology to enhance or improve your BBC computer. Well this month I want to look at what you can do with a material whose only link with high technology is that it is used as packing material for it. This is the stuff that is always thrown away when you unpack your latest ROM; I am talking about black plastic conducting foam! To protect delicate electronic gates from damage by static electricity is fairly easy, in theory, simply connect all the pins together so that there can't be any potential difference between the pins. In this way the chips are kept safe. When the first FETs (Field Effect Transistors) were produced they were supplied with a wire lasso wrapped round all three pins. You soldered it into the circuit like this and then snipped off the wire before applying the power. However, with the advent of multi-legged beasties (integrated circuits ), a more practical method of protection was needed. One way was to use aluminium foil wrapped around polystyrene blocks. This is alright but you can only perform one insertion, if you plug the IC back in the same holes you find that the aluminium has moved away and no longer shorts out the IC legs. Conducting plastic foam was invented to overcome these problems and allow a safe and convenient way of storing ICs. Basically there are two grades: light and dense. The dense grade gives the IC legs some support whereas the light grade does not. However I have seen both types used for supplying ICs. If you buy ICs in bulk like I do, they usually come in long plastic tubes with an anti- static coating, the plastic foam is reserved for smaller quantities. Nevertheless I seem to have acquired a great collection of this stuff as I tend to treat it like we used to treat string, I never thrown it away. There are many different manufacturers and grades of conducting plastic foam, the main electrical characteristic being conductivity. This is measured in ohms per square. Remember the school teachers who would not accept your perfectly correct answer because you had missed the units off? "Ohms per square WHAT, Cook?" they would say! Well in this case it does not matter, it really is simply ohms per square. Let me explain: look at Figure Ia) where we have a square of conducting material which can be represented by a resistance of value R. Suppose we stick another square on the end so we now have a rectangle as in figure I b). As the resistors are in series they will add to give a value of 2R. Now suppose we add the extra square on the other edge as in Figure I c). The resistors are in parallel and so the total resistance will be half the original, namely 0.5R. Now if we combine these two rectangles to make a square the effect of the resistors in series increasing the overall value is exactly balanced by the resistors in parallel reducing the value and so we are back to our original value of R, see Figure I d). So you see the square does not need any units to qualify it. A typical conducting foam will be about 20K per square. However, the interesting property as far as we are concerned is that this value drops when the foam is compressed. This is because the individual filiments making up the foam are forced into contact with each other thus reducing the length of path the electricity has to travel. This can be used as a sort of pressure sensitive resistor which opens up potential for all sorts of applications. However, there are a few snags. For a start the material will tend to suffer some fatigue and so the reproducibility of results is not high. This means that it is no good for precision measurements such as weighing. Nevertheless, for a suitably chosen application this limitation can be irrelevant. Another snag with this material is the problem of how to make an electrical connection to it. If you apply a soldering iron you just end up with a charred bit and a bad smell. The ideal method would be to use an electrically conducting glue. I know these must exist but I don't actually know of one. You could then sandwich the foam between two plates and use it as a foot pedal or squeeze control. Fortunately you do not need to have electrical access to both sides of the foam to utilise the effect. I have some adhesive backed copper strip that I use in stained glass work, I also used it in the Anemometer project (August 85). This is ideal for making a connection to the foam. Simply stick the strip to some sound surface and lay the foam on top. Smooth the copper with the back of the thumb to get maximum adhesion. You can then solder wires directly to the copper strip. This is best done at the ends using fine wire, also make sure you solder quickly as prelonged application of the iron will bubble the adhesive and lift the strip. I used a thin perspex sheet for my experiments and found the heat caused the plastic to melt very slightly thus increasing the adhesion of the strip. Then if you like you can tack the foam to the surface with ordinary glue just to hold it into place. When the foam is compressed the resistance drops. You can now use the analogue input port of your Beeb to measure when and how much pressure is applied to the foam. As the analogue input port measures voltages we have to convert the change in resistance to a changing voltage. This is simply done as can be seen in Figure II. One strip is connected to an analogue input channel and also through a resistor to the reference voltage, the other strip is connected to earth. This is connected to the analoge input port by means of the standard 15 way D-Type connector and multi-cored cable. In the absence of any conduction by the foam the analogue channel reads the maximum voltage. However, as the foam starts to conduct it diverts current through it pulling down the voltage on the analogue input. The harder it is compressed the lower the voltage will be. You can experiment here with the value of the resistor. If it is too low then the foam will not be able to pull the voltage down very much. If it is too high the foam will easily pull the voltage down but you will then loose any proportional effect. The best bet is to experiment as it will depend on all sorts of factors. I found it best to keep the gap between the copper strips as small as possible when pressing on the foam with your finger. However large separation of the copper strips could be used when you want a pressure pad, hidden under a carpet, as part of a security monitoring set-up. One use of this material would be to make a very different type of joystick. As joysticks should give a midway reading when not being touched (self-centring) we need to pull up the analogue input as much as we pull it down. This can be done by using two identical resistors. Figure III shows a two finger joystick where pressure on one pad will raise the voltage and pressure on the other will lower it. As you have two axes of control on a joystick you will need two of these circuits, the other channel connection being shown in brackets. Alternatively, Figure IV shows a single finger circuit. This uses three strips of copper, the centre one connected to the input and the other two connected to the supplies. To achieve movement simply roll the finger from one side to another. In my prototype I did not manage to get the full movement range but it was close enough to be used with most applications that require a joystick. In order to monitor the effectiveness of these devices I used the program shown in Listing 1. This reads each analogue input channel in turn and displays its value along with a line proportional to this value. The use of a varying length line makes it a lot simpler to see what's going on and gives a better feel in assessing limits of pull and proportionality. You can make all sorts of variations on this simple theme. Figure V shows a four channel pressure sensor with the copper strips getting further apart. The idea is that the input reading will vary with the distance along the strip you apply the pressure. However this effect was not as great as I expected and I suspect that a little more experimentation with resistor values and copper strip separation would yield better results. Whatever the arrangement you can use this new form of input in all kinds of interesting ways. For example, let the strips control the sound channels from the touch and pressure of your hands. You could have the pitch and volume controlled separately or the speed of a rhythm unit under your direct control. Alternatively you can control patterns on a moving graphics display. The patterns will change and respond to your touch, for a start you could use the sound to light pattern program in the Novemeber 83 Micro User, this can be run with no modifications. "Sellotape" is a trade name which has become the generic name for what Blue Peter viewers know as self adhesive sticky backed tape. In the same way The Concept Keyboard is a trade name, however you can use conducting foam to make a "Concept like" keyboard. These keyboards are large and do not look like keyboards at all, instead they have some overlay picture and underneath there is a membrane switch. So if the program is about animals all you have to do to indicate to the computer a giraffe is to touch the picture of the giraffe thereby activating the switch underneath the picure. These keyboards are mainly used in education but can be useful where you want an untrained operator to make a limited response. However, with only four analogue input channels it would seem that we could only have four switches on our keyboard. We can expand the number of switches we can read by enlisting the help of the user port. Now the user port is digital so how can this help us? If you look at Figure VI you can see we can have a matrix of copper strips. You can lay this out on any size grid but I should keep at least an inch between each strip. Where the strips cross there is no connection, I used some of the backing off the copper strip to separate the columns and rows. Over this matrix is placed a large sheet of conducting foam and the point of pressure can be calculated quite easily. All the analogue inputs (rows) are pulled up. If all the digital outputs (columns) are at logic 1 then no row can be pulled down. If however, one column is placed at logic zero then this can pull the inputs down. The input pulled the furthest is the one nearest the compression on the foam. If the analogue inputs are checked while each column in turn is placed at logic zero then the lowest reading will indicate where the foam is being pressed. I used Body Build Packs1 & 2 to make the connections to the User Port (see Sep 86 for a brief description) but you could use a connector and ribbon cable. The program in Listing 2 is used to check out the construction. This places a zero on each user port output in turn then reads and displays the value on the analogue input port. To get the value of the travelling zero to output to the user port I use the simple method of generating a travelling 1, (start with 1 and keep multiplying by two). Then, before being output, I invert the value with an EOR command. The display of numbers is in the same formation as the matrix and you will be able to see it in action. I found I could get a better speed of response if I used the *FX17 command to force the conversion on one channel and then waited until conversion was completed. As *FX commands do not accept a variable as a parameter I had to call each channel up specifically. A tidier program could be made by converting the command into a string and passing it to the command line interpreter but this raises difficulties between BASICs 1 and 2. For incorprating into a program however, you need to give each matrix position a number and only scan the matrix when you know something is being pressed. An example of such a program is given in listing 3. To see if anything is being pressed simply put all the columns to zero and look at each analogue input channel in turn. If the reading is below some threshold T% then go and scan the matrix. This is done in a similar way to the previous program only this time we make a note of the value, column and channel number of the minimum reading. Then we can work out the matrix position from these values. The value returned will be the intersection nearest to the pressure. The only problem here is that the column value is a variable with a logic 1 in one bit, for each position to the left the bit is found we have to add four onto the matrix number (because we have four input channels). The program is not "de-bounced" which means that if you are rapidly changing from one key to another you might get some intermediate value. This is done deliberately so you can see the effect. In a real application you would either incorporate a delay before starting the matrix scan or else take two scans and only report back when successive scans gave the same results. To finish off the keyboard you can overlay a plastic sheet or put a cardboard mask with holes in to press. You could even cut out shapes in the cardboard and those would act as protection for the foam. Remember you can glue to the top surface of the foam with no detrimental effect. This type of keyboard involves a much greater degree of travel than conventional membrane switches but some people think this is an advantage rather than a disadvantage. Like all projects constructed out of "junk box" material not every one has the same junk box. Therefore I have tracked down suppliers of the foam and the other bits and pices and they can be obtained as Body Build Pack No. 35, see page XXX for the order form. I was quite surprised at the high price of this foam as I had been receiving pieces free for many years. However with a size of 300mm square you should be able to make a decent keyboard. Also there is also probably more copper strip than you need but it is nearly impossible to repack and you could always take up stained glass work. So, there you have it, a project from high tech packing material. Next month back to the high tech itself.