L293 and L293D are popular motor driver ICs having a wide supply voltage range of 4.5V - 36V and is capable of handling an output current of 1A per channel. Pinout diagram of L293 and L293D is given below.
Main difference between L293 and L293D is , D in L293D indicates an internally fitted diode ( Output Clamp Diodes ) meaning that we don't need to add any external components. But if you are using L293 external diode has to be added. This diode is used for Inductive Transient Suppression.
Pages
▼
Wednesday 30 April 2014
Monday 28 April 2014
Difference Between CMOS and TTL Signals
Characteristics of CMOS Logic.
CMOS logic gates dissipates less power : Power dissipation depends on the power supply voltage, frequency, output load and input rise time. At 1 MHz and 50 pF load, Each gate dissipates a typical power of 10nW.
Short propogation delays : Propogation delays are normally around 25nS - 50nS. It is dependant on the supply voltage.
Noise immunity approaches around 50% of the full Logic swing.
Levels of the Logic signals are approximately equal to the power supplied since the input impedance is too high.
Voltage levels range from 0 - VDD where VDD is the supply voltage and it varies from 4.75V - 5.25V. Voltage in the range 0 - 1/3 VDD V will be considered as LOW and voltage in the range 2/3 VDD - VDD Vwill be considered as HIGH.
Characteristics of TTL logic.
Each gate dissipates around 10mW.
Propogation delays are normally 10nS when driving a 15pF/400 OHM load.
Voltage levels range from 0 - Vcc where Vcc is the supply voltage and it varies from 4.75V - 5.25V. Voltage in the range 0 - .8 V will be considered as LOW and voltage in the range 2V - Vcc will be considered as HIGH.
Comparison between CMOS and TTL logic.
CMOS components are more susceptible to damage from electrostatic discharge than TTL components.
Transmission of digital signals are simpler and less expensive with CMOS chips because of longer rise and fall times of Digital signals.
CMOS circuits consume less power compared to TTL circuits at rest. But the CMOS power consumption increases faster with high clock speeds than the TTL circuits. Lower power consumption requires less power distribution and requires simpler and cheaper circuit.
CMOS components are more expensive than TTL components. But on a system, CMOS components are less expensive due to smaller design and hence the lessser regulation.
CMOS logic gates dissipates less power : Power dissipation depends on the power supply voltage, frequency, output load and input rise time. At 1 MHz and 50 pF load, Each gate dissipates a typical power of 10nW.
Short propogation delays : Propogation delays are normally around 25nS - 50nS. It is dependant on the supply voltage.
Noise immunity approaches around 50% of the full Logic swing.
Levels of the Logic signals are approximately equal to the power supplied since the input impedance is too high.
Voltage levels range from 0 - VDD where VDD is the supply voltage and it varies from 4.75V - 5.25V. Voltage in the range 0 - 1/3 VDD V will be considered as LOW and voltage in the range 2/3 VDD - VDD Vwill be considered as HIGH.
Characteristics of TTL logic.
Each gate dissipates around 10mW.
Propogation delays are normally 10nS when driving a 15pF/400 OHM load.
Voltage levels range from 0 - Vcc where Vcc is the supply voltage and it varies from 4.75V - 5.25V. Voltage in the range 0 - .8 V will be considered as LOW and voltage in the range 2V - Vcc will be considered as HIGH.
Comparison between CMOS and TTL logic.
CMOS components are more susceptible to damage from electrostatic discharge than TTL components.
Transmission of digital signals are simpler and less expensive with CMOS chips because of longer rise and fall times of Digital signals.
CMOS circuits consume less power compared to TTL circuits at rest. But the CMOS power consumption increases faster with high clock speeds than the TTL circuits. Lower power consumption requires less power distribution and requires simpler and cheaper circuit.
CMOS components are more expensive than TTL components. But on a system, CMOS components are less expensive due to smaller design and hence the lessser regulation.
Saturday 26 April 2014
CD4543B - IC to Control Both Common Anode and Common Cathode SSDs
CD4543B is a BCD-to-seven segment display latch/decoder/driver designed for Liquid Crystal Display Applications. It is also capable of driving light emitting diode, incandescent, gas-discharge and fluorescent displays.
Most amazing feature of CD4543B is it's ability to control Common Anode as well as Common Cathode seven segment displays. A logic 0 is required at the phase input (PH) for common-cathode devices and a logic 1 is required at the phase input (PH) for common anode devices.
Get the pdf of CD4543 from here.
LD - Latch Disable
PH - Phase
BL - Blanking
Read my blog on controlling Common Anode Seven Segment Display using Arduino and CD4543.
Read my blog on controlling Common Cathode Seven Segment Display using Arduino and CD4543.
Truth table of CD4543B to control seven segment displays.
Most amazing feature of CD4543B is it's ability to control Common Anode as well as Common Cathode seven segment displays. A logic 0 is required at the phase input (PH) for common-cathode devices and a logic 1 is required at the phase input (PH) for common anode devices.
Get the pdf of CD4543 from here.
LD - Latch Disable
PH - Phase
BL - Blanking
Read my blog on controlling Common Anode Seven Segment Display using Arduino and CD4543.
Read my blog on controlling Common Cathode Seven Segment Display using Arduino and CD4543.
Truth table of CD4543B to control seven segment displays.
Thursday 24 April 2014
Control Common Anode Seven Segment Display Using Arduino and CD4543B
CD4543B can be used to control common anode seven segment display too. Controlling common anode seven segment display using CD4543B is pretty simple. VCC pin of the seven segment display should be connected to the positive
Truth table of CD4543B for Common Anode Seven Segment Display.
To control a common cathode seven segment display using CD4543B
PH ( Pin 6 ) should be set HIGH.
LD ( Pin 1 ) should be set HIGH.
BL ( Pin 7 ) should be set LOW.
If all the above conditions are satisfied, then the output will change when the input changes.
If LD goes LOW from HIGH, then the output will be same as the previous output when LD pin was HIGH. Changes in INPUT will not affect the OUTPUT.
If BL goes HIGH, then the seven segment display will turn off and is independant of any other pins.
Now upload the following program to your arduino board. Reset the arduino board if needed.
int Ph = 6; //arduino pin connected to the Ph pin of 4543
int BL = 5; //arduino pin connected to the BL pin of 4543
int LD = 11; //arduino pin connected to the LD pin of 4543
int A = 7;
int B = 9;
int C = 10;
int D = 8;
void setup()
{
// Declare all the pins as OUTPUT pins
pinMode(Ph, OUTPUT);
pinMode(BL, OUTPUT);
pinMode(LD, OUTPUT);
pinMode(A , OUTPUT);
pinMode(B , OUTPUT);
pinMode(C , OUTPUT);
pinMode(D, OUTPUT);
}
void loop()
{
// Display 0
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 1
digitalWrite(A , HIGH);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2
digitalWrite(A , LOW);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 3
digitalWrite(A , HIGH);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 4
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , HIGH);
digitalWrite(D , LOW);
delay(1000);
}
Output of the above program is given below.
To get an idea about the working of LD pin, upload the following program.
int Ph = 6; //arduino pin connected to the Ph pin of 4543
int BL = 5; //arduino pin connected to the BL pin of 4543
int LD = 11; //arduino pin connected to the LD pin of 4543
int A = 7;
int B = 9;
int C = 10;
int D = 8;
void setup()
{
// Declare all the pins as OUTPUT pins
pinMode(Ph, OUTPUT);
pinMode(BL, OUTPUT);
pinMode(LD, OUTPUT);
pinMode(A , OUTPUT);
pinMode(B , OUTPUT);
pinMode(C , OUTPUT);
pinMode(D, OUTPUT);
}
void loop()
{
// Display 0
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 1
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , HIGH);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2 itself
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, LOW);
digitalWrite(A , HIGH);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 4
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , HIGH);
digitalWrite(D , LOW);
delay(1000);
}
int Ph = 6; //arduino pin connected to the Ph pin of 4543
int BL = 5; //arduino pin connected to the BL pin of 4543
int LD = 11; //arduino pin connected to the LD pin of 4543
int A = 7;
int B = 9;
int C = 10;
int D = 8;
void setup()
{
// Declare all the pins as OUTPUT pins
pinMode(Ph, OUTPUT);
pinMode(BL, OUTPUT);
pinMode(LD, OUTPUT);
pinMode(A , OUTPUT);
pinMode(B , OUTPUT);
pinMode(C , OUTPUT);
pinMode(D, OUTPUT);
}
void loop()
{
// Display 0
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 1
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , HIGH);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2 itself
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, LOW);
digitalWrite(A , HIGH);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 4
digitalWrite(Ph, HIGH);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , HIGH);
digitalWrite(D , LOW);
delay(1000);
}
Output of the above program will be:
Control Common Cathode Seven Segment Display Using Arduino and CD4543B
I had already published my blog on controlling seven segment display using 4511. In this blog we will see the method of controlling seven segment display using Arduino and 4543 driver IC. CD4543B is amazing by it's ability to control both Common Anode as well as Common Cathode seven segment displays.
Truth table of CD4543B for Common Cathode Seven Segment Display.
To control a common cathode seven segment display using CD4543
PH ( Pin 6 ) should be set LOW.
LD ( Pin 1 ) should be set HIGH.
BL ( Pin 7 ) should be set LOW.
If all the above conditions are satisfied, then the output will change when the input changes.
If LD goes LOW from HIGH, then the output will be same as the previous output when LD pin was HIGH. Changes in INPUT will not affect the OUTPUT.
If BL goes HIGH, then the seven segment display will turn off and is independant of any other pins.
Now upload the following program to your arduino board. Reset the arduino board if needed.
int Ph = 6; //arduino pin connected to the Ph pin of 4543
int BL = 5; //arduino pin connected to the BL pin of 4543
int LD = 11; //arduino pin connected to the LD pin of 4543
int A = 7;
int B = 9;
int C = 10;
int D = 8;
void setup()
{
// Declare all the pins as OUTPUT pins
pinMode(Ph, OUTPUT);
pinMode(BL, OUTPUT);
pinMode(LD, OUTPUT);
pinMode(A , OUTPUT);
pinMode(B , OUTPUT);
pinMode(C , OUTPUT);
pinMode(D, OUTPUT);
}
void loop()
{
// Display 0
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 1
digitalWrite(A , HIGH);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2
digitalWrite(A , LOW);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 3
digitalWrite(A , HIGH);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 4
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , HIGH);
digitalWrite(D , LOW);
delay(1000);
}
Output of the above program will be:
To get an idea about the working of LD pin, upload the following program.
int Ph = 6; //arduino pin connected to the Ph pin of 4543
int BL = 5; //arduino pin connected to the BL pin of 4543
int LD = 11; //arduino pin connected to the LD pin of 4543
int A = 7;
int B = 9;
int C = 10;
int D = 8;
void setup()
{
// Declare all the pins as OUTPUT pins
pinMode(Ph, OUTPUT);
pinMode(BL, OUTPUT);
pinMode(LD, OUTPUT);
pinMode(A , OUTPUT);
pinMode(B , OUTPUT);
pinMode(C , OUTPUT);
pinMode(D, OUTPUT);
}
void loop()
{
// Display 0
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 1
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , HIGH);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2 itself
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, LOW);
digitalWrite(A , HIGH);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 4
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , HIGH);
digitalWrite(D , LOW);
delay(1000);
}
Complete the circuit as shown in the following image.
Important* - Don't forget to put some resistors ( 1 KOhm ) in series with your segments.
Truth table of CD4543B for Common Cathode Seven Segment Display.
To control a common cathode seven segment display using CD4543
PH ( Pin 6 ) should be set LOW.
LD ( Pin 1 ) should be set HIGH.
BL ( Pin 7 ) should be set LOW.
If all the above conditions are satisfied, then the output will change when the input changes.
If LD goes LOW from HIGH, then the output will be same as the previous output when LD pin was HIGH. Changes in INPUT will not affect the OUTPUT.
If BL goes HIGH, then the seven segment display will turn off and is independant of any other pins.
Now upload the following program to your arduino board. Reset the arduino board if needed.
int Ph = 6; //arduino pin connected to the Ph pin of 4543
int BL = 5; //arduino pin connected to the BL pin of 4543
int LD = 11; //arduino pin connected to the LD pin of 4543
int A = 7;
int B = 9;
int C = 10;
int D = 8;
void setup()
{
// Declare all the pins as OUTPUT pins
pinMode(Ph, OUTPUT);
pinMode(BL, OUTPUT);
pinMode(LD, OUTPUT);
pinMode(A , OUTPUT);
pinMode(B , OUTPUT);
pinMode(C , OUTPUT);
pinMode(D, OUTPUT);
}
void loop()
{
// Display 0
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 1
digitalWrite(A , HIGH);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2
digitalWrite(A , LOW);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 3
digitalWrite(A , HIGH);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 4
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , HIGH);
digitalWrite(D , LOW);
delay(1000);
}
Output of the above program will be:
To get an idea about the working of LD pin, upload the following program.
int Ph = 6; //arduino pin connected to the Ph pin of 4543
int BL = 5; //arduino pin connected to the BL pin of 4543
int LD = 11; //arduino pin connected to the LD pin of 4543
int A = 7;
int B = 9;
int C = 10;
int D = 8;
void setup()
{
// Declare all the pins as OUTPUT pins
pinMode(Ph, OUTPUT);
pinMode(BL, OUTPUT);
pinMode(LD, OUTPUT);
pinMode(A , OUTPUT);
pinMode(B , OUTPUT);
pinMode(C , OUTPUT);
pinMode(D, OUTPUT);
}
void loop()
{
// Display 0
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 1
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , HIGH);
digitalWrite(B , LOW);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 2 itself
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, LOW);
digitalWrite(A , HIGH);
digitalWrite(B , HIGH);
digitalWrite(C , LOW);
digitalWrite(D , LOW);
delay(1000);
// Display 4
digitalWrite(Ph, LOW);
digitalWrite(BL, LOW);
digitalWrite(LD, HIGH);
digitalWrite(A , LOW);
digitalWrite(B , LOW);
digitalWrite(C , HIGH);
digitalWrite(D , LOW);
delay(1000);
}
Output of the above program will be:
Tuesday 22 April 2014
Difference Between ULN2803 and ULN2003 Darlington Array ICs
ULN2803
ULN2803 is an eight channel darlington array used to interface microcontrollers to high voltage, high current devices such as solenoids, lamps, relays etc. It has the capacity to drive 500mA into a single channel, upto 250mA per channel if four of the eight channels are active and 125 mA per channel if all the eight channels are active. It's output have clamp diodes for transient suppression to protect the low power microcontroller circuits. ULN2803 is commonly used for controlling large seven segment displays.
ULN2003
ULN2003 is a seven channel darlington array used to interface microcontrollers to high voltage, high current devices such as solenoids, lamps, relays etc. It has the capacity to drive 500mA into a single channel, upto 250mA per channel if four of the seven channels are active and 125 mA per channel if all the seven channels are active. It's output have clamp diodes for transient suppression to protect the low power microcontroller circuits.
The ULN2003 is the replacement for the ULN2803 when using the Prop-1 Trainer Board or when using P7 (Prop-1) or P15 (Prop-2 and Prop-SX) for serial communications with devices like the AP-8, DC-16, FC-4, and RC-4.
Monday 21 April 2014
What is the Code for Arduino shiftOut() function ?
After completing my blog on Arduino shiftOut I became enthusiastic to know, what is happening while calling shiftOut function. So i searched for that and found the code for the shiftOut() function. Code for shiftOut() function is given below.
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
uint8_t i;
for (i = 0; i < 8; i++) {
if (bitOrder == LSBFIRST)
digitalWrite(dataPin, !!(val & (1 << i)));
else
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
}
To check whether this code will work, complete the following circuit.
Now upload the following program to the arduino board. shiftOut function is renamed as shiftOut_function.
//Pin connected to ST_CP of 74HC595
int latchPin = 12;
//Pin connected to SH_CP of 74HC595
int clockPin = 13;
////Pin connected to DS of 74HC595
int dataPin = 11;
void setup()
{
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
//code for shiftOut function
void shiftOut_function(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val)
{
uint8_t i;
for (i = 0; i < 8; i++) {
if (bitOrder == LSBFIRST)
digitalWrite(dataPin, !!(val & (1 << i)));
else
digitalWrite(dataPin, !!(val & (1 << (7 - i))));
digitalWrite(clockPin, HIGH);
digitalWrite(clockPin, LOW);
}
}
void loop()
{
// count from 0 to 255 and display the number
// on the LEDs
for (int display_number = 0; display_number < 256; display_number++)
{
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut_function(dataPin, clockPin, MSBFIRST, display_number);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
delay(500);
}
}
Output of the above program is given below.
Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0
Saturday 19 April 2014
Control DC Motor Using Arduino and ULN2803
If we want to control a DC motor using Arduino, we have to go for some kinds of drivers such as ULN2803 or L293DNE. I had already published one blog on controlling a DC motor using L293D and Arduino. Controlling a DC motor using ULN2803 is pretty simple. But the problem is, we cannot change the direction of rotation of motor by this circuit. If you are not familiar with ULN2803, read this blog to get a brief idea.
Circuit diagram to control a DC motor using Arduino and ULN2803 is given below.
Circuit diagram to control a DC motor using Arduino and ULN2803 is given below.
Now upload the following program to arduino board.
int motor = 13;
void setup() {
pinMode(motor, OUTPUT);
}
void loop() {
digitalWrite(motor, HIGH);
delay(1000);
digitalWrite(motor, LOW);
delay(1000);
}
Output :
Motor will rotate for one second. Then motor will turn off for next one second and the process continues for ever.
Friday 18 April 2014
ULN2803 - Darlington Pair IC For Controlling High Current Devices
If we want to control a motor or relay using a microcontroller, we have to use driver ICs such as ULN2803 or ULN2003 because each digital output pin of arduino can sink or source only 40 mA. If motor is connected directly to the digital output of arduino pin, board get damaged due to overload.
Pinout diagram of ULN2803 is given below.
ULN2803 has eight darlingtons with common emitters. Each darlington can hold load current upto 500 mA. Chip is capable of handling output voltage of 50V. Inputs and outputs are pinned opposite to each other to simplify the circuit. Output pins can be parallelled for higher current rating.
Circuit diagram to control nine parallelly connected LEDs using Arduino and ULN2803 is given below.
LED bank will turn on if the state of PIN13 of Arduino is HIGH. Eight such LED banks can be controlled using a single IC.
Tuesday 15 April 2014
Control Seven Segment Display Using 74HC595 Shift Register IC and Arduino
We had already discussed the topic on controlling seven segment display using 4511 Driver IC in the previous tutorials . Here we are going to discuss, how seven segment display can be controlled using 74HC595 IC and Arduino. Circuit is done as shown in the following image. Pin 11 (SH_CP), Pin 12 (ST_CP) and Pin 14 (DS) of 74595 IC is connected to the Pin 13, Pin12 and Pin11 of Arduino board respectively.
Important : Seven Segment Display should be common cathode display.
Following table shows the states of Q0-Q7 pins of 74HC595 IC to display numbers from 0 to 9. To display a particular number in seven segment display, corresponding EQUIVALENT DECIMAL (column before last column) should be shifted out from Arduino.
Upload the following program to arduino board. Following program displays from 0 to 9 in the seven segment display.
//Pin connected to ST_CP of 74HC595
int latchPin = 12;
//Pin connected to SH_CP of 74HC595
int clockPin = 13;
////Pin connected to DS of 74HC595
int dataPin = 11;
void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop()
{
// Decimal 63 Binary output 01111111 Displays 0
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 63);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 6 Binary output 00000110 Displays 1
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 6);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 91 Binary output 01011011 Displays 2
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 91);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 79 Binary output 01001111 Displays 3
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 79);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 102 Binary output 01101010 Displays 4
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 102);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 109 Binary output 01101101 Displays 5
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 109);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 125 Binary output 01111101 Displays 6
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 125);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 7 Binary output 00000111 Displays 7
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 7);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 127 Binary output 01111111 Displays 8
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 127);
digitalWrite(latchPin, HIGH);
delay(1000);
// Decimal 102 Binary output 01101111 Displays 9
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, 111);
digitalWrite(latchPin, HIGH);
delay(1000);
}
Output of the above program will be as shown in following image.
Sunday 13 April 2014
Serial to Parallel Shifting - Out with Two Shift Register ICs 74HC595 and Arduino
Important: Before starting this tutorial, don't forget to refer the tutorial on connecting one 74595 IC to Arduino.
If we want more outputs than the outputs from one 74595 IC, we will go for more 74595 ICs. Pinout diagram of 74595 is given below.
Complete the circuit as shown in figure given above. Now upload the following program to your arduino board.
//Pin connected to ST_CP of 74HC595
int latchPin = 12;
//Pin connected to SH_CP of 74HC595
int clockPin = 13;
////Pin connected to DS of 74HC595
int dataPin = 11;
void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
// count from 0 to 255 and display the number
// on the LEDs
for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
delay(1000);
}
}
Output of the above program will be as shown in figure given below.
First row of following image indicates Q0 - Q7 of IC 1. Second row indicates Q0 -Q7 of IC 2.
Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0
If we want more outputs than the outputs from one 74595 IC, we will go for more 74595 ICs. Pinout diagram of 74595 is given below.
While using more ICs, Pin 11 (SH_CP) and Pin 12 (ST_CP) of all 74595 ICs must be connected to the same pins of arduino board. Pin 14 (DS) of the first 74595 IC must be connected to the Arduino pin. Pin 14 of all the other 74595 ICs must be connected to the Pin 9 ( Q7' )
of the previous IC as shown in the following figure.
Complete the circuit as shown in figure given above. Now upload the following program to your arduino board.
//Pin connected to ST_CP of 74HC595
int latchPin = 12;
//Pin connected to SH_CP of 74HC595
int clockPin = 13;
////Pin connected to DS of 74HC595
int dataPin = 11;
void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop() {
// count from 0 to 255 and display the number
// on the LEDs
for (int numberToDisplay = 0; numberToDisplay < 256; numberToDisplay++) {
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, numberToDisplay);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
delay(1000);
}
}
Output of the above program will be as shown in figure given below.
First row of following image indicates Q0 - Q7 of IC 1. Second row indicates Q0 -Q7 of IC 2.
Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0
Explanation of the Output.
During the first shiftout (First iteration of for loop) 1 (00000001) will be displayed in the LEDs connected to the first IC. During the second shiftout (Second iteration of for loop), 1 (00000001) will be shifted to the second IC and 2 (00000010) will be displayed in the first IC.
Thursday 10 April 2014
Arduino - ShiftOut, Extend Output Pins on Arduino With Shift Register 74HC595
Sometimes we will need more output pins than the output pins provided on the arduino board. In such situations we will use shift register ICs such as 74595. Pin diagram of 74595 is as shown in following figure.
By properly connecting one shift register IC to arduino, we can create eight digital outputs from three digital output pins of arduino. Circuit Diagram to create eight digital outputs from three digital output pins is as shown in the following figure.
Complete the above circuit and upload the following program.
//Pin connected to ST_CP of 74HC595
int latchPin = 12;
//Pin connected to SH_CP of 74HC595
int clockPin = 13;
////Pin connected to DS of 74HC595
int dataPin = 11;
void setup()
{
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop()
{
// count from 0 to 255 and display the number
// on the LEDs
for (int display_number = 0; display_number < 256; display_number++)
{
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, MSBFIRST, display_number);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
delay(500);
}
}
Output of the above program will be as shown in figure given below.
Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0
Now upload the following program.
//Pin connected to ST_CP of 74HC595
int latchPin = 12;
//Pin connected to SH_CP of 74HC595
int clockPin = 13;
////Pin connected to DS of 74HC595
int dataPin = 11;
void setup()
{
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop()
{
// count from 0 to 255 and display the number
// on the LEDs
for (int display_number = 0; display_number < 256; display_number++)
{
// take the latchPin low so
// the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
// shift out the bits:
shiftOut(dataPin, clockPin, LSBFIRST, display_number);
//take the latch pin high so the LEDs will light up:
digitalWrite(latchPin, HIGH);
// pause before next value:
delay(500);
}
}
Output of the above program will be as shown in figure given below.