RS232 with Opto-Isolation

I had to once interface an high voltage circuit to PC, The uC had to communicate thru RS232–Comm port–Serial Port.

Part of the 80C31 8051 SBC

Even though i had isolation at the sensors and actuators to make doubly sure the PC also has been isolated. There are chips that are available for this purpose, The circuit above is built with discrete and passive components except for the opto 4N35. You can use MCT2E and CNY17-3 Optos too. For MCT2E some tweak may be needed as current transfer ratio is 20, for the other two CTR is 100 so above design will work.
RS232 with Opto-Isolation

The circuit derives power from PC but does not load the PC supply. Any voltage above 5V applied to the PC connectors may lead to damage of motherboard in PC. Old PCs were more vulnerable but PCs today maybe a bit rugged at the Ports. Due to internal current limits and clamping.

The VCC, VDD and Agnd are derived from PC no other power needs to be applied on PC side of opto. On uC side of opto the uC power supply lines +5 and gnd has to be used. There is no copper link between the two sides and depending on opto a 1KV isolation is possible if PCB is well designed. The PCB should show the visual isolation above and components should be laid on separate areas of PCB to prevent creepage.

The LEDs are to indicate the port activity Rx and Tx, they are not required once testing is over. The circuit can be simpler, but this worked for me and it is not tested at very-high buad rates.

The levels of RS232 are not TTL like 0-5 we have both polarities +10 and -10. The circuit has to change that to drive the Opto Leds.

RS232 software. Understanding RS232 Serial Port Communication.

Frequency Divider 74HCT4040

U1 7555 is a CMOS version of 555. The 555 here is in Astable Oscillator mode, C1 and C4 are decoupling capacitors 0.1uF value, ceramic disc.

Mixed and Interface Circuits

The output is around 100kHz, If C3 is plastic or mica the frequency output will be stable with temperature. It is better to use a crystal oscillator.

Frequency Divider 74HCT4040

The 555 output is fed to clock input of 4040, the output of 555 will be a square wave, on every high to low transition (falling edge or negative transition) the counter increments by one and the output is 12 bit binary.

Read more at my Digital Timers, Counters and Clocks

If input frequency is F the final output at Q12 is F/4096. The period T = 1/F.
If you make the 555 run at 1Hz, C3 around 7uF, Then this circuit becomes a long duration timer, the Q12 period will be 4096 seconds or 68 minutes.

OR gate with two 555

This shows how to OR gate two 555, when one 555 cycles at a low frequency a valve turns on an off, the second 555 stretches the ON duration of the pulse with a diode OR gate.

 Digital Timers Counters and Clocks

OR gate with two 555

The OR output uses sample and hold to get the stable analog data from a sensor after the actuator has gone OFF, this ensures correct reading.

555 is a fundamental Mixed Signal Circuit as it can be made into a VCO using Pin-5. If you see old exar databooks, you can see 555 and PLL and Tone decoders all applications compiled in one base. I feel the Venerable Signetics 555 “Architecture” and Intersil ICL8038 ‘CMOS’ were inspiration behind early communication chip designs, Moving from Bakelite Telephones to Compact Push Button Electronic Phones and more.

Running Lights with CD4017

The 555 Astable generates a clock for this circuit, an oscillator giving a square wave output at pin 3 which is counted by 4017 to give a running lights effect.

Digital Timers Counters and Clocks

The decade counter-divider CD4017 has 10 outputs, for every low to high transition at the clock input, rising edge, the counter advances one LED. After going one full circle the the first LED lights again and it goes on. You can vary the value of R2 100K Linear potentiometer to make LEDs run fast or slow.

Running Lights with CD4017

The frequency of oscillation of astable 555 is given as f = 1.44 / ((R4 + 2 * (R2 + R3)) * C3)

The 10 outputs have 10 green LEDs. The current thru the LED is limited by R1, the current can be calculated like this (9V – 1.6V) / 1K = 7.4mA this is within 20mA which is the danger limit of the CMOS output. You want it to be bright use transistors for every output.

The cap C1 is a filter and C2 is to prevent noise at pin 5 influencing the output as it is a control voltage point.
You can cascade or chain many more counters with the CO or carry out pin 12 of 4017. The pin 15 reset is kept at low for counting, on high it will reset the counter but is not used in this circuit.

pdf links may take time to load in the browser if you just click it, do right click save target to your disk.

Printer Port 256 Relays 16K Dot Matrix

Using this circuit on Printer Port, one could drive 256 Relays or 16K LEDs as Dot Matrix display. It can be used to drive a Large size multiplexed LED dot matrix display or Latched Relay-Solenoid-Motor-Lamp Array Drivers.

This circuit can be modified for a Static drive output or a fast changing output like a Waveform Generator. You can also make it a 16 Bit waveform generator. The frequency limited to the speed of the port or a fraction of it, depending on 8bit, 16bit or 32bit.

Now I have Some Explaining to do. Latch the U7 with a 8 Bit Data to address the device you want to talk to. So one among the 32 Output Devices can be Selected by a combination of G1-G2 of U5-U8 and U7 8 Bits, Split into Two Nibbles for Upper and Lower 16 Devices. That means 16 * 2 = 32 Devices of 1 Byte each,. 32 * 8 = 256 if my calculations are correct. Please verify.

One of the decoders U5 or U8 decode their respective nibble and output a Low on Selected device to Latch Data on the Chosen one (74HCT373). Why HCT ? Speed is good, low power and CMOS ! and works with TTL too. It Interfaced well for me on a Card with Both TTL and CMOS levels, with a Fast uC.

The 74HCT373 outputs are current amplified and isolated by darlingtons and optoisolators. Both source and sink examples shown. This circuit was not tested and documented properly. So there may be things missing. It is just a Concept design..

Printer Port 256 Relays 16K Dot Matrix – del20021

Printer Port 256 Relays 16K Dot Matrix

High Resistance Meter

I don’t remember if this circuit worked properly. But a few were made and i might not have shown the modifications that were done to make it work. This was meant to be a portable, low cost, insulation tester for an electrician. If you try it out and debug it it may work well.

A negative voltage is derived by shifting gnd with two diodes, i feel this did not work very well. Two pins of CD4028 pins are also used to boost the reference to get two extra ranges as 4051 has a 100E on resistance.

High Resistance Meter

The 555 clock makes 4029 counter count. But the clock can be clamped to gnd by a TL062 window comparator. The clock is frozen when the input value to comparator pin 5-2 is within a lower limit and upper limit “window” pin 3-6.

The 4029 counter BCD is decoded to decimal by 4028 which drives the LEDs, keep LED drive within 3mA or chip will be loaded. Use high efficiency extra-bright LEDs.

The 4029 BCD also controls a shunt resistor array with CMOS switches 4051. The voltage across shunt is a sample of leakage current. This is compared in the window comparator to freeze the Clock and LED display to give a reading of the leakage current or Insulation Resistance.

Crystal Oscillator – Parallel Resonant

74HCU04 is a chip that was made for this purpose, HCT may not work for such a circuit. C1 and C2 can go to upto 33pF and R2 can be increased to make R2 * C2 = t.

Time constant much less than the period T of the crystal T = 1/F . This is to remove higher frequency components in the Oscillator.

Crystal Oscillator - Parallel Resonant

The circuit above is a parallel resonant oscillator circuit. The Crystal works by the piezoelectric principle, piezo means pressure. The electric field causes the impedance of the crystal to change. The LP Record Player needle is the reverse of this, the bumps on the spiral groove of the record applies pressure to needle which generates electricity. Both are piezo-electric effects.