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] Single lcd usage- not counting correctly

Status
Not open for further replies.

Kubilay

Newbie level 4
Newbie level 4
Joined
Jun 11, 2015
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
42
DEAR FRIENDS
I'M USING PIC 16F84A, AND CODING WITH MPLAB V8.87 AND I WANT LCD TO COUNT "0" TO "F"
YOU KNOW 0,1,2,...,D,E,F
HERE IS MY CODE
WHAT IS WRONG
IT DOES NOT WORK PROPERLY
Code:
LIST P=PIC16F84A

__CONFIG_XC_OSC

STATUS EQU 0X03
PORTA EQU 0X05
PORTB EQU 0X06
TRISA EQU 0X85
TRISB EQU 0X86
SAYAC EQU 0X0C

BSF STATUS,5
BSF TRISB,0
CLRF TRISA
BCF STATUS,5

CLRF SAYAC
CLRF PORTA

GENEL
CLRWDT
BTFSS PORTB,0
GOTO GENEL
MOVF SAYAC,W
CALL TABLO
MOVWF PORTA
INCF SAYAC,F
GOTO TEST

TEST
CLRWDT
BTFSS PORTB,0
GOTO GENEL
GOTO TEST

TABLO
ADDWF PCL,F ;PCL(program counter) + W >>PCL
RETLW B'00111111' ;segmen data 0 >> W (PCL+0)
RETLW B'00000110' ;segmen data 1 >> W (PCL+1)
RETLW B'01011011' ;segmen data 2 >> W (PCL+2)
RETLW B'01001111' ;segmen data 3 >> W (PCL+3)
RETLW B'01100110' ;segmen data 4 >> W (PCL+4)
RETLW B'01101101' ;segmen data 5 >> W (PCL+5)
RETLW B'01111101' ;segmen data 6 >> W (PCL+6)
RETLW B'00100111' ;segmen data 7 >> W (PCL+7)
RETLW B'01111111' ;segmen data 8 >> W (PCL+8)
RETLW B'01101111' ;segmen data 9 >> W (PCL+9)
CLRF SAYAC
RETURN GENEL

        goto $

        END
 

Please don't use upper case letters, it is considered 'shouting'. What doesn't work properly? Please tell us the symptoms.

Start by copying the template provided by Microchip and add your code to it. Also add comments so we can see what your lines of code are supposed to do.
From what I can see, this has nothing to do with an LCD, did you mean LED ?
If it is an LED, how do you have it connected? You seem to be sending 7 bit segment data to a 4 bit port.

Brian.
 

Hi,

I think there are people, they see that undocumented code and leave your thread.
If you want people to help you... you have to help them first - at least by including some informative dcomentation to your code.

****

how fast do you expect it to count form 0 to F?

Klaus
 

7 Segment Display Counter- Not Working Properly

Dear Friends

I'm using PIC16F84a and MPLAB V8.87. I want to design a 7-seg dsiplay counter, zero to F increase when i push the button.
It's not working properly and i couldn't found the problem.
Problem is its not start from zero and not goes on 1,2,3,4,... instead i see F,8,d,6 or sth like that
Code:
LIST P=PIC16F84A

__CONFIG_XC_OSC

STATUS EQU 0X03
PORTA EQU 0X05
PORTB EQU 0X06
TRISA EQU 0X85
TRISB EQU 0X86
SAYAC EQU 0X0C

BSF STATUS,5 ;BANK1
BSF TRISB,0 ; PORTB,0 input
CLRF TRISA  ; PORTA output
BCF STATUS,5 ;BANK0

CLRF SAYAC
CLRF PORTA

GENEL
CLRWDT  ;not let wdt to reset my program 
BTFSS PORTB,0 ; button makes 1 or 0
GOTO GENEL ;button not pushed
MOVF SAYAC,W ;when button pushed
CALL TABLO
MOVWF PORTA ; change output
INCF SAYAC,F
GOTO TEST

TEST ; to avoid unintended increase when button pushed i made this loop 
CLRWDT
BTFSS PORTB,0
GOTO GENEL
GOTO TEST

TABLO
ADDWF PCL,F ;PCL(program counter) + W >>PCL
RETLW B'00111111' ;segmen data 0 >> W (PCL+0)
RETLW B'00000110' ;segmen data 1 >> W (PCL+1)
RETLW B'01011011' ;segmen data 2 >> W (PCL+2)
RETLW B'01001111' ;segmen data 3 >> W (PCL+3)
RETLW B'01100110' ;segmen data 4 >> W (PCL+4)
RETLW B'01101101' ;segmen data 5 >> W (PCL+5)
RETLW B'01111101' ;segmen data 6 >> W (PCL+6)
RETLW B'00100111' ;segmen data 7 >> W (PCL+7)
RETLW B'01111111' ;segmen data 8 >> W (PCL+8)
RETLW B'01101111' ;segmen data 9 >> W (PCL+9)
CLRF SAYAC
RETURN GENEL

 END                       ; directive 'end of program'

circuit shematic:
circuit.png

thank you
 

look at my last post on this subject...
it is more clear...
 

When you press a button, you may get several (up to hundreds) of pulses.
The mC sees all that and executes all (or most) of them.

Try adding a delay of 50msec after reading the key pressed.

I noticed that you tried to enter something like that with checking for the release of the button.
It is definitely not enough, because you have a lot of pulses on a single press.

Electronicaly, a solution would be to use an RC network on the button, or even better a schmitt trigger input and an RC network, but for economy of time-space-and-money we use software solution for button bouncing.

---

RETURN GENEL???????
Check what happens, if SAYC is increased beyond table limits, what value will be placed on 7seg?
You return a memory address to PORTA on return from TABL0 function... (RETURN GENEL)
So you probably set PORTA to value 00000111 whatever it displays. Was that your intension?
 
Last edited:

Hardware:
1. You are missing a ground connection between the two crystal loading capacitors.
2. You need decoupling capacitors across VSS and VDD
3. It's an LED not an LCD but in any case you only have 4 connections to it. You need 7 plus ground/supply.

Software:
1. You have the LED connected to PORTA but it only has 4 bits, you need 7.
2. Your segment look-up table only has 10 entries, you need 16.
3. You have no debounce on the RB0 input
4. The RETURN instruction takes no parameters. (last line)

If you use the Microchip template you will find it easier to write code.

Brian.
 

Zip and post the complete MPLAB project files and Proteus file if you need some help.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top