PC interfaces | suggested interface (2 transistors) | no serial ports? | interface with MAX232 | interface with logic gates | embedded or external? | suggested connectors | serial cables | 9/25 pin adapters
This interface is reliable and simple. It has been built without problems by thousands of satisfied readers. It is the chepest and the simplest at the same time, and it employs parts you can get from any electronics shop. We use this interface for all of the projects described in this book.
Interface needed to program the Nutchip through the PC's serial port
- Q1 = NPN transistor, BC337 or similar
- Q2 = PNP transistor, BC557 or similar
- R1, R3= 4,7 kohm (=4700 ohms) resistor, 1/4 W or bigger
- R2, R4= 10 kohm (=10000 ohms) resistor, 1/4 W or bigger
- CN2= 4-pole pin strip, alternatively 4 short pieces of 0.65 mm dia. copper wire
- CN1= 9 pin female "D" type connector (aka "Canon" or PC serial port connector)
- A small breadboard or PCB
The circuit employs just two transistors and does a trick to get a negative voltage as required by some PCs. When the PC does not transmit data, its TX pin is stuck to a negative voltage. As the Nutchip transmit and receive cycles are guaranteed not to overlap, the negative voltage is picked up from the TX pin and brought back - thorugh resistor R3 - to the PC's RD pin on CN1. therefore, when the Nutchip needs to send some data, it switches the Q2 transistor between the negative voltage previously "stolen" and the 5V positive supply voltage. This results in a voltage swing well over the ±3 Volts required by the PC serial port to recognize data as valid.
(a) How to build the interface on a small piece of prototype board.
(b) the connections between the parts are highlighted using different colors
Note: the PC connector is soldered at the solder side only.
On the component side there are no solder joints: in order to avoid short-circuits we removed the copper pads with a small file.
The completed interface plugs directly on a serial cable, whereas the pin-strip connector plugs in the circuit or solderless breadboard with the Nutchip to be programmed.
Ensure your pin-strip is tall enough (see figure) to comfotably fit to the circuit to be programmed without touching other components.
A pin-strip is also suitable for connection to a dual-in-line integrated circuit socket: in this case, use half of a 4+4 pins socket and make the pin-strip from thin wires.
solder side, tracks match the color paths on figure above
Some PCs, particularly notebooks, lack a serial port. In this case an USB to serial port adapter solves the problem, with some exceptions. Not all of the devices currently available offer a full RS232 implementation, some are limited to modems while others are designed for connectiong cell phones or digital cameras only. Therefore it is a good advice to ask your dealer to try before you buy.
Full-size computers (desktops and towers) can be expanded whit a serial port card, too; when possible, this is the solution to be preferred, as it usually works smoother and it is cheaper.
- If you embed the interface to the nutchip board, a standard serial port connector ("D" type, 9 pin, female) is the best chioce. A simple serial extersion cord will provide a convenient connection to the nearest PC.
- If you are building an external interface, in order to use it to progam different target boards, a pin-strip compatible connector is a convenient way to attach your circuit to the interface. The strip pinout follows:
1 = GND
2 = TX
3 = RX
4 = +5V
note: be careful not ot reverse your connector (i.e. pin 1 gets connected to pin 4, etc). Usually a reversal does not damage your prototype..
We have chosen these connectors based on cost and convenience, and we have followed these conventions throughout all of the designs published on our site. We suggest you to conform to this standard connection style: doing this, you will be alble to exchange or program your prototype on the fly, bring it in the class, exchange it with a friend, post it on the Internet with maximum clarity.
The pin-strip connector is well suited to the hobbyst:
- you can get two pin-strip compatible female connectors from an eight pin (4+4) IC socket. Just cut it in two.
- can fit as well a solderless bradboard, which is convenient to experiment with Nutchips
- should you need an higly reliable connector, compatible high quality connectors are commercially available
- advanced user can adopt a "boxed" compatible connector. The connecotrs offer the advantage of being impossible to reverse.
The serial cables required to connect the PC to the interface for Nutchip programming are commonly available from computer shops. Ask for a 9-pin serial extension cord. You can also buy one for by yourself with a couple of 9-pin D connectors (male+female) and 9-pole wire.
(to Nutchip interface NUTCHIP )
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9
Do not use "null modem" cables, because they don't work!
Some PCs feature a 25-pin female serial port connector instead of the usual 9-pin one. If you are unable to find a ready-made adaptor, here is the connection table to build one by yourself, all you need is a 25-pin male connector and a 9-pin female one.:
pin number, 25 pole
(female on the PC)
pin number, 9 pole
(male on the PC)
RS232 name direction 2 3 TD PC out - Nutchip in (RX) 3 2 RD PC in - Nutchip out (TX) 4 7 RTS PC out 5 8 CTS PC in 6 6 DSR PC in 7 5 GND GND 8 1 DCD PC in 20 4 DTR PC out 22 9 RI PC in
Too many wires? Well, if you are going to use exclusively the transistor interface described above, you can solder just three wires:
1) from pin 2 of 25-pin to pin 3 of 9-pini;
2) from pin 3 of 25-pin to pin 2 of 9 pin;
3) from pin 7 of 25-pin to pin 5 of 9-pin.
This interface requires a specilized IC (MAX232) capable to make standard voltages as required by RS232 standards. Thanks to this IC, this circuit features the best noise rejection and is very reliable and protected against discharges and short-circuits. However, this circuit is also more expensive and takes more space than the transistor-based interface.
If you have some spare logic gates on your application circuit, then you can profitably use them to build the programming interface.
The circuits based on logica gates do not provide the negative voltages as prescribed by the standards: the provide only the necessary logic inversion. Almost every PC can work with positive-only signals, although not guaranteed. Therefore we discourage you to use this solution if you don't know in advance whether the PC will like it or not.
The first example uses two out of the six inverters available on a 4066 (full name: CD4066B) cmos IC:
When using 4000-series CMOS logic ICs, always choose the "B" (buffered) versions, as the can supply more current than the unbuffered counterparts.
Any logic inverter can be used to build a PC interface; the following circuits take advantage from inverters realized with NAND and NOR gates, coming form two out of the 4 ports in a 4001 or 4011:
Note: don't forget to power the logic ICs connecting the respective power pins to +5V and GND!
There is no general answer. Here are the rule-of-thumb:
- If the circuit does a job which requires no changes, you can always program the Nutchip before assembling it. You can drop the interface in order to semplify the circuit.
- If you make the circuit for your own use and pleasure, you can avoid building a new interface for every circuit. Just place a pin-strip compatible connector and connect the external interface. This is solution is very popular among hobbyists, as it simplifies the circuits and does not sacrifice the capability of reprogramming the Nutchip without removing it from the circuit.
- If you expect your circuit to be programmed by other people using unknown PCs, we suggest you to embed a complete interface on the final board and to use a standard 9-pin connector. The connection to the actual PC requires no more than a simple serial cable. This solution is to be preferred by professionals.
- Of course, you can always opt for just putting the Nutchip on a socket and to remove it from the application circuit when you need to reprogram it. This is the only way to program the Nutchip it if the circuit is connected to the mains, which makes it very dangerous to connect it directly to the PC.