@L|}6CD l0C)HCC WhL/h `CmCDiD`  R@W1  Y0@R !L` D  C D     )16CS S)  C)D1 p p 0 C9DI pCDL~CiCDiD` D  C D     )16CS S)  C)D1 p p }0 C9DI pCDL~CiCDiD` DD˙` d J)L !}D L(( LL()  L| L( S LH 0p n  } CY?  q  L L  ` )} `A! d߰")-݆ "  $G@LLL&0") $G% }H0 3S8`G ȱG ȱG   Gȭ Gȭ GG}GHiH8(()) G$H% `(0 })8` d)L ݆ & LGȘ ݆LL d  ! LL d)N>Q  HH) }  hyhyB q L> Lm JJ  Ln*` dB%' }8  H H` 1 { LL   !L     Hh SY?  q  1L }  !? S   q 1 L   Ll  Lg E`L   !L)  q 1L}) `L0AM݊L݉ ML  N݆LLLNLMLHG!@}1F GȱGLLEEȩÑEȑEEȑE Ed E7EȩE  q} L !,0,0SGɛ L 1 !L EHEh W G gLLSROTCES EERF } G) *Gȩ GȽG GȌd q q G`  8   0G  `D}CEDC0X:Ȣ Y ȱC* ? 0.. , 0%n ?A[ 0 : L`L  `, 0`Y}`piH n0)բY? 08`0 }  0$L GGȽG L `8L`L}8`  05G)݁,G)ȱGȱGHh0})Hh` B! 8`8iiiLE`}E8FEh( l0`ɃLL L8^~jj8jHi hEEEiEȱEiE` dTE} H8EEȱEEȩEh J E8   . m  i`LI!)E1FR}1LJ舩9GIH`LJJ`HGHh l`} S gL   8 rii `дCDCG W  }C  Lq` X٨`DOS SYS IIIIIIIIIIIIIIIC`0 ߩ0}}}540 |||DDOS DOSDOS SYS }}}}}CDOS SYS} 0`BDELV !B }`LVUQ   ]   TU J ]L!T  #      TU  } L ? .  t`GBJ V~DEHI B V0dV!}QDEHI VF9 ,0 ,0 s0hhL  L` H hDHEh"}DEL8HI   0 HI,0 0  9 .G VLO#},0 L4*IJ`llD1:AUTORUN.SYSNEED MEM.SAV TO LOAD THIS FILE.D1:MEM.SAV J y08 B|DEHI$} V0 0`B;DELV䌚 !B y`@ʆ v s? F0Ξ05: [ BDEHI%} VY8 B V  @  /DE `E:D1:DUP.SYSERROR-SAVING USER MEMORY ON DISKTYPE Y TO &}STILL RUN DOS B;DE J V (` 9 V⪍ ઍ  -'}LLu DEHILV 9 .l 9 .l  `` s$B VBH(}I|DE V BLV nB,DE J V* \*` B V BLVDEHI BLVL)}1u H232435; 1 ;  hh@2 e1i1LHҍ 00) 08 109hh@ Ҡ2e*}1i1232435ޥ<<8} 3E:}DISK OPERATING SYSTEM II VERSION 2.0SCOPYRIGHT 1980 ATARIA. DISK DIRECTORY I. FORMAT DISKB. RUN CARTRIDGE J. D,}UPLICATE DISKC. COPY FILE K. BINARY SAVED. DELETE FILE(S) L. BINARY LOADE. RENAME FILE M. RUN AT ADDRESSF. LOCK F-}ILE N. CREATE MEM.SAVG. UNLOCK FILE O. DUPLICATE FILEH. WRITE DOS FILES9!&x#!7&p))'&X*./)L''-؆莟.}R'S  vW DEHHI 1A#! @ ~0ɛ8A0.) ȅ 1 1i/}il ! 1L NO SUCH ITEMSELECT ITEM OR FOR MENU! 0 .{z:*{}.|~ 1 0 00}JB 18L^%|DLl%DIRECTORY--SEARCH SPEC,LIST FILE? # 0 0 n&|D! 1L NOT A DISK FILE1}N !B 1L " 1 !BDED:}:1BJ|DE 1DEBH2}I 1 h0ߢ 0.  0?詛 1 ~0YЛ 1 "L<" "L 3} BL1TYPE "Y" TO DELETE...DELETE FILE SPECCOPY--FROM, TO?OPTION NOT ALLOWED COPYING---DN:4}# 0|D .L$A#B#C#JB|DE 1BHIDD#E 1D#0: B5} 1L B#C#C#B# B 1N#$0SYS1}:e#D# d# D# .d#ȽD# d# 𩛙d#X# 1,A#6}PdD#ELO- A.BJdD#E 1 1HH 0hh|DL^%1}:e# Lt% e#dD#EL%7} 1 0 . .0% 1L WILD CARDS NOT ALLOWED IN DESTINATION 0 A.|K@C}//3Hu ξL/L DRIVE TO WRITE DOS FILES TO?WRITING NEW DOS FILESTYPE "Y" TO WRITE DOS TO DRIVE 1.?}D1:DOS.SYSERROR - NOT VERSION 2 FORMAT. , &* բ( 1L `[) 0NΞ 0 L1M) 1@} L BAD LOAD FILELOAD FROM WHAT FILE?) 0 0#B 1L WHAT FILE TO LOCK?) 0 0$B 1L WHAT FILE TO UNLOCK?DUA}P DISK-SOURCE,DEST DRIVES?TYPE "Y" IF OK TO USE PROGRAM AREACAUTION: A "Y" INVALIDATES MEM.SAV. h  ,B}  `)  <0 2 2 0  ,   ,,ޢ* 1L ,K* 1 ~0 0C}FINSERT BOTH DISKS, TYPE RETURNERROR - DRIVES INCOMPATIBLE., 1 ~038  , 1L D}, &*  Lz+, 0 , 1 ~0 + Y,0!,0 ,L+ ,mm  v,"ǭE}0Ξ, 05,Lt+L +,Hh` NOT ENOUGH ROOMINSERT SOURCE DISK,TYPE RETURNF}INSERT DESTINATION DISK,TYPE RETURN`    `L,8,0( rG}L1(`ߢ) 1* 1 ~0Y`hhL S SL1) 8`NAME OF FILE TO MOVE?- 0 0|DLtH}% A., 1 <0 0 .@L# .BJ 1  DEHIB V L1 ,5 1 <0,L. I} JB|,A#Pd#DE 1 HI BDEHHII 1 B 1 , 1 <0,0Lf- B VJ},A#P, 1 <0 0L#L ߢ) 1* 1 ~0Yj383}mm ݭK}}`8}``|* ? ɛ,`|:(|/ 1L `DESTINATION CANT L}BE DOS.SYS0 0H{ $22Δ $28/L /) $2 Π $2 0 ξM}hAΞB,0 J 1 BޝDEHI,HDE 1HIHIDELSAVE-N}GIVE FILE,START,END(,INIT,RUN)O X0 1`BDEPHI V` X0H 1 L O}0 0 1L0`PLEASE TYPE 1 LETTER,0`hhL <0 1L0LA1 ,;ɛ7,"ɛ:ݦ1ݥP}A"D|ݤD|ȩ:|ȩ|ɛ,,(/+.ީ1 1,ɛ`轤{Q}NAME TOO LONG B VL ` L1I H1EӝDL1|mDiE` V0`8d/8 i:"2!22 1R} L ERROR- 170ɛ+,' 20*.. өw2 1``2TOO MANY DIGITSINVALIDS} HEXADECIMAL PARAMETER800 0 8 00`,0'D800H,ɛh`2L1NEED D1 THRU D4uT} HEXADECIMAL PARAMETER800 0 8 00`,0'D800H,ɛh`2L1NEED D1 THRU D4u27 64 6 2 1 5 0 18 66 4 2  114 2740Len Golding - Great Little Gadgets. 2710636@ 10101010mfV}GREAT LITTLE GADGETSThis series is all about hardware you can make for your 400/800/XL/XE. We'll be describing devices to mW}anage your central heating, water your house plants, control your train set or operate your burglar alarms. Remote keyboards,X} customised for for children, disabled people or ham-fisted amateurs. Energy-saving aids, acoustic interfaces and simple roboY}tics. All driven by software written in Basic or by simple USR-level machine code routines. And they can be constructed - in Z}prototype form at least - without any soldering.All the gadgets work through the joystick ports, and this month we look in [}detail at the various signals you can put in and get out.Fig 1 shows the pin functions2FIG 1: JOYSTICK PORT PIN-OUTS\} Signal Lines Paddle 1 input o o o o o 1 2 3 4 5 6 ]} 7 8 9 o o o oJoystick +5v 0v Paddle 0trigger input48Pins 1 to 4 are th^}e main on/off signal lines, and they are normally held at +5v by internal circuitry. A signal occurs when the line is taken t_}o 0v by some external means, like a joystick. You can plug a switching device of your own into port 1, and read its output by`} PEEK STICK(0), or PEEK (632). The pattern of highs and lows on the four signal lines is interpreted as a 4-bit binary numbera}, with 0v meaning "on" and +5v meaning "off", so a number between 0 and 15 will be returned.It's best if the transition frob}m +5v to 0v is rapid, so sensors which produce a slowly changing output (like temperature-sensitive resistors) are not reallyc} satisfactory. Devices that switch quickly - like photodiodes or keyboard switches - are suitable, so long as they can handld}e at least 1 milliamp per line.The signal lines can easily be turned into output switches. POKE 54018,56 to set up both pore}ts for output, then POKE a number between 0 and 255 into 54016. The number will appear in binary form at port 1 (bits 0 to 3)f} and port 2 (bits 4 to 7). In 'output' mode, pins 1 to 4 are held at +5v while they are off, and fall to 0v when they switch g}on. They can each sink 15mA in the 'on' state, which is enough to control transistors, thyristors, LEDs and integrated-circuih}t devices.Some form of current and voltage amplification will normally be needed before these outputs can do useful work ini} the outside world, but with appropriate hardware you could control appliances the size of Tower Bridge. More about this nextj} month.Pin 6 is the joystick trigger line. It can't be made into an output, but remains effective as an input regardless ok}f how the four signal lines are configured. Taking this pin to 0v will change the number in address 644 from 1 to 0. This opel}ns the way for simple feedback - a motorised device driven by pins 1 to 4 could send a 'stop' signal when it had finished opem}ning a door, or drawing the curtains. Or the pin could be used as a "fault" line, triggering an alarm if anything went wrong n}with the hardware. As with the signal pins, 1 milliamp of current is required to make it operate.Pin 7 is held constantly ao}t +5v, and will deliver 500 milliamps or more if you let it. But Atari specify a maximum current drain of 50mA, and if you exp}ceed this you could wind up with an expensive smell. Some form of over-current protection is advisible, and we'll be using a q}50mA quick-blow fuse.Pin 8 is the common 0v line. It connects to all the rest of the computer circuitry, and provides the 0r}v point for signal and trigger inputs.Pins 5 and 9 are analogue inputs, designed for use with paddles. A variable resistancs}e can be connected between either of these pins and the +5v line. The computer measures this resistance, converts it into a nt}umber between 1 (1K or less) and 228 (500K or more), then puts the result into address 624 (pin 9) or 625 (pin 5).These pinu}s continue to work as inputs even when the signal lines are outputting data, so complex feedback is possible. The obvious usev} is for servo sensors in robot arms. Pins 1 to 4 can control motor on/off lines, while variable resistors connected to pins 5w} and 9 monitor the degree of rotation in two dimensions.The analogue inputs can also be used for devices which produce a slx}owly changing voltage. How about a photocell to set a burglar-deterrent program running when it gets dark? Or sensors to conty}rol temperatures and exposure times in your darkroom? Or a humidity monitor for the conservatory? Or a transducer that will rz}eact to sound? It's all possible, without too much knowledge of electronics.Here's a simple light-sensitive gadget to get y{}ou started. You will need the materials shown in the parts list. First test the extension lead using joysticks and paddles in|} the usual way. If all is well, unplug it, cut off the end you don't need and carefully strip about 1/2" of insulation from e}}ach of the nine wires.Screw the terminal block to the baseboard, and attach the wires as in Fig 2. The colours shown are th~}ose used in the Tandy extension lead - other makes may be different. The 470 ohm resistor protects the +5v line by limiting t}he output current to around 10mA. Never connect anything directly to pin 7, or you could wind up with an expensive smell.}FIG 2: PRACTICAL LAYOUT1902273320____________________________________________________________________________________}____________________ --------- ----Green---- o 1 o ----Yellow--- o 2 } o ----Orange--- o 3 o ----Red------ o 4 o --- ----Brown---- o 5 o --- ----}Blue----- o 6 o ----Black---- o 7 o 470 ohm [ ] o o Cadmium ---}-Grey----- o 8 o SulphideStrain ----White---- o 9 o Cellrelief o } 0clamp o o ---------_________________________________________________}________________________________________________________2740466Now fit the cadmium sulphide cell to the terminal block} as shown, check that all the screw terminals are tight and, then plug the gadget into port 1. Run this program: 10 POK}E 752,1:PRINT CHR$(125) 20 POSITION 2,2:PRINT PEEK(624);" " 30 GOTO 20Initially the displayed number will be lo}w - probably less than 10 - but if you now cover the cell with your hand, the number will rise rapidly to 50 or more. Try thi}s: 10 SOUND 0,PEEK(624)+10,10,8: GOTO 10and you get a light-activated swanee whistle, guaranteed to delight even the yo}ungest members of the family.Shopkeepers could use this device to make their window displays more alluring. Fit extension l}eads to the cell and tape it inside the window so that passers-by can cover it with their hands. Then write appropriate softw}are to generate something interesting on the TV screen when the number in 624 exceeds your threshold value. Later in the seri}es we'll see how you could control animated models or motorised displays in the same way.A similar gadget can be used to he}lp train hand co-ordination in severely disabled children who have little control over body movement. Random waving will have} no effect, but careful positioning of the hand can be made to produce some form of reward.Next month we'll explain in deta}il how to use the four signal lines as output switches, and how you can get them to control high power appliances.2PARTS }LIST. _______________________________________ 1 Joystick extension lead (Tandy 276-1978 or similar) } 1 Cadmium Sulphide cell - ORP12 or equivalent. (Maplin type HB10L, Tandy 276-116A or similar) } 1 470 ohm 0.25 watt resistor 1 12-way 5 Amp moulded terminal block (Maplin HF01B, Tandy 61-7009 or} from most electrical shops) 1 Baseboard about 6" x 12", preferably 12mm or 15mm ply * COST }- AROUND #5.50 * _______________________________________endsttle Gadgets. 2710636@ 10101010mfK 18190273320________________________________________________________________________________________________________ } --------- ----Green---- o 1 o ----Yellow--- o 2 o ----Ora }nge--- o 3 o ----Red------ o 4 o --- ----Brown---- o 5 o --- ----Blue----- o 6 o } ----Black---- o 7 o ----Grey----- o 8 o ----White---- o 9 o } o 0 o o o o --------- } 50mA Fuse____________________________________________________________________________________________________ }_____90273320________________________________________________________________________________________________________ 27 64 6 2 1 5 0 18 66 4 2 114 2740Len Golding: Great Little Gadgets, Part II 2710636@ 10101010}mfSETTING-UP AND SWITCHINGThis month we explain how to get useful signals out of the joystick ports, and how to amplify} them so that they can switch external appliances on and off under software control. With the power switch described you can }make animated models, control a train set, drive low-voltage disco lights or operate equipment designed for use in car, carav}an or boat. The switching action can be controlled directly by your software, or manually from the keyboard, or by an externa}l sensor such as the light-activated switch described last month.First let's look in detail at setting up the joystick port}s. Each one has four signal lines (pins 1 to 4) which can be made to behave as outputs by Program 1. Line 10 notifies the com}puter that you are about to change the way ports 1 and 2 are handled, line 20 specifies that all eight signal lines are to be} treated as outputs, and line 30 sets 54018 back to its original value, with the new rules operational. Line 40 clears the sw}itch register, making sure all the signal lines are OFF. From then on, any number you POKE into 54016 will appear as a patte}rn of 'high' (ON) and 'low' (OFF) voltages on the output pins of ports 1 and 2.Table 1 shows the numbers to POKE for all po}ssible on/off combinations at port 1. Each line has its own unique number (1,2,4 or 8), and by adding these numbers together }in different combinations you can control each output independently.Numbers higher than 15 will bring port 2 into operation}. Pins 1, 2, 3 and 4 in this port are controlled by 16, 32, 64 and 128 respectively, as shown in Table 2, and these numbers }can be combined as before. So for example POKE 54016,195 (1+2+64+128) will switch on pins 1 and 2 at port 1 together with pin}s 3 and 4 at port 2. Similarly POKE 54016,150 (2+4+16+128) will switch on pins 2 and 3 at port 1 and pins 1 and 4 at port 2. }Any pin which is not specifically selected will automatically switch off when you POKE a new number into 54016.When a pin i}s ON it carries 5v, and will supply 0.5mA. When it goes OFF the voltage drops to 0v, but it can pass 15mA in this state. You }can't do much with such tiny signals, and in any case it isn't wise to connect loads directly to the joystick port. But both }of these problems can be overcome by using a transistor.There are many different species of transistor, but for the moment }we'll concentrate on the 'bipolar' kind, which come in two varieties - PNP and NPN. Fig 1 shows the circuit symbols for both,} together with the pin-outs for the two types we'll be using.Both types have three leads: Collector, Base and Emitter. In }each case a small current flowing through the base will enable a much larger current to pass between collector and emitter. T}he current can flow only one way - from positive to negative in the direction of the arrow - so it doesn't behave exactly lik}e a switch, but the effect is similar.A PNP transistor turns on when its base voltage is at least 0.6v lower than its emitt}er voltage, whereas the NPN variety needs the base to be at least 0.6v higher than its emitter. Actually it's a lot more comp}licated than that, because the voltage and current in the base also determine how much voltage and current can flow through t}he collector-emitter circuit, but we don't want to get into transistor theory at this stage.Fig 2 shows how you can use an }NPN transistor as a simple current amplifying switch. The load is a light-emitting diode (those small red lamps on your keybo}ard, cassette recorder and disk drive are LEDs), and its only purpose is to indicate ON or OFF. When pin 1 goes to 5v the tr}ansistor switches on, allowing current to flow through the LED. Nearly all the power comes from pin 7 - less than half a mill}iamp is required at pin 1 - and the transistor acts as a kind of buffer, protecting the signal line.Because they are so sma}ll, transistors and LEDs can be very fiddly to wire together, especially if you're not too happy about soldering. The easiest} solution is to use a "solderless breadboard", like the one in the photograph. Each hole contains a spring-loaded electrical }contact which can grip a wire or a component lead. The contacts are connected together in rows of five, and there are longer }strips of interconnected sockets at the edges, for use as power supply lines. You simply plug components into the breadboard }and take wire leads from the adjacent holes.Screw the breadboard to your plywood base, and wire everything together as in F}ig 3. Use single-conductor insulated wire, not the stranded type, as the bared ends will push into the breadboard holes more }easily and you won't get broken strands coming off inside. The LED won't work if it is fitted the wrong way round - the catho}de is indicated by a "flat" on the LED body, and also by a shorter lead. Run program 1, then type:POKE 54016,1and the LED} will light.Atari's Technical Reference Notes specify a maximum current drain of 50mA from the joystick ports, and you must} not exceed this under any circumstances. In fact, the internal power supply starts showing signs of distress at about 20mA, }so it's best to keep at or below this level if possible. Therefore, to drive anything worthwhile, you will need an external p}ower source capable of delivering higher voltages and currents. A battery will do, or a mains power supply unit, and 12v is s}ufficient for all the gadgets we'll be describing.A BC108 can't handle more than 100mA so an extra amplification stage is n}eeded, and the circuit in Fig 4 shows how to add a second, much more powerful, transistor.When TR1 switches on, it supplies} base current to TR2, which in turn handles all the power for the load. If anything should go wrong with the battery circuit,} the two transistors prevent high voltages getting back to the joystick ports, so the risk is minimised. The output of this s}witch is in phase with the input - a positive voltage on the signal line produces a positive voltage at the collector of TR2.}If the load is an electromagnetic device, such as a relay, solenoid or motor, it will generate high-voltage 'spikes' on the} power lines, which could damage the output transistor. The diode D1 is used to suppress these, and it must be wired as show}n, with cathode to positive, or it will self-destruct. The case has a black or coloured band to mark the cathode end.Fig 5 }shows how to wire everything up without soldering, using a miniature terminal block. The transistor leads are quite short, so} you will need the smallest block you can find - not more than 8mm between terminals. Be extremely careful when bending the l}eads of the TIP127. They have a flat cross-section and will break very easily if you try to bend them across their width, but} a half-twist will help them round the corners. The power transistor is rated at 5 Amps, but it gets very hot when controll}ing 1 Amp or more, so some form of heat sink is necessary. The 'twisted vane' type is adequate for loads up to 2.5 amps (25 w}atts at 12v), but heavier loads require larger heat sinks - a '527830 02784C per watt' type will enable you to draw up t}o 5 Amps. You can buy one of these, or make your own from a piece of scrap aluminium - about 50 square centimeters of 3mm pla}te or angle should be adequate. A touch of silicon grease will improve the thermal contact, but isn't strictly necessary so l}ong as the surfaces are clean and the transistor is bolted down securely.Because the first transistor places such a small l}oad (about 1mA) on the joystick port, you can have a power switch on every signal line, giving you eight independent channels}.Now we have something really useful. You could construct animated Lego or Meccano models, moving displays for shop-windows} or even simple robots. You could control up to eight separate tracks (or points switches) on your model train set, and progr}am the whole layout like the London Underground. A safe disco display for the children can be made from 21 Watt car indicator} bulbs. Or you might use 12v pumps or solenoid valves to construct an automatic watering system for your conservatory.Remem}ber, though, that the external power source must be able to supply enough current. A car battery charger is worth trying, or }you might use an old car battery itself, taking the usual care to avoid sparks and excessive currents which could start a fir}e.The power switches can be operated by external sensors rather than a fixed program. We'll be describing many different ki}nds - temperature, sound, humidity, movement and others - in a future issue, but for now you could try the cadmium sulphide c}ell we looked at last month. Wire it between pin 9 and the free end of the 50mA fuse, then use Program 2 to switch the load o}n when it's dark and off again when it's light. Line 20 sets the switching threshold (L), and you can reverse the action by c}hanging the ">" at line 30 to "<".You could use this device to set an intruder-deterrent system into operation at dusk. How} about a gadget which switches low-voltage lamps on and off in random patterns, to give the impression that your house is occ}upied while you're away?A word now about buying all the necessary bits and pieces, which can be a problem, especially if yo}u're relatively new to the game. It's all too easy to pay over the odds, or end up with the wrong thing, since components whi}ch look alike may have totally different specifications.For things like transistors, resistors and other small components, }the easiest and safest method is to use one of the big mail-order companies. They all produce catalogues (some better than ot}hers) containing photographs and specifications, so you know exactly what you're buying. We've tended to quote order codes fr}om Maplin Electronic Supplies, because they are among the less expensive quality suppliers, and their catalogue is readily av}ailable from W H Smiths. Other mail-order companies advertise regularly in the monthly electronics magazines.Some high-stre}et audio stores, such as Tandy's, also supply a limited range of electronic components. They are useful for certain unusual i}tems (like the joystick extension lead) or for things you need in a hurry, but you'll usually pay more for them and the shop }assistant is not likely to be very knowledgeable.Try your local scrap yard for bargains in 12v electro-mechanical equipment} like windscreen wiper motors, door-locking solenoids and headlamp relays. Caravan, camping and boat shops can also supply a }wide range of suitable gadgetry, and most electronics magazines advertise 'surplus' and ex-equipment devices which are fine f}or low-voltage experimentation.Now how about mains appliances? Transistors cannot handle the very high voltages and current}s involved, so you can't use the circuit of Fig 4 to switch on your electric blanket, control your central heating or turn th}e TV off when you've gone to sleep over the keyboard. Besides which, you and your computer need much more protection from mai}ns AC than from low-voltage DC circuits.Next month we'll give full constructional details for an opto-coupled mains switch }box with two independent channels.ends2740Len Golding: Great Little Gadgets, Part II 2710636@ 10101010+0 4 1 5 0 10 90 2 0 1202740Len Golding: Great Little Gadgets III FIG 4: VEROBOARD LAYOUT OF MA}INS CONTROL BOX 7273348276514 ABCDEFGHIJKLMNOPQRSTUVWX ------------------------ 1 '''''''''''''''''''''''' 1} 2 '''''''''''''''''''''''' 2 3 '''''''''''''''''''''''' 3 4 '''''''''''''''''''''''' 4 5 '''''''''''''''''''''''' 5 6 '}''''''''''''''''''''''' 6 7 '''''''''''''''''''''''' 7 8 '''''''''''''''''''''''' 8 9 '''''''''''''''''''''''' 910 ''''''}'''''''''''''''''' 1o11 '''''''''''''''''''''''' 1112 '''''''''''''''''''''''' 1213 '''''''''''''''''''''''' 1314 '''''''}''''''''''''''''' 1415 '''''''''''''''''''''''' 1516 '''''''''''''''''''''''' 1617 '''''''''''''''''''''''' 1718 ''''''''}'''''''''''''''' 1819 '''''''''''''''''''''''' 1920 '''''''''''''''''''''''' 2021 '''''''''''''''''''''''' 2122 '''''''''}''''''''''''''' 2223 '''''''''''''''''''''''' 2324 '''''''''''''''''''''''' 2425 '''''''''''''''''''''''' 2526 ''''''''''}12 4 1 5 0 4 90 2 0 120273348276514----------------------------------- ''''' ''''' ''''' ''''' ''''' } ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' '''''''''''''''}'''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' }' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ''''' ''''' '''''} ''''' ''''' ---------------------------------------------------------------------- ''''' ''''' ''''' ''''' '''}'' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' '''''''''''}'''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' '''''''''''''''''''''''''''''} ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ''''' ''''' '}12 4 1 5 0 9 70 4 0 1322740Len Golding :Great Little Gadgets IIPARTS LIST901 Battery, 6v to 12v, with c }lips to attach leads1 5mm Red Light-emitting Diode (Maplin WL27E; Tandy 276-041)1 'Verobloc' Solderless Breadboard (Maplin } YL11M)1 BC178 Transistor (Maplin QB32K)1 TIP127 Transistor (Maplin WQ74R)1 1N4148 diode (Maplin QL80B)1 High-power Twist }ed-vane Heatsink (Maplin FG55K)1 Cadmium Sulphide cell: ORP12 or similar (Maplin HB10L; Tandy 276-116)1 Joystick extension  }Lead (Tandy 276-1978)2 Small terminal blocks (Radiospares 423-166 or similar)1m Single-conductor connecting wire, up to 0.}6mm core diameter.2m 5 Amp low-voltage flexible wire (car accessory shops). 0.25 watt carbon resistors: [Colour codes }in square brackets]1 100 ohm [brown/black/brown]1 1K (1000 ohms) [brown/black/red]1 10k (10,000 ohms) [brown/black/oran}ge]4 1 5 0 9 70 4 0 1322740Len Golding :Great Little Gadgets IIPARTS LIST901 Battery, 6v to 12v, with cCBAARELMISTARA6) @A &&R!l Fi1{}'''' ''''' ''''' -------------------------------------------------------------------- ''''' ''''' ''''' ''''' ''''' 8'''''''''''''' 2627 '''''''''''''''''''''''' 2728 '''''''''''''''''''''''' 2829 '''''''''''''''''''''''' 2930 '''''''''''}''''''''''''' 30 ------------------------ ABCDEFGHIJKLMNOPQRSTUVWXets III FIG 4: VEROBOARD LAYOUT OF MAH KB@@V'B@AU9B@@`KB@4F:!}27 64 6 2 1 5 0 18 66 4 2 11427402780Len Golding: Great Little Gadgets, Part II 2710636@ 101010)}A$,!@*B@@4 @ B@ @ D:GG3PROG4.BASKB@4F: a27 64 6 2 1 5 0 18 66 4 2 114 e2740Len Golding: Gadgets, Part III 2710636@ 10101010mfTAMIN%}G THE MAINS: PART 2Last month we covered the theory behind a two-channel mains controller. Now it's time to fix all the bit%}s and pieces together. Don't be put off if you've never done any electronics construction before - we're using a commercially%} made printed circuit board, so all you have to do is plug in the various components and solder them correctly.Before you d%}o anything else, lay the PCB on a piece of strong paper and mark the outline and fixing holes. This will be used as a templat%}e when you come to drill the case, and saves a great deal of measurement.You will need a soldering iron rated at 15 to 25 w%}atts, with a 1mm to 3mm bit. Anything larger will be too hot or too cumbersome for use on delicate components. Also it's wort%}h buying the special thin (22 swg) solder, as this is much more likely to go where you want it, without forming untidy blobs.% } A damp sponge is useful for wiping excess solder from the bit.Make sure all your materials are scrupulously clean, as dirt%!} and grease will stop the solder adhering correctly. Hold the soldering iron bit in contact with the component lead and PCB t%"}rack simultaneously. Melt a small quantity of solder by touching it to the lead and track (not to the iron) and keep the heat%#} applied until you see the solder flow evenly onto the track and around the lead.Remember, though, that small components ca%$}n be damaged by excessive heat, so don't hold the soldering iron in contact for any longer than necessary, and allow the comp%%}onent to cool after soldering each lead. With transistors it's best to solder one lead, then turn the board over and make sur%&}e the case is vertical before soldering the other two. For extra safety you could attach a temporary heat sink to the compone%'}nts while soldering - a small "bulldog" type paper clip works quite well.Fig 1 shows the layout of components on the printe%(}d circuit board. Start by fitting the resistors, diodes and transistors, followed by the IC socket, terminal blocks, jack soc%)}kets and wire link, then the relays, C1 and transformer. Don't fit the fuse holders, C2 or C3 at this stage, since these will%*} become live during normal use and it's safer to keep mains voltages on the PCB's underside during initial testing.The resi%+}stors may be wired either way round, but the remaining components must be fitted as shown. Diodes have a black or coloured b%,}and at their cathode (negative) end, the bridge rectifier has "+" marked, the transistors have a small metal tag nearest thei%-}r emitters, and the capacitor has a wide grey band printed with chevrons and the number "0" to indicate its negative side. Th%.}e transformer will fit only one way round, but "240v" and "9v" are marked on the board for extra safety.Prepare the joystic%/}k extension cable by cutting off the unwanted socket, stripping back about three inches of the outer insulation and baring ha%0}lf an inch of each wire. Use some kind of continuity tester (a small bulb and battery will do) to find which lead goes to whi%1}ch pin, bearing in mind that cables, even from the same source, may vary in the colours they use.Now it's time for the prel%2}iminary testing. There are three separate stages to the circuit (see last month's diagram), and we can check each stage in tu%3}rn. Leave the opto isolator out of its socket for the moment, and don't connect the mains. Temporarily fit the joystick wires%4} to their PCB terminals and plug the lead into joystick port 1.Run Program 1 and hold the test LED across pins 1 and 2 of t%5}he IC socket, with its cathode (shorter lead) to pin 2. It should light when you type "1" and turn off when you type "0". Do %6}the same with pins 3 and 4 (cathode to pin 3), this time typing "2" and "0".If either is at fault, turn the board over and %7}make sure you haven't left any connections unsoldered. Also look for "dry" joints which have a dull, crumbly appearance, and %8}for blobs of solder which have either adhered to the component lead and not the track, or have bridged across two tracks. Re-%9}make any joints that look suspicious. When the first test works satisfactorily, it means that stage 1 is all correct.Now ch%:}eck again to see that all polarised components - especially the two diodes - are fitted the right way round. Correct polariti%;}es are marked on the PCB, and if you get any of them wrong the component will probably self-destruct.Fix the PCB temporaril%<}y to a piece of scrap wood or ply, using No. 4 woodscrews. This will hold it firmly when the mains is connected, and reduces %=}the risk of your touching a live track. Wire up the mains supply, taking very great care from now on because some of the trac%>}ks, and the screw heads on the mains terminal block, will be live. If everything is wired correctly, all the other components%?} will be safe to touch.With a small screwdriver, or a piece of thin wire, bridge across pins 5 and 6 on the IC socket. The %@}right-hand relay should operate with an audible click. Do the same with pins 7 and 8, and the left hand relay should work. If%A} not, disconnect the mains and check all the tracks, joints and polarities again. Especially make sure that the two diodes ar%B}e connected the correct way round (anode to 0v), and replace them if you got it wrong.When all is well, insert the opto-iso%C}lator, making sure that the small dot on its case goes to the pin 1 position, and plug the joystick lead into port 1. Check t%D}hat the relays operate correctly when you type "1","2" or "0".Finally disconnect the mains and joystick leads, then fit the%E} two fuseholders, along with C2 and C3.273324REMEMBER THAT THE METAL PARTS OF THESE COMPONENTS WILL BECOME LIVE WHEN YOU%F} NEXT CONNECT THE MAINS SUPPLY.2740That's the electronics part finished. It only remains to prepare a suitable case (pref%G}erably all-plastic), and connect the various inputs and outputs. If you have to use a box with metal panels, make sure that a%H}ll exposed metal is properly earthed.It's difficult to mark accurate positions for holes and cutouts directly onto a case, %I}so make paper templates and stick them in place using Copydex. They will peel off cleanly when you've finished drilling and c%J}utting.The mains cable and joystick lead should be run through rubber grommets to prevent chafing, and they will each need %K}some form of cable clamp to take the strain if they are accidentally jerked during use.Mains appliances can be wired direct%L}ly to the terminal block, but it's more versatile to use some form of mains plug and socket. Standard 13 Amp wall sockets wil%M}l work, but "Euro" style 6 Amp mains connectors are smaller, neater and cheaper.The PCB is fixed using internally threaded %N}spacers, so you can have a bolt at each end instead of fiddling with bolt, spacer and nut assemblies. Attach the spacers to t%O}he PCB with 1/4" 6BA metal bolts, but use nylon bolts through the case to ensure that the exposed heads cannot become live un%P}der any circumstances. You may need to shorten each nylon bolt using a sharp craft knife.Wire the mains cable and joystick %Q}lead into their respective terminal blocks and secure them with cable clips. Fit the mains sockets - Neutral and Earth leads %R}to the PCB terminals marked "N" and "E", and the live leads to the two marked "outputs". Then assemble the case and plug in.%S}The software is easy - just use the first line of Program 2 to set everything up, then POKE 54016 with 1 to operate relay on%T}e, 2 to operate relay two, 3 to operate both together or 0 to turn them both off. Program 2 is a simple "flasher" routine, an%U}d Program 3 is an equally simple delay switch. For ideas on more complex timing operations, have a look at this month's Five-%V}Liner.You can plug external sensors into the jack sockets - try the cadmium sulphide cell with Program 4 to switch a table%W} lamp on when it gets dark. These jacks can supply 5v at about 30mA (total), provided nothing else is drawing current from th%X}is or any other joystick port. If you need more power, you can draw a nominal 12v at around 300mA from the terminals marked "%Y}12v DC" and "0v" on the PCB, but remember that this is an unstabilised supply and will vary from about 14v to 12v, depending %Z}on the load.Details of how you can modify the gadget to handle greater loads and more channels were given last month.Next%[} month we'll be turning our attention to inputs, with full constructional details for a plug-in keypad.endsmfTAMIN$p27 64 6 2 1 5 0 18 66 4 2 114 2740Len Golding: Gadgets, Part III 2710636@ 10101010mfTAMING]} THE MAINSThis month's project gives your computer the power to control mains appliances. It can be operated directly from ^}the keyboard, or by a Basic program, or by external sensors such as light or heat detectors. There are two independent channe_}ls, expandable to four, and each channel can handle 750 watts.In this first part we look at the electronics and theory of o`}peration. Next month we'll describe the practical construction and programming.Safety is our first consideration because, na}o matter what design is used, the control box must have a mains cable going in at one end and a joystick lead coming out of tb}he other. If ever the twain should meet, your computer (or at very least its PIA chip) will rapidly depart this life, and mayc} attempt to take you along with it. This design has two separate stages of protection - an opto isolator on the input circuitd}, and mechanical relays to handle the mains voltage outputs.Let's look at the opto isolator first. Fig 1 shows in schematice} form how it works - you may recognise the symbols from last month. It has two components, housed together in a light-proof pf}ackage. The input is a conventional light-emitting diode and the output is a phototransistor which switches off in darkness ag}nd on when illuminated.The only link between input and output is a beam of infra-red light, and there's no way that high voq}'``b'DOS SYSb*+DUP SYSbBUGADGET1 TXTbGG1FIG1 TXTb[GADGET2 TXTb GG3FIG4 TXTb GG2PARTSTXT VEROBLOCFIGbGG3PROG4BASbDGADGET3BTXTb GG2TABS TXTb GG2FIG3 TXT WRDCOUNTBASbGG5PROG3BASbGG3FIG1 TXTbGG3FIG5 TXTbGG3FIG6 TXTbGG3FIG7 TXTROYHDR TXTbGG3PROG2BASbGG3PROG3BASbGG3PARTSTXTbGG3PROG1BASbsGG4PROGSTXTbEGADGET4 TXTbSGG4FIG1 TXTbUGG4FIG2 TXTbYGG4FIG3 TXTbGG3PROGSTXTb,{GADGET5 TXTbGG4PARTSTXTbcGG4PROG1BASb GG4PROG1SRCbhGG4PROG2BASb DGG4PROG2SRCbGG5PROG1BASbGG5PROG2BASbGG5PROG2SRCb2\GADGET3ATXTbGG3PANELTXTGG3ACOVRTXTGG3BCOVRTXTGG5COVERTXTbGG5PARTSTXTMUSICPADBASltages can cross the gap. Your computer sees only the LED side - all the dangerous work is done by circuitry which it never nr}eeds to know about. Since our controller has two channels we need two opto-isolators and, for convenience, we've used a dual s}type which has everything contained in a single 8-pin package.A second level of mains isolation is achieved by using mechant}ical relays to do the actual switching. Relays come in many shapes and sizes, but they all work on the same principle (Fig 2)u}. A coil of fine wire generates a magnetic field when current flows through it, and the magnetic attraction is used to operatv}e one or more sets of switch contacts. The coil uses little power and can operate on low voltages, but the switch contacts caw}n handle much higher voltages and currents. Since the coil is heavily insulated from the switch contacts, mains voltages cannx}ot get through to the low-voltage lines.Fig 3 shows the circuit for the complete mains controller, with its three distinct y}stages. Stage 1 is the LED input circuitry which connects to the computer through a joystick port, and operates on power fromz} pins 7 (+5v) and 8 (0v). Control signals are taken from pins 1 and 2, via resistors R1 and R2, to the base leads of TR1 and }le Name: WRDCOUNT.BAS &&;@',;@,;@,%6-@6-%#@P""6@A01|}()A6%6-%@) @02KK104,104,141,85,3,133,204,104,141,84,3,133,203,104,104,141,157,6,169,7<GG141,1}}82,3,169,255,141,88,3,141,89,3,162,16,32,86,228,160,0,140,252FII6,140,253,6,140,254,6,140,255,6,140,156,6,177,203,201,32,21~}40,31,176PKK19,32,133,6,176,66,177,203,201,33,144,245,201,48,144,4,201,58,144,237ZHH201,155,240,6,238,156,6,76,124,6,171}10 23Table 1: OUTPUT SWITCHING 2________________________________________Number PORT 1 in54016 Pin 1 )}3,156,6,240,29,205,157,6,176,11dGG238,254,6,208,14,238,255,6,76,119,6,238,252,6,208,3,238,253,6,169nAA0,141,156,6,32,131}3,6,176,3,76,53,6,96,206,88,3,208,8,173,89x<<3,240,11,206,89,3,230,203,208,2,230,204,24,96,56,96,-1/ +/6-F:A1}D,%AV$F:AE,1@(1(Name of file to be checked?$6.D:$67B:,%@,.* A@*1}@@6-?:A6<<,4(>:A%,"-@@4( File name: "( ("(Number of w1}ords with::( or more letters =F:A,%AV$F:A,"( ("(Number of words with??( less than  1} Pin 2 Pin 3 Pin 4________________________________________ 0 OFF OFF OFF OFF 1 ON OFF )}OFF OFF 2 OFF ON OFF OFF 3 ON ON OFF OFF 4 OFF OFF ON OFF 5 )} ON OFF ON OFF 6 OFF ON ON OFF 7 ON ON ON OFF 8 OFF OFF )} OFF ON 9 ON OFF OFF ON 10 OFF ON OFF ON 11 ON ON OFF ON 12 )}12 4 1 5 0 18 190 2 0 120273352FIG 3: BREADBOARD LAYOUT OF SIMPLE SWITCH 35274827332027851______-}________________________________________________________________________________________ -------- - Gr-}een - o1 o - Yellow - o2 o - Orange - o3 o - Red - o4 o - Brown - o5 o - Blue -} - o6 o - Black - o7 o - Grey - o8 o - White - o9 o o o o -} o o o -------- Breadboard 50 Ma fu-}se Terminal Block_____________________________________________________________________-}__________________________ 75273342765427106254271062542710625427106254________________________________-}___ ..... ..... ..... ..... ..... . ............................. . . ............................. . . ...........-}.................. . . ............................. . . ............................. . . .............................-} . . ............................. . . ............................. . . ............................. . . ..............-}............... . ..... ..... ..... ..... ..... ___________________________________ 15273320Joystick Lead______,v OFF OFF ON ON 13 ON OFF ON ON 14 OFF ON ON ON 15 ON ON )} ON ON ________________________________________Table 2: SWITCH CONTROL NUMBERS ______________)}___________________ PORT 1 PORT 2____________________________________________ Pin Number 1 )} 2 3 4 1 2 3 4____________________________________________ Control Number 1 2 4 8 16 32 64 )}128____________________________________________ 1840Len Golding: Great Little Gadgets, Part II 2710636@ 101010(7letters =F:A,%AV$F:A,( ( ( A@D:WRDCOUNT.BAS.TXTSAFEAREA.TXTED:GADGET2A.TXT1}GADGET2A.TXT27 64 6 2 1 5 0 18 66 4 2 114 2740Len Golding: Great Little Gadgets, Part II 2710636l Fi0w+,qPKEPEKNOTELENGTHPITCHFINISTIME@@@@@5} @ F-@5")AU%- FVertical Blank RoutineGG104,162,6,1605},230,169,7,32,92,228,96,173,132,2,10,10,10,10,24,10988120,2,73,31,141,255,6,240,4,169,0,133,77,76,98,228(S6-?:AU5},Skey value (1 to 25) now automatically returned at address 17912D9@%,$-@%("168,-5 DPit5}ch values<770,193,182,173,162,153,144,136,128,121,114,108,102F,,96,91,85,81,76,72,68,64,60,57,53,50,47PV9A,6n}TR2, where they are amplified and made to drive LEDs A and B inside the opto-isolator. Resistors R3 and R4 limit the current }through each LED to around 8mA.The two jacks are optional - they connect to the joystick port's analogue inputs, so you can} use external sensors (like light detectors or central heating thermostats) to control the switching action.Stage 2 operate}s on a nominal 12v DC from transformer T1. The power supply is not critical, so the circuit uses a simple bridge rectifier (B}12 4 1 5 0 14 55 2 0 120273352Len Golding: Great Little Gadgets IIIFIG 1: OPTO-COUPLER I9}nput OutputFIG 2: MECHANICAL RELAYLow voltage High voltageCo9}il Switch at Little Gadgets IIIFIG 1: OPTO-COUPLER I8>6 4 1 5 0 14 55 2 0 120273352Len Golding: Great Little Gadgets IIIFIG 5: RESISTOR COLOUR CODES 18=}Band1 Band 2 Band 3 Ignore 1st 2nd Number anynumber number of '0's other =}to add bands Colour Values:Black 0Brown 1Red 2Orange 3Yellow 4G=}reen 5Blue 6Violet 7Grey 8White 9Examples:47k (47000 ohms) = 4 + 7 + =}3 zeros = Yellow,Violet,Orange1k (1000 ohms) = 1 + 0 + 2 zeros = Brown,Black,RedRemember the mnemonic:"Black Beetles =}Running Over Your Garden Bring Very Good Weather". ISTOR COLOUR CODES 18<b6 4 1 5 0 14 55 2 0 120273352Len Golding: Great Little Gadgets IIIFIG 6: CONTINUITY TESTER12 4 1 A} 5 0 4 90 2 0 120273348276514----------------------------------- ''''' ''''' ''''' ''''' ''''' ' '''''A}'''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' '''''''''''''''''''''''''A}'''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''A}''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ' ''''''''''''''''''''''''''''' ' ''''' ''''' ''''' ''''' '''A}'' -----------------------------------2Len Golding: Great Little Gadgets IIIFIG 6: CONTINUITY TESTER12 4 1 @*6 4 1 5 0 14 55 2 0 120273352Len Golding: Great Little Gadgets IIIFIG 7: CUTTING AND DRILLING DIMENSIONE}SREAR PANELCASE TOPtle Gadgets IIIFIG 7: CUTTING AND DRILLING DIMENSIONDC0 4 1 5 0 16 70 2 0 1322740Len Golding :Gadgets IVPARTS REQUIRED FOR 15-KEY VERSION OF KEYPAD y} Maplin Order Codes32 1N4148 signal diodes y}R1) and smoothing capacitor (C1). The output from this network is around 14v when no load is connected, falling to 12v or so }when the maximum current (about 500mA) is drawn. An auxiliary output is provided on the terminal block so that you can tap th}is supply for other purposes if you wish.When phototransistor A switches on, its collector voltage falls towards 0v, causin}g TR3 to switch on. Current therefore flows through the coil of Relay 1, and switch SW1 operates. The same happens with TR4, }Relay 2 and SW2 when phototransistor B is activated. Diodes D1 and D2 are included to suppress the voltage spikes which relay} coils tend to generate.Stage 3 is the 240v AC section, containing the two relay switches, each with a capacitor across its} contacts to suppress sparking and mains interference. You can see that, if everything is wired up correctly, there is no ele}ctrical path from the mains supply to the computer. Even if stage 2 were to become live - for example after an insulation bre}akdown in the relays or transformer - the opto-isolator still provides protection.A printed circuit board is used to hold a}ll components, as this greatly simplifies construction. If you have facilities to make your own, the foil pattern is shown in} Fig 4, with the drilling schedule at Fig 5.It's a lot easier, and not much more expensive, to buy the commercially produce}d board from RH design (details in the panel), especially since this comes drilled and tinned ready for use.The basic desig}n will suit most domestic applications, and it can easily be adapted to handle specialised jobs. For example, you could use a} different type of relay. It won't fit on the PCB, but leads to the coil can be taken from points A and B (Relay 1) or C and }D (relay 2) which are marked on the board. And you could drive two or even three relays simultaneously from each output, shou}ld your application demand more current, or a more complex switch configuration, than a single relay can handle. It doesn't m}atter which way round the coils are connected, and the output transistors can each handle up to 500mA.Mains currents in exc}ess of 5 Amps should be kept off the PCB, so use a large screw terminal block. or a junction box, to connect the switch conta}cts of any off-board relays.There is enough power available from the joystick ports to drive two extra channels, making fou}r in all. Use two PCBs, and connect joystick pins 3 and 4 in place of 1 and 2 on the second board. The specified transformer }will supply enough current for all four channels, so you can omit T1, BR1 and C1 from the second board, and just connect the }12v and 0v output terminals from one board to the other.If you plan to drive several relays from each output, ensure that t}heir combined coils will not draw more than 500mA, or you will need a more powerful off-board transformer. The bridge rectifi}12 4 1 5 0 10 70 2 2 132Len Golding: GREAT LITTLE GADGETS III27332427820PROGRAM 110 POKE 54018,56:Rq}EM notify prospective change20 POKE 54016,255:REM set up all joystick pins for output30 POKE 54018,60:REM lock new systemq} in place40 POKE 54016,0:REM turn all pins off50 INPUT N:POKE 54016,N:GOTO 50PROGRAM 210 POKE 54018,56:POKE 5401q}6,255:POKE 54018,60:POKE 54016,020 X=030 X=X+(X=0)-(X=1):POKE 54016,X40 FOR W=1 TO 300:NEXT W:GOTO 30PROGRAM 3q}10 POKE 54018,56:POKE 54016,255:POKE 54018,60:POKE 54016,020 PRINT"INPUT TIME DELAY":INPUT D30 FOR W=1 TO D:NEXT W40 Pq}0 4 1 5 0 16 70 2 0 1322740Len Golding :Gadgets IIIPARTS LIST Maplin OrU}der CodesResistors:R1,R2 10k (brown/black/orange) M10KR3,R4 470ohm (yellU}ow/violet/brown) M390RR5,R6 47K (yellow/violet/orange) M47KR7,R8 2.2K (red/red/red) M2K2Capacitors:U}C1 470mfd 25v PC electrolytic FF16SC2,C3 0.047mfd 250v AC suppressors FF55K Semiconductors:TR1,TR2 BC10U}8 transistors QB32KTR3,TR4 2N2905 transistors QR17TD1,D2 1N4148 signal diodes QL80BBR1 U} W005 bridge rectifier QL37SIS1 Dual opto-isolator YY62SD(test) Red Light-emitting diode U}WL32K (see text)Connectors:J1,J2 3.5mm PCB jack sockets FK02C (optional)1 8-way PC terminal block U} RK38R1 4-way PC terminal block RK73Q1 3-way PC terminal block RK72P1 2-way PC terminal blocU}k FT38R1 8-pin DIL IC socket FJ63T2 Euro facility chassis sockets HL42V (optional)HardwaU}re:1 pack 1/2" 6BA threaded spacers LR72P1 pack 1/4" 6BA round-head bolts BF05F1 pack 1/2" 6BA nylon bolts U} BF75S1 Cable clip 3/16" LR44X1 Cable clip 5/16" LR46A1 Cable-sealiU}ng grommet LR51F1 Small grommet FW59P1 set Stick-on feet for case FW38R (optional)U}Miscellaneous:2 12v Flat relays HY20W1 PCB mains transformer 9v YJ53H2 Chassis fuse U}holders 20mm RX49D2 3.15 anti-surge fuses 20mm RA11M1 Pack 22SWG solder FR21X1 JoU}ystick extension lead (eg Tandy 276-1978)1 All-plastic case, eg Maplin ABS box 2006 (order code LH62S) or ABS box MB4 U}er can handle 1.5 Amps at up to 35v.Next month we'll cover the construction, testing and programming.endsmfTAMINGq(Order code LH23A)70 2 0 1322740Len Golding :Gadgets IIIPARTS LIST Maplin OrT0 4 1 5 0 16 70 2 0 1322740Len Golding: Gadgets III(Panel)Printed circuit board (order code DBP1) avai}lable from: R H Design 137 Stonefall Avenue Harrogate North Yorks. Tel 0423 50}8359Price #3.95 including VAT and postageJoystick extension lead available from Tandy stores or large computer shopP}10 2 1 5 0 12 74 2 0 122 2764273324Instructional Article Len Golding }27 64 6 2 1 5 0 18 66 4 2 114 2740Len Golding: Gadgets, Part IV 2710636@ 10101010mfEXTRA Ka}EYS AND A NUMERIC KEYPADThis month's constructional project is a plug-in keypad which gives you up to sixteen extra keys ana}d behaves almost exactly like the standard keyboard. The version described works as a numeric keypad with its own Return key a}and single-touch cursor movement, but all keys are fully programmable.It works like a joystick, by setting up patterns of ha}igh and low voltages on the four input signal pins, as described in the June issue. The operating system reads this pattern fa}ifty times a second, converts it into a decimal number between 0 and 15, and stores it in address 632 (port 1) or 633 (port 2a}).Fig 1 shows the circuit for four extra keys, one to each line, and is about the simplest worthwhile gadget you can build.a} You could make the keys extra large for disabled people, colour-code them for pre-readers or set them up as function keys. Ya}ou could label them "Yes", "No", "Don't know", "Help" for a children's quiz, or "Strongly agree", "Slightly agree", "Slightlyb}OKE 54016,1PROGRAM 410 POKE 54018,56:POKE 54016,255:POKE 54018,60:POKE 54016,020 IF PEEK(624)>10 THEN POKE 54016,1q}:GOTO 2030 POKE 54016,0:GOTO 20Len Golding: GREAT LITTLE GADGETS III27332427820PROGRAM 110 POKE 54018,56:Rp"A KB@@V'B@AU9B@@`KB@6-M}-!6-%+",&+"@,-B@(%-@A % @0D:GG3PROG2.BAS6-LfBB KB@@V'B@AU9B@@`KB@ IQ}NPUT TIME DELAY-@ (B@@D:GG3PROG3.BASB@@`KB@ IPT% 1B@@V1notify prospective change;B@AU;seY}t up all joystick pins for output0B@@`0lock new system in place()B@)turn all pins off2Y}B@ @PD:GG3PROG1.BAS 1B@@V1notify prospective change;B@AU;seX1 QL80B15 Keyboard switches FF61R14 Keytops (1 position) FF62S 1 Keytop (2 posity}ion) FF63T 2 3-way PC terminal blocks RK72P 1 Cable 'P' clip 3/16" LR44XAvailay}ble from: Maplin Electronic Supplies P.O. Box 3 Rayleigh Essex SS6 8LR Tel: 0702 552911Approy}ximate cost #8.40Joystick extension lead available from Tandy stores (code 276-1978) or from large computer shops. y}Printed cicuit board (order code DBP2) available from: R.H. Design, 137 Stonefall Avenue, Harrogate, Ny}orth Yorkshire, HG2 7NS Tel: 0423 508359Price #3.40 including VAT and postage15-KEY VERSION OF KEYPAD xZ04 ;Rl QD05 ;Len Golding: Gadgets IV 06 .OPT NOEJECT07 ; PROGRAM 1 SOURCE LISTING 10 ATRACT}=$4D20 CH=$2FC30 FLAG=$60040 KEYPAD=$27850 SETVB=$E45C60 XITVBL=$E46270 *=$60180 VBSET90 PLA0100 LDX #VBCODE/256}0110 LDY #VBCODE&2550120 LDA #70130 JSR SETVB0140 RTS0150 VBCODE0160 LDA KEYPAD Read pad0170 EOR #15 I}nvert the bit pattern0180 BEQ ZFLAG Branch if no key pressed0190 LDX FLAG Branch if same key0200 BNE EXIT } still held down0210 STX ATRACT Prevent colour rotation0220 TAX Use Keypad value as0230 DEX } index into TABLE, to find0240 LDA TABLE,X corresponding character0250 STA CH Store it in character register@} disagree" and "Strongly disagree" for a questionnaire survey. Or you could connect something other than keyboard switches - b}pressure mats, for example, to operate burglar alarms, or central-heating thermostats to monitor room temperature.However, b}you're not limited to four keys. By using all possible combinations of high and low states on the four signal lines you can gb }enerate up to fifteen different numbers (sixteen if you count 0).Most keyboard switches are simple on/off devices - they cab }n't control more than one line without electronic help. But a simple diode matrix is all that's needed, and the circuit of Fib }g 2 will work perfectly well. When any of the keys is pressed, it connects one or more signal lines to 0v, through the diodesb }, while the other lines remain held at 5v by circuitry inside the computer.Fig 3 shows a practical layout on the Verobloc bb }readboard - there's room for only ten of the fifteen possible combinations, but you can see the general principle.The diodeb}s are marked with a black band at their cathode ends, and they must be connected the correct way, with cathodes to the switchb}es, but you won't do any damage by trying them both ways round.Connect the breadboard to port 1, using the joystick extensib}on lead, then run this short program: 10 POKE 752,1:PRINT CHR$(125) 20 POSITION 2,5:PRINT PEEK(632);" ";:GOTO 20b}The number 15 will be displayed (all lines high). Now connect a test lead to the 0v line, touch it to each of the numbered pob}ints in turn and watch the number change on screen. The "single touch" action can be made to generate any number from 0 to 14b}.Having established the principles of operation, we can move on to the keypad construction. A printed circuit board is avaib}lable (see the parts list) and this makes assembly very straightforward. If you have facilities to make your own, the foil pab}ttern is given in Fig 4. Holes for the diodes are 0.8mm, those for the switches are 1.2mm and the fixing holes are 3mm or 1/8b}". A ready-made board is available from RH design, and this comes drilled and tinned ready for use.For a professional finisb}h, the design uses full-travel keyboard switches which have removable transparent covers, so you can insert Letraset legends.b} The PCB holes are spaced so that the keys butt up to one another, avoiding the need for a complicated panel cut-out.Solderb} the diodes first, making sure you get them the right way round (black band towards the centre of the PCB), then fit the termb}inal blocks and switches. Make sure the switch bodies sit firmly onto the board's surface, with no gaps, otherwise constant pb}ressing will cause the copper track to peel away from the PCB.Fit a cable clip to anchor the joystick lead, and mount the wb}hole assembly in a suitable case using at least four of the six mounting holes. The front panel cut-out should be 75mm squareb}.Now we need some software to drive the gadget. You could program it in Basic, just like a joystick, but it's more impressib}ve if the new keypad can be made to act like the existing keyboard, with no visible software driving it. This means using a mb}achine-code routine to scan the keypad during the vertical blank interval and activate the operating system's keyboard handleb }r whenever a key is pressed.There is a trick we can use to cut corners, using address 764. Whenever you write a number intob!} this address, the computer thinks you have just pressed the key which generates that number, and will obediently print the cb"}orresponding character on screen for you. Our software simply reads the keypad (address 632), converts the number into an appb#}ropriate keycode, stores it in address 764 and lets the operating system do the rest.Once in place, the routine will executb$}e every fiftieth of a second, independently of any Basic program which may be running at the same time.From the user's poinb%}t of view, the only difference between our new keypad and the existing keyboard is that the new keys don't have auto-repeat. b&}This is a feature, not a bug, since it helps to guard against accidental double-entry. The standard keyboard keys can still bb'}e used, of course, in circumstances where auto-repeat is an advantage.Two different versions of the software are presented.b(} Program 1 is the simpler, and runs as part of a Basic program using page 6 to store the machine code. Program 2 is the de-lub)}xe version for disk drive owners. It will create an AUTORUN.SYS file which boots automatically at power-up, resets the MEMLO b*}pointer to make a safe area for our machine code and traps the SYSTEM RESET routine to ensure that the new keyboard stays actb+}ive as long as the computer is switched on. This version is completely invisible to the user, and you can use it with cartridb,}ge-based languages other than Basic.Both programs work in exactly the same way. Pressing any keypad key will return a numbeb-}r from 0 to 14 in address 632. The bit pattern is inverted (which is equivalent to subtracting the number from 15) and the reb.}sult is used as an index into a table of keycodes supplied by you. The number retrieved from this table is written into addreb/}ss 764, then the operating system takes over to print out the selected character.The new keys can be programmed to duplicatb0}e any of the standard keys or key combinations, by changing the values in our keycode table. This table appears in the Basic b1}programs as fifteen entries in a single line of DATA (line 40 in Program 1; line 70 in Program 2), and can be altered simply b2}by changing the values.Let's say you want one of the new keys to print a comma, so that you can type long DATA statements wb3}ith one hand on the keypad and the other on your program listing. First you need to find the keycode which corresponds to ","b4} (it's not the ATASCII number), so run this line: 10 PRINT PEEK(764):GOTO 10then press "," on your keyboard. The numbb5}er that comes up is the keycode you want - in this case 32. Now decide which of your new keys you want to do the job, and getb6} its number from the underside of the PCB. This tells you which of the fifteen DATA values to change.Let's say you want theb7} comma to be printed by the double-width key. This is key number thirteen, so count to the thirteenth DATA entry and change tb8}he "12" to "32". Run the modified program and you're in business.The specified key layout is suitable for most purposes, bub9}t you can set the double-width key to the right if you prefer. It then becomes key number fifteen, and the remaining two keysb:} on that line become thirteen and fourteen, as the PCB markings show.There is also provision for a sixteenth key, so that yb;}ou could make a hex keypad for use with the Assembler Editor cartridge. An extra input is needed for this, and the joystick tb<}rigger line is the obvious one to use.To add a sixteenth key, cut the copper track where it is marked "cut" on the PCB, theb=}n connect joystick pin 6 to the terminal marked "NC". If you're programming the keypad in Basic, you'll need to combine the vb>}alue in 632 with the trigger line value (644). Here's one way: 10 KEY=PEEK(632)+16*(PEEK(644)=0)This returns the normab?}l joystick values for keys 1 to 15, and 16 whenever the sixteenth key is pressed. However, if you want a hex pad, the chancesba}0260 STA FLAG Set Flag >0 (disable keys)0270 JMP XITVBL and exit0280 ZFLAG0290 STA FLAG Set flag =0 (enA}able keys)0300 ;0310 EXIT0320 JMP XITVBL and exit0330 TABLE0340 ;Contains hardware key codes for0350 ;1,2,3,4,5,6,B}7,8,9,0, Cursor up, cursor down, RETURN, cursor left and cursor right0360 .BYTE 31,30,26,24,290370 .BYTE 27,51,53,48,500C}380 .BYTE 142,143,12,134,135n, RETURN, cursor left and cursor right0360 .BYTE 31,30,26,24,290370 .BYTE 27,51,53,48,50004 ;Rl QKC0 05 ;Len Golding: Gadgets IV06 .OPT NOEJECT07 ; PROGRAM 2 SOURCE LISTING10 ATRACTE}=$4D20 CH=$2FC30 DOSINI=$0C40 KEYPAD=$27850 MEMLO=$2E760 SETVB=$E45C70 XITVBL=$E46280 *=$1D2090 COLDST0100 LDA DOSF}INI Trap SYSTEM RESET0110 STA WARMST+1 routine0120 LDA DOSINI+10130 STA WARMST+20140 LDA #WARMST&2550150G} STA DOSINI0160 LDA #WARMST/2560170 STA DOSINI+10180 JMP WMST20190 WARMST0200 JSR OLDINIT0210 WMST20220 LDA #FINH}ISH&255 Reset MEMLO to0230 STA MEMLO protect our new0240 LDA #FINISH/256 machine code0250 STA MEMLO+10260 I} LDX #VBCODE/256 Insert new vertical0270 LDY #VBCODE&255 blank vector0280 LDA #70290 JSR SETVB0300 OLDINIT0310 RJ}TS0320 ;0330 VBCODE0340 LDA KEYPAD Read pad0350 EOR #15 Invert the bit pattern0360 BEQ ZFLAG K} Branch if no key pressed0370 LDX FLAG Branch if same key0380 BNE EXIT still held down0390 STX ATRACTL} Stop colour rotation0400 TAX Use Keypad value as0410 DEX index into TABLE, to find04M}20 LDA TABLE,X corresponding character0430 STA CH Store result in character register0440 STA FLAG N} Set Flag >0 (disable keys)0450 JMP XITVBL and exit0460 ZFLAG0470 STA FLAG Set Flag =0 (enable keys)O}0480 EXIT0490 JMP XITVBL and exit0500 TABLE0510 .BYTE 31,30,26,24,290520 .BYTE 27,51,53,48,500530 .BYTE 142,1R}s, price around #3.50Other components available from: Maplin Electronic Supplies Ltd PO Box 3 Q} Rayleigh Essex SS6 8LR Tel 0702 552911Approximate cost #18.00 plus caseboard (order code DBP1) avaia43,12,134,1350540 FLAG *=*+10550 FINISH0560 *=$2E00570 .WORD COLDST,24,290520 .BYTE 27,51,53,48,500530 .BYTE 142,1J0 4 1 5 0 12 75 2 0 1322740Len Golding:Gadgets IVFIG 1: FOUR EXTRA KEYS PIN 1 PfT}IN 2 PIN 3 PIN 4 OV PIN 8 ing:Gadgets IVFIG 1: FOUR EXTRA KEYS PIN 1 Pd10 4 1 5 0 12 90 2 0 1322740Len Golding: Gadgets IV FIG 2: DIODE MATRIX. 827651jV}6A .B .C .D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0v . 1 2jW} 3 4 5 6 7 8 9 10 11 12 13 14 152740 1270This matrix allows fifteen separate on/off inputs jX}to be chanelled through a single joystick port.ding: Gadgets IV FIG 2: DIODE MATRIX. 827651h00 4 1 5 0 12 90 2 0 1322740Len Golding: Gadgets IV FIG 3: BREADBOARD LAYOUT FOR FIRST TEN KEYS.12 nZ}4 1 5 0 4 90 2 0 120273348276514----------------------------------- ..... ..... ..... ..... ..... n[}A B C D . ............................. . . ............................. . . ............................. .n\} . ............................. . . ............................. . . ............................. . . ..............n]}............... . . ............................. . . ............................. . . ............................. . n^} 1 2 3 4 5 6 7 8 9 10 ..... ..... ..... ..... ..... 0v273312740(pin 8) ---------------------------n_}------------------------ 1270A,B,C,D are outputs to joystick port 1, pins 1,2,3 and 4.1 to 10 are inputs - take any on`}ne of them to 0v and the contents of address 632 will change. IV FIG 3: BREADBOARD LAYOUT FOR FIRST TEN KEYS.12 l= are that you're already into machine code programming, so you should have no difficulty modifying either of the source listibb}ngs to take account of key sixteen.ends2740Len Golding: Gadgets, Part IV 2710636@ 10101010mfEXTRA K`-#l RQJ Len Golding: Gadgets IV .. PROGRAM 1, BASIC LISTING ~d} --@Y")A7%- LL104,162,6,160,12,169,7,32,92,228,96,173,120,2,73,15,240,21,174,0,6,208~e}NN19,134,77,170,202,189,46,6,141,252,2,141,0,6,76,98,228,141,0,6,76,98,228(6631,30,26,24,29,27,51,53,48,50,142,143,12,13~f}4,1352aaLine 40 contains the 15 key codes for: 1,2,3,4,5,6,7,8,9,0,Cursor up,down,RETURN,left,right<6-?:A7,~g}D:GG4PROG1.BASl RQJ Len Golding: Gadgets IV .. PROGRAM 1, BASIC LISTING |"PRScp22 PROGRAM 2, BASIC LISTING ..@@ D:AUTORUN.i}SYS,-@A"(*@, NN255,255,32,29,124,29,165,12,141,54,29,165,13,141,55,29,169,53,133,12,169j}(RR29,133,13,76,56,29,32,75,29,169,126,141,231,2,169,29,141,232,2,162,29,160,762PP169,7,32,92,228,96,173,120,2,73,15,24k}0,21,174,125,29,208,19,134,77,170,202<DD189,110,29,141,252,2,141,125,29,76,98,228,141,125,29,76,98,228F6631,30,26,24,29l},27,51,53,48,50,142,143,12,134,135P224,2,225,2,32,29D:GG4PROG2.BASNO SUCH ITEMSELm}22 PROGRAM 2, BASIC LISTING ..@@ D:AUTORUN.#9A,Vmaximum number of notes allowed - change it if necessaryZ## >:A%,START WHEN READYd!6-!A6o}dAUn6 F:A,"A6wait for first notexE@ $6-F:A,Estart timer and read6p} key value.68,-8,.get pitch value for that keyB"28,@@Bgenerate the appropriate tone6q}YF:Ad,AU*AdAU4 AYbranch if any keyboard key pressed<"F:A,AP<wait until6r} value of KEY changes]68,-F:@ ,#6-%@- A ]store duration value and return for next note5 6-+6}12 4 1 5 0 10 70 2 2 132Len Golding: GREAT LITTLE GADGETS IV27332427820PROGRAM 110 FOR X=0 TO 59:R^t}EAD D:POKE 1537+X,D:NEXT X20 DATA 104,162,6,160,12,169,7,32,92,228,96,173,120,2,73,15,240,21,174,0,6,20830 DATA 19,134,7^u}7,170,202,189,46,6,141,252,2,141,0,6,76,98,228,141,0,6,76,98,22840 DATA 31,30,26,24,29,27,51,53,48,50,142,143,135,134,12^v}50 REM Line 40 contains the 15 key codes for: 1,2,3,4,5,6,7,8,9,0,Cursor up,down,right,left,RETURN60 X=USR(1537)PROGR^w}AM 210 OPEN #1,8,0,"D:AUTORUN.SYS"20 FOR X=1 TO 105:READ D:PUT #1,D:NEXT X30 DATA 255,255,32,29,124,29,165,12,141,54,^x}29,165,13,141,55,29,169,53,133,12,16940 DATA 29,133,13,76,56,29,32,75,29,169,126,141,231,2,169,29,141,232,2,162,29,160,76^y}50 DATA 169,7,32,92,228,96,173,120,2,73,15,240,21,174,125,29,208,19,134,77,170,20260 DATA 189,110,29,141,252,2,141,125,2^z}9,76,98,228,141,125,29,76,98,22870 DATA 31,30,26,24,29,27,51,53,48,50,142,143,135,134,1280 DATA 224,2,225,2,32,29O 59:R\w27 64 6 2 1 5 0 18 66 4 2 114 2740Len Golding: Gadgets, Part V - music keyboard2710636@ 10101010v|}mfMUSIC KEYBOARDThis simple keyboard can be used for playing live music, or as a programming aid to help you add musv}}ic to your Basic games or educational programs. It has a full two-octave range (E to E), which is adequate for most popular tv~}unes, and it's very easy to build. We've opted for a stylus system, which means you can play only one note at a time, but thiv}s keeps the cost down and simplifies construction and programming.A diode matrix decodes the signal from each key into a fiv}ve-bit binary word, which is sent to pins 1,2,3,4 and 6 of the joystick port. Last month's project explained the technique inv} some detail, so we won't go into it again. A short driver program converts the five bits into a decimal number between 0 andv} 25, which can then be used in any music program you care to write.Fig 1 shows the printed circuit board pattern, reduced iv}n size so that it will fit onto the magazine page. Its actual dimensions are 230mm x 85mm, so if you want to enlarge it and mv}ake your own PCB, good luck. Otherwise buy the professionally produced version from RH design.Construction could hardly be v}simpler. Fig 2 shows the board layout - make sure all the diodes are soldered with their black or coloured bands towards the v}keys. A bending jig (Fig 3) will save time and ensure that the diodes all slot neatly into place.Although type 1N914 is spev}cified, almost any silicon signal diode will work, and you may be able to pick up a job lot fairly cheaply - Tandy stores selv}l a pack of 50 for about #2.50.The stylus is made from a standard test probe and is connected by a flexible lead to the poiv}nt marked "stylus" on the PCB. The terminal marked "NC" is not connected to anything.When everything is soldered together, v}fit the joystick lead and stylus, using a cable clamp or 'P' clip to take the strain. Plug the gadget into port 1 and Run Prov}gram 1. You should see "0" displayed on the screen. Touch the stylus to bottom E and the number should change to '1'. The nexv}t key (F) should produce '2' and so on up to top E, which should return '25'.If any are at fault, make sure that all the div}odes connected to the offending key are wired the right way round. Also check that the solder has correctly joined each compov} 42 Westcliffe Grove Harrogate } North Yorkshire HG2 0PL Tel: 0}nent lead to its intended track, and that no blobs of solder have bridged gaps between tracks.Mounting the PCB in a case rev}quires a bit of care. The keys must be supported along their length, and you'll want to hide the solder blobs somehow. The prv}ototype case was made entirely from a 6' length of 25mm x 9mm planed Ramin. This size can often be found among the hardwood mv}ouldings and beadings in large DIY stores.Programming is straightforward. Four of the five bits are returned at address 632v}, while the fifth appears at address 644. Our software must combine these into a single five-bit word, and store the result av}s a decimal number from 0 to 25. This can be done as shown in program 1 but it's more elegant, and faster, to use a short macv}hine code routine.Program 2 shows one way of doing it. Lines 10 to 40 contain a machine code routine (see the source listinv}g) which decodes the keyboard's output fifty times a second, during the vertical blanking interval. The result is stored in av}ddress 1791, and can range from 0 (no key pressed) to 25 (top E). Lines 50 to 70 set up a matrix P which contains all the pitv}ch values in ascending order.Line 80 generates the sound, using the number held in 1791 as an index into the matrix to retrv}ieve the appropriate pitch value. For example, key 6 will select matrix entry number 6 (144) and this value, used in a SOUND v}statement, produces the note "A".The program also resets address 77 to 0 every time a key is touched. This prevents the scrv} KE""lQH PROGRAM 1 "AR@" >:A%,-@@--6-@1}&F:A2,&@$F:AD,(   @ D:GG5PROG1.BAS" >:A%,-@@--6-@1N  4J`PKEPEKA@&@G@""lQH PROGRAM 2 F-@5"})AU%- FVertical Blank RoutineGG104,162,6,160,230,169,7,32,92,228,96,173,132,2,10,10,10,10,24,10988120,}2,73,31,141,255,6,240,4,169,0,133,77,76,98,228(S6-?:AU,Skey value (1 to 25) now automatically returned at address }423 60393 43727871GADGETS IIITAMING THE MAINSPart 1 507427870About 1050 word}s5 Illustrations1 Parts list 2764273324Instructional Article Len Golding "10 2 1 5 0 12 74 2 0 122 2764273324Instructional Article Len Golding } 42 Westcliffe Grove Harrogate } North Yorkshire HG2 0PL Tel: 0}423 60393 43727871GADGETS IIITAMING THE MAINSPart 2 507427870About 1350 word}s1 Illustration1 Parts list4 short program listings nstructional Article Len Golding :17912D9@%,$-@%("168,-5 DPitch values<770,193,182,173,162,153,144,136,128,121,114,108,1}02F,,96,91,85,81,76,72,68,64,60,57,53,50,47P5+28F:A,,@@5 @D:GG5PROG2.BAS"z05 ;Rl  SOURCE CODE FOR PROGRAM 2 06 ; VBLANK routine to combine stick and trigger inputs into07 ; a} single five-bit word, and store it at address 1791 10 ATRACT=$4D20 HOLD=$6FF30 STICK=$27840 STRIG=$28450 SETVB=$E45C6}0 XITVBL=$E46270 *=$6DB80 PLA90 LDX #VBCODE/2560100 LDY #VBCODE&2550110 LDA #70120 JSR SETVB0130 RTS0140 VBCOD}E0150 LDA STRIG0160 ASL A0170 ASL A0180 ASL A0190 ASL A0200 CLC0210 ADC STICK0220 EOR #310230 STA HOLD0240} BEQ EXIT0250 LDA #00260 STA ATRACT0270 EXIT0280 JMP XITVBLutine to combine stick and trigger inputs into07 ; aD10 2 1 5 0 12 74 2 0 122 2764273324Instructional Article Len Golding } 42 Westcliffe Grove Harrogate } North Yorkshire HG2 0PL Tel: 0}423 60393 43727871GREAT LITTLE GADGETS: PART VMUSICAL KEYBOARD 507427870About} 700 words3 illustrations3 program listings1 Parts listtructional Article Len Golding <0 4 1 5 0 16 70 2 0 1322740Len Golding :Gadgets V - musical keyboardPARTS REQUIRED FOR 25-KEY MUSICAL KE}YBOARD Maplin Order Codes57 1N914 signal} diodes QL71N 1 8-way PC terminal blocks RK38R 1 Cable 'P' clip 3/16" LR44X 1m }Extra-flexible wire XR40T 1 Test prod pack FK32KAvailable from: Maplin Electron}ic Supplies P.O. Box 3 Rayleigh Essex SS6 8LR Tel: 0702 552911Approximate cost #3.60Joystick} extension lead available from Tandy stores (code 276-1978) or from large computer shops. Price around #3.30Printed ci}cuit board (order code DBP3) available from: R.H. Design, 137 Stonefall Avenue, Harrogate, North Yorkshi}re, HG2 7NS Tel: 0423 508359Price #5.95 including VAT and postageoardPARTS REQUIRED FOR 25-KEY MUSICAL KENeen colour rotation which would otherwise occur after about eight minutes.Program 3 shows one way of recording and playing v}back your tunes. Add the extra lines to program 2, deleting the existing line 80. This program waits for your first note, thev}n stores its pitch and duration in two matrices, named PITCH and TIME respectively. Duration is calculated by using the real-v}time clock at address 20. This address increments automatically every fiftieth of a second, so it's easy to time an event by v}25 A02-#@ 2start replay2"28,@@6}checking the before and after values. In program 3 the counter is set to 0 whenever you touch a note, and read again when youv} move the stylus. The count value at that moment is stored in matrix TIME, and indicates the note's duration in fiftieths ofv} a second.When you've finished your live performance, press any key on the console keyboard - the space bar is convenient. v}You can then ask for an action replay or start another tune. The replay option lets you increase or decrease the playback spev}ed by up to ten times - a tempo value of 1 gives roughly the same speed as the live performance, 2 is twice as fast; 0.5 is hv}alf as fast. Try picking out the Flight of the Bumble Bee at dirge speed then playing it back at warp factor ten.Replay is v}a simple reversal of the recording process. Pitch and duration values are read from their repective matrices, then PITCH is uv}sed directly in a SOUND statement (line 200) and TIME is used in conjunction with the tempo value to control a delay loop at v}line 210.ends 0 18 66 4 2 114 2740Len Golding: Gadgets, Part V - music keyboard2710636@ 10101010t2generate tone@F:@ , 8,'A@hold it for specified duration) )26} Press SELECT to replay"" Press START to start again"F:B2y,"@" @6F:B2y,"@(( I6}NPUT TEMPO,6 A APD:GG5PROG3.BAS@@@@4<27 64 0 2 1 5 1 6 34 2 0 124 273356LIGHT-ACTIVATED SWITCH27642740 1268CONSTRUCTIONFit the joysticHm