ebook img

Elektor 200001 PDF

51 Pages·3.3 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Elektor 200001

This article describes how to write PIC 16C84 assem- bler code programs using a compiler written for the Windows 95/98 platform. The PIC compiler allows programs to be written in a high-level language and it generates the necessary assembler code. The code can be modified, assem- bled or simulated using the (free) Microchip MPLAB software. By Roger Thomas compiler for PIC16C84 with code optimisation Compiler main features mer need not worry about the intrica- cies of assembler code programming. for PIC16C84 It can be educational for those learn- ing to program in assembler to see how easily understood high-level com- ➧Extensive manual (56 pages) on disk mands are translated into the equiva- lent PIC assembler code. ➧Three worked out examples on disk Assembler code output files pro- ➧Syntax similar to Visual BASIC and Pascal duced by the compiler contain both ➧Windows 95/98 compatible, no DLLs required the original high-level program (com- mented out) and the PIC assembler ➧Generates assembler code for Microchip MPLAB (freeware) code ready to be assembled (or simu- ➧Variables: Boolean, byte, word lated) by the Microchip MPLAB software ➧Arithmetic Operations: +, –, /, *, mod version 4.12 or later. Having both the source and assembler code helps in ➧Numeric Formats: decimal, hexadecimal, binary, char debugging the program. Writing in ➧Boolean Functions: =, >, <, >=, <=, <> compiled language does not preclude ➧Boolean Operators: AND, OR, XOR modifying or adding assembler code ➧Compiler Commands: if...then…else, select/case, while…loop, table, read, to the program when using the MPLAB software. MPLAB software is freely avail- write/read, EEPROM, procedure, directive, ASM directive, input, output, alias, able from Microchip’s web site at pin-name, RTTC, prescaler, wait, picfuse, http://www.microchip.com. ➧Equation Handler The cost (in programming terms) of using compiled code can be reduced ➧Code Optimiser speed of execution as the machine ➧Error messages code program may not be as efficient ➧Interrupt handling as a program written directly in assem- bler. With this PIC compiler this is not the There are considerable advantages in ments of Pascal and Visual BASIC. case, in most circumstances the using a compiler. The ability to write a Furthermore the compiler is flexible and assembler code produced is the fastest PIC program using English like com- allows for different program syntax. The code possible. There is very little com- mands is easier than programming compiler is written for the Windows envi- piler overhead on the assembler code directly in assembler language. Time ronment, which should make the soft- in terms of needing extra variables or taken to write and test software is usu- ware easy to use. As all the necessary increased number of assembler instruc- ally much less with a compiled lan- PIC codes are defined within the com- tions. The only additional program guage, and to prove the point the Win- piler program, no external setup or code required is support for the dows PIC compiler itself was written header files are needed. Boolean and arithmetic commands. using a compiler. The compiler produces assembler Arithmetic is either 8 bit (unsigned) or 16 The PIC compiler is not based on any code directly from the high-level bit (unsigned). The compiler requires one high-level language but has ele- source program, so that the program- several bytes for storing arithmetic 2 - 1/2000 Elektor Electronics EXTRA —————————————— PC TOPICS results, these are labelled _STACKxx in the output assembler file. The compiler makes two passes of the source program. The first pass creates a list of procedure declarations as the compiler may come across a call to a procedure before finding the proce- dure declaration. On the second pass the procedure calls are reconciled with the procedure declarations. Compiler syntax is not case sensitive but the MPLAB software can be, this option is selected in the project hex file. For this reason all the procedure names and variables appear in uppercase in the assembler output file. To allow the compiler to be used for any similar PIC microcontroller the com- piler does not impose any code restric- tions. This is left to the MPLAB assembler which will check program size and can more easily produce memory usage maps and cross-reference files. Figure 1. The Compiler window. Note that PIC pin functions can be seen at a glance. Using the compiler Use a text editor (such as Notepad, This file will be saved in the same direc- font - to change the font or font WordPad or the MPLAB editor) to create tory as the source file. This assembler size of the text displayed on the screen the high-level source program and output file will contain all the additional press the font button. A font dialogue save the text file with a .psf file exten- PIC code required as the compiler will box will appear, from which you sion (PIC Source File). Ensure that the automatically add any support routines. choose the required font and font size. saved file is text only and does not con- tain any embedded text formatting error - saves the error file as a text pins - will display the PIC pin information. file to the same directory as the source names and colour coded input or out- Unlike an assembler program that file. This file has the same file name but put port pins. requires a strict code column order with an ‘.ser’ (source error) file exten- (labels, mnemonics, operands, com- sion. It contains all the error messages display- if there are any compiler error ments), a high-level program freely (which includes the source line number) messages these are inserted into the uses spaces to indent the program. but not any of the source or assembler assembler output file, optionally the These spaces have no relevance to the code. compiler will stop and display a mes- program execution and are ignored by the compiler. Using spaces should Figure 2. Another example of the PIC Compiler in action. Here, a traffic lights program is make the reading and de-bugging the being written. Note the procedure names in the top right-hand window. program easier. User interface The Windows PIC compiler is very easy to use, apart from using load and save file the compiler does everything else! As shown in Figure1, the taskbar has a number of icons. load - press the load button and a directory dialog box will appear listing all the source (filenames.psf) files in the directory, select and load the relevant source file. The compiler will default to the directory that was last used. When the compiler is run for the first time the directory will be where the compiler program is located. save - after a successful compila- tion save the assembler source file (same file name but with filename.asm file extension) by pressing this button. PC TOPICS —————————————— Elektor Electronics EXTRA 3 - 1/2000 5V ; yellow = 0 ; turn yellow off BCF PORTB,YELLOW ; red = 1 ; turn on red BSF PORTB,RED 14 R1 D1 680Ω 4 6 MCLR RB0 green PIC interrupts 7 RB1 R2 D2 18 8 RA0 IC1 RB2 680Ω When an interrupt occurs the program 17 9 RA1 RB3 yellow counter is loaded with address loca- 1 PIC16C84 10 RA2 RB4 R3 D3 tion 4, this contains code to save the 2 11 RA3 RB5 680Ω program status and calls the interrupt 3 12 RA4 RB6 red handler procedure. After completion of 13 RB7 the interrupt handler code within pro- OSC1 OSC2 cedure(interrupt), the PIC executes a 16 X1 15 5 retfie instruction (return from interrupt). It is not necessary for the source pro- gram to re-enable global interrupts as C1 C2 4MHz the retfie instruction will do it automati- 33p 33p cally. The routine to handle interrupts must be called interrupt. 000012 - 13 The use of interrupts makes a PIC pro- gram more efficient as the alternative Figure 3. Traffic Lights demo hardware. is having to continually poll flags to see if a particular event has taken place. reading the various PIC status flags. There are four sources of interrupts that sage dialog box (default is to display For example, part of a traffic lights the PIC 16C84 interrupt handler soft- error message). On the first pass any output procedure is shown, the com- ware has to deal with: error messages will be displayed irre- piler will generate the following code: spective of this setting. 1. external interrupt on pin RB0; (Original source code fragment) 2. interrupt on change to pins RB4-RB7; source - selects whether the source green = 0 ; turn green off 3. RTCC timer overflow; lines should be included in the output yellow = 0 ; turn yellow off 4. assigned to EEPROM write complete. assembler file as comments (default is red = 1 ; turn on red to include source code). Source lines The EEPROM write interrupt is taken care that only contain a comment will ; code not optimised of by the writeEEPROM function. always be included. ; green = 0 ; turn green off To enable the interrupts use the MOVLWH’00’ irq_enable = truecommand. The indi- abort - stops the compilation BTFSS_STATUS,_Z vidual interrupt source must be process. BSF PORTB,GREEN selected before this command is BTFSC_STATUS,_Z invoked. Next to the eight buttons is a list of all BCF PORTB,GREEN To disable all interrupt use the the procedure names used in the pro- ; yellow = 0 ; turn yellow off irq_enable = falsecommand. gram. To find and display a particular MOVLWH’00’ This command acts globally using the procedure, select it from the list (the BTFSS_STATUS,_Z Global Interrupt Enable (GIE) flag irre- name will be briefly highlighted) by BSF PORTB,YELLOW spective of the individual interrupt clicking on the left mouse button. The BTFSC _STATUS,_Z being used. screen text should scroll and display BCF PORTB,YELLOW The interrupt handler procedure the relevant procedure (Figure2). ; red = 1 ; turn on red needs a few bytes for intermediate stor- The main procedure of the PIC pro- MOVLWH’01’ age, the interrupt routine has to have its gram is called ‘main’. Program execu- BTFSS_STATUS,_Z own variable storage as it cannot share tion will start at this procedure, it is BSF PORTB,RED storage with the rest of the program. called whenever the PIC is reset. The PIC BTFSC_STATUS,_Z As an interrupt can occur at any time it application program is generally held BCF PORTB,RED is possible that with 16-bit arithmetic this in a continuous loop after any initialisa- could happen half way through an tion is done, waiting for events to hap- With the code not optimised the com- arithmetic procedure. Assigning a 16- pen. It is extremely rare for a PIC pro- piler has calculated the equation after bit variable to another 16-bit variable gram to be required to run only once. the equals sign and sets the bit accord- requires multiple instructions to move ing to the equation result: zero or one. the value of the lower and then the Compiler code optimisation The optimiser looks at the code and higher byte. If an interrupt occurs half finds it has a constant value as it always way through the process then the vari- After the compiler has successfully has the same result and deletes the able may end up with the value of the compiled a segment of source pro- intermediate calculation. old value (lower byte) and the new gram, the code optimiser checks the value of the higher byte. For this reason assembler program for redundant ; code optimised the compiler will not allow 16-bit arith- code. Redundant code usually takes ; green = 0 ; turn green off metic in the interrupt handler proce- the form of unnecessary setting or BCF PORTB,GREEN dure. 4 - 1/2000 Elektor Electronics EXTRA —————————————— PC TOPICS If only one source of interrupts has red = 1 ; turn on red in Figure3please observe the PIC cur- been enabled then it is not necessary wait(3000) ; wait for 3 seconds rent limits. The maximum total current to look at the individual interrupt If you intend to build the circuit shown output on PortB is 100mA, any pin has enable flags. In general it is best to make the interrupt handler procedure Listing 1. Traffic Lights (1) Source program as small and execute as fast as possi- ble using simple equations. Note that ; Traffic Lights 1 other procedures cannot be called ; Written by Roger Thomas. from within the interrupt handler proce- dure. #compiler clock = 4000 ; 4MHz clock It is better to make a copy of any #ASM list p=16C84 variable that the interrupt handler may #FUSE CP_OFF + PWRTE_ON + WDT_OFF + XT_OSC use and use the copy. Referencing a variable that the interrupt handler var x : word ; create 16 bit variable var y : byte ; create 8 bit variable directly uses can have unforeseen results. For example, if x is changed by procedure(main) the interrupt handler then the following alias(RB3,red) ; rename port RB3 to red program might not function as alias(RB2,yellow) ; rename port RB2 to yellow intended. The value of x may have alias(RB1,green) ; rename port RB1 to green been altered after the first but before output(red) ; make ‘red’ port pin output the second comparison command, so output(yellow) ; make ‘yellow’ port pin output output(green) ; make ‘green’ port pin output no statements are executed. clr(red) ; turn off red = 0 clr(yellow) ; turn off yellow = 0 var x : byte clr(green) ; turn off green = 0 procedure(main) if x >=6 and x <= 10 then clr(x) ; initialise = 0 ; x = 4 clr(y) ; initialise = 0 begin while true statement inc(x) ; x = x + 1 end ; interrupt occurs here if x = 1500 then if x >= 0 and x <=5 then begin ; x changes to 6 inc(y) ; y = y + 1 begin clr(x) ; x = 0 statement end else end begin if (y >= 0) AND (y<= 49) then If a byte variable needs to be incre- begin mented or decremented or set to zero red = 1 ; turn on red within the interrupt handler then use yellow = 0 ; turn off yellow inc(x) or dec(x) or clr(x) statements as green = 0 ; turn off green these compile to a single assembler end instruction. if (y >= 50) AND (y<= 75) then begin Program examples red = 1 ; turn on red yellow = 1 ; turn on yellow To help demonstrate the advantages of green = 0 ; turn off green using the compiler and clarify the lan- end guage syntax, the documentation file if (y >= 76) AND (y<= 110) then contains some example programs to begin help illustrate the various compiler red = 0 ; turn off red commands. As these programs are for yellow = 0 ; turn off yellow didactic purposes, they do not neces- green = 1 ; turn on green sarily represent the best software solu- end tion. Note that some of the comment lines have been deleted and the if (y >= 111) AND (y<= 130) then begin assembler file tidied up for publication. red = 0 ; turn off red All variable labels that the compiler yellow = 1 ; turn on yellow generates are preceded by an under- green = 0 ; turn off green score to differentiate them from vari- end ables used in the source program. The easiest method of implementing if y = 131 then a traffic lights sequencewould be to begin clr(x) use the wait command after setting the clr(y) appropriate LED on or off. end end green = 0 ; turn green off loop yellow = 0 ; turn yellow off PC TOPICS —————————————— Elektor Electronics EXTRA 5 - 1/2000 ; 16C84 ; RA2 1 | i i | 18 RA1 ; while true ; RA3 2 | i i | 17 RA0 _WHILE0 ; RA4 3 | i i | 16 osc2 ; inc(x) ; x = x + 1 ; mclr 4 | i i | 15 osc1 INCF X,F ; Vss 5 | p p | 14 Vdd BTFSC _STATUS,_Z ; RB0 6 | i i | 13 RB7 INCF XH,F ; GREEN 7 | o i | 12 RB6 ; if x = 1500 then ; YELLOW 8 | o i | 11 RB5 _IF1 ; RED 9 | o i | 10 RB4 MOVF X,W MOVWF _STACK0 MOVF XH,W _PCL EQU H’02’ MOVWF _STACK1 _STATUSEQU H’03’ MOVLW H’FF’ _CEQU H’00’ MOVWF _STACK2 _ZEQU H’02’ MOVLW H’DC’ _RP0 EQU H’05’ SUBWF _STACK0,F PORTB EQU H’06’ BTFSS _STATUS,_Z _PCLATHEQU H’0A’ CLRF _STACK2 _INTCONEQU H’0B’ MOVLW H’05’ IRQ_ENABLE EQU H’07’ SUBWF _STACK1,F _STACK0EQU H’0C’ BTFSS _STATUS,_Z _STACK1EQU H’0D’ CLRF _STACK2 _STACK2EQU H’0E’ MOVF _STACK2,W _STACK3EQU H’0F’ MOVWF _STACK0 _STACK4EQU H’10’ MOVWF _STACK1 _STACK5EQU H’11’ BTFSC _STATUS,_Z _STACK6EQU H’12’ GOTO _ELSE1 _STACK7EQU H’13’ ; begin _STACK8EQU H’14’ ; inc(y) ; y = y + 1 _STACK9EQU H’15’ INCF Y,F X EQU H’16’ ; clr(x) ; x = 0 XHEQU H’17’ CLRF X Y EQU H’18’ CLRF XH RED EQU H’03’ ; end YELLOW EQU H’02’ ; else GREEN EQU H’01’ GOTO _END1 _ELSE1 ORG 0 ; begin ; if (y >= 0) AND (y<= 49) then goto MAIN _IF2 MOVF Y,W ; Traffic Lights 1 MOVWF _STACK0 ; Written by Roger Thomas. MOVLW H’00’ SUBWF _STACK0,W list p=16C84 CLRW __config H’3FF9’ BTFSC _STATUS,_C ADDLW H’FF’ ; var x : word ; create 16 bit variable MOVWF _STACK4 ; var y : byte ; create 8 bit variable MOVF Y,W SUBLW H’31’ MAIN CLRW ; alias(RB3,red) ; rename port RB3 to red BTFSC _STATUS,_C ; alias(RB2,yellow) ; rename port RB2 to yellow ADDLW H’FF’ ; alias(RB1,green) ; rename port RB1 to green ANDWF _STACK4,W ; output(red) ; make ‘red’ port pin output BTFSC _STATUS,_Z BSF _STATUS,_RP0 GOTO _ELSE2 BCF PORTB,RED ; begin ; output(yellow) ; make ‘yellow’ port pin out- ; red = 1 ; turn on red put BSF PORTB,RED BCF PORTB,YELLOW ; yellow = 0 ; turn off yellow ; output(green) ; make ‘green’ port pin output BCF PORTB,YELLOW BCF PORTB,GREEN ; green = 0 ; turn off green ; clr(red) ; turn off red = 0 BCF PORTB,GREEN BCF _STATUS,_RP0 ; end BCF PORTB,RED ; clr(yellow) ; turn off yellow = 0 ; if (y >= 50) AND (y<= 75) then BCF PORTB,YELLOW _ELSE2 ; clr(green) ; turn off green = 0 _IF3 BCF PORTB,GREEN MOVF Y,W MOVWF _STACK0 ; clr(x) ; initialise = 0 MOVLW H’32’ CLRF X SUBWF _STACK0,W CLRF XH CLRW ; clr(y) ; initialise = 0 BTFSC _STATUS,_C CLRF Y ADDLW H’FF’ 6 - 1/2000 Elektor Electronics EXTRA —————————————— PC TOPICS MOVWF _STACK4 MOVLW H’6F’ MOVF Y,W SUBWF _STACK0,W SUBLW H’4B’ CLRW CLRW BTFSC _STATUS,_C BTFSC _STATUS,_C ADDLW H’FF’ ADDLW H’FF’ MOVWF _STACK4 ANDWF _STACK4,W MOVF Y,W BTFSC _STATUS,_Z SUBLW H’82’ GOTO _ELSE3 CLRW ; begin BTFSC _STATUS,_C ; red = 1 ; turn on red ADDLW H’FF’ BSF PORTB,RED ANDWF _STACK4,W ; yellow = 1 ; turn on yellow BTFSC _STATUS,_Z BSF PORTB,YELLOW GOTO _ELSE5 ; green = 0 ; turn off green ; begin BCF PORTB,GREEN ; red = 0 ; turn off red ; end BCF PORTB,RED ; yellow = 1 ; turn on yellow ; if (y >= 76) AND (y<= 110) then BSF PORTB,YELLOW _ELSE3 ; green = 0 ; turn off green _IF4 BCF PORTB,GREEN MOVF Y,W ; end MOVWF _STACK0 MOVLW H’4C’ ; if y = 131 then SUBWF _STACK0,W _ELSE5 CLRW _IF6 BTFSC _STATUS,_C MOVF Y,W ADDLW H’FF’ SUBLW H’83’ MOVWF _STACK4 MOVLW H’00’ MOVF Y,W BTFSC _STATUS,_Z SUBLW H’6E’ ADDLW H’FF’ CLRW ANDLW H’FF’ BTFSC _STATUS,_C BTFSC _STATUS,_Z ADDLW H’FF’ GOTO _ELSE6 ANDWF _STACK4,W ; begin BTFSC _STATUS,_Z ; clr(x) GOTO _ELSE4 CLRF X ; begin CLRF XH ; red = 0 ; turn off red ; clr(y) BCF PORTB,RED CLRF Y ; yellow = 0 ; turn off yellow ; end BCF PORTB,YELLOW ; end ; green = 1 ; turn on green _ELSE6 BSF PORTB,GREEN _END1 ; end ; loop GOTO _WHILE0 ; if (y >= 111) AND (y<= 130) then _ELSE4 END _IF5 MOVF Y,W MOVWF _STACK0 Listing 2. Traffic Lights (1) Assembler program a absolute maximum current output of required by the compiler but help doc- found on diskette no. 996033-1which 20 mA. Incorporate an appropriate ument the program. The resulting may be ordered through our Readers current limiting resistor (R) in series with assembly-code file is shown in Listing2. Services. The disk also contains the the LED (in the range 470 Ω to 1 kΩ Other programming examples found in example source code files (.psf) and, of depending on the LED). Here, 680Ωis the documentation file are Traffic Lights course, the Compiler itself (Com- suggested. (2)and LCD Display Driver. The source piler84.EXE). The readme.txt file explains The example program will continue to code and assembly-code listings of the extremely simple installation. execute until the supply voltage is these programs may be found in the (000012-1) removed from the PIC. documentation file. Article editing:Jan Buiting The source code of the program is shown in Listing 1. The ‘x’ variable is Syntax and incremented on each loop of the pro- command descriptions gram. After reaching a certain number it then increments the ‘y’ variable. This A full description of all available com- is needed to slow the program down — mands and the syntax the Compiler if the ‘x’ variable was used directly the wants to see may be found in the 56- lights would switch too fast. The brack- page project documentation file. This ets separating the ‘y’ conditions are not file, an MS Word document, may be PC TOPICS —————————————— Elektor Electronics EXTRA 7 - 1/2000 This experimental circuit board was designed and built as a development aid for those constructors who wish to design their own parallel printer add-on boards. The author used the prototype board whilst experimenting with digital to analogue converters (DACs) and liquid crystal displays (LCDs) amongst other things. Hardware design & software: Adrian Grace LPT exerciser gateway to the PC parallel port The board of which the circuit diagram is shown in Figure 1, connects to the standard 25 way ‘D’ connector of the R5 D5 D0 computer’s parallel port via a 25 way 1k8 K1 R6 ribbon cable, and is terminated on the D6 D1 26 25 1k8 circuit board with a transition connec- 24 23 R7 D7 D2 tor (see the relevant construction notes). 22 21 1k8 The design itself comprises of three cir- 20 19 R8 D8 D3 18 17 1k8 cuits — one for each of the registers 16 15 R9 (DATA register, STATUS register and CON- D9 D4 14 13 1k8 TROL register) associated with the par- 12 11 R10 D10 D5 allel printer port. 10 9 1k8 8 7 R11 R1 R2 R3 R4 D11 D6 Registers 1k8 1k8 1k8 1k8 246 135 0kR170kR180kR150kR140kR13 R1112kk88 D12 D7 1 1 1 1 1 First, a quick word about the registers. DATA REGISTER The DATA register is an 8 bit output latch which is normally used to transfer data E trcpoeor aintmhdteepa rubp tlerfeionr rtt ieoner p.‘r mruTohtosre n amSitTonAedrT’s U stiahSs e grue essgtsea isdtetue tsbcr o.hy f a Tttshhh eee5 STROBE AUTOFEED INITIALISE SELECT-IN BUSY1ACKNOWLEDG0 9PAPER OUT8SELECT7ERROR6 CONTROL register has 4 outputs, and is D1 D2 D3 D4 S1 normally used to control the function- ality of the printer. 1 2 3 4 5 Data register CONTROL REGISTER STATUS REGISTER 002002 - 11 The 8 outputs of the data register are Figure 1. Circuit diagram of the LPT board. connected to 8 LED’s (D5-D12) via cur- rent limiting resistors (R5-R12). The LEDs themselves are 5mm wide by 2mm thick and fit comfortably into the tradi- The switch contacts are pulled up via Control register tional 2.54mm grid pattern. resistors (R13-R17) and their status can The control register is 4 bits wide — be read providing the SELECT IN, bit D3 lower nibble. Each output is connected Status register of the control register is at a logic high. to an LED via a current limiting resistor The status register has 5 inputs which This allows the board to become self in a similar manner to the data register are simulated via a DIL switch. The powered — i.e. batteries not required. outputs. Indeed, the LEDs should have inputs are as follows: the same packaging but preferably a different colour. The function of each bit D7 D6 D5 D4 D3 D2 D1 D0 is shown below: Busy Acknowledge Paper out Select Error Unused Unused Unused 8 - 1/2000 Elektor EXTRA ———————————————————— PC-PLUS R1 D1 strobe R2 D2 autofeed R3 D3 initialise R4 D4 select in R5 D5 bit 0 R6 D6 bit 1 R7 D7 bit 2 R8 D8 bit 3 R9 D9 bit 4 1-200200 002002-1 R10 D10 bit 5 ROTKELE )C( (C) ELEKTOR R11 D11 bit 6 R12 D12 bit 7 LK R13 error R14 select LK1 RR1156 W1 apcakper out J1 R17 S busy Figure 2. PCB artwork designed by the author. D7 D6 D5 D4 D3 D2 D1 D0 COMPONENT LIST Unused Unused Direction IRQ Select In Initialise Autofeed Strobe D1-D4 =5mm x 2mm LED, high efficiency, green LED D4 has a dual purpose, when it is J1 can now be soldered onto the cir- D5-D12 =5mm x 2mm LED, high energised it provides power to allow cuit board. efficiency, red the switch positions connected to the R1-R12 = 1kΩ8, 0.25W status register to be read. Software R13-R17 = 10kΩ, 0.25W The upper nibble of the control register SW1 = 5-way DIL switch contains some control bits which are The software associated with this design J1 = 26-way TRANSITION connector, not addressed in this design. is available on the above mentioned plus strain relief clip. diskette with order code 006002-1. It J2 = 25 way MALE IDC ribbon connector Construction has been written in ‘C’ and is suitable 26 way ribbon cable, cut to length with for running under DOS. As you can see one ‘way’ removed. The Ultiboard design files of the PCB in Figure 3, the program itself (exe- designed by the author for this project cutable file) is menu-driven. The pro- may be found on diskette 006002-1 gram will first of all interrogate the com- object file as well as the executable which is available through the Elektor puter’s BIOS to establish the printer port file. The source code is highly com- ElectronicsReaders Services. Popula- address and display it on screen. At mented and you are at liberty to exper- tion of the board is straightforward, see present, the program will only look for iment with it — that’s how I learnt how Figure2. Fit all components on the cir- the first port LPT1. to write it. cuit board except for J1. Don’t forget The main menu displays three options, If you intend to go on and experi- the link. J2 can be fitted to the ribbon one for each register and an exit path. ment further with your own designs con- cable at this point — after the extra The first option is for the STATUS regis- nected to the parallel port, it is ‘way’ has been removed, of course, as ter. With this option, Select In is auto- strongly suggested that you obtain a a 26-way ribbon cable won’t go into a matically actuated, allowing the switch ‘cheap’ secondary LPT port board. 25-way connector! The coloured positions to be read. The hex value of This will prevent you from damaging leader stripe on the ribbon cable the switches is displayed on screen until your main parallel port, which is usually (which identifies pin 1) should be a key is pressed on the keyboard. integrated into the motherboard. Dam- aligned with pin 1 on J2. The second option is for the DATA aging your motherboard is not a good Now comes the fun bit. Lay the cir- register. When selected, a second sub- idea! cuit board in front of you so that the menu is displayed along with the pre- (002002-1) position of J1 is furthest away from you. sent value of the data register. The sub- Technical editing: Karel Walraven Lay the ribbon cable over the top of menu allows the user to shift bits left or Article editing: Jan Buiting the circuit board so that the free end of right and increment or the ribbon cable is at the J1 position. decrement the register val- The ribbon cable should be orientated ues. The register value is writ- so that the leader stripe is on the right ten out to the parallel port hand side. OK so far? Slide the ribbon so the bit patterns can be cable into the transition connector J1, viewed on the LEDs. so that there is an empty space on the The third option is for the right hand side, and the left-hand side CONTROL register. This fits snugly against the edge of the con- option just cycles a moving nector. J1 can now be squeezed onto LED up and down the four the ribbon cable – make sure that it is LEDs associated with the fitted squarely. This is easy to do if you control register — until a key use a couple of pieces of scrap ‘ver- is pressed as before. oboard’ on top of each other to pro- Diskette 006002-1 con- tect the pins of J1. Finally flip the ribbon tains the original source Figure 3. Screen dump showing some of the options cable over and fit the strain relief clip. code and the intermediate offered by the program. PC-PLUS ——————————————————— Elektor EXTRA 9 - 1/2000 Presently, data transfers between the PC and printers, scanners, fax machines and modems, as well as communication between a laptop and a cellular phone, still require inconvenient cable interconnections and the time-consuming installation of drivers. Wouldn’t it be nice if all your data-processing devices could indepen- dently converse with each other, with no need for cables or driver installation? This is now possible, thanks to Bluetooth, a short-range radio system that renders cables redundant and which should allow new applications to be developed. By G. Kleine Bluetooth 2.4-GHz data radio instead of computer cables geted unit price, given large-scale mass production (more than one million pieces), is less than five dollars. Frequencies When the BSIG was looking for licence- exempt frequency bands that are avail- able worldwide, it came across the Industrial, Scientific and Medical (ISM) bands. These frequency bands may be used without any licence or fee for industrial, scientific and medical equipment with a limited radiated power. In addition to the available ISM bands listed in Table1, there are other ISM bands at 5.8 GHz, 24.25 GHz and 122.5 GHz, but these cannot be utilized at a rea- sonable cost at the present time. Since the possibility of interfer- ence from other unlicensed users of the ISM bands must always be taken Presently, more into account, and given that Bluetooth than 1100 firms are members of the should have a data transfer rate of Bluetooth Special Interest Group (BSIG) around 1Mb/s, the only suitable choice Nokia Mobile Phones, Ericsson (see the box ‘King Bluetooth and his is the 2.4-GHz ISM band (2400 to Mobile Communications, IBM, Intel and friends’). They include not only all lead- 2483 MHz). This band is 83 MHz wide Toshiba recognized the potential of this ing computer and communications and thus provides enough room to technology and founded the Bluetooth technology firms, but also automobile avoid interfering signals coming from Special Interest Group (BSIG) [1,2]in May and aeroplane manufacturers and equipment that uses a particular fre- of 1998. Its objective is to define a uni- representatives of the entertainment quency, such as a microwave oven. versal standard for radio data communi- industry. The BSIG presented the provi- This frequency band is available world- cation between data-processing equip- sional version of the Bluetooth 1.0 spec- wide, although its extent is somewhat ment. In the beginning, the main area of ification in the autumn of 1999. It has reduced in Japan (2471 to 2497MHz), interest was data transfers between cel- been made publicly available on the France and Spain. lular phones and peripheral equipment, Internet [2], in order to promote the In order to avoid problems with antici- in order to eliminate annoying and incon- establishment of the Bluetooth system. pated interference signals, most of venient cables. Later, the area of interest This extensive specification fills more which have fixed frequencies, Bluetooth was extended to include other applica- than 1500 pages. The primary objec- makes use of spread-spectrum tech- tions, ranging from wireless connections tive of the Bluetooth project is the niques. This means that the frequency between PCs and laptops and their development of extremely inexpensive, is changed rapidly (up to 1600 times peripheral equipment to the ad-hoc con- compact modules that can be built per second) in a pseudo-random man- figuration of wireless networks. into a variety of equipment. The tar- ner, with the result that enough interfer- 10 - 1/2000 Elektor Electronics EXTRA —————————————— PC TOPICS

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.