Thursday, December 7, 2023

What is NOT Logic Gate



What is logic?

In digital we define some conditions of anything in two states that are 0 and 1 for example switch conditions possibly open and close so in digital it will be 0 and 1 respectively Same as down up, left-right, off ON and false true, etc.

Due to the electronics field, we deal with current and voltages so according to the voltages we have two levels as shown in the following.


Now here we will discuss the NOT Logic.

NOT Logic Gate

NOT Gate performs the function to invert the logic. If the input is 0 then the output will be 1 and if the input is 1 then the output will be 0.

Symbol of NOT Logic Gate


Truth Table

we can understand the NOT (inverter) function by a simple electrical circuit.

 
S1 close LED will be OFF
S1 open LED will be ON

RTL of NOT Gate 

Resistor Transistor Logic (based circuit)

by using the switching mode of the transistor to understand the

working of RTL NOT gate.

working of RTL NOT gate.

Input 0: Q1 will be in off condition and current flow toward output through R1 means output 1.

Input 1: Q1 will be ON and current flow through Q1 and R1 and ground. Max voltage drop across R1. (VCE = VCC – ICRC) and the output will be 0.

CMOS (basic circuit is) NOT gate 

CMOS is Complementary to MOS which means in this logic NMOS and PMOS twice are used. CMOS basic circuit is NOT gate.

If input A=0:

When input A=0 then PMOS will be ON and NMOS will be OFF and the current flows through output so output logic = 1.

If input A=1:

When input A = 1 then PMOS will be OFF and NMOS will be off Now current flow through PMOS and output so the output is 0.

Read More

Wednesday, December 6, 2023

Water Level Indicator Digital Logic Design based with Alarm

 

Water Level Indicator Digital Logic Design based with Alarm

What is a Water level Indicator?

A water level indicator is a device used for an indication of the water level in the water tank. So that the operator of the water pump knows the level and operates the motor to fill it again or take any particular required action.

Application of Water Level Indicator

Mostly this device is used as an assignment for Digital Logic Design students to complete. But this is very useful at the domestic level as well as for small industry for to automate the water level of water tanks.

Water level indicator circuit story

Here we have used only the logic gates game to complete this Project. It was very complicated to make the logic in the scenario of the water tank.

look at the scene here

Water level sensor

Water Level Sensor

we have used PVC pipe in the tank and adjusted wires according to the diagram of the tank. all wire connections are terminated at PNP Transistor 3906 Q1, Q2,Q3 and Q4 base terminal through resistor.

Water level sensor principle 

GND wire is in the bottom of the tank and other wires are at different water levels. when any level wire connects with GND through water then that PNP transistor switches ON and current flow through the emitter to the collector Max voltage drop across the 1k ohm resistor at the collector. 
when the water level drops from the wire approximately 0 voltage appears across a 1k ohm resistor.
So now it's simple to make the logic that could be in the form of DLD, any Microcontroller, Arduino, etc.
So here we are making the logic of the water tank.

Truth Table

When the Tank is at 0% (empty) the Motor will start using NAND Logic and stop when the tank will touch 100% (Full).

DLD based Water level Indicator with an alarm

The motor is not only dependent on the NAND gate because if the level drops from 100% then again motor will start but we want to ON the motor again at 0%. So we apply NAND output at the input of D Flip Flop. Now the rising edge is required to pass the logic.

For the D-FF clock signal we use the AND gate and NOR gate at the same inputs (Table of all Gates is given above Table) 
see the working
At 0% NAND gate sends logic 1 at D and at the same time, XOR will send an enable rising signal to D-FF So the output of D-FF will be high due to which the motor starts by the motor driver circuit. The motor will remain ON until the status of D-FF is changed. 
So Now when the tank reaches 100% of the level the NAND gate sends 0 at D-FF and again XOR gate will send the rising signal at the clock and D-FF will transfer 0 at output and the motor will stop until again status of D-FF changes. The status of D-FF will change at 0% or at 100%.

ALARM: The alarm will start by NOR Gate Output because here water tank is at 0%.

Motor Driver Circuit

Motor Driver Circuit


D-FF output terminated at R5. An NPN transistor 3904 uses BJT as a Switch to operate the SPDT relay to drive the motor. 

Water Level Indicator 

Water level Indicator

LEDs are used to indicate the percentage level of the water. All LEDs are connected with respective water-level transistors through 220 ohms resistors. 

Now here is the full Circuit of DLD based Water level Indicator with an alarm 

DLD based Water level Indicator with an alarm

 
Read More

Sunday, November 26, 2023

The falling edge detection code Using PIC16F877A and MikroC Compiler

The falling edge detection code for PIC16F877A and MikroC Compiler

The falling edge detection code Using PIC16F877A and MikroC Compiler

Edge activation is very important for counting or any enabling application. so here we are going to discuss falling edges to activate or detect the falling edges. This is a very important example we are sharing with all.
counter count on falling edge (press the button it will not count but when the button is released then counter increment or decrement depending on the application.

Related topic:

I have discussed the falling edge issue in this topic too, but the given topic is on Multiplexing of 7 segments.

Falling edge detection is very tough for electronic players so we are going to solve this problem in coding by using the compiler MikroC pro for PIC16F877A and Simulate it on Proteus 8.15 for testing.

What is Falling Edge?

The falling edge of the clock means that when the clock pulse goes to low from high level that makes high to low a shorter time edge. You can be seen here in the diagram as illustrated.

falling edge of the clock

On the way, we will also discuss the multi-press problem solution for the button here. 

What multi-press of buttons?

For example, we have created a counter application circuit using a PIC microcontroller and wrote the code to Count up when the push button is pressed. here is the problem when we write a simple code. we press one time but the microcontroller reads it many times and the counter scrolls up many numbers with a single click.

Code chunk example:

while(1){
if (button ===1){
counter++;
Lcd_Out(1,1,counter);
}
}

Multipress Problem:

In starting coding experiments I used delay before counter++  to solve this problem but it was not as practical as I wanted or you wanted to. then I have to use a method that works perfectly on the edges of the clock and also resolve the multipress problem.
Here we are sharing with you all. 

See the results here using Proteus 8.15 Simulations:

Proteus Oscilloscope


Circuit Diagrams

The falling edge detection code for PIC16F877A and MikroC Compiler

You can download the circuit in PDF format:
 

MikroC Coding Chunk:

while(1)
     {// UP counting using Falling Edge
      led=0;
      if(up==1){up_pr++;}
       // Here is a technique when we press the button then
       // increment in an int variable
      if(up==0 && up_pr>=1)
      // Now here apply the condition when (button depress
      // and up_pr>=1) then apply the action function as under
        {count++;led=1;Delay_ms(100);up_pr=0;}

      // DOWN counting using Falling Edge
      if(down==1){down_pr++;}
      if(down==0 && down_pr>=1){if(count>0){count--;}
                               down_pr=0;}

      if (rst==1){count=0;} // Reset the counter

So by this, I have Solve the Problem ..... Enjoy

Happy Emoji



Read More

Sunday, November 5, 2023

Scrolling text on Dot-Matrix Using PIC controller & MikroC Pro



Scrolling text on Dot-Matrix Using PIC controller & MikroC Pro

Scrolling text on Dot-Matrix Using PIC controller & MikroC Pro

 Dot Matrix is the combination of LEDs in Matrix form in different sizes. Dot Matrix LED display use to display any type of text on it, but on 7 segment we can display digits only. We can see the Dot Matrix Display in marketing for advertising and in other different application to display some text.

Related Topic: 

So here we are sharing the scrolling text on dot matrix. MikroC Pro for PIC is use for coding and compilation and Proteus 8.15 is use for simulation for circuit testing.

Dot-Matrix concept:

Dot Matrix PINOUT

Working of dot matrix:

Here we are using common cathode dot matrix, it means the Anodes of the LEDs are common with columns and cathode with rows as you can see in above 1st diagram.

If we want to ON top left dot, then we will do column 1 high and row 1 low. Here if we will scan columns and row 1 low all others row at high then top row of the matrix will glow one by one from left to right. Wise versa if we scan rows and select to high one column then selected column dots glow one by one.

Interesting this is that if we increase the scanning speed and cross the human eye flickering sensitivity then we see a line of row or column.

Circuit diagram:

Circuit designed in Proteus8.15

Scrolling text on Dot-Matrix Using PIC controller & MikroC Pro

MikroC Pro for PIC Coding:

/// Dot Matrix 5x7 using PIC ///
/// by Elektronics Garage    ///
/// Date: 4 Nov 2023         ///

//Dot_Matrix size
unsigned int columns = 10;
unsigned int rows = 7;
unsigned int loop=0;
unsigned int col=0;
unsigned int row=0;
int int i,j;
unsigned int col_num[] = {0x01,0x02,0x04,0x08,0x10,0x01, 0x02, 0x04, 0x08, 0x10};
unsigned int row_A[] = {0x01, 0x76, 0x76, 0x76,0x01,0xFF,0xFF,0xFF,0xFF,0xFF};
unsigned int row_B[] = {0x00, 0x36, 0x36, 0x36,0x49,0xFF,0xFF,0xFF,0xFF,0xFF};

void main() {
TRISB=0x00;
TRISD=0x00;
PORTB=0x00;
PORTD=0x00;

col=columns-1; 

while(1) {

for (j=0;j<300 delay_us="" else="" for="" i="" if="" j="" loop="" portb="col_num[col-i];" portd="row_A[row];" row="loop;">col-1){loop=0;}
}
}

Read More

Sunday, October 29, 2023

Interface 7 Segment 4x1 with PIC controller using PIC controller

Interface 7 Segment 4x1 with PIC controller using PIC controller

Interface 7 Segment 4x1 with PIC controller using PIC controller

7 Segment display use to display the values in form of digits. So it’s important to learn 7 segment and how to drive single 7 segment using different controllers and that code programs in different compilers. The basic Concept remain same. So here we are going to drive 4 digit 7 segment using PICcontroller and compile it working code in MikroC pro for PIC.

After coding compilation its important to test it on circuit so we use Proteus 8.15 for simulation.

For types of 7 segments see this topic:7 Segment Interfacewith PIC Microcontroller as Up Counter

4 digit 7 segment in Proteus:

4 Digit 7 Segment
4 Digit 7 Segment


PINOUT of 4 digit 7 segment:

4 Digit 7 Segment Pinout

Example to Display the 4 digits value:

1234 is value for example:

4 is at unit position

3 is at 10th position

2 is at 100th position and

1 is at 1000th position

When we will display 4 then we select unit digit by using pin DG1 and send the data of 4 (in form of binary which drive the 7 segment)

See this table:

Digit

Dp

G

F

E

D

C

B

A

Hex

0

0

0

1

1

1

1

1

1

0x3F

1

0

0

0

0

0

1

1

0

0x06

2

0

1

0

1

1

0

1

1

0x5B

3

0

1

0

0

1

1

1

1

0x4F

4

0

1

1

0

0

1

1

0

0x66

5

0

1

1

0

1

1

0

1

0x6D

6

0

1

1

1

1

1

0

1

0x7D

7

0

0

0

0

0

1

1

1

0x07

8

0

1

1

1

1

1

1

1

0x7F

9

0

1

1

0

1

1

1

1

0x6F

 

And we are using decoder 74LS138 Mux IC to select the 7 segment digits and saving the pins of controller. We are using Just for 4 output control red blocked area of the table.


74LS138 Decoder IC

When we will display 3 then we select 10th digit by using pin DG2 and send the data of 3.

When we will display 2 then we select 100th digit by using pin DG3 and send the data of 2.

When we will display 1 then we select 1000th digit by using pin DG4 and send the data of 1.

Circuit Diagram:

Interface 7 Segment 4x1 with PIC controller using PIC controller

MikroC coding:
/// Multiplexed 7 Segments ///
/// Eleltronics Garage     ///
/// By: Fayyaz Hussain     ///
///   29 Oct, 2023         ///

int count=0;
void counter();

int up_pr=0,down_pr=0,digit1=0,digit2=0,digit3=0,digit4=0;

// Array of 7 Segment display decoder
unsigned int seg_num[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};

sbit up at RD4_bit;  // Up count Button
sbit down at RD5_bit;// Down count Button
sbit rst at RD6_bit; // Reset to 0 button

sbit A at RD0_bit; // Decoder 74LS138 IC INPUT A,B
sbit B at RD1_bit; //

void main() {
TRISB=0x00;
TRISD=0xF0;
PORTB=0x00;
PORTD=0x00;

while(1)
     {// UP counting using Falling Edge
      if(up==1){up_pr++;}
      if(up==0 && up_pr>=1){count++;up_pr=0;}
      
      // DOWN counting using Falling Edge
      if(down==1){down_pr++;}
      if(down==0 && down_pr>=1){if(count>0){count--;}
                               down_pr=0;}
            
      if (rst==1){count=0;} // Reset the counter

counter(); // function to define digits position
     // Unit position Digit
     B=0;A=0;
     PORTB=seg_num[digit1];
     Delay_ms(2);
     // 10th position digit
     B=0;A=1;
     PORTB=seg_num[digit2];
     Delay_ms(2);
     // 100th position Digit
     B=1;A=0;
     PORTB=seg_num[digit3];
     Delay_ms(2);
     // 1000th position Digit
     B=1;A=1;
     PORTB=seg_num[digit4];
     Delay_ms(2);
     }
}

void counter()
{
digit1 = count%10;
digit2 = (count%100)/10;
digit3 = (count%1000)/100;
digit4 = count/1000;
}
Read More

Important Artical

Popular Articals

Total Page views in This Month

© 2019-20 Electronics Garage. Designed by Uzma 0101 & Distributed by elektronicsgarage1.blogspot.com