@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}}} HE |||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}0 4 1 5 0 16 74 2 0 1322740 Len Golding :Gadgets X - Analogue Joystick Sketchpad MAIN PARTS REQUIRED F,}OR SKETCHPAD Maplin Code 1 2-axis joystick -} HQ50E 2 .047 mfd capacitors WW20W 2 .022 mfd capacitors WW19V 1 4-way screw termina.}l block 1 Plastic box LH20W 1 0.5" x 4BA plain spacer FW32K 1 Handwheel bolt and T nut /} YL23A 4 0.5" No 4 self-tapping screws BF66W 1 Joystick extension leadstick Sketchpad MAIN PARTS REQUIRED FP27 64 6 2 1 5 0 18 66 4 2 114 2740Len Golding: Gadgets, Part VI2710636Page @ of 710101010mfV}FOUR-CHANNEL MODEL CONTROLLERThis gadget gives your computer the power to control Lego and Meccano models, slot-car racerW}s, small model railways and computer-driven buggies. It provides independent on/off switching for up to four motors, relays, X}solenoids or other low-voltage devices. It can operate as a four-channel speed controller, or as a two-channel reversing switY}ch, so you can make a buggy move forwards, backwards, left or right at different speeds under software control. Each channel Z}can drive a dozen torch bulbs for childrens' disco displays - including chaser lights - and there are even some limited appli[}cations in robotics.Fig 1 shows the circuit in schematic form. Each of the four outputs is driven by a two-transistor power\} switch, which enables the tiny currents and voltages from the joystick port to control currents up to 5 Amps and voltages up]} to 24v at the outputs. We explained transistor switching action in part 2 of this series.Fig 2 shows the printed circuit b^}oard pattern for those of you who want to etch your own but, as usual, a commercially-made PCB is available from RH Design._}The component layout is shown in Fig 3, and construction is straightforward. Start by soldering the resistors and diodes, mak`}ing sure the diodes are connected with their silver bands to the top. Then fit the BC108 transistors and all connecting blocka}s.Bend the leads of each TIP127 transistor at right angles, and spread them slightly to fit the PCB holes. Smear a small amb}ount of silicon grease onto the back of each transistor, then bolt the four transistor and heat-sink assemblies into place BEc}FORE soldering the leads. Make sure that the heat-sink vanes cannot touch each other, or the gadget will not work properly.d}Cut the joystick cable to length, discarding the socket end, then wire each of the nine leads to its appropriate point on tere}minal block 1, as indicated in Fig 3. Use a 'P' clip to secure the joystick cable and take any strain.Motors require far mof}re current than a joystick port can provide, so the next thing you need is some kind of low-voltage DC power supply. This desg}ign allows very wide latitude - anything from 4.5v to 24v is acceptable. At high output currents, the voltage delivered to yoh}ur load may be up to 1v less than the full supply voltage.A properly stabilised mains power supply unit is best, but these i}are expensive and not really necessary for things like motors, solenoids, relays, lamps and other non-electronic devices. "Baj}ttery eliminators" intended for transistor radios or computers give good results, but the cheap ones cannot usually supply cuk}rrents above 1 Amp.DC power packs designed for model railways, slot-racers, Lego or Meccano sets will work quite well, and l}even a car battery charger should give acceptable results, though the output from all these devices tends to be unstable. A 1m}2v car battery charger, for example, may deliver 18v or more under no-load or light load conditions, falling to 12v or less wn}hen supplying several amps. These voltage fluctuations will affect the speed of most model motors, so you may find that thingo}s tend to slow down as more channels are switched in.Lead-acid accumulators give a clean, stable output and can supply extrp}emely high currents, but they need careful handling. Dry batteries are safest, though expensive, and rechargeable nickle-cadmq}ium cells may be worth considering.Whatever type of power supply you choose, its output must be wired to terminal block 2 ar}s shown in Fig 3. Take great care not to reverse the positive and negative leads, or you could damage the transistors.Each s}output transistor can easily handle 1 Amp continuously, and up to 5 Amps for periods of a few seconds. If you plan to draw stt}eady currents above 1.5 Amps, you will need larger heat sinks.Programming follows the familiar pattern. Start by setting upu} the joystick ports for output (first line of Program 1), then POKE a number from 0 to 15 into address 54016, to switch on yov}ur chosen combination of channels. Table 1 shows all the possibilities.Program 1 is a simple demo which switches each channw}el in turn, so if you connect a line of four torch bulbs you will see the 'chaser' effect. An attractive animated display canx} be made from an old set of Christmas lights - cut the flex half-way between each bulb, untwist the tails to each holder and y}re-wire the bulbs in parallel, for low-voltage operation.If you're using motors, you can introduce an element of speed contz}rol by switching the power on and off in rapid pulses. Program 2 shows the conventional way of doing this, using a variable '{}mark/space' ratio. A short burst of power (the 'mark') is applied, followed by a short off period (the 'space'). By choosing |}appropriate values for MARK and SPACE you can usually reduce a motor's speed by as much as eight times before its movement be}}comes too jerky. Try, for example, setting MARK = 1 and SPACE = 8. Though Program 2 operates with channel 1, you can apply th~}e same principle to all channels.Some applications - such as buggies and robot arms - need a controller which can change a }motor's direction of rotation. Most model motors can be reversed simply by changing the polarity of their supply leads, and F}ig 4 shows how to do this with DPDT relays. Each relay uses two channels, one for the on/off function and the other to select} forward/reverse. Any DPDT relay will work, provided the coil and contact ratings suit your application.An add-on PCB (DBP5}) is available for use with two of Maplin's ultra-miniature relays, which can each handle 2 Amps at up to 24v. Choose the coi}l voltage which best suits your power supply - 6v types will operate on 4.5v to 7.5v, while 12v types work on 9v to 15v.The} foil pattern and layout for this PCB are shown in Fig 5. The 8-way terminal block is connected pin-for-pin to terminal block} 3 on the main board, using flexible wires or rigid pins cut from 2.5 sq. mm. mains cable. Table 2 gives the numbers to POKE }into 54016 for the various output states in this mode.You could build a Lego model tank, with a separate motor for each tra}ck, or a model car with some kind of servo to operate the steering. Or you can fit only one reversing relay and still have tw}o on/off channels available - to control a model train and two signal lamps, for example.External sensors can be connected }to the main board at terminal block 2, as shown in Fig 3. Joining the two pins marked 'Trig' will cause the number in address} 644 to change from 1 to 0. Try wiring a microswitch to operate when your buggy hits an obstacle, or a robot hand closes.Th}e other inputs (Pot A and Pot B) both measure the amount of electrical resistance between their two leads, and store the resu}lt at address 624 (pot A) or 625 (pot B). A 470k variable resistor will return numbers from 1 to about 200, and this could be} used to measure the degree of rotation in a servo shaft, or the angular movement of a robot arm.Alternatively you could fi}t a cadmium sulphide cell, whose resistance varies according to the level of illumination. Arrange for your train or slot car }27 64 6 2 1 5 0 16 75 4 2 1142740Len Golding: Gadgets Part VITable 1: OUTPUT SWITCHING FROM PORT 12_ }______________________________________________________Number in Channel 1 Channel 2 Channel 3 Channel 454016___ }____________________________________________________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 OFF }OFF ON ON 13 ON OFF ON ON 14 OFF ON O }N ON 15 ON ON ON ON ________________________________________________ }______ 6 2 1 5 0 16 75 4 2 1142740Len Golding: Gadgets Part VITable 1: OUTPUT SWITCHING FROM PORT 12_ 27 64 6 2 1 5 0 18 63 2 2 1142740Len Golding: Gadgets, Part VI 271063610101010 28 21Table 2: RE}VERSE SWITCHING FROM PORT 1 23__________________________________ Number Left Rightin 54016 Motor } Motor__________________________________4 0 OFF OFF 1 OFF OFF 2 F}ORWARD OFF 3 REVERSE OFF 4 OFF OFF 5 OFF OFF 6 } FORWARD OFF 7 REVERSE OFF 8 OFF FORWARD 9 OFF FORWARD }10 FORWARD FORWARD 11 REVERSE FORWARD 12 OFF REVERSE 13 OFF }REVERSE 14 FORWARD REVERSE 15 REVERSE REVERSE2___________________________________able 2: REs0 4 1 5 0 16 75 2 0 1322740 Len Golding :Gadgets VI - 4-channel model controllerPARTS REQUIRED FOR 4-CHANNE}L MODEL CONTROLLERMAIN BOARD Maplin Order }Codes 4 BC108C transistors QB32K 4 TIP127 transistors WQ74R 4 Vaned Heatsinks } FL58N 4 1N4001 diodes QL73Q 4 150k resistors (brown/green/yellow) M150K 4 } 47k resistors (yellow/violet/orange) M47k 4 1k resistors (brown/black/red) M1K 3 3-way PC terminal blocks } RK72P 2 8-way PC terminal blocks RK38R 1 Cable 'P' clip 3/16" LR44X 1 Tube silico}n grease HQ00A 1 Pack 6BA x 1/2" bolts BF06G 1 Pack 6BA nuts BF1}8UApproximate cost #9.80RELAY BOARD 1 8-way PC terminal block RK38R 1 4-way PC terminal block } RK73Q 2 Ultra-miniature DPDT relays BK48C (6 volt) YX95D (12 volt})Approximate cost #3.85All components available from: Maplin Electronic Supplies P.O. Box 3 Rayleigh } Essex SS6 8LR Tel: 0702 552911Main printed circuit board (DBP4) #3.10Relay PCB (DBP5) 48p (plus 20p post}age if not ordered with main board)Available from: R.H. Design, 137 Stonefall Avenue,} Harrogate, North Yorkshire, HG2 7NS Tel: 0423 508359Joystick extension lead available from Tandy store}s (code 276-1978) or from large computer shops. Price around #3.30- 4-channel model controllerPARTS REQUIRED FOR 4-CHANNEC.PP(l QFLen Golding: Gadgets part VI - 4-channel low voltag}e switch && PROGRAM 1 qB@@V'B@AU9B@@`KB@}qset up joystick ports for outputA #@p-@$"$Get channel control number(&B@&Turn} that channel on29-@@` 9sets speed of chaser effect<  @ F 1,2,4,8D:GG6PROG1.BAS}that channel on29-@@` 9sets speed of chaser effect<  @ F 1,2,4,8D:GG6PROG1.BAS >MARSPAC@ @@QQ(l QFALen Golding: Gadgets part VI - 4}-channel low voltage switch $$ PROGRAM 2 KB@@V'B@AU9B@@`}KB@( SET MARK,SPACE(Set speed+B@@+Switch on channel 1(#-@ #"},A;;R!PROGRAM 1 - SIMPLE ANALOGUE JOYSTICK ROUTINE  +@@'6-F: }A$,!6-F:A%,',!6-F:A$,!6-F:A%,(!AY6-AY2!@y6-@y<6@w }6Prevent screen colour rotationF / @0 D:SKETCH1.BASTINE  +@@'6-F: Un[[R!PROGRAM 2 - VB ROUTINE CONVERTS STICK OUTPUT INTO GR.7 PLOTTING CO-ORDINATES 8} +@A-@h")A6%- AInsert VB routineGG104,169,79,141,253,6,162,6,160,16,169,7,32,9}On" period2(B@(All channels off<$-@ $"Off" periodF @0D:GG6PROG2.BAS- 4z27 64 6 2 1 5 0 18 66 4 2 114 2740Len Golding: Gadgets, Part VII2710636Page @ of 710101010mf$}SIXTEEN CHANNEL INTERFACE Here's a simple interface which allows your computer to scan a large network of sensors, su$}ch as pressure mats, microswitches and thermostats. It can be used for intruder alarms, energy management systems or any othe$}r task which requires this kind of continuous monitoring. Each joystick port has nine pins - seven signal lines plus 5v $}and 0v. Five of the signal lines can detect only whether a device is "on" or "off", but the other two can distinguish between$} 228 different states. These two "analogue" lines will accept inputs from a wide range of devices, but you can't do anything $}very ambitious with only two lines per port. This simple interface uses a kind of electronic rotary switch to scan sixteen se$}parate devices, and feed the results through a single analogue line. Fig 1 shows in how it works in simplified form. Any$} one of sixteen inputs can be connected to the common output line, by setting up a binary number from 0000 to 1111 at the fou$}r control pins. These codes represent decimal values 0 to 15, and we can send them from the joystick port by making pins 1 to$} 4 serve as outputs, in the now familiar way. The switch's 'common' line is connected to the analogue input at pin 9, though $}it could equally well go to the other one at pin 5, provided you modify the software. The programs described use port nu$}mber 2, leaving port 1 free for an output device, such as the mains controller or four-channel switch described in previous i$}ssues. Information from the sensor network can therefore be used to trigger sirens, switch lights on or off, control central $}heating systems, water your plants, feed the goldfish or whatever. Figs 2 and 3 show the printed circuit board foil patt$}ern and component layout. It could hardly be simpler to put together. The terminal blocks account for about one quarter of th$}e total cost, and may be omitted if you don't mind soldering the various leads directly to the PCB tracks. The 4067 chip$} is a CMOS device, so needs careful handling. Leave it in its package until you're ready to insert it, and touch an earthed m$}etal appliance before handling the chip, to get rid of any static charge that may have built up on your hands. Make sure you $}insert the chip the right way round and check that every one of its pins is correctly fitted into the socket. Remember the in$}terface has to plug into joystick port 2, if you're using the software shown here. Software is fairly straightforward, a$}nd Program 1 shows a Basic routine which will work reasonably well. Line 10 initialises an array to hold the sixteen sensor v$}alues, turns the cursor off and clears the screen. Line 20 sets up both joystick ports for output - if you prefer to keep por$}t 1 set for input, change the POKE 54016,255 to POKE 54016,240. Line 30 starts a loop which steps through the numbers 0 $}to 15, multiplies them by 16 (because we're using port 2) and sends out the corresponding binary codes at each step. The shor$}t delay at line 40 gives the analogue reading time to settle down once a particular input has been selected. Line 50 stores t$}he chosen sensor's value into the array, and line 60 completes the loop. Lines 70 to 90 print out all sixteen values, then st$}art the process again. Unfortunately this method is very slow. It can take a couple of seconds for a new reading to regi$}ster, and if you want to add any extra lines of code - to trigger a siren for example - you will have to fit them into the ma$}in loop. This will slow things down even further, and makes the program needlessly complex. It's much more elegant to use the$} machine code routine at Program 2. This is inherently faster and, because it is executed during the vertical blanking i$}nterval, it will run alongside your Basic program without interfering with it in any way. The biggest advantage, though, is t$}hat it synchronises precisely to the TV frame counter, which also drives the computer's analogue-to-digital converter. With v$}ery little effort we can ensure that the chosen analogue value is stable and valid by the time it is read, so there's no need$} for an external delay loop. This routine updates each sensor's value about three times every second. Now let's look at $}a practical burglar alarm system. Fig 4 shows the simplest DIY layout using normally closed switches on windows and doors. Th$}ey are all wired in series, so if any one of them is opened, the circuit is broken and some kind of sensing device sounds an $}alarm. This approach has three drawbacks: it cannot tell you which switch has been opened, an enterprising burglar can easily$} bridge the switch terminals using a jump lead, and if a fault occurs it can be very tedious to trace. Fig 5a shows how $}our gadget can overcome these problems. When a switch is closed, it shorts out the resistor across its terminals, leaving onl$}y 150k in circuit, which returns a number around 75 at address 626. Opening the switch puts an extra 150k in series, and the $}number goes to around 150. Cutting the wire will return 228, and bridging the switch with a jump lead will give 0. This $}ability to distinguish four separate states is a clear advantage, and the system can easily be adapted to work with normally $}open switches, such as pressure mats. Fig 5b shows how to wire four switches within a single room - only 0ne 5v line needs to$} go all the way back to the computer, which saves cost and complexity. Since the switches are effectively in parallel rather $}than series, it's easy to see which one has been activated. You can tell instantly where the intruder attempted to gain entry$}, and trace faults very quickly. If you really want to impress the neighbours, why not draw a house plan on screen, with all $}sensors marked in colour to indicate whether they are open or closed. The other main application for this gadget is ener$}gy management. You could use sensors to monitor individual room temperatures, or keep track of lights that were (or needed to$} be) switched on. To measure temperature, use a thermistor whose resistance at room temperature is between 100k and 400k$} - type VA1067 is suitable. Individual devices may vary by up to 20% so if you want accurate readings you will need to calibr$}ate each one, using a conventional room thermometer. Light levels can be measured using our friendly cadmium sulphide cell - $}type ORP12 works quite well. Fig 6 shows how you can wire these sensors into the system, using terminal blocks. As for o$}ther uses, well you could connect sixteen keyboard switches to make a complex signalling system (for a disabled person perhap$}s) and, unlike the simple keypad described in part 5, this gadget will respond to more than one key at a time. How about$} fitting moisture sensors in the soil beside your favourite conservatory plants? A couple of stiff copper wires will do, thou$}gh they will tend to corrode before long. Carbon rods reclaimed from old dry batteries are better, and you can solder leads d$}irectly to the brass caps. If you encase the rods in epoxy resin, leaving just the ends showing, it makes a rain or flood det%}0 4 1 5 0 16 74 2 0 1322740 Len Golding :Gadgets VII - 16-channel InterfacePARTS REQUIRED FOR 16-CHANN(}EL INTERFACE Maplin Order Codes 1 406(}7BE analogue switch IC QW42V 1 24-pin IC socket BL20W 3 8-way PC terminal blocks (} RK38R 1 4-way PC terminal block RK73Q 1 3-way PC terminal block RK72P 1 Cable 'P' cli(}p 3/16" LR44X Approximate cost #5.86 with terminal blocks, #3.18 without.All components, including all (}sensor devices mentioned in the text, are available from: Maplin Electronic Supplies P.O. Box 3 Rayleigh (} Essex SS6 8LR Tel: 0702 552911Printed circuit board (order code DBP6) available from: R.H. Design, (} 137 Stonefall Avenue, Harrogate, North Yorkshire, HG2 7NS Tel: 0423 508359Price 1.88 including VAT and(} postageJoystick extension lead available from Tandy stores (code 276-1978) or from large computer shops. Price around #3)} to break a beam of light when it passes a given point, and you have the basis for an accurate position sensor or lap counter }.ends2 1 5 0 18 66 4 2 114 2740Len Golding: Gadgets, Part VI2710636Page @ of 710101010mf ector which returns 228 when it's dry and between 0 and 100 when it gets wet. If you're content to use simple on/off dev%}ices, you can connect the PCB common line to pin 6 at port 2, in which case the sensors' status - "1" or "0" - will be return%}ed at address 645. There's no need to allow 'settling down' time in this case, so a Basic program will work quite well. With %}suitable software and three interface boards you could use joystick pins 5,6 and 9 simultaneously, giving forty-eight inputs %}per port! The gadget can even be used in reverse, as an output device. Try connecting the common line through a 220 ohm %}resistor to 5v (joystick pin 7), and take each output through a light-emitting diode to 0v (pin 8). Numbers at the control pi%"}92,228,96,173,112,2,56(HH233,20,176,7,169,0,141,254,6,240,9,201,160,144,2,169,159,141,254,62FF173,113,2,56,233,40,176,79}  +SENSORA@@!@,,Rl QFLen Golding: Gadgets VII ## PR- }OGRAM 1 /9@,"AR@/ >:A%,KB@@V'B@AU9B@@`KB@- }:-@+B@$@:Using port 2(-@@  268,-F:A&,< F- }-@@P)-@% 8, ) Z @0D:GG7PROG1.BASVII ## PR,]05 ;Rl Len Golding : Gadgets part VII 06 ; Source code for program 2 10 COUNT=$6FF20 PACTL=$D30231}0 POT2=$D20240 PORTA=$D30050 SETVBV=$E45C60 TABLE=$6EE70 SYSVBV=$E45F80 *=$6AE90 PLA0100 LDA #56 Set1} up joystick0110 STA PACTL ports for output0120 LDA #2550130 STA PORTA0140 LDA #600150 STA PACTL0160 1} LDA #0 Set all outputs0170 STA PORTA to zero0180 STA COUNT0190 LDX #VBCODE/256 Set1} new vector for0200 LDY #VBCODE&255 immediate VBLANK0210 LDA #60220 JSR SETVBV0230 RTS0240 VBCODE0250 LDX C1}OUNT Get channel number0260 LDA POT2 Read pot value0270 STA TABLE,X Store it in TAB1}LE0280 INX Next channel?0290 CPX #160300 BCC OK Branch if <160310 LDX #0 1} Else reset to 00320 OK0330 STX COUNT Update counter0340 TXA0350 ASL A Shift COUN1}T four0360 ASL A places left, to0370 ASL A get the binary0380 ASL A 1}number & switch0390 STA PORTA to next channel0400 JMP SYSVBV Exit vertical blank PACTL=$D30230o]s$$ PROGRAM 2 F-@c")A%- FStore the5} machine codeII104,169,56,141,2,211,169,255,141,0,211,169,60,141,2,211,169,0,141,0HH211,141,255,6,162,6,160,208,169,65},32,92,228,96,174,255,6,173,2,210(TT157,238,6,232,224,16,144,2,162,0,142,255,6,138,10,10,10,10,141,0,211,76,95,2282K6-5}?:A,KNew routine now executed during stage 1 vertical blank<1AR@" >:A%,1clear screenF-@5}@Pj-@- F:At%, 1 ; @pjPrint current values for all sixteen sensors5}D:GG7PROG2.BAS$$ PROGRAM 2 F-@c")A%- FStore the4.304 1 5 0 16 74 2 0 1322740 Len Golding :Gadgets VII - 16-channel InterfacePARTS REQUIRED FOR 16-CHANN(,169,0,141,255,6,240,11,205,253,6,144,3<##173,253,6,141,255,6,76,98,228Fp6-?:A6,pSet VB routine running. X and 9}Y co-ordinates are now returned at 1790 and 1791 respectivelyP% @%,F:A,F:A,Z%/F:A,F:A,9 }% @ D:SKETCH3.BAS[[R!PROGRAM 2 - VB ROUTINE CONVERTS STICK OUTPUT INTO GR.7 PLOTTING CO-ORDINATES 8 05 ;Rl SKETCH3.SRC: VB routine to convert analogue joystick output into direct GR.7 plotting co-ordinates 10 HPOS=$6FEM}ns will switch one LED on at a time, and there you have the basis for a wheel of fortune, roulette game or bargraph display.$}27 64 6 2 1 5 0 18 66 4 2 114 2740Len Golding: Gadgets, Part VIII2710636Page @ of 1010101010m=$}fSOUND-ACTIVATED SWITCH Cure those trigger-finger blisters by adding a voice-operated fire button to your favourite =%}joystick. Astonish your friends with a "talking" head, whose lips move when you speak into a microphone. Keep track of vibrat=&}ion from any source (fridges, washing machines, TV speakers, major earthquakes). Or just train your computer to do tricks whe='}n you whistle. This gadget can do it all. Since you can trigger it by touch, or by blowing gently across the mike, it c=(}ould find a less frivolous use in "Possum"-type systems, to help severely disabled people open the curtains, answer the door =)}or switch the TV on and off. And it can easily be adapted to accept inputs other than sound (more about this later). You=*} can't connect a microphone directly to the joystick port for two main reasons. Firstly, the output from most mikes is very s=+}mall (a few thousandths of a volt at best), and the computer isn't sensitive enough to detect it. Secondly the signal is AC, =,}which the internal hardware can't handle. We need to amplify the mike's output and convert it into a DC signal which can swit=-}ch cleanly between 5v and 0v, then it can be connected to any of the five on/off input lines at your joystick port. Fig=.} 1 shows the circuit. It's not the simplest possible design, but it is very versatile and costs only a few pence more than a =/}rudimentary sound switch. Stage 1 is a fairly conventional AC amplifier, which converts the microphone output into a re=0}spectable voltage swing at C3. Stage 2 is less conventional, but it's built around an ordinary quad 2-input NOR gate chip. Tw=1}o of the gates are wired as a monostable, which converts brief input pulses into output pulses long enough for the computer t=2}o detect. The remaining two gates form a Schmidt trigger, which ensures a clean on-off transition at the output. Stage 2 is i=3}n fact a self-contained analogue-to-digital switch, which behaves in the following way. The input (point A) is normally =4}held above 2.7v, by the action of VR1 and R5. In this state the output is held at +5v (logic 1). When a brief negative-going =5}pulse is received from C3, point A falls below 2.3v, and the output then switches very rapidly to 0v (logic 0). The Schmidt t=6}rigger action ensures that the gadget can't send out any intermediate voltage which might confuse the computer. The mono=7}stable holds the output low for about one tenth of a second, no matter what happens at the input. If at the end of this perio=8}d point A has gone back to 2.7v or more, the output returns to its high state. Otherwise it remains low until the input volta=9}ge rises above the 2.7v threshold. This gap of 0.4v between 'rising' and 'falling' thresholds ensures that the output won't c=:}hatter on and off when the input is exactly at one or other of the trigger voltages. Now let's look at practical constru=;}ction. If you like to etch your own PCBs, the foil pattern is shown at Fig 2. Alternatively you can buy a ready-etched and dr=<}illed board from RH Design, as usual. Use the board as a template for drilling the case before you solder any components. At ==}the same time, it's a good idea to drill a small access hole so that VR1 can be adjusted when the case is assembled. Dimensio=>}ns are given in Fig 4. Fig 3 shows the component layout for the basic sound-operated switch. Notice that the 741 IC is =?}inserted 'upside down', with pin 1 in the top right position. This IC needs no special handling precautions, but the 4001 chi=@}p is a CMOS device, so treat it with care. Avoid handling it unduly, and get rid of any static charge on your hands by grippi=A}ng an earthed metal appliance before touching the IC pins. The amplifier (Stage 1) is matched to a microphone impedance=B} of around 200 ohms, so a standard cassette mike will work very well. Telephone inserts also give good results, and these are=C} cheaper and more robust, especially for applications which involve tapping or blowing. Crystal and other high-impedance micr=D}ophones are not suitable. Connect the microphone and joystick leads to their respective terminal blocks as shown in Fig =E}3. If the mike has a screened lead, its outer braiding should go to the pin nearest VR1. We've assumed you will connect the g=F}adget's output to the fire button line at joystick pin 6, but any of the other four on/off input lines (pins 1,2,3 and 4) wil=G}l work, provided you modify the software. If you use joystick port 1, these pins return a four-bit word at address 632, as we=H} have explained in previous articles. Plug the gadget into port 1 and run program 1. Adjust the variable resistor until=I} the number on screen is 0, then advance it until the number changes to 1 and holds there reliably. The text window will als=J}o change colour, so it's easy to spot the transition. Now clap your hands near the mike, and the number should change mo=K}mentarily to 0, then return to 1. Fine adjustment of the variable resistor will set the sensitivity to suit your application.=L} At its best, the gadget will respond to a snap of the fingers at up to three meters distance, or a pin dropping on a hard su=M}rface close to the microphone. To give your joystick a voice operated fire button, use both ends of the extension cable=N}. Remove a section from the middle of the cable, to make it the correct length. Strip back the black outer sheath to expose t=O}he nine internal wires, and join each wire back to its partner - matching the colours. Solder the joints, and insulate all ex=P}cept the ones to pins 6, 7 and 8, then= connect those three joints to the terminal block as shown in Fig 3. If you want to di=Q}sable the joystick's own fire button, leave the socket end of wire 6 disconnected. Plug your joystick into the extensio=R}n socket, load up a game and set the gadget's sensitivity low enough to eliminate spurious triggering. Then shout, clap or wh=S}istle to blast away. There's scope here for some simple fund-raising games, if you can stand the racket. You may need to posi=T}tion the mike fairly carefully, so that it doesn't pick up sound from the TV speaker or other inappropriate sources. If =U}you would like the output pulse to last longer than one tenth of a second, there are two options. You can increase the value =V}of R6 (10 megohms will give a delay around three seconds) or you can build a delay loop into your software, as shown in Progr=W}am 2. Program 3 is the 'talking head'. Lines 10 to 50 put a simple face shape on screen, then lines 60 and 70 use the ga=X}dget's output to modify addresses 709 and 710, which control the 'mouth' colours. This gives the effect (if you're imaginativ=Y}e enough) of lips opening and closing. OK it's a primitive program, but you could use the same principle for a much more impr=Z}essive multi-coloured display, say in Graphics mode 7. Remember, though, that inexpensive mikes respond best to high fr=[}equencies so the gadget will pick up most consonants without difficulty, but it may not detect vowels unless you're very clos=\}e. That's it, so far as the sound switch is concerned, but the gadget can easily be modified to accept other types of in=]}put. For example, you can trigger it by touching the microphone input, even if there is no mike connected. So it's easy to ma=^}ke a touch-sensitive switch by attaching a wire, or metal pad (eg Maplin type HY01B) to the terminal pin nearest the mounting=_} hole. Many types of sensor - such as thermistors, pressure transducers and moisture detectors - change state slowly, so=`} can't be connected directly to the on/off input lines. Others (like photodiodes), can switch on and off so rapidly that a tr=a}igger pulse may be long gone by the time your computer gets around to looking for it. This gadget can be used as an interface=s}uPEK@ +@16-F:AD,$-@ @1(@!A@$! @Ac} D:GG8PROG1.BAS@ +@16-F:AD,$-@ @1(@!A@$! @@DELA +@16-F:AD,$-@ @1(@'"#-@Ee}A' ( @ D:GG8PROG2.BAS16-F:AD,$-@ @1(@'"#-@D0 @ 1 +@A @@1Ag @,@@1/@&@C/Ig}@&@U/@@g/@@9,@@',@#@9,@ @ (1 @,@Iq}&b'DOS SYSb+GG10PRTSTXTb<UGADGET6 TXTb GG6TAB1 TXTbGG6TAB2 TXTbGG6PARTSTXTbGG6PROG1BASbGG6PROG2BASbGG10PRG1BASbAGADGET7 TXTb GG7PARTSTXTb GG7PROG1BASb GG7PROG2SRCbGG7PROG2BASbGG10PRG2BASbM#GADGET8 TXTbbGG8PROG1BASbdGG8PROG2BASbfGG8PROG3BASb!GG10PRG2SRCbGG8PARTSTXTbcGADGET9 TXTb GG10PRG3BASbGG9TAB1 TXTb GG9PARTSTXTbGG9PRG1ASRCb.GG9PRG1BSRCb CGG9PRG2 BASb LGG9PRG3 BASYGG9COVERTXTbWYGADGET10TXTbGG10PRG3SRCVOICE3 BAS@1/@#@2y @,@@1/@@C,@#@U/@"@g/@"Ir}@y/@@<:6-F:AD,"@0A: @`F!"!A@@P Ix} for both types of signal. To modify the board, leave out all the amplifier components and fit a two-way terminal block =t}in place of R5, as shown in Fig 5. Connect your sensor to this terminal block - if it's polarised (like a photodiode), make s=u}ure the negative end goes to the left-hand terminal. Adjust VR1 as before, so that the gadget triggers at your chosen thresho=v}ld. If you want to use a thermistor, choose one whose resistance is between 5k and 20k at the desired trigger temperatur=w}e. Type VA1055S is suitable for most purposes. A rise in temperature will send the output low, and it will stay that way unti=y}@`D:GG8PROG3.BAS@A @@1Ag @,@@1/@&@C/Hl the temperature falls a degree or two below your pre-set threshold. Any commonly-available photodiode or phototransist=z}or will work, and a very brief flash of light will trigger the output pulse. Steady illumination will hold the output low unt={}il the light level falls below your threshold value. Now suppose you want it to work the other way round - to make a co=|}unting device which increments when a light beam is momentarily broken, for example. That's easily achieved, but it requires =}}a bit of engineering. Look at the track side of the PCB. Just above VR1 you'll see a pattern of four pads which have not been=~} drilled, and below them two arrows. Break the tracks at the two arrows, drill the four new pads and fit a wire link horizont=}20 POTA=$27030 POTB=$27140 SETVB=$E45C50 VMAX=$6FD60 VPOS=$6FF70 XITVBL=$E46280 *=$60090 INIT0100 PLA0110 LDA #79M}0120 STA VMAX0130 LDX #VBCODE/2560140 LDY #VBCODE&2550150 LDA #70160 JSR SETVB0170 RTS0180 VBCODE0190 LDA POTAM}0200 SEC0210 SBC #200220 CHKLEFT0230 BCS CHKRT0240 LDA #00250 STA HPOS0260 BEQ VERT0270 CHKRT0280 CMP #16002M}90 BCC HORZOK0300 LDA #1590310 HORZOK0320 STA HPOS0330 VERT0340 LDA POTB0350 SEC0360 SBC #400370 CHKTOP0380 BM}CS CHKBTM0390 LDA #00400 STA VPOS0410 BEQ EXIT0420 CHKBTM0430 CMP VMAX0440 BCC VERTOK0450 LDA VMAX0460 VERTOK0N}0 4 1 5 0 16 74 2 0 1322740 Len Golding :Gadgets VIII - Sound-activated Switch PARTS REQUIRED FOR SOUNQ}D-ACTIVATED SWITCH Maplin Order Codes 1 Q}uA741 8-pin Op Amp QL22Y 1 4001 Quad 2-input NOR gate QX01B 1 8-pin DIL IC socket Q} BL17T 1 14-pin DIL IC socket BL18U 1 2-way PC terminal block FT38R 1 3-way PC terminQ}al block RK72P 2 Cable 'P' clips 3/16" LR44X 3 0.22 mfd Polyester layer capacitors WW45Y 1 Q} 100 mfd 10v Axial Electrolytic FB48C 1 Small plastic box LH14Q 1 200 ohm cassette microphone Q} (eg Maplin YB31J), or telephone insert. Miniature resistors: 1 220 ohm (red,red,brown) M220R 2 10k Q} (brown, black,orange) M10K 1 18k (brown,grey,orange) M18K 1 220k (red,red,yellow) M22Q}0K 2 470k (yellow,violet,yellow) M470K 1 22k Horizontal sub-miniature preset WR59PApproximate cost #3.20 plusQ} microphone.All components, including all sensor devices mentioned in the text, are available from: Maplin ElectroniQ}c Supplies P.O. Box 3 Rayleigh Essex SS6 8LR Tel: 0702 552911Printed circuit board (order code DQ}BP7) available from: R.H. Design, 137 Stonefall Avenue, Harrogate, North Yorkshire, HG2 7NS TeQ}l: 0423 508359Price 1.48 including VAT and postageJoystick extension lead available from Tandy stores (code 276-1978) orQ} from large computer shops. Price around #3.30Golding :Gadgets VIII - Sound-activated Switch PARTS REQUIRED FOR SOUNP/ally (parallel to the terminal blocks) across each pair of holes. This reverses the positions of VR1 and R5, so the ter=}minal block will now be connected between point A and +5v instead of point A and 0v. If your sensor is polarised, make sure i=}ts positive lead now goes to the left-hand pin. In all other respects, the gadget will perform exactly as before.endsm<{27 64 6 2 1 5 0 18 70 4 2 114 2740Len Golding: Gadgets, Part IX2710636Page @ of 1110101010mfU}LOW-COST PRINTER INTERFACE Epson printers have always been recommended by Atari as an alternative to their own own lowU}-cost and relatively limited machines. But they, together with 'Epson compatible' types produced by other manufacturers, all U}suffer from one big disadvantage - you can't plug them into the Atari's serial port. If you want to drive this kind of printeU}r, you will need some form of interface which can send out data in parallel form. You can pay #99 for an Atari 850 inteU}rface module (plus a further #20 for the printer cable), or around #60 for a third party hardware interface such as the GraphU}ix. But this software-driven gadget can be built for under #12.00 complete. It will handle all printer commands (LPRINTU}, LIST "P:" and so on) just like a hardware interface, but it needs no seperate power supply and very little can go wrong witU}h it. The driver program is written entirely in machine code, it loads and runs automatically on power-up and it's SYSTEM RESU}ET proof, so you can forget all about it once it's loaded into RAM. Unlike some commercially available joystick printer interU}faces, this one leaves page 6 free and it will work with any language cartridge, including ATARIWRITER. Let's look at tU}he hardware first. You will need two joystick extension cables and a 36-way Centronics-type plug with solder terminals - not U}the insulation displacement (IDC) type. Test the cables first, using a standard joystick, then cut them to a length of 1.5 meU}tres or less, and discard the socket ends. Table 1 shows how everything should be connected together to suit Epson and Epson U}compatible printers. Remember to link Centronics pin 9 to pin 30 inside the plug. Soldering this type of connector is tU}he sort of job examiners love to give their students, since it's a good test of soldering skill and plenty of things can go wU}rong. If you don't fancy doing it yourself, you can buy a ready built and tested cable assembly from RH design, for not much U}more than its component parts would cost you. The software is less than 150 bytes long, but it's quite complicated to uU}nderstand. So unless you're happy with machine code, you can ignore programs 1a and 1b, and skip straight to our discussion oU}f the Basic listings. Still with us? OK, the interface works by inserting a new printer handler, which intercepts the nU}ormal OS routine and diverts all output to the joystick ports, where it appears in parallel form. Adding a new handler U}is straightforward. Every peripheral device is controlled by the central input/output subsystem (CIO), with the help of up toU} six machine code routines which are unique to that peripheral. The addresses of these device-specific routines are containedU} in a Handler Vector table - one table for each peripheral. The addresses of all the handler vector tables are themselves coU}ntained in a single 'directory' table known as HATABS, which resides permanently at $31A (decimal 794). The first entry in HAU}TABS is the character "P", followed by the two-byte address of the printer's handler vector table. Now look at the sourU}ce listing for the disk version (Program 1a). The last few lines of WARMST change the first entry in HATABS so that it pointsU} to a new handler vector table (NEWTAB) which we have inserted ourselves. This table contains the addresses of the three routU}ines which a printer needs - OPEN, CLOSE and PUTBYTE. To keep the format correct, it also has to contain addresses for three U}other routines: GETBYTE, GET STATUS and SPECIAL, but since the printer doesn't use these functions, they point to a routine wU}hich generates "Error 146" (function not implemented) and exits. The OPEN routine first checks to see whether your prinU}ter is connected and on-line. If not, it exits with "Error 138" (Device timeout). If everything is correct, it configures theU} joystick ports for output and returns with '1' in the Y register, which tells CIO that all is well. The CLOSE routine simplyU} returns the joystick ports to their default state as inputs. PUTBYTE is the routine which outputs the characters. WhenU} the computer is instructed to print a block of data, CIO sends out one byte at a time through the 6502 Accumulator. So at thU}e start of PUTBYTE, register A will contain the next character to be printed, without any help from us. PUTBYTE first checks U}that the printer is ready to receive data, by looking at the 'BUSY' line (STRIG0). If it is high (5 volts) it means the printU}er is working on some other task, so the routine pauses until STRIG0 goes low again. Then it looks to see whether the cU}haracter in A is an Atari end-of-line and, if so, translates it into the carriage return code. This code instructs the printeU}r to start printing the characters in its buffer and also produces a line feed, provided you have selected 'automatic line feU}ed' on its internal DIP switches. Sending the character to the joystick ports is easy - we just store it at PORTA ($D30U}0), whereupon bits 0 to 3 appear at port one, and bits 4 to 7 at port two, as shown in Table 1. But the printer won't do anytU}hing until its STROBE line goes low, and here we have a problem. There are only eight output lines available from the two joyU}stick ports, and we need all of them to carry an eight bit character. So what can we connect the Strobe line to? The anU}swer is that we cheat, by stealing the eighth bit (bit 7) from the character, and connecting it to the Strobe line. Since norU}mal characters use only bits 0 to 6 (ASCII codes 0 to 127), this doesn't matter for most purposes. Now by masking bit 7 on orU} off, we can send the strobe line high or low at will, without affecting the character data. The printer expects to receive eU}ight-bit characters, so we can't just ignore its DATA 8 line. Instead we connect it permanently to ground, via Centronics pinU} 30. The printer therefore sees an eight-bit character whose eighth bit is low. Back to the source listing. PB1 first mU}akes sure that bit 7 is high, then sends all eight-bits to the joystick ports. JSR DELAY wastes about six microseconds, whichU} gives the data lines plenty of time to stabilise, then bit 7 is switched off, sending the strobe line low, and the printer rU}esponds by loading the character into its buffer. After a further six microseconds, the strobe line is sent high again,U} and the routine exits to CIO, using the Y register to indicate a successful data transfer. This process continues until all U}the data have been printed, then CIO calls the CLOSE routine and hands control back to BASIC, or whatever other language cartU}ridge is installed. Program 1b shows the alternative initialisation code for the cassette version. It's different from U}the disk code because we will be using autoboot files to hold the interface program. This ensures that it is invisible to theU} user, loads rapidly, doesn't need to occupy page 6, has no worries about memory size and can be used with any language cartrU}idge. Also it looks more professional that way. In both versions, the code ahead of NEWTAB contains initialisation rouU}tines which make sure the program loads correctly into a safe area of RAM, and is SYSTEM RESET proof. The cassette version usU}es a standard autoboot format, so the RUN address is contained in a header, and the Atari's own boot handler protects the codU}e against SYSTEM RESET. We'll be explaining how cassette autoboots work in a future issue. The disk version loads into U}an AUTORUN.SYS file, which is a lot friendlier and easier to handle than a disk autoboot. Wth this system the header is diffeU}rent, and extra code is needed to protect the interface program against SYSTEM RESET. Also the disk version needs to insert aU} RUN address during the load process, and this appears as a footer, after FINISH. The code from NEWTAB to FINISH is identicalU} in both versions. The cassette version loads into RAM at $700 (1792 decimal), but the disk version has to leave room fU}or DOS and a few other things, so it starts at $1D00 (7424 decimal). If you have an assembler you can put the program anywherU}e you like in RAM, but once assembled the code is not re-locatable. That's the end of our machine code interlude; BasicU} programmers can re-join us now. Programs 2 and 3 are completely self-contained. They need to be Run just once to create the U}appropriate autoload file, and can then be discarded. Type in the version you want, bearing in mind that machine code has to U}be absolutely correct or it will probably lock up the computer. BE SURE TO SAVE A COPY BEFORE YOU TRY RUNNING IT. For tU}he disk version, insert a disk which doesn't already contain an AUTORUN.SYS file, then type RUN and hit RETURN. The file wilU}l be created in a few seconds, and it will load and run automatically whenever you switch power on with that disk inserted. YU}ou probably won't notice anything different from the usual power-up procedure, though. To make the cassette version, inU}sert a blank cassette which has been fully re-wound, then type RUN and hit RETURN. Press PLAY and RECORD as usual, in responsU}e to the two beeps, and hit any key. The file will be written in about twenty seconds. Whenever you want to load the interfacU}e, make sure the tape is fully re-wound then switch the computer on while holding down the START key. Press PLAY when you heaU}r the single beep then hit any key. When the READY prompt appears on screen, your interface is loaded and ready to use. U} A word now about 'Epson Compatible' printers. This description generally means that the control codes are identical, or neaU}rly identical, to the Epson range, but the internal hardware may be very different. So occasionally you could come across a pU}rinter which won't respond correctly to the raw signal from the joystick ports. This applies mainly to printers which hU}27 64 0 2 1 5 0 18 66 4 2 122 2740Len Golding: Gadgets, Part IX2710636 182TABLE 1: CONNECTING THE J]}OYSTICK LEADS TO THE PRINTER'S CENTRONICS PLUG _____________________________________________ Joystick Joystick ]}Centronics Printer pin function pin function _____________________________________________ ]}1 BIT 0 2 DATA 1 _____________________________________________ 2 BIT 1 ]} 3 DATA 2 _____________________________________________ 3 BIT 2 4 DATA 3 ]} _____________________________________________ 4 BIT 3 5 DATA 4 ________________]}_____________________________ 5 POT B - - ______________________________________]}_______ 6 STRIG0 11 BUSY _____________________________________________ 7 ]} +5V * - - _____________________________________________ 8 0V 16 ]} GROUND _____________________________________________ 9 POT A - - _]}ave internal pull-up resistors less than about 3k on their data lines. The problem arises because each joystick line goes thrU}ough a series resistor inside the Atari console. These resistors are only a few hundred ohms, but they can stop the output siU}gnals going low enough to be recognised as 'logic 0' by the printer. Most printers use pull-up resistors of 3.3k or moU}re, and these should respond correctly. If you happen to be unlucky, it's easy enough to get round the problem by using our bU}uffer board (DBP10) to clean up the signals. Each data line is run through an AND gate, wired as a non-inverting buffer, and U}this gives an unambiguous logic 1 or logic 0 output. Fig 1 shows the PCB pattern, in case you want to etch your own, but a reU}ady etched and drilled board is available as usual from RH Design. Fig 2 shows how to construct the buffer and fit it into thU}e printer lead. You can dispense with the terminal blocks if you don't mind wiring directly to the PCB tracks, or using VeropU}ins. A software interface isn't as versatile as its expensive hardware counterpart, and it does have a few drawbacks. IU}t can't handle inverse characters, since they use the eighth bit which we have commandeered for the strobe line. This isn't aU} great problem, because most machines can't print inverse characters anyway, but ASCII codes 128 onwards are sometimes used fU}or italics, or other special typefaces, and you'll have to sacrifice that facility. For the same reason, this interface can'tV }____________________________________________ 1 BIT 4 6 DATA 5 ______________________]}_______________________ 2 BIT 5 7 DATA 6 ____________________________________________]}_ 3 BIT 6 8 DATA 7 _____________________________________________ 4 BIT]} 7 1 STROBE _____________________________________________ 5 POT B - ]} - _____________________________________________ 6 STRIG1 32 FAULT _______^}______________________________________ 7 +5V * - - _____________________________^}________________ 8 0V 33 GROUND _____________________________________________ ^} 9 POT A - - _____________________________________________ - - ^} 9 ** DATA 8 _____________________________________________ * Not used unless buffer board fitted ** Connect pe^}rmanently to ground at pin 306 4 2 122 2740Len Golding: Gadgets, Part IX2710636 182TABLE 1: CONNECTING THE J\0 4 1 5 0 16 74 2 0 1322740 Len Golding :Gadgets IX - Printer interface PARTS REQUIRED FOR PRINTER INTb}ERFACE 2 Joystick extension leads - available from larger Tandy stores, or most computer shops, price around #3.50 b}each. 1 36 way Centronics plug (solder type) eg Maplin FJ61R, price around #4.00. A ready built and tested cable asb}sembly is available, price #12.85 (inc. VAT and postage) from: R H Design 137 Stonefall Avenue b } Harrogate North Yorkshire Tel: 0423 880520 PARTS REQUIRED FOR BUFFER BOARD b } Maplin order code 2 74LS08 AND gate chips b } YF06G 2 14 pin DIL IC sockets BL18U 1 12 way PCB terminal block (optional) RK47R 1 8 way Pb }CB terminal block (optional) RK38R 1 suitable box, eg Vero 301 LL12NAll these parts, or equivalents, areb} handle graphic image data correctly. Also it won't work with commercial autoboot disk or cassette software, unless that softV}ware makes special provision for loading extra code. However, the simplicity and low cost of this gadget make it attraV}ctive despite its limitations. It will handle the majority of home programming tasks, so you may never need to buy a hardwareV} interface. Even if you are planning ultimately to get an 850 module, it's worth building this as a stopgap measure, and keepV}ing it as a backup system. Alternatively you can easily convert the lead for permanent use with an 850, by fitting a 15-pin DV}-type plug (the 850 manual shows how to wire it). This saves the cost of a new printer cable and leaves you with two joystickV} plugs which can be used for other gadgets.endsn Golding: Gadgets, Part IX2710636Page @ of 1110101010mfT505 ;Rl PROGRAM 1A: PRINTER INTERFACE - DISK VERSION 10 CR=$0D20 DOSINI=$0C30 EOL=$9B40 HATABS=$31A50 LOADADR=$1D006f}0 MEMLO=$2E770 PACTL=$D30280 PORTA=$D30090 STRIG0=$D0100100 *=LOADADR0110 ;0120 ;Header is added automatically on assef}mbly0130 ;Format is: 255,255,Load Address, end Address0140 ;0150 INIT0160 LDA DOSINI Force the original value0170 f}STA WARMST+1 held in DOSINI into the0180 LDA DOSINI+1 operand of JSR OLDINIT0190 STA WARMST+20200 JMP WMST20210 ;f}0220 WARMST0230 JSR OLDINIT0240 WMST20250 LDA #FINISH&255 Reset MEMLO to reserve0260 STA MEMLO a protected aref}a at0270 LDA #FINISH/256 the low end of RAM.0280 STA MEMLO+10290 LDA #WARMST&255 Change the value in0300 STA DOSINIf} DOSINI to ensure that0310 LDA #WARMST/256 SYSTEM RESET won't0320 STA DOSINI+1 destroy the interface.0330 LDf}A #NEWTAB&255 Change the printer handler0340 STA HATABS+1 address in HATABS, so0350 LDA #NEWTAB/256 that it points f}to our new0360 STA HATABS+2 handler table at NEWTAB.0370 OLDINIT0380 RTS0390 ;0400 NEWTAB0410 ;This table containf}s the addresses of our new handler routines0420 .WORD OPEN-10430 .WORD CLOSE-10440 .WORD GETBYTE-10450 .WORD PUTBYTE-f!} readily available from most suppliers. Cost should be around #1.60 without terminal blocks, or #3.20 with. 1 Printed cirb}cuit board (DBP10), available from RH Design, price 95p (plus 25p postage if not ordered with joystick cable assembb }ly)4 1 5 0 16 74 2 0 1322740 Len Golding :Gadgets IX - Printer interface PARTS REQUIRED FOR PRINTER INT`10460 .WORD GETSTAT-10470 .WORD SPECIAL-10480 ;0490 ;New handler routines start here0500 ;0510 OPEN0520 LDX #00530f"} PRTEST0540 LDA STRIG0 Check 'Busy' line0550 BEQ PROK If low, printer is connected0560 DEX If not,f#} try again up to 2560570 BNE PRTEST times and if still no joy0580 LDY #$8A generate error code 1380590 RTS f$} then abort.0600 PROK0610 LDX #$FF All joystick pins to be outputs0620 JMP PORTSET0630 ;0640 CLOSE0650 f%} LDX #$0 All joystick pins to be inputs0660 PORTSET0670 LDA #$38 Configure joystick ports0680 STA PACTL069f&}0 STX PORTA for input ($FF) or output ($00)0700 LDA #$3C0710 STA PACTL0720 LDA #$800730 STA PORTA0740 LDY #1 f'} Tell CIO all OK0750 RTS0760 ;0770 PUTBYTE0780 LDX STRIG0 Wait for 'Busy' to clear0790 BNE PUTBYTE0800 f(} CMP #EOL If character is Atari End-of-Line0810 BNE PB10820 LDA #CR change it to an Epson Carriage Return08f)}30 PB10840 ORA #$80 Make sure Strobe is high0850 STA PORTA Send character to joystick ports0860 JSR DELAY f*} Wait a few microseconds0870 AND #$7F Send Strobe low0880 STA PORTA0890 NOP for about 1 microsec090f+}0 ORA #$80 Then send it high again0910 STA PORTA0920 LDY #1 Tell CIO all OK0930 RTS0940 ;0950 ;The folf,}lowing functions are not implemented:0960 ;0970 GETBYTE0980 GETSTAT0990 SPECIAL1000 LDY #$92 Generate error code f-}1461010 DELAY1020 RTS1030 ;1040 FINISH1050 *=$2E01060 .WORD INIT Insert initialisation address0 LOADADR=$1D006dl05 ;PROGRAM 1B: PRINTER INTERFACE - CASSETTE VERSION10 CR=$0D20 DOSINI=$0C30 EOL=$9B40 HATABS=$31A50 MEMLO=$2E760 PACTj/}L=$D30265 70 PORTA=$D30080 SECTORS=FINISH-LOADADR+127/12890 LOADADR=$7000100 STRIG0=$D0100110 *=LOADADR0120 ;01j0}30 HEADER0140 .BYTE 0 Boot file format0150 .BYTE SECTORS0160 .WORD LOADADR0170 .WORD WARMST0180 ;0190 INIT0j1}200 LDA #$3C Stop cassette motor0210 STA PACTL0220 CLC Indicate successful boot0230 RTS0240 ;0250 Wj2}ARMST0260 LDA #FINISH&255 Reset MEMLO to reserve0270 STA MEMLO a protected area at0280 LDA #FINISH/256 the lowj3} end of RAM0290 STA MEMLO+10300 LDA #NEWTAB&255 Change the printer vector0310 STA HATABS+1 in HATABS so that it poj4}ints0320 LDA #NEWTAB/256 to our new list of handler0330 STA HATABS+2 routines at NEWTAB0340 RTS0350 ;0360 NEWTABj5}0370 ;This table contains the addresses of our new handler routines0380 .WORD OPEN-10390 .WORD CLOSE-10400 .WORD GETBYj6}TE-10410 .WORD PUTBYTE-10420 .WORD GETSTAT-10430 .WORD SPECIAL-10440 ;0450 ;New handler routines start here0460 ;04j7}70 OPEN0480 LDX #00490 PRTEST0500 LDA STRIG0 Check 'Busy' line0510 BEQ PROK If low, printer is connected052j8}0 DEX If not, try again up to 2560530 BNE PRTEST times and if still no joy0540 LDY #$8A generate erj9}ror code 1380550 RTS then abort.0560 PROK0570 LDX #$FF All joystick pins to be outputs0580 JMP PORTSEj:}T0590 ;0600 CLOSE0610 LDX #$00 All joystick pins to be inputs0620 PORTSET0630 LDA #$38 Configure joystickj;} ports0640 STA PACTL0650 STX PORTA for input ($FF) or output ($00)0660 LDA #$3C0670 STA PACTL0680 LDA #$80069j<}0 STA PORTA0700 LDY #1 Tell CIO all OK0710 RTS0720 ;0730 PUTBYTE0740 LDX STRIG0 Wait for 'Busy' to clearj=}0750 BNE PUTBYTE0760 CMP #EOL If character is Atari End-of-Line0770 BNE PB10780 LDA #CR change it to aj>}n Epson Carriage Return0790 PB10800 ORA #$80 Make sure Strobe is high0810 STA PORTA Send character with STROBj?}E low0820 JSR DELAY Wait a few microseconds0830 AND #$7F0840 STA PORTA Send Strobe low0850 NOP fj@}or about one microsecond0860 ORA #$80 then send Strobe high0870 STA PORTA0880 LDY #1 Tell CIO all OK0890jA} RTS0900 ;0910 ;The following functions are not implemented:0920 ;0930 GETBYTE0940 GETSTAT0950 SPECIAL0960 LDY #$92 jB} Generate error code 1460970 DELAY0980 RTS0990 FINISH=*0 DOSINI=$0C30 EOL=$9B40 HATABS=$31A50 MEMLO=$2E760 PACThARl QF55PROGRAM 2: PRINTER INTERFACE - DISK VERSION FFCreates an AUTORUNnD}.SYS file from the data which start at line 70..@@ D:AUTORUN.SYS6-(""6@nE}2*@ @@<ppLine 70 contains the header data (file type, load address, end address). 80 onwards contnF}ain the interface.F255,255,0,29,133,29PII165,12,141,14,29,165,13,141,15,29,76,16,29,32,44,29,169,134,141,231ZHH2,1nG}69,29,141,232,2,169,13,133,12,169,29,133,13,169,45,141,27,3,169dEE29,141,28,3,96,56,29,74,29,130,29,97,29,130,29,130,29,16nH}2,0,173nKK16,208,240,6,202,208,248,160,138,96,162,255,76,77,29,162,0,169,56,141xHH2,211,142,0,211,169,60,141,2,211,169,nI}128,141,0,211,160,1,96,174,16KK208,208,251,201,155,208,2,169,13,9,128,141,0,211,32,133,29,41,127,141GG0,211,234,9,128nJ},141,0,211,160,1,96,160,146,96,224,2,225,2,0,29,-1\\the last six bytes are a footer which stores the Run address into RUNnK}AD (736 and 737). D:GG9PRG2.BASRl QF55PROGRAM 2: PRINTER INTERFACE - DISK VERSION FFCreates an AUTORUNl'%:BFRl QF99PROGRAM 3: PRINTER INTERFACE - CASSETTE VERSION MMCrerM}ates an Autoboot cassette file from the data which start at line 160b$6-+F:A,&@$,$AVbreserve a safe arerN}a at the top of RAM as a temporary buffer]-@F")A6%- ]Load the Autoboot creator program inrO}to page 6(UULines 40 to 60 contain the program which will create an autoboot cassette file.2PP104,104,133,204,104,133,2rP}03,104,133,206,104,133,205,162,16,169,11,157,66,3<II165,203,157,68,3,165,204,157,69,3,165,205,157,72,3,165,206,157,73,3FrQ}32,86,228,96,67,58,155PKKLoad the interface program temporarily into the reserved buffer spaceZ6-#ArR}d""6@A0n# %6-%@# AxPPNow read the data from the temporary buffer into an AutorS}boot cassette file##@@A(C:))6-?:A6<159 then POTA=1590660 BCC HORZOK0670 LDA #1590680 HORZOK0690 STA HPOS S~}tore horizontal value0700 VERT0710 LDA POTB0720 SEC0730 SBC #400740 CHKTOP0750 BCS CHKBTM0760 LDA #00770 STA VP~}OS0780 BEQ CLEAR0790 CHKBTM0800 CMP VMAX0810 BCC VERTOK0820 LDA VMAX0830 VERTOK0840 STA VPOS Store vertical~} value0850 CLEAR0860 LDA VCPOS0870 CLC0880 ADC #50890 TAY0900 LDX #50910 LDA #00920 WIPE0930 STA (TEMP2),Y C~}lear old cursor image0940 DEY0950 DEX0960 BPL WIPE0970 CONVERT0980 LDA HPOS Convert screen co-ordinates0990 ~}CLC into corresponding1000 ADC #46 PM co-ordinates1010 STA HCPOS1020 STA HPOSP0 Set horizontal po~}sition1030 LDA VPOS1040 CLC1050 ADC #141060 STA VCPOS1070 TAY1080 LDX #ENDIMAGE-IMAGE-11090 DRAW1100 LDA IMAGE~},X1110 STA (TEMP2),Y1120 INY1130 DEX1140 BPL DRAW1150 LDA #01160 STA ENDFLAG1170 JMP XITVBL1180 IMAGE1190 .B~}YTE 32,32,248,32,321200 ENDIMAGE1210 HCPOS *=*+11220 VCPOS *=*+1 ENDFLAG=$6FC20 GRACTL=$D01D30 HPOS=$6FE40 HPOSP0=$D00|Dially to young children, and could be a useful introduction to learning keyboard skills. Anyone care to write a really good Pz}AINT-type program for it?ends2 114 2740Len Golding: Gadgets, Part X2710636Page @ of 1010101010mfx"