Tuesday, March 26, 2013

OP-amp Sine wave generator

OP-amp Sine wave generator


Basically, this sine wave generator circuit is using op-amp (TL082) to generate the triangle wave and then convert the triangle wave into sine wave. This circuit will have upper frequency limit where limit op-amp slew rate.


[Note] this actual circuit component is difference from simulation.
The U2 is configure become comparator circuit, U1 is integrator, U3 is amplifier and U4 is buffer or amplifier.
The U1 and U2 is oscillator circuit, where, the U2 try to compare the U1 voltage with ground and generate the square wave, the U2 output is control by R3 and R2 value. The U1 is integrator circuit, the R1 and C1 is component that control the triangle wave rise and fall time. The rise time and fall time will affect the triangle wave frequency.

The triangle to sine wave converter circuit, input voltage must be around 4V (the triangle wave peak), to get nice sine wave. If the input wave is lower than 4V, the output still triangle wave. If the input wave is higher than 4V, the sine wave will distorted.

You can adjust the R2 value to control the triangle wave amplitude. Please notice the triangle wave frequency, it may affect by R2 value. The best solution to control the triangle wave amplitude without affect the oscillator frequency, is add in the amplifier (U3). By changing the U3 gain is will affect the sine wave quality. Using difference part of diode in triangle to sine wave converter, the input triangle peak requirement may change.

The last stage is U4 buffer or amplifier. the R6 is resistor to control the sine wave peak voltage. It will reduce the loading affect to converter circuit.

Output Signal:-

Sunday, March 24, 2013

RS232, serial port, UART

RS232, serial port, UART

The RS232 DB9 connector is one of legacy communication interface that today still using it. The RS232 is traditional name for serial communication. This interface protocol is very simple, easy to understand and design. This interface last time using in telecommunications, it function seem like replaced by Messager today. This interface is using ASCII symbol to communicate, therefore, you can sending any text file throw this interface. Hyper-terminal is software that used to manage this interface. It can configure the interface, sending key, sending file or as received.

Today, there a lot of communication between IC to IC still using this interface, but, they called the interface as Universal Asynchronous receiver or transmitter (UART). UART still follow the RS232 standard, but it reduce the number signal pin. UART is 3-wire RS232 system, which consisting TxD, RxD and GND. When hardware required in 2 way, the RTS and CTS line are added in, become 5-wire RS232 system.

The standard RS232 signal level is in between +15V to -15V.  Voltage range between -3 to +3 volts is not a valid RS-232 level. High in range +15 ~ +5V and Low in range -15 ~ -5V. The UART signal level is TTL signal level. High will be +5V and Low will be 0V.

This interface still very useful, for embedded project can use this interface to communicate with PC.

DB9 Female and Male pin number

Pin out and signal name


Pin Number Signal Signal Name
1 DCD Carrier Detect
2 RxD Received Data
3 TxD Transmitted Data
4 DTR Data Terminal Ready
5 GND Common Ground
Signal Ground
6 DSR Data Set Ready
7 RTS Request To Send
8 CTS Clear To Send
9 RI Ring Indicator

Serial Communication Parameter

Bit per Second also named as baud rate. Number of bit per second, it will determine the signal width.
Example:-
Baud rate = 9600
Data width = 1/9600 = 104.167us

Data bits is data frame size. (number bits of data)

Parity is check bit use for error detecting. The parity is last bit of data (before stop bit).
None = All data bit is data.
Even  = 1 = when high (1) bits count is odd.
         = 0 = when high (1) bits count is even.

Odd  = 1 = when high (1) bits count is even.
         = 0 = when high (1) bits count is odd.

Mark = parity bit always 1.
Space = parity bit always 0.

Example for Even and Odd:-
7 bits of data High (1) bit count 8 bits including parity
Even Odd
0000000
0
00000000 00000001
0011000
2
00110000 00110001
1001010
3
10010101 10010100

Stop bits is configure the stop bit length.

Flow control is configure the communication handshaking method. It can control by hardware or software or none.

Communication Signal frame

The figure shown the 8 bit RS232 and UART signal (TTL signal). This communication use one signal format only for Transmit and Receive.
The IC (micro-controller) something will offer 8-bits UART or 9-bit UART. The difference between is data size, the 9-bit UART will have 9 bit of data. The start and stop bit still remain.

Saturday, March 23, 2013

Tri-state logic

Tri-state logic

Tri-state logic also called as three-state logic.
The tri-state condition always can find in buffer or inverter gate.

For normal logic, it only have 2 logic, there are HIGH (1) and LOW (0). But, 3-state logic allows an output port to have HIGH (1), LOW (0) and High impedance (High-Z).

As normal logic circuit, the gate will supply voltage at HIGH, pull voltage level to 0V at LOW. The High impedance (High-Z) condition is the gate is remove (open) from the circuit, the gate output in floating condition. As electrically figure show, the switch at high and low in open condition.

The other word, the High-Z output influence to the rest of the circuit is removed, and the circuit node will be “floating”, if no other circuit element determines its state. The floating mean, the point before opened (connect nothing, like Open Collector circuit).


The application of High –Z 
  1. The High-Z state is to effectively remove the device's influence from the rest of the circuit. 
  2. If more than one device is electrically connected, putting an output into the Hi-Z state is often used to prevent short circuits, or one device driving high (logical 1) against another device driving low (logical 0). The other word, release the control to other device.

Example circuit

The tri-state logic can found in bus circuit, there have multiple device is sharing the same connection. The IO port need 2 tri-state logic to managed input and output signal.

For today micro-controller and most of digital device offer the tri-state output and it can control by CS (chip select) or Enable pin. The tri-state logic gates are no longer familiar.



Wednesday, March 13, 2013

Understand MCB and MCCB

The MCB and MCCB both are circuit breaker and most people confused with its difference. The key difference between the circuit breaker is rating. Circuit breaker are made to ensure there is not electricity over flow, where may cause by short circuit or overload. The location of circuit breaker in every structure should be known to the people who reside in it.

MCB (Miniature Circuit Breaker)
MCB current limit rated under 100A with an interrupting rating of under 18kA (18,000A). Their trip characteristic may not be adjusted since they basically cater to low power circuit. They will found in commercial (house main switch) use.

MCCB (Molded Case Circuit Breaker)
MCCB current limit rated as high as 2500A or as low as 10 with an interrupting rating can be around 10kA to 20kA. Their come with an adjustable trip characteristic. It will use for high power equipment/circuit.
There have some MCCB for electrical motor load limit where they can be tripped using only a remote control. They will found in industrial use or heavier power requirements.

The MCB and MCCB are classified under low voltage circuit breaker, therefore, their standards set by the IEC 947.

Main parameter for circuit breaker
Current rating and Interrupting rating are main parameter for circuit breaker.
Current rating is limit where circuit breaker will open circuit when the short-circuit current is exceeded.
Interrupting rating is limit where circuit breaker able to withstand the destructive energy of short-circuit currents. If the short-circuit current exceeded the interrupting rating, the circuit breaker may have explosion, rupture could result, or permanence damage. The easy explanation is maximum short-circuit current rating.
[P.S.] Interrupting rating is not equal to Interrupting capacity.

Example choosing circuit breaker for load:- 
If you have load (motor or contactor), you have to know the load start-up peak current.
You circuit breaker current rating must equal or higher than start-up current, because the inductance load will have spike current (high current) at initial.
The short-circuit current calculation study is need to choose right interrupt rating or try to using higher interrupt rating circuit breaker.

Sunday, March 10, 2013

Free-wheeling diode


Figure 1

Refer figure 1, the D1 have a lot of name for it. It called flyback diode, snubber diode, free-wheeling diode, suppressor diode, or catch diode. It have a lot of name, but its purpose only one, use to de-charge the solenoid (L1) energy.

Refer figure 2, looking at the inductor equation, V = L di/dt. At initial (2a), the current start flow into inductor, the inductor will generate the voltage (EMF / electromotive force) to block current flow. When current is constant / continuous (DC), the voltage across the inductor is 0V (short circuit). When circuit open instantly (2b), will cause the current flow across inductor change instantly. The energized inductor will generate voltage (back EMF) same as source direction. The inductance, current change and time will determine voltage that generated by the energized inductor. This spike voltage can up to few hundred volt. 


Figure 2

Faraday's Law of induction, any change in the magnetic environment of a coil of wire will cause a voltage (EMF) to be induced in the coil. When current start flow across solenoid, the solenoid generate the magnetic field and EMF at the same time. Until the current flow across solenoid is constant, the EMF disappear (0V), but magnetic field still exist. When the inductor disconnect from current source, the solenoid magnetic field have decay (change), the back EMF is generate at this time.

Back to figure 1, if without the free-wheeling diode, when the Q1 turn off. The solenoid L1 may generate few hundred volt and top up with supply voltage (12V). This voltage will exceed the Q1 collector breakdown voltage, and Q1 will damage.


When free-wheeling diode connect to circuit, the back EMF will reduce, due to the continued circulation of current in the inductor and diode.

Choosing the Free-wheeling diode

The smallest spike voltage to transistor Q1 is the best, but what diode parameter can help to reduce spike voltage?
1. Diode turn on voltage (diode forward voltage)
    => diode easy to turn on will have lower spike voltage.
2. Diode turn on speed (diode turn on speed)
    => spike voltage is voltage change in short period. dV/dt
         faster diode turn on, the lower spike amplitude.
         the diode a will conduct at low voltage, but diode b will conduct at high voltage. that mean, it need higher peak forward current.
3. Peak forward current
    => The larger EMF generated, the larger current flow across the diode.
         Just a concept, if diode in turn condition is equal to 100 ohm resistor, the spike voltage is around 100V.
         I forward (pk) | min = (100/100) A = 1A

4. Reverse voltage
    => the reverse voltage must higher than supply voltage (e.g. 12V in figure 1).



Low-cost applications unconcerned with efficiency often use 1N4007 series power diodes as free-wheeling diodes.






Open Collector and Open Drain Circuit



The Open Collector output is term for BJT transistor circuit. The Open Collector output is the unconnected Collector of an NPN transistor, make available to the external circuitry, which switches to ground when active. This type of output would no supply voltage to output device, unless pull-up resistor connected to the Collector

The Open Drain output is term for FET type transistor circuit. The Open Drain output is the unconnected drain of an N-type FET, make available to the external circuitry, which switches to ground when active. This type of output would no supply voltage to output device, unless pull-up resistor connected to the drain.

Example Open Collector / Open Drain Application
1. Normally, this circuit operate as switch and it can have difference voltage between control path and Load path. As connection show in figure at below, the control voltage can be 3.3V or 5V (lower voltage). It output pin (collector) is applied with 12V. The L1 is load. The Diode D1 is protection diode (see note).


2. Circuit shown in figure at below, this circuit is working but, you will seldom see it because this circuit always have power loss (power consume).When control off (Q1 turn off), the current flow to the load L1. When control on (Q1 turn on), the current flow to Q1. This circuit will always have current flow.
This consider as bad design, because it always consume power.
The circuit will invert the signal output from control signal.
The R1 act as current limiter in this circuit, but it also have other name call pull up resistor.



Advantage of Open Collector / Open Drain circuit
1. The control line and output (collector/drain) can use difference voltage level.
2. Increase the output pin power.

Example Open Collector IC
The ULN2003 is most common open collector IC. Its output allow sink high current and bias with high voltage (500mA and 50V) and its input is normal TTL signal. The typical ic output voltage is Vcc voltage, and source current is from 100mA ~ 150mA.

Key to Remember
1. The Open Collector / Open Drain circuit will not supply voltage/current. It only sink current.