Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

pic 16f877 with keypad

Status
Not open for further replies.

PA3040

Advanced Member level 3
Joined
Aug 1, 2011
Messages
883
Helped
43
Reputation
88
Reaction score
43
Trophy points
1,308
Activity points
6,936
Dear all

please advice me how may I scan and recognize witch number press from
the key board ( 0 to 9 ) connected to portb

my most prefer language is assembly
 

Dear all can we use A/D converter to recognised the key in key pad
that mean, each keys has unique resistance
can somebody explain it more

thanks in advance
 

Hi,

See this Microchip pdf, tip #7.
https://ww1.microchip.com/downloads/en/devicedoc/40040b.pdf

Basically the resistors to each key form a potential divider from the 5V supply to the adc i/o pin.
You carefully select the values to create an suitably spaced voltage for the 16 keys across the 5v range, so when you read the keys voltage into a ADC port you can work out which key was pressed.

When selecting your resistors ensure you have a total of at least 2k for any key otherwise you will risk shorting out the +5v rail.
Electronics 2000 | Potential Divider Calculator
 
  • Like
Reactions: PA3040

    PA3040

    Points: 2
    Helpful Answer Positive Rating
Dear wp100
Thanks for reply

as per this method, if resister or supply voltage will changed how MCU recognise actual key
 

Hi,

It would take too long to explain it all here.

You first need to do some basic tests with a simple adc routine using a 10k pot as the input source, so you understand how it works, then the answer for you keypad should become clear.

Have a look at that Winpicprog ADC tutorial which gives a good description of the software.
However his extra ADC input hardware is not needed for a simple voltage test, just feed the 10k pots slider directly to the adc pin.

Also see this sites ADC lesson
**broken link removed**
 

Dear All
what is the most precise method to recognize a key in the key pad in between AD converter and
PORTB change( interrupted ) methods
Thanks in advance
 

Dear all
if we configure portb as input
then we
movlw 0xff
movwf portb

and then read the port
movf portb,w
movwf result ; result register

so in MPLAB SIM result is
result = 0x00
but anther simulator (PIC SIMULATOR IDE) result is 0xff

PLEASE ADVICE
 

Hi,

To set the Port to Input or Output you use the TRIS instruction.

banksel TRISB
movlw 0xFF
movwf TRISB
banksel PORTB

movf PORTB,W
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top