Discussion in "8051 Discussion Forum" started by    sks    Sep 19, 2008.
Sat Sep 27 2008, 09:15 pm
#31
Hello Sahuji,

Nice effort !

your 255 counter seems OK, but what happens after the counter has reached 255 ?

and coming to 1000 counter, why are you using DPTR, R registers ( 2 of them ) and Acc.

just follow your first 255 counter (now make it 250 counter) and increment a register after completion of 250 counts , do this 4 times and you have a 1000 counter.

one more thing, after execution of your said task, you have to define the state of Micro i,e should it continue repeating same task (looping) or just stay at particular address.


Pl.note : your counter/s need external or internal "trigger" to increment the count
(can be a pulse from external circuit, a switch, or internal timer)



Arun
 sks like this.
Sat Sep 27 2008, 10:16 pm
#32
Hello Mr Arun,
thanks fr the quick response. as per ur advice i hv modified those two codes, which are pasted bellow. pl see and comment.
thanks again.
sks

; 0 TO 255 DEC COUNTER
;A Push Button Switch is connected to P3.0, and when the button
;is pressed it start counting. After reaching 255 counts
;the counter resets and starts from begin.



ORG 00H

BEGIN:
SETB P3.0
MOV A,#0
PB:
JB p3.0,PB

MAIN:
INC A
CJNE A,#255,MAIN
AJMP BEGIN
END

; 0 TO 1000 DEC COUNTER

ORG 00H
BEGIN:
MOV A,#0
MOV R6,#0

MAIN:
INC A
CJNE A,#250,MAIN

MAIN_1:
INC R6
CJNE R6,#4,MAIN
AJMP BEGIN

END
Sat Sep 27 2008, 10:22 pm
#33
Mr Arun,
Sorry.... i hv forgot to inform u that, i know how to trigger from out side, but don't how to trigger internally. don't know any thing about Timer & Interrupts. pl help

sks
Sun Sep 28 2008, 09:13 am
#34
Hello sahuji,

i have revised (optimised) your 255 counter code, pl.go thru it and your assignment is to revise your 1000 counter on similar lines


ORG 0000H

MAIN: MOV P1,#0FFH
           MOV A,#0

PB:SETB P3.0
     JB P3.0,PB

PP: JNB P3.0,PP    ; THIS INSTR. IS TO COPE WITH SWITCH DEBOUNCE 
CJNE A,#255D,GO    ; CHECK IF COUNT IS ALREADY 255, 
MOV A,#00H
SJMP PB

GO: INC A
MOV P1,A     ; DISPLAY COUNT ON PORT 1 IN BINARY USING 8 LEDS
SJMP PB

END



timers is a vast subject and you need to take your time to learn about them, it better you complete your preliminary exercises before understanding about timers.


Arun


 nischay kumarsks like this.
Mon Sep 29 2008, 02:08 pm
#35
Hello Mr Arun,
Nice to see my Code modified by you, thank u. I have studied the modified code, is it every ACTION should follow a DECISION or every DECISION should follow an ACTION?. u hv assigned me to revise my 1000 counter code, (Now i am sure I can write codes of course by your help) i hv a doubt how can i connect leds in a single port which can display max 255/ffh. shall i display in BCD form? pl clarify.
thanks again
sks
Mon Sep 29 2008, 02:16 pm
#36
Hello Mr pdi,
how r u. r u observing my progress guided by Mr Arun. write some thing to me, u people r so nice.
thanks
sks
Mon Sep 29 2008, 02:46 pm
#37
Hello sahuji,

in my/our above code, the counter advances after you press and release a switch, so for each increment you have to press and leave the switch.

now for the decision or action part, first we have a action (i,e a key press) and then we have a decision (checking if the count is already 255,if yes restart the counter and if no, increment the counter and display on port)

initially you'll have to display on port using 8 leds connected like this:



and switch like this:





later on, you have to convert the hex count to 3 digit BCD and display on 7 seg displays.

BTW have you started working on your trainer board ?


Arun




[ Edited Mon Sep 29 2008, 02:49 pm ]
 sks like this.
Mon Sep 29 2008, 05:17 pm
#38
hello Mr Arun,
thanks fr the fast reply, yes i am using one NSK 8051 kit. i had tested one of my counter code through 8 nos led. it works, but sorry to inform u that that kit don't have BCD to 7seg converter chip, all 7seg data lines are parallel and separate com pins are connected through Transistors. i can write for single digit of course it may not be fully correct. it can count up to 9. what do u mean BTW. thanks again
sks
Mon Sep 29 2008, 11:25 pm
#39


its good that your trainer kit doesn't have Binary to BCD ic 4511, otherwise it would be very easy.

now the set up you have on your trainer is called "Multiplex display", you can look up on this concept in ayala's book (since you are already referring to it).

meaning of BTW is "By The Way"

Arun
 sks like this.
Mon Sep 29 2008, 11:29 pm
#40


Hello Mr pdi,
how r u. r u observing my progress guided by Mr Arun. write some thing to me, u people r so nice.
thanks
sks

sks



hello sks,
yes, i am observing ur progress and u are surely progressing very well ( just as i expected! ).
u are being guided by arun, one of the best programmers, so be sure to learn as much from him as u can. :-) . We all are here to support u and it would be wiser to let one of us guide u at a time instead of too many suggestions being bombarded into ur direction totally confusing u. .
at this rate, i don't think it would be very long for u to complete ur project.
good luck. :-)
 sks like this.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am