delabs Circuits

Showing posts with label Embedded-Systems. Show all posts
Showing posts with label Embedded-Systems. Show all posts

Tuesday, October 04, 2016

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.

Monday, February 15, 2016

Battery Backup for SRAM or Microcontroller

This circuit can be used as a low cost SRAM and Microcontroller-Microprocessor Battery Backup. All the diodes are 1N4148, The diodes prevent battery discharge back to power source. D8 gives a one way path to charge Battery thru R13 which limits current. D4 ensures a one way path of supply to chip when power is present. D5 is backup supply on power failure.

Battery Backup for SRAM or Microcontroller

The chip a real time clock, RAM or Processor can be put to standby or sleep on power failure. If it is not a smart chip then make sure on power failure all outputs of chip are high impedance or floating. do not use any pullups or resistor dividers to Vbat, which is the supply to chip. There should be no leakage path from Vbat, decoupling cap of chip must be plastic.

Microcontroller in Process Control

If you want to use this circuit for short term retention or for CMOS logic chips then you can use a 4700uF Cap in place of battery. This works for many hours but the cap has big footprint on PCB. For long duration use more battery AH Ampere-Hour. Vcc is 5V DC regulated.

The Vbat and Vcc can be monitored with comparator like LM339, this circuit can generate the reset or low battery signals. The power on reset and power down reset can corrupt data on brown outs or black outs or even spikes and EMI. So back up data on flash. For Rapid writing and reading SRAM is better and if write-read cycles are high SRAM is best. But if you need to store values and refer to them like a look-up table flash is better.

Serial Interface a 80C31 to ICL7135

The power fluctuations can hang the chip, so a watchdog chip may be required. The conventional way was the to monitor the keyboard-display scan on a i/o port. If the pulses are coming at the rate you programmed the cpu is alive and kicking and doing its job. If the CPU is taking a nap, then the pulses stop coming and it needs to be reset.

Monday, May 11, 2015

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.

More on Piezoelectric Crystal 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.

Friday, August 15, 2014

Digital to Analog Converter with uC Watchdog

This is the continuation of the earlier post. Part of 80C39 based Process Controller. In this schematic you can see the Watchdog and D/A Converter.

80C39 and MCS48 based Process Controller is the main circuit that has the LED 7 segment display for output and push keys for input. The old form of Human Machine Interface - HMI.

Digital to Analog Converter with uC Watchdog

My first observation of a very complex watchdog in action was an Agilent(hp) Benchtop Multimeter based on this 8048 family of 1st generation microcontrollers that did not even have a UART among many things.

At that time CMOS was just making an entry and FLASH memory was unheard of. The UV Eprom was the way firmware was set on these systems. These consumed a lot of power. 80C39 was the CMOS one.

The  4040 counter derives a slow clock from the 7555 timer. The counter has to be reset by firmware by periodically sending a reset pulse on port pin P2.7 to say "Alls Well".

If the firmware or uC "hangs" or due to EMI or Spikes the uC gets into an endless loop. Then the "Alls Well" pulses stop coming. The 4040 keeps counting till Q10 output goes high and resets the uC or can we say Wakes it up rudely.

The D/A converter was used to get the 1-5 V to obtain 4-20 mA control Signal to operate the Actuators like a Motor Drive or Heaters in a Industrial Process control System.

Thursday, October 15, 2009

Interface a uC to PC RS232 with MAX232A

This is the standard configuration on how to Interface a uC like 8051 to PC RS232 with MAX232A. The UART or Serial port was not present in 8049/8749 chips which were the ancestors of 8051/8031. Pages of code were needed to make a software UART in MCS-48. The 8051 integrated the hardware UART and short commands made it tick. The most important innovation which made uC popular was the C in 80C31. C is for CMOS. This made the chip work cooler and work on even batteries and small power supplies.

80C51, SBC, Firmware and Circuits

The 8749 and 8751 are the UV EPROM type of uC. With limited erase/write cycles. The FLASH revolution changed every thing, you could update firmware over a phone line modem. Even without Ethernet, the firmware could be updated by making every embedded device a node on the EPABX. Now TCP/IP and Wi-Fi makes it all very easy.

Interface a uC to PC RS232 with MAX232A
Read also -

Circuits by Application

Analog Circuits

  1. Battery Level Indicator
  2. Simple Sample and Hold
  3. Sample and Hold Standby
  4. Voltmeter Attenuator
  5. Precision Current Source
  6. Opamp Supply Virtual Ground

SCR and Triac

  1. Solid State Relay
  2. Normally Closed AC SSR
  3. AC-AC-SSR
  4. DC-DC SSR
  5. 2N2646 based Pulser
  6. Drive SCR thyristor

Mains Power

  1. Flashing Neon Lamp
  2. Dimmer power control
  3. Edison Bulb Life Extend
  4. Mains Current LED
  5. Mains Voltage LED

Digital Circuits

  1. Simple Digital Counter
  2. Running Lights
  3. Frequency Divider
  4. Crystal Oscillator
  5. Simple High speed switch
  6. Differential TTL converter

Measureall DMM

  1. Ohmmeter Measure Resistance
  2. Precision Digital Attenuator
  3. Precision Amplifier

Mixed Circuits

  1. Monostable Multivibrator
  2. Digital to Analog
  3. LM311 Oscillator
  4. PLL using 4046
  5. VCO with LM331
  6. BCD Thumbwheel to Analog
  7. V to F Converter ICL8038
555 Circuits
  1. OR gate with two 555
  2. fixed frequency duty cycle
  3. Pulse width modulation
  4. Astable Multivibrator
  5. uC Reset Generator
  6. LM555 Voltage Doubler
  7. 555 Power Oscillator
Discrete Circuits
  1. Isolated dual supply
  2. Sound to light converter
  3. Water operated relay
  4. Telephone Indicator
  5. Passive volume control
  6. RS232 Opto-Isolation
  7. Voltage Level Indicator
  8. Relay Driver
  9. Constant Current LED
  10. Voltage Doubler
  11. FET Current Source
Opamp Circuits
  1. Three Opamp Differential
  2. Two Opamp Differential
  3. Buffer Opamps
  4. Differential Op-Amp
  5. Inverting Opamp
  6. Non Inverting Opamp
  7. Digital gain control
  8. Square Triangle Oscillator
  9. Dual Polarity Output Amps
  10. Ammeter Precision Rectifier
  11. Voltage / Current 4-20 mA
  12. Current Source for RTD
Power Electronics
  1. Dual Power Supply
  2. Single Power Supply
  3. Battery Backup Supply
  4. 5V 1A Supply LM2575
  5. 5V Power Supply L296
  6. Dual Power Supply
  7. Tubelight Electronic Choke
  8. Voltage Doublers Multipliers
  9. White LED Lamp on Ni-Cd

uC and uP

  1. PC RS232 with MAX232A
  2. Battery Backup SRAM
  3. watchdog uC uP systems
Instrumentation Circuits
  1. Mains monitor LM3914
  2. Simple Mains monitor
  3. single digit voltmeter
  4. High Resistance Meter
  5. Diode Thermometer
  6. Function Generator
  7. Diode Leakage Tester
  8. Analog LED Ohm Meter
  9. Millivolt Source Current Loop
Process Control
  1. AD590 - temperature
  2. Thermocouple Amplifier
  3. Linearizing Thermocouple
  4. Thermocouple Amplifier
  5. 0-1V to 4-20 mA
  6. 1-5V to 4-20 mA
  7. InfraRed - Optical Switch
  8. InfraRed Detector