💾 Archived View for gemini.spam.works › mirrors › textfiles › hacking › CABLE › max233.txt captured on 2022-07-17 at 01:54:13.
⬅️ Previous capture (2022-06-12)
-=-=-=-=-=-=-
Title : PC to VideoCrypt and/or Smart Card interface via RS232 port. Author: Alex Ivopol (cyborg@actrix.gen.nz) Date : 10 Jan 1995 The following interface has been built and used succesfully. It is loosely based on Markus Kuhn's ADAPTER.TXT and can be used in three modes: * PC listens to traffic between VideoCrypt decoder and Smart Card. * PC pretends to be the Smart Card and talks to the VideoCrypt decoder. * PC pretends to be a VideoCrypt decoder and talks to the Smart Card. DB9F 7??????????o?????????o?????????????????????1 PLUG ???????????? ? R ? R ??????????? 5? MAX233 ? 2 ??/\/\/?? ??/\/\/?? 2? VCC ?6 DCD(1)????????o<?????????????????o??????????????????RST VPP?? N/C 18? ? 1 ? ? 7? SC1 ?3 RXD(2)????????o<???????????????????????????o????????I/O CLK?? * see 4? ? 3 R ? / E ? GND ? options TXD(3)?????????>o????????/\/\/???????????? TR ??????????? 19? ?20 R / E \ C ? RTS(7)?????????>o????????/\/\/?? TR ? ? ???????????? \ C ? ? 8 ???C1+ C2+??? 11 ? ? ? 13 ???C1- C2+??? 15 ? ? ? 12 ???V- C2-??? 10 ? ? ? 17 ???V- C2-??? 16 ? ? ? 14 ???V+ GND GND? ? ? ? ???????????? ? ? ? 6? 9? ? ? ? GND(5)?????????o???o?????????????o?????????o????????????? Option 1: Option 2: 8 5 3 5 8 VCC o????????? ???o CLK output VCC o??????????????? ? ???????? ? ???????????2 100 ??? ? OSC1 ? 100 ??? 1?? EXO-3C ???o CLK output nF ? ???????? nF ? ??????????? GND o???????????? GND o??????????????? 1 4 4 6 7 Qty Part Package Description 1x SC1 - Smart card connector 1x DB9F DB9F Female 9 pin D connector 1x MAX232 DIL 20 RS232 <-> TTL level translator 2x TR TO92 BC558 general purpose PNP transistor 4x R - 10k resistor Optionally, one of the following: Qty Part Package Description 1x OSC1 DIL 8 Crystal Oscillator Module 3.579545Mhz 1x EXO-3C DIL 8 Programmable Oscillator 14.31818Mhz max frequency For those who have access to a Radio Spares store, the following components can be obtained through them: Part RS Stock # MAX233 655-290 EXO-3C 296-885 SC1 453-785 The rest of the components are easy to get and not critical in value. CIRCUIT DESCRIPTION The interface is designed to be connected to a PC with a 9 pin RS232 port. As such the interface has a Female 9 pin D connector like that found on a serial mouse. An extension cable is necessary between the PC's serial port and the location of the interface. The wiring of the extension cable is straight thru with a male DB9 at one end and a female DB9 at the other. Those who know how to do it, can replace the female DB9 with a female DB25 if their PC has a 25 pin serial port. The PC's RS232 port operates with signals that swing from +12V to -12V. The smart card however, operates with TTL signals that swing between +5V and 0V. An RS232 -12V level corresponds to a TTL high (+5V) and a RS232 +12V level corresponds to a TTL low (0V). Due to this incompatibility, a signal level translator such as the MAX233 must be used. The MAX233 is powered from a single +5V supply and generates internally the +/-12V voltages necessary for the RS232 communication. Unlike it's MAX232 brother, the MAX233 needs no external components to achieve this. Thus in the above diagram, all signal lines to the left of the MAX233 are at RS232 levels while all signal lines to the right of the MAX233 are at TTL levels. The DCD line is used to monitor the state of the RST line on the smart card. This allows us to detect when a reset takes place. The RTS line allows us to force a card reset. When the interface is not connected to a PC, pin 19 of the MAX233 is pulled to GND via an internal resistor producing a high level on pin 20. This forces the transistor to "open" (think of the transistor as a switch), effectively disconnecting pin 20 from the card's RST line. The same happens when the interface is connected to the PC and the RTS line is placed at -10V (inactive state). When the RTS line is activated (placed at +10V), pin 20 goes low and the transistor "closes", forcing the card's RST line low and causing a reset. The RXD line is used to receive data from the smart card. The TXD line is used to transmit data to the smart card. When the interface is not connected to the PC, the line is pulled to GND via an internal resistor producing a high level on pin 3. This "opens" the transistor, in effect disconnecting the TXD line from the card's I/O pin. When the interface is connected to a PC and the PC is not transmiting data to the smart card, the TXD line is idle (-10V) and is again disconnected from the card's I/O pin. Only when the PC transmits a zero, the TXD line goes to +10V making pin 3 go low and forcing the card's I/O pin low. At all other times, the card's I/O line is pulled high via the resistor R. This allows the PC to send data to the card. All TTL signals from the MAX233 go to SC1 which is a smart card connector accepting cards with contact locations that conform to the ISO7816-2 standard, section 4, fig 2. The final part of the circuit is an optional oscillator. This is only needed if you intend to have the PC exchange data with a smart card. At all other times the oscillator must be disconected. In the prototype the oscillator was built on the board and a jumper is used to connect or diconect the oscillator output to the card's CLK pin. There are many options for building oscillators. Some people use discrete components. In this age of electronic miniaturisation however, we have two appealing options. Option 1 is a Crystal Oscillator Module housed in a metal package. It can be found in two sizes. Either a DIL (Dual In Line) 14 pin or a DIL 8 pin. These have pins spaced so that they can plug directly into a 14 pin or an 8 pin IC socket. Regardless of the package, only the corner pins are fitted. Pin one on either package is a No Connection. When this oscillator module has power applied, a TTL level clock signal of the appropriate frequency can be observed at the output. The card divides the CLK input signal by 372 (usually) to clock the serial I/O data in or out. Therefore, if we want to talk to the card at 9600 bps, we must fit an oscillator of 372*9600=3.571200Mhz. Unfortunately these are hard to come by, but modules of 3.579545Mhz are quite easy to find producing 9622 bps which works just fine. Option 2 is a programmable frequency divider. This is a DIL 8 pin chip with a built in crystal oscillator. The one in this project has a base frequency of 14.31818Mhz. Three pins on the chip allow a divisor between 2^1 to 2^8 to be selected allowing frequencies between 7.15909Mhz and 55.93khz to be produced. A separate output, provides the undivided base frequency. In this project a divisor of 2^2=4 was selected effectively providing an output frequency of 3.579545Mhz. Oscillators are really noisy devices. They produce a lot of noise on the power line. Therefore, a 100nF capacitor _must_ be fitted as close to the supply lines of the oscillator as possible. This not only eliminates the noise on the supply lines but improves the sqareness of the generated waveform. The working prototype was built on a PCB of 95mm x 45mm, 1.6mm thickness. The PCB holds the DB9 connector, the SC1 connector, MAX233 with a 10uF 25V tantallum capacitor across the power supply lines, oscillator in option 2 with its 100nF capacitor across the power supply lines, 4 resistors, 2 transistors, a jumper (for connecting the oscillator) and a power plug (for connecting an external +5V supply when talking to the card, otherwise the interface draws power from the decoder). Total current drawn at 5V with oscillator active is 7.6mA. See PPLACE.BMP for parts placement. In addition there is a .6mm thickness single sided PCB of the exact dimentions of a smart card (see INSERT.BMP). In the decoder used, the card protrudes by about 20mm so the contacts are brought to the outside. A piece of 5 wire flat ribbon cable brings these contacts to the interface PCB (see IRD_V3.BMP) where they are soldered directly on the trace side to the coresponding pins on SC1. WARNING: Before attempting to connect the interface to any decoder, use a high impedance DMM to measure the AC voltage difference between the interface GND and the decoder's GND. If the difference is not close to 0VAC, earth the decoder's GND before connecting the interface. Use at your own risk. If you damage something you have no one to blame but yourself for stuffing with it in the first place. Take care. Alex Ivopol (cyborg@actrix.gen.nz)