Tuesday, February 1, 2011

Tiling Backsplash How To Extend Outlets

An eight-channel controller card 2 Kbit chip with PC interface A Geiger counter

Have you ever heard of virtual money? Yes, of course. It is this map that you have been given to your tennis club, against hard cash, which you can open the door of your room price or shower. You can also use the bar or restaurant in the club until you are asked a small settlement for charging. The project described in these lines is a system with an RS232-C interface for configuration and playing cards 2 Kbit chip. He found employment in the initialization and reloading of credit or access units on cards to be used in automatic equipment made available to authorized viewers such as, electronic purse,
beverage vending machine, access control, holiday villages, campsites, hotels, etc..
Possible uses are endless!


These first months of implementation of the Euro cause much of a hassle for those who must now travel with a pocket calculator because of the double labeling of prices and concerns that conversion entails.
Consumers and traders, as such, housed in the same boat.
Under these conditions, talk of money or payment systems, can pass for a kind of provocation, "as if the chaos sown by the television was not enough, we now are getting into the magazines! .
However, for those who manage distribution points automatically turned to the general public, this may be a good opportunity to, not from the Franc to the euro, but systems that use the cash payment to those who operate credit or prepayment.

Why?
Simply because the use of rechargeable magnetic cards eliminates the need to travel with cash in hand, to remain "Beak in the water" because it lacks some Francs to pay a particular purchase, or spend time at the bank or find a distributor to withdraw cash.
Moreover, in this transitional phase towards European unification, these smart cards can avoid making any conversion price to find out how many Euros or how Franks would have to pay for individual purchase.
This type of smart card is a solution to all these concerns which obsess us, not so young, whose head is full of numbers and calculations and diverse to be convinced there has to see the ease with which they are familiar with the computer, but rather the generation most "mature" used to calculate the money she managed to put aside each month from his salary.

Chip 2 Kbit


The programmer / reader in this article is dedicated to the smart card chip Siemens SLE4442 equipped with a capacity of 2 Kbits. In this capacity used for data (main memory) plus two other small areas of memory that can be also other levels of protection.
The 2048 bits are divided into cells (byte) 8 bits or 256 zones which are the first 32 memory protection. This can be write protected byte by byte, simply by selecting or clearing the corresponding bit of memory protection.
This area is a PROM. Therefore, when one of its 32-bit is written, no changes on this bit is no longer possible. At each of the 32 bits of memory protection is one of the first 32 bytes of main memory.
It is therefore clear that the protection is permanent if it protects one of the first 32 bytes. Thus, once the data has been entered and that the bit of the corresponding memory protection has been set to logical 0, one can neither erase or write new ones. That is the first level of protection as regards the bytes from 0 to 31.
Circuit SLE4442 can also perform a write protection bytes 32 to 255, simply by logic (logic of security) that requires the input of a code to modify one or more areas.
Note however that there is a significant difference between the two protections. Once protected, the first part of the main memory becomes a PROM, which prevents any rewriting. Of course the configuration is done byte by byte. By cons, between the 32nd and the 255th byte, the protection is only effective if writing is influenced by the introduction of a code, said PSC (Programmable Security Code), also programmable, and located in the memory security is itself part of the security logic cited earlier.
For these protections, we use 4 bytes of which 3 are the PSC and 1 byte for the error count, a total of 32 bits in all. Moreover, it is clear that the main memory can always be read without any additional operation. To change the content, must agree with the logic of protection. This agreement may be obtained by comparing the SGP, or by sending the card a 3-byte code that is then compared to the code in the security memory. If the two codes are identical, we obtain access to writing, as the card is powered.
In each comparison, the error count of the 4 sets a bit to zero. Since the other 3 bits are high (1) it is obvious that the error count goes to zero after three attempts. If this happens, it is no longer able to write to the card. So the first thing to do after a comparison of the SGP is to restore the error count by postponing all its bits to 1.
Finally, about the security memory, it goes without saying that the byte allocation counter 00 is the error itself.
This area can still be read but also written with the understanding that the act of writing is equivalent to 0 to bring a bit which was previously at logic 1. By reducing the value is reduced thus attempts remaining. By cons, for recovery, it is necessary to pass comparison to validate the CSP. In this connection, we recall that the latter is stored in areas 01, 02, 03 which may also be modified only after a comparison with the positive result of the same programmable security code.

Figure 1: Functions of the chip Siemens SLE4442.

Figure 2: Schematic diagram of the chip Siemens SLE4442.

system
Let us therefore know a system whose applications are numerous, since it can perform recognition and reloading a smart card 2 Kbit directly from our personal computer. It's sort of a circuit for reading / writing credits, which can be connected to a serial RS232-C. This circuit works with a small program in Qbasic under MS-DOS, Windows 3.x or Windows 95, 98 and NT.
This project, with multiple uses as we have already said, is particularly suitable for automatic payment on credit, vending machines, turnstiles for access to the stands, but also to libraries, cinemas, gymnasiums, lunchrooms, etc.. Its main advantage is to be used as a main unit for management from an office or from the headquarters of the company that manages services.
By integrating the program in QBasic in a custom program, it is also possible for an employee to know, for example, the status of a smart card deemed defective by a customer, to know the remaining credit or to proceed with charging or assigning a new card.
This system is of course able to perform all related operations a bit laborious.
On an order of computer, an output relay is activated for a period that can be programmed in advance. This relay can be used to activate vending machines, various electromechanical devices, or to simulate the introduction of coins in machines originally designed to operate with coins.
circuit, and has multiple functions, can work either as a token reader but is also able to plan and charge a credit card.



study the wiring diagram
After this necessary introduction, we watch how structured the circuit, thanks to the wiring diagram.
As can be noted that the device uses only three ICs.
We find a microcontroller, PIC16C56 type programmed with generic serial communication routines, as well as another routine to convert strings of 8 bit data, timed appropriately.
The microcontroller interprets commands from the PC, and the responses of the smart card. The integrated circuit U2 (MAX232) provides processing logic levels + or -5 volt TTL level RS232-C + or -10 volts when the timer U5, activated by the microphone is used to determine the time during which the output relays should remain stuck.
The circuit power 12 to 15 volts DC is applied to the points + V and-V (respectively positive and negative). Voltage after the protection diode D1, feeds directly into the coil of relay RL1 and the circuit of the smart card reader. Note also the presence of a classic 7805 integrated controller (U1), which can provide the 5 volts needed for the proper operation of logic circuits U2, U3 and U5.
U4, meanwhile, is used to provide the +5 V to the IC card once it is introduced in the drive and until it is withdrawn. U4 is supplied by the transistor T3 led by the special touch of the reader, that is, without a map, normally closed (opening allows the saturation of T3 feeding the regulator U4).

Figure 3: Diagram of the programming interface smart card.

Figure 4: Implementation Plan components of the interface.

Figure 5: PCB scale 1 / 1 on the deck of player / recorder.

List components
R1: 15 kΩ
R2: 47 kilohm
R3: 47 kilohm
R4: Trimmer 470 kΩ
miniature
R5 R6 4.7 kΩ
: 47 kilohm
A7: 47 kilohm
R8: 470 Ω R9
: 470 Ω
R10: R11 10 kilohms
: 10 kilohms
R12: 33 kΩ
R13: 33 kΩ R14
: 10 kilohms
R15: 47 Ω
R16: 1 kilohm
R17: 1 kilohm
R18: 1 kilohm
C1: 100 nF multilayer
C2: 220 uF 25 V electrolytic rad.
C3: 100 nF multilayer
C4: 47 uF 25 V electrolytic rad.
C5: 10 uF 25 V electrolytic rad.
C6: 22 pF ceramic
C7: 22 pF ceramic
C8: 10 uF 25 V electrolytic rad.
C9: 10 uF 25 V electrolytic rad.
C10: 10 uF 25 V electrolytic rad.
C11: 10 uF 25 V electrolytic rad.
C12: 100 nF multilayer
C13: 470 uF 25 V electrolytic rad.
D1 Diode 1N4004
D2 Diode 1N4148
D3 Diode 1N4004
LD1: LED 5 mm green
LD2: 5mm Red LED RL1
: Relay 12 V min. 1 contact
U1: LM7805 regulator
U2: U3
MAX232 integrated circuit: Microcontroller PIC16HS56 (MF269)
U4: U5
78L05 Regulator: integrated circuit NE555
T1: BC547B NPN Transistor
T2: BC547B NPN Transistor
T3: BC557B PNP Transistor
Q1: Quartz 8 MHz

Miscellaneous:
- Terminal 2 poles
- 3-pole
- Support This 4 + 4 pin
- Support this 8 + 8-pin
- Support this
9 + 9-pin connector - D-Sub 9 pin female
- 5 + 5-pin connector
- PCB ref. S269
Unless otherwise noted, all resistors are 1 / 4 W 5%.

The assembly of our prototype completed
The magnetic card has a PCB connector 10-pin HE10 type 2 x 5 pin which we must connect the interface card with a suitable ribbon cable. The circuit also has a female DB9 connector to allow connection to the serial port of the computer, screw terminals for 3-pole relay contacts and a screw terminal with two poles for the diet. As we can see, the system has only three integrated circuits: the microcontroller, which is vested in the work of converting the commands from the PC to control the card and the response of the smart card in ASCII characters, a MAX232 for convert TTL levels to RS232 levels and vice versa, and the NE555 timer, controlled by the microcontroller to determine the bonding time of the relay.


Figure 6: Implementation Plan of the card reader / writer.

Figure 7: PCB scale 1 / 1 of the plate interface PC-lecteur/enregistreur.

The card reader / writer of our prototype
Virtually any component but special care to mount the drive / recorder.


Iist
- Player / Recorder AMPHENOL
- 5 + 5-pin connector
- Flat cable 10 conductors
- PCB ref. S237


Our program is completed on two separate circuit boards. One is all the electronics, the other, only the reader / writer smart card Amphenol 10 pin connector and ribbon cable for connecting interface-lecteur/enregistreur.

What happens in the system
We said our system is a reader / writer smart card that reads, of course, but also to write the usage data entered from the keyboard of the computer.
This is done through routine in Qbasic, which serves as a general rule, treat all possible operations such scripture reading, use of memory protection, replacing the CAS, etc..
More than a long description, we suggest you refer to the command window that can be visualized by running the small program 2KBIT.BAS and where you will find a list of all the functions it can perform . Remember that some of these functions require the comparison of "programmable security code. So make sure the correct code, because after 3 failed attempts the smart card becomes unusable.
Note that if you do not pass through the comparison mentioned above, the program displays random data. For example, if one wishes to change the state of memory, it will then go through the PSC but without compare. The operation appeared to be normal but does not lead properly. Indeed, if we control the situation immediately after, no area seems to have changed.
It goes without saying that our system must necessarily use the smart card 2 Kbit based on the circuit SLE4442 Siemens, already configured with a PSC to FFFFFF.
Do not use other compatible cards, but provided a different program within Security Code to ignore. In this case, the program we have developed running comparisons without warning and, thus, after three unsuccessful attempts, the smart card becomes permanently unusable.
Furthermore, remember that for every comparison of the SGP, it must first zero the error count otherwise, even if the transaction was completed after 3 attempts the card is lost. The latter operation is performed automatically by the program.

Here is the screenshot Our management program Smart Card 2 Kbit. The software is made in QBasic and manages the 3 memory areas used in the chip.

From the interface to drive
Turning to the analysis of the device from the interface and going to the smart card reader and communications lines. For this binding we used lines RB2, RB4 RB6 and the microcontroller U3. These connections correspond to pins 8, 10 and 12. We can manage the channel input / output data. The clock signals and reset are directly connected to the contacts of the drive that are connected on points 1-8 of the printed circuit, and easily identifiable by their markings Memory Card (memory card, smart card) in fig.
Regarding the clock signal, it is from the pin 10 and is generated within the PIC16C56 by an internal programmable timer. This signal is used to the sunsetting of the read / write.
Pin 12 is also used as an output, and generates reset pulses on the order of the program, or even based on instructions from the computer.
Finally, pin 8 is initialized as input / output open collector. As such, it has the resistance R11 pull-up (for maintaining a high level) and is, of course, serial data line to download and read the information in memory. All levels are TTL.
management program of the microcontroller is designed so it can recognize the state of NC in the presence of the magnetic card into the reader. At rest, points 1 and 2 are closed and, therefore, the base / emitter junction of PNP transistor is blocked, the collector is at logic zero.
When inserting a smart card, the contact opens and the transistor, whose base is supplied by the resistor R14, is saturated, the supply voltage of 12 volts joined the R12/R13 voltage divider that allows to cut it to 4 or 5 volts. The pin 18 of U3 receives a level 1, and the microcontroller executes the operations may be required by the serial port.
It is clear that if nothing is controlled from the control panel Qbasic program on the PC, the card remains idle and waits for the arrival PIC16C56 Data channel RX (pin 6).
sure that the transistor T3 feeds well pin 18 of microcontroller and onboard regulator U4 which is a 78L05. Thanks to the protection resistor R15, this regulator provides the 5 volts at point 3 to power the logic circuits of the card inserted in the drive. For his part, R15 avoids short circuits or damage caused either by mistake by the introduction of a smart card not compatible, either by the presence of contacts that the provision would be different.
Timer, a classic NE555 designated U5, serves to provide a time delay relay RL1. Its input (pin 2) is controlled through a transistor that acts as an inverter for the signal from pin 13 of microcontroller designated, for its part, as an output.
When the order comes from the computer (T = relay activation), the LoC RB7 goes high, the collector of Q2 goes to zero volts for a short time and thus provides a low level to the U5 pin 2 connected as monostable.
The latter is triggered and sets its own output, pin 3, at 1 during the delay determined by R3, R4 and C4. This period will also be determined by the formula t = (R3 + R4) x C4 which is in seconds if the resistors are in ohm, and capacitor mF (1 millifarad = 1000 microfarads).
The activation time relay can range from 2 seconds (potentiometer fully closed) to 25 seconds (control maximum).
Finally, pin 17 of the PIC16C56 controls two LEDs, one green and one red. The first, LD2, illuminates when the pin is at logic high, while the second, LD1 will turn on the logic level zero. Usually, the state of the two levels depends on the data from the computer, since the card is limited to managing the connection of the smart card and interface with the PC.

View of the prototype card programmer smart interface and player / recorder.



program in QBasic
Now to the description of the BASIC program 2KBIT.BAS available under MS-DOS or Windows 3x1, 95/98 and NT.
After launched, the program shows an input window (Control Program for Smart Cards 2 Kbit, Futura Elettronica ...) and asks "press any key to continue". After that, the control panel appears, and we find a list of all transactions executable with a summary of their functions. A letter is assigned to each of these operations.

The program listing
You will find the following pages, listing the full program 2KBIT.BAS to write using the MS-DOS Editor. Copy line by line, instructions, and check carefully and eliminate any syntax errors or spelling.
Finally, you must register the program (File, Save As ...) with an appropriate name, for example, 2KBIT.BAS.
Note that by default the program uses COM2, because usually the COM1 is used by the mouse. However, if for various reasons, COM2 is occupied (or internal modem other devices) you must not use it for our application. In this case, you must redirect your devices to the leave available, or, and this is still the simplest change in our program, line 30.
To do this, simply change com1 to com2, com3 or COM4. Do not change any other parameter in the serial.
If you type the entire program discourage you, it is available on diskette, ref. SFW269.

Let them in order
Pressing "A", the screen displays "Response to Reset" and "Manufacturer Code" which is the production code the magnetic card, readable without any protection procedure.
The "B" can be read one byte of main memory (256 bytes). The computer requests entry address in hexadecimal format between 00 and FF. 0A
example is the address of the zone 10.
The screen display shows the value as two hexadecimal digits that sum up the 8-bit byte requested. With 8-bit code can have from 0 to 255 with hexadecimal digits.
Therefore if we take FF, which corresponds to byte 255, the content is also of type 11111111.
With the command " C "can be read more bytes from the specified area.
On screen he is asked to enter one after the other, the starting area and the amount of bytes to be displayed, of course under the usual hexadecimal. For example, if one wishes to know the status of 4 bytes starting with the one whose address is 0A, you type 0A04. The first two characters are the address, the other two are the number of bytes requested, that is to say 4 in our example.
With the letter "D", you reach a complete reading of the memory Main (Main Memory Dump) from 00 to FF.
The screen shows a few lines containing, in the upper left to lower right, all the bytes, always in hexadecimal. Note that to better identify each portion, the numbers are displayed in color pairs.
These are all, 2 x 256 pairs of hexadecimal type 00 0D 0F FF that should appear on the screen.
command "E" can write a number of bytes in main memory. A screen is then asked to indicate the starting address and the amount of application areas. To do this, remember that the format is always two hexadecimal digits for the address, and two figures for the number of bytes. In addition, forget, the writing is up to carry all the bits to logical 0. For example if you want to run E from the address 00 for 1 byte, 8 bits correspondents become 00000000. One can easily verify if the results are read by "C", specifying 00 as the start and 01 as number of bytes to read. But the most important thing is to remember that the operation "E" is one of those calling for the introduction and comparison of the security code programmable (CHP) under penalty of hindering the launch of the "J". For, although the program authorizes the transaction actually writing does not occur. This applies to all operations that require an operation of the SGP.
The letter "F" authorizes the Dump (listing) of the memory protection, which allows to view the content, it's PROM 32 bits (one for each byte of main memory), and that specifies which bytes must be permanently write protected. Reading visible on the computer screen, is presented in hexadecimal composed of 4 groups. Each of them, from 00 to FF, summarizes the value of a block of 8 bits.
Knowing the state of the memory protection, allows to know which areas (bytes) of main memory, one of 32 bytes may be protected, have already been configured as read-only address.
This is very useful to know, for example, why we can not write any of the cells, or when it is impossible to identify any damage on a smart card.
Now for the letter "G" with which it is possible to write 1 bit in memory protection.
screen calls for the introduction to his address in hexadecimal format, still in double digits. Then, after you have confirmed with ENTER, the computer sends the order to plug the programming / reading or in memory of the smart card. Rappelezvous that once you wrote any of the information, you can not cancel it.
Therefore, the corresponding byte to the memory of security among the first 32 bits of main memory is, at this moment, just read only.
Take all necessary precautions Before you use the button "G".
key "H" is used to determine the status of the security memory. Just after starting this command, the screen shows the situation in hexadecimal format into 4 groups of 2 digits. Of these the first 3 right demioctet represent all 8 bits (eg. 00,001,111 10,101,010) containing the SGP. Typically
FF FF FF Smart Card advocated. In practice, each group expresses FF 8 digit binary format 00000000. The fourth from the left is actually the bit error counter. However, we observe that it serves only bit low weight. In fact, the error count is actually 3 bits. Thus, it can go around in a nibble of 4 bits and be made from a position hexadecimal.
The most significant is unused cons. Ensure that a reading of the Security Memory Type 07 FF FF FF indicates that CCS is the FF FF FF, while the error count is reset to dispose of three possible tests. 07 expresses, in turn, the binary number 0000 0111, and therefore, the 3 bits of the counter are high. After an initial comparison, the situation becomes 0000 0011 (03 hex.), Then two 0000 0001 (01 hexadecimal) and finally 0000 0000 (00 hex.) At the end of the 3 attempts.
The 'I' command is used to write or modify the PSC and the error count.
This calls previously made the comparison that is the SGP, because otherwise, even if the computer is running the operation, the smart card will ignore the command. However, it is possible to write the error count without going through the comparison of the PSC, provided that this is equivalent to reset a bit, or reduce the value and number of attempts available. Restoration of all 1 bits must, by cons, must go through the comparison mentioned earlier.
With the command "I", the screen requires the introduction of the starting address two figures and data. This, of course, for a maximum of 4 bytes. The start address can be 00 to 04 because it is no longer beyond the memory protection. Consider an example and imagine, starting from the default, remove an attempt to counter errors.
The area concerned is the area 00, 00 that appears as the address of departure. For data, you must use a value less than hexadecimal 07, or 03 for 2 bits to logic 1 and equal to 0000 0011.
Then, repeat numbers of the SGP. Useless, of course, to rewrite them if they are not modified. Make ENTER from the keyboard for the computer to execute the order commanding the stage.
As for the operation "J", it is the comparison of the PSC which is carried out to access the protected functions that are "E", "G", "I" (only limited to the restoration of the meter error and modification of the SGP himself) and "K" we shall see later. Once the code is compared, it gains access to all procedures, as it does not remove the smart card reader. After pressing the "J" key, the comparison involves the introduction of the SGP (after the screen display we had made the request). Then press ENTER. If the result of serial communication is positive, the message ACK (acknowledgment) appears.
Otherwise we see displayed NACK (not acknowledged).
Warning: These messages indicate only the result of the exchange transaction data between the PC and our plate, and not the result of the command itself. The error count is decremented by one since a bit is set to zero, and therefore the first thing to do is set the error count to zero or to reset it via the command " I '. Our program runs automatically, therefore the command "I" after each comparison of the SGP.
With the letter "K" it is possible to change the current CSP by writing the new, when the computer asks, with a 6-digit hexadecimal format all attached example 0F0F0F0F. Each digit is a nibble of 4 bits, two of which make up a byte of 8 bits of memory safety.
is through the command "S" that we are entering the management board and its peripherals. It allows the reader to ask whether a smart card in place or not. The answer will be 0 for the absence of the card and 1 for presence. If one includes the routine 2KBIT.BAS in a more complex program, the application may then be transmitted automatically, for example loop to verify the presence of a card and launch, again for example, a reloading phase. This is, of course, merely a suggestion, since with a little imagination we can all do! The "T" key is used to trigger the monostable circuit. It determines a line from the serial RS232-C is the connector pin 3, joins the output of the MAX232 (pin 9) and the data input of the microcontroller U3 (RB0).
This identifies the signal and produces a short pulse at logic 1 on pin 13 of U3. The transistor Q2 goes into saturation for a moment, causing the reset pin 2 of the NE555 by forcing its output high. It activates, therefore, the transistor Q1 which controls the relay RL1 bonding for a time imposed by the trimmer R4.
delay which can vary from 2 to 25 seconds. If the transaction was completed, the response will be received ACK. If unsuccessful, NACK displayed.
key "U" entails lighting the red LED LD1. The program generates an order to give the order to bring its own microcontroller pin 17 low, thereby lighting the LED LD1.
If the transaction was completed, the display ACK and NACK in case of failure. The order is stable, which means that once the instruction sent, the LED will remain lit.
The "V" key is the same " U ", but for the green LED LD2 with the same considerations as for LD1.
Finally, 'e' in lower case corresponds to the request for identification of the reader.
For example, if we introduce a code on the PIC card, it can be utilized in the virtual link to a given program. While typing the letter "e" screen displays the code stored in the microcontroller. This feature is still optional.
key "0" (zero) is the order of abandonment of proceedings. After pressing that letter, the computer will prompt you to press any other key to exit the program.
Before moving to assembly instructions, we conclude by recalling that each process is triggered by a clear language. Screen displays very useful guide the user, and any procedure ends by sending the keyboard instruction requested in advance by the computer. For entering data and memory addresses, the values must always be hex, each digit being between 0 and F and with no space. For example, to 0A and 0E FF and the data, it will take 0AFF0E since the program knows how to recognize and separate them without help.

 REM ********************************************** *************** 
SMART-CARD MANAGER ***** REM ***** REM *****
CARD: 2 Kbit FILE: 2KBIT.BAS DATE: 20/06/1998
REM ***** **** * (C) 1998 FUTURE ELECTRONICS - *****
REM *********************************** **************************

CLS
1 2 3
OFF KEY ON ERROR GOTO 60000
4 COLOR 15: LOCATE 5, 10
5 PRINT 'PROGRAMME DE CONTROLE POUR CHIP-CARD 2Kbit'
7 COLOR 12: LOCATE 7, 10
9 PRINT 'FUTURA ELETTRONICA SNC - Rescaldina (MI);
11 COLOR 13: LOCATE 9, 10
13 PRINT "PRESSEZ UNE TOUCHE POUR CONTINUER»;
15 A$ = INKEY$
17 IF A$ = «» GOTO 15
20 DEFINT C, I, R
30 OPEN «com1:9600,E,7,1,CD,DS,CS» FOR RANDOM AS #1
35 GOSUB 17000
40 STX$ = CHR$(2): ETX$ = CHR$(3): ENQ$ = CHR$(5): ACK$ = CHR$(6): NAK$ = CHR$(21)
RESET$ = «A»: REM REPONSE AU RESET
RDMM1$ = «B»: REM Read 1 byte MAIN MEMORY (localisation a0 a1)
RDMMN$ = «C»: REM Read n bytes MAIN MEMORY (de a0 a1)
RDMMA$ = «D»: REM dump MAIN MEMORY (256 bytes)
WRMM$ = «E»: REM Write 1...4 bytes MAIN MEMORY (de a0 a1)
RDPMA$ = «F»: REM dump PROTECTION MEMORY (32 bits)
WRPM$ = «G»: REM ecriture 1 bit PROTECTION MEMORY
RDSM$ = «H»: REM dump SECURITY MEMORY (32 bits)
WRSM$ = «I»: REM ecriture 1...4 bytes SECURITY MEMORY (de a0 a1)
CMPSC$ = «J»: REM comparaison PIN
WRPSC$ = «K»: REM ecriture du PSC
STATO$ = «S»: REM demande de STATO (carte présente)
EJECT$ = «T»: REM commande activation relais (temporisé)
BUSY$ = «U»: REM commande eclairement LED ROUGE
READY$ = «V»: REM commande eclairement LED VERTE
IDENTY$ = «e»: REM demande identification lecteur
REM NOTE: les donnees d0, d1, ... LOCATE 2, 3, 0:: dn caracteres ASCII 30H-3FH
70 COLOR 14 PRINT sont «Sélectionner la fonction DEMANDEE";
COLOR 71 11 72
LOCATE 4, 3, 0: PRINT "A - RESPONSE AU RESET: READ MANUFACTURER CODE ";
73 LOCATE 6, 3, 0: PRINT" B - READ 1 BYTE MAIN MEMORY: moun ADDRESS DE DEBUT DE HEXA. DE 00 A FF ";
74 LOCATE 7, 3, 0: PRINT" C - n READ BYTES MAIN MEMORY: moun ADDRESS DEBUT ET DE NOMBRE DE BYTES ";
75 LOCATE 8, 3, 0: PRINT" D - DUMP MAIN MEMORY (256 bytes: d0 ... dn, adresse de 00 a FF) ";
76 LOCATE 9, 3, 0: PRINT" E - n BYTES WRITE IN MAIN MEMORY (PROTEGE PAR PSC) ";
79 LOCATE 11, 3, 0: PRINT «F - DUMP PROTECTION MEMORY (PROM de 32 bit): protection permanente»;
80 LOCATE 12, 3, 0: PRINT «MAIN MEMORY»;
81 LOCATE 13, 3, 0: PRINT «G - WRITE 1 BIT ON PROT. MEMORY»;
82 LOCATE 14, 3, 0: PRINT «H - DUMP SECURITY MEMORY (32 bits: d0...dn, EC - PSC)»;
83 LOCATE 15, 3, 0: PRINT «I - WRITE n BYTES SECURITY MEMORY»;
84 LOCATE 16, 3, 0: PRINT «J - COMPARAISON PSC (formé par: d0 d1 d2 d3 d4 d5, d‚faut FFFFFF)»;
85 LOCATE 17, 3, 0: PRINT «K - WRITE PSC (forme par: d0 d1 d2 d3 d4 d5, sont disponibles de 0 a F)»;
90 LOCATE 19, 3, 0: PRINT "S - REQUEST STATUS: 0 = absent card 1 = card present"
91 LOCATE 20, 3, 0: PRINT "T - RELAY ACTIVATION weather imposes trimmer;
92 LOCATE 21, 3, 0: PRINT U - RED LED LIGHTS "
93 LOCATE 22, 3, 0: PRINT" V - GREEN LED LIGHTS "
94 LOCATE 23, 3, 0: PRINT" E - REQUEST IDENTIFICATION ";
110 COLOR 13: LOCATE 24 , 3, 0: PRINT "0 - EXIT;
125 COLOR 15: LOCATE 25, 3, 0: PRINT" WHAT FEATURES? "
130 LOCATE 25, 24, 0: PRINT" ";: LOCATE 25, 20, 1 $ = 135 KB
INKEY
$ 140 IF KB $ = "" GOTO 135 IF
141 KB $ = "e" GOTO 12000
145 IF KB$ > CHR$(&H60) AND KB$ < CHR$(&H7B) THEN KB$ = CHR$(ASC(KB$) - 32)
150 COLOR 12: LOCATE 23, 20: PRINT KB$;
160 IF KB$ = «A» GOTO 1000
161 IF KB$ = «B» GOTO 1500
162 IF KB$ = «C» GOTO 2000
163 IF KB$ = «D» GOTO 2500
166 IF KB$ = «E» GOTO 3000
167 IF KB$ = «F» GOTO 4500
168 IF KB$ = «G» GOTO 5000
169 IF KB$ = «H» GOTO 5500
170 IF KB$ = «I» GOTO 6000
171 IF KB$ = «J» GOTO 6500
172 IF KB$ = «K» GOTO 7000
178 IF KB$ = «S» GOTO 10000
179 IF KB$ = «T» GOTO 10500
180 IF KB$ = «U» GOTO 11000 IF
181 KB $ = "V" GOTO 11500 IF
200 KB $ = "0" THEN END 300 GOSUB 17000

310 GOTO 40
A - reply to reset
1000 DT $ = STX $ + $ + RESET ETX $ 20,000

GOSUB GOTO 300
'B - MAIN MEMORY READING 1 byte
1500 ST $ = "START INSERR ADDRESS IN HEX. (00 - FF) ": GOSUB 70000

IF LEN (STT $) = 0 THEN GOTO 300
IF LEN (STT $)> 2 THEN STT $ = LEFT $ (STT $ 3)
DT $ = STX $ + RDMM1 STT $ + $ + ETX $ 20,000

GOSUB GOTO 300
'C - read nbytes MAIN MEMORY
2000 ST $ = "INSERR ADDRESS THE BEGINNING (00 - FF) AND THE NOMBRE
DE BYTES ( 00 - FF)»: GOSUB 70000
IF LEN(STT$) = 0 THEN GOTO 300
IF LEN(STT$) > 4 THEN STT$ = LEFT$(STT$, 5)
DT$ = STX$ + RDMMN$ + STT$ + ETX$
PRINT DT$;
GOSUB 20000
GOTO 300
‘ D - DUMP INTERA MAIN MEMORY
2500 DT$ = STX$ + RDMMA$ + ETX$
GOSUB 20000
GOTO 300
‘ E - ECRITURE n BYTES MAIN MEMORY
3000 ST$ = «INSERRER ADRESSE DE DEBUT ( 00 - FF ) ET DONNEE (MAX
4 BYTES 00-FF)»: GOSUB 70000
IF LEN(STT$) = 0 THEN GOTO 300
IF LEN(STT$) < 4 THEN GOTO 3000
IF LEN(STT$) > 10 THEN STT$ = LEFT$(STT$, 11)
DT$ = STX $ + + STT WRMM $ $ + ETX $ 20,000

GOSUB GOTO 300
'F - MEMORY DUMP PROTECTION INTERA
4500 DT $ = STX $ + $ + ETX $ RDPMA

GOTO GOSUB 20000 300
' G - WRITE 1 BIT MEMORY PROTECTION
5000 ST $ = "BIT ADDRESS REGISTER (00 - 1F) WRITING AND THE VALUE OF BYTE
(00-FF)" + CHR $ (13) + "ADDRESS MATCH IN MEMORY
MAIN ": GOSUB 70000 IF LEN
(STT $) = 0 THEN GOTO 300
IF LEN (STT $) IF LEN < 4 THEN GOTO 5000
(STT $)> 4 THEN STT $ = LEFT $ (STT $ 5)
DT $ = STX $ $ + + WRPM STT $ + ETX $ 20,000

GOSUB GOTO 300
H - DUMP SECURITY MEMORY
5500 DT$ = STX$ + RDSM$ + ETX$
GOSUB 20000
GOTO 300
‘ I -WRITE n BYTES SECURITY MEMORY
6000 ST$ = «INSCRIVEZ ADRRESSE DE DEBUT ( 00 - 03 ) ET DONNEES
(MAX 4 BYTES 00-FF)»: GOSUB 70000
IF LEN(STT$) = 0 THEN GOTO 300
IF LEN(STT$) < 4 THEN GOTO 6000
IF LEN(STT$) > 10 THEN STT$ = LEFT$(STT$, 11)
DT$ = STX$ + WRSM$ + STT$ + ETX$
GOSUB 20000
GOTO 300
‘ J - COMPARAISON PSC
6500 ST$ = «INSCRIVEZ P.S.C. ( 000000 - FFFFFF )»: GOSUB 70000
IF LEN(STT$) = 0 THEN GOTO 300
IF LEN(STT$) > 6 THEN STT$ = LEFT$(STT$, 7)
DT $ = STX $ + $ + CMPSC STT $ + ETX $
GOSUB GOTO 300 20 000

'K-ECRITURE
PSC 7000 ST $ = "Inscrivez PSC (000000 - FFFFFF)": GOSUB 70 000 IF LEN
( STT $) = 0 THEN GOTO 300
IF LEN (STT $)> 6 THEN STT $ = LEFT $ (STT $ 7)
DT $ = STX $ + $ + WRPSC STT ETX $ + $ 20 000

GOSUB GOTO 300
'S - DEMANDE DE STATO
10 000 DT $ = STX $ + STATO $ + ETX $
GOSUB 20 000
GOTO 300
' T - ACTIVATION RELAY '
10 500 DT $ = STX $ + EJECT $ + ETX $
GOSUB 20 000
GOTO 300
'U - Allum LED BUSY
11 000 DT $ = STX $ + $ BUSY + ETX$
GOSUB 20000
GOTO 300
‘ V - ALLUME LED READY
11500 DT$ = STX$ + READY$ + ETX$
GOSUB 20000
GOTO 300
‘ e - DEMANDE IDENTIFICATION
12000 DT$ = STX$ + IDENTY$ + ETX$
GOSUB 20000
GOTO 300
17000 CLS : LOCATE 1, 3, 0: COLOR 15
17010 PRINT «PROGRAMME DE CONTROLE POUR CHIP-CARD 2Kbit»; :
RETURN
18000 COLOR 10: LOCATE 18, 2, 0: PRINT «COMMANDE TRANSMISE: «;
COLOR 9
PRINT LEFT$(DT$, 2);
FOR I = 3 TO LEN(DT$) - 1
X$ = MID$(DT$, I, 1)
X = ASC(X$)
IF X < 58 THEN PRINT X$; ELSE PRINT CHR$(X + 7);
NEXT
PRINT RIGHT$(DT$, 1); RETURN

20000 PRINT # 1, DT $ 20,050
GOSUB GOSUB 18000 20100 17000

20300 GOSUB 25000 20400 RETURN

25000 REM WAIT AND DISPLAY ANSWER
25020 COLOR 3: LOCATE 25, 2, 0: PRINT "PRESS ANY KEY TO CONTINUE ";" "25050
COLOR 3: LOCATE 20, 2, 0: PRINT" responses: ": COLOR 14 YEARS $ 25,055
=" "
25060 FOR I = 1 TO 30000 25070
n = LOC (1)
25080 IF n> 0 THEN YEAR = YEAR $ $ + INPUT $ (n, # 1): n = 0: I = 1

25090 NEXT 25100 IF LEN (ANS $) = 0 THEN PRINT "NO RESPONSE": GOTO
26200 25110 IF LEN (ANS $) = 1 THEN GOTO 25440 25115
FLGCOL
25 120% = 0 FOR I = 2 TO LEN (ANS $) - 1
25 130 X $ = MID $ (ANS $, I, 1)
25 140 IF ASC (X $) < 48 THEN : COLOR 7: X$ = CHR$(ASC(X$) + 16) ELSE COLOR 14
25 150 IF (FLGCOL% AND 2) = 0 THEN COLOR 14 ELSE COLOR 11
25 300 IF ASC (X $) < 58 AND ASC(X$) > 47 THEN PRINT CHR $ (ASC (X $));
25 435 IF ASC (X $)> 57 AND ASC (X $) IF ASC < 64 THEN PRINT CHR$(ASC(X$) + 7);
25 436 (X $)> 63 THEN PRINT X $;
25 437 FLGCOL FLGCOL% =% + 1 GOTO 25 490 25 438 AND 255

25 440 IF ANS $ = CHR $ (6) THEN PRINT "ACK";
25 450 IF ANS $ = CHR $ (21) THEN PRINT "NAK";
25 460 IF ANS $ = CHR $ (5) THEN PRINT "ENQ";
25 480 IF ANS $ = CHR $ (7) THEN PRINT "BEL";
25490 IF I = 1024 THEN
25500 A$ = INKEY$: IF A$ = «» THEN GOTO 25500
25510 END IF
25520 NEXT
25600 ‘PRINT (LEN(ANS$) - 2) / 2;
26200 I$ = INKEY$: IF I$ = «» THEN GOTO 26200
26250 COLOR 7
26300 RETURN
60000 RESUME NEXT
70000 ST$ = ST$ + « «: COLOR 9: LOCATE 25, 1: PRINT « SPACE>=effacer =annuler»; : COLOR 14
70001 LOCATE 24, 1
70002 FOR I = 1 TO 80
70003 PRINT « «;
70004 NEXT
70005 LOCATE 24, 1: PRINT ST$; : STRN$ = «»
70006 A$ = INKEY$: IF A$ = «» THEN GOTO 70006
70007 IF A$ = CHR$(13) THEN GOTO 70024
70008 IF A$ = CHR$(27) THEN STT$ = «»: RETURN
70009 IF A$ = CHR$(8) THEN
70010 A$ = «»: X$ = «»
70011 FOR G = 1 TO LEN(STRN$) - 1
70012 X$ = X$ + MID$(STRN$, G, 1)
70013 NEXT
70014 LOCATE 24, LEN(ST$) + 1
70015 FOR G = 1 TO LEN(STRN$)
70016 PRINT « «;
70017 NEXT
70018 STRN$ = X$
70019 END IF
70020 LOCATE 24, LEN(ST$) + 1
70021 IF LEN(STRN$) + LEN(ST$) = 80 THEN BEEP: GOTO 70006
70022 STRN$ = STRN$ + A$: PRINT STRN$; : A$ = «»
70023 GOTO STT
70006 70024 $ = ""
70025 FOR I = 1 TO LEN ($ STRN)
70026 X $ = MID $ (STRN $ I, 1)
70027 IF X $> CHR $ (96) AND $ X < «g» THEN X$ = CHR$(ASC(X$) - 32)
70030 IF 70035 IF X $ < «0» THEN GOTO 70001
X $> "F" THEN GOTO 70001 70040 IF
X $> "@" AND X $ 70,050 < «G» THEN X = ASC(X$) - 7: X$ = CHR$(X)
STT STT $ $ = $ X + NEXT

70060 70100 RETURN END

Download txt format program

Practical realization
To construct the reader / programmer smart card from 2 Kbit, the first thing to do is to prepare the printed circuit, or more precisely the two printed circuit namely that of the base map and that of the interface.
For this you will find in this article the design of slopes, copper side, scale 1 / 1. Make a photocopy on tracing paper or acetate to obtain the necessary film to photogravure.
After cutting and drilling the channels, you can switch to the mounting of components starting with the smallest that is to say, resistors and diodes. For the latter, make sure the polarity, the cathode being the colored band.
Mount dip-switches and potentiometer adjustable horizontal. Then it's turn supports the microcontroller, and MAX232 NE555.
All must be positioned in ensuring that the notch is turned-keyed as shown in the drawing board layout, in order to receive this mark during the assembly of integrated circuits under the respective achievement.
Continue soldering the capacitors and to observe proper polarity of the electrolyte. When assembling the two LEDs remember that red is LD1, LD2 is green, and the cathode is on the side of the flat (short leg).
Regarding quartz Q1, there is no mounting direction particular.
Transistors, meanwhile, turned to be mounted as shown in the site plan components.
regulator LM7805 (U1) must be positioned so that its metal face is facing the outside of the PCB. Insert the bridge rectifier PT1 in the holes provided for this purpose, position it as shown on the timeline, then solder it. The relay should, in turn, be very small, like "TT-12V MZ" or "HM4101F" and has only one possible position on the PCB.
Finally, remember the DB9 connector to circuit bent printed material that is welded to the plate, taking care to strengthen the welds on both side clips securing the connector.
To facilitate power connections as well as the output of the relay contacts, it is necessary to use screw terminals at 5 mm pitch PCB. A terminal block for power welded to + V and ground, and the other on the OUT (RL1).
Regarding the smart card reader, the required model is brand AMPHENOL having a normally closed, which opens with the introduction of a smart card. It will be connected to the base map with a flat 10 conductor cable in which two female connectors are crimped type HE10 2 x 5 pin pitch of 2.54 mm with the red mark on the ribbon cable to pin 1 of connectors, as well as hand side drive map.
To connect, you must also add two plugs in the holes for the ribbon cable connecting the card reader to the main board.
At this stage, it remains only to insert the ICs in their respective media paying attention to properly aligning the corresponding encochesdétrompeur. For food, you can use any what model capable of providing 200 milliamps at 12 to 15 volts DC. The positive will be connected to V + card, and the V-to ground.
Before powering up, get an extension provided at one end of a sheet DB25 or DB9 female as the type of computer used, and at the other end of a DB9 male. To make the link operational, connect the plug to the serial port of the computer, and plug in circuit programmer / reader.
Turn the PC and load the program disk to start the system.
You can also transcribe the routine published in these pages with the editor in MS-DOS. From the moment it is routine in Qbasic, simply copy the program file in the root 2KBIT.BAS. To activate, simply start QBasic, enter the menu "File" then go to "OPEN" and enter the name 2KBIT.BAS preceded by any folder (directory) in the command line. You can access the listing and then clicking on "Run" from the menu "Run" it shows the presentation screen. At this time the display is activated by tapping operations n'impor you key on the keyboard. To abandon program execution and return to routine, simply press 0 (zero).

0 comments:

Post a Comment