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.

Counter programing in 8051 using asm language

Status
Not open for further replies.
Hmm... I got that. But I have three questions.

A two wheeler vehicle cannot stand all by itself. It needs atleast 3 wheels to make a tripod. So how is your wheel formation???

Is the 9v battery you are using is a single solid one or it is a pack of multiple cells such as 6x1.5v AA types???

As you said your motor runs on 3-6v that means any voltage between 3v to 6v can do???
 

i will be doing something like this:https://www.google.co.in/search?q=l...nics.com%2Flfr-using-transistors%2F;3487;2493
the image here is actually bigger one mine will be even smaller.
yes 9v i am using is single solid one.
the shopkeeper showed me the dc motor which ran on 3v i.e aa-cells with 1.5v each connected in series so=3v yes it ran very properly on 3v.

- - - Updated - - -

but as i was doing the setup and as i told you that i will not be using hbridge or microcontroller i want to do it strictly on transistors only(just for fun) so when i operated transistor as switch then the motor switched on and switched off properly but the transistor got very hot..i had used bc547.
then i replaced transistor with 2n3904(npn) thinking that it has higher capability to withstand but,it toooo didnot work(i.e it too got heated a lot)so, what do you think might be the reason or should i try with some other kind of transistors?? i had even not placed a diode across the motor is that the sole reason for the transistor getting heated up??
 

Power dissipated by a transistor is the product of the potential drop across CE and the current flowing through it. For a typical silicon transistor, Vce is around 0.7v. If its getting hot that means a lot of current is drawn by the motor. This heat is obvious. BC547 & 3904 differs just with their gain factor. Their power capacities are almost same. If you think your transistors could burn, then you can use one of TO220 casings such as TIP33A. Did you added proper resistance to the base & collector???

Its better to add a diode across the motor. See if it helps.
 

i have not calculated any resistances values by using formulaes but, i just by trial & error i made changes in the circuit till transistor behaved as a switch.
i will try completing the line follower & i will be back if any difficulty.
another question: can we make a pov without using sensor??? one of my friend has done pov without using sensor no matter he has got the display properly but,...i am in a fix he might have had many many mathematical calculations in his programing right???
 

To do a POV, you need to know the RPM. If you can use a motor with known & precise RPM, like a stepper motor, you no need to use any sensor. DC motors like this used in cassette players have fixed RPM, I guess. That's why they can keep a constant speed in playing an audio.

**broken link removed**
 

i am unable to convince myself that i can dispaly properly without sensor. Because sensor will tell uc from where it should start displaying and this will help me at which part of circum i have to display what. I want to discuss more about this topic.Ok let me consider i know the rpm of motor and i haven't used the sensor let us say 60ms is the time taken for total rotation. As soon as i power the microcontroller it starts displaying the names/letters. i start fan after this and then within the program i have given a 15ms delay and after 15ms delay all leds should light then you mean that anywhere in the space they may light need not be 1/4th of the circumference(though i want to display at 1/4th of the rotation).In such cases we have no provision to select the place where we want to display right??? have i got it right???
 

You are right... To start a display from a specific point we need a reference, and that reference is directly or indirectly relates to a sensor. All such POV projects I have seen had always used a sensor, mostly IR. In your project you had seen that any text you are displaying is stretching wide to left. This is because of an unstable RPM of the fan. Even if you stable it, the text will start to appear from anywhere without a sensor.
 

yes yes that stretching of the words was because of small un stability of fan's speed and also i actually did it purposely because when i was shooting for the video at the start i pressed the first speed on fan and then after sometime i pressed the second speed on the fan so it looked stretched.
any way i will get back to you about the line follower later.
i had a minor doubt about PSW register as you know that PSW register as shown here:https://www.circuitstoday.com/wp-content/uploads/2012/01/Processor-Status-Word.jpg.
our poffesor gave an ex i.e
Code:
org 0000h
main:
mov a,#9ch
add a,#64h
end
and later he asked us the status of the flag bits in PSW register.
my answer was:cy=1 ,ov=1,p=1
but, he said that AC flag is=1 because when adding two above numbers i.e 9ch & 64h :
d7 d6 d5 d4 d3 d2 d1 d0
9ch= 1 0 0 1 1 1 0 0
+64= 0 1 1 0 0 1 0 0
= 1 0 0 0 0 0 0 0 0
as seen above there is a carry when adding from d3 to d4 and due to this AC flag will be set how???
d3 and d4 of ""PSW"" are use to select the register banks right??? can you explain me when AC flag is set high???
 

Here d3 & d4 doesn't refers to the bits of PSW register. d3 & d4 are the bits of the register in which you are performing the addition, here the accumulator 'a'. At the time of addition there are possibilities of having an unsigned integer. If that integer carries from d3 to d4, the AC overflows. This is because d0 to d3 (lower 4 bits) are lower nibbles. If this low nibble overflows, the AC is set. I am not sure why this facility is present, but it exists from the time of 8030 or maybe far back. I guess it relates to the previous 4bit processing back to 60's (4040). I could be wrong.
 

exactly i too tried convincing professor that d3 & d4 bits which he made us write while performing the addition operation are bits of accumulator and not that of the PSW.
I do not know whether i am right or no but,i tell it.
By default register bank0 is selected when may be our program exceeds to much far that it occupies the whole register bank0 space then automatically bank 1 is selected and then automatically bank2 and then finally bank3 is selected. Now carry is generated from d3 to d4 because decimal no 3 in binary =11(i.e rs0bit=1,rs1 bit=1) and at this time the AC bit is set high.This is the way i have tried convincing myself i discussed the same point with my professor he told it is right but.... still he said that the addition what we have performed above with d3 , d4 bits are of PSW and not of accumulator. I really don't know whether he has understood it or not. Did u get my point?

- - - Updated - - -

exactly i too tried convincing professor that d3 & d4 bits which he made us write while performing the addition operation are bits of accumulator and not that of the PSW.
I do not know whether i am right or no but,i tell it.
By default register bank0 is selected when may be our program exceeds to much far that it occupies the whole register bank0 space then automatically bank 1 is selected and then automatically bank2 and then finally bank3 is selected. Now carry is generated from d3 to d4 because decimal no 3 in binary =11(i.e rs0bit=1,rs1 bit=1) and at this time the AC bit is set high.This is the way i have tried convincing myself i discussed the same point with my professor he told it is right but.... still he said that the addition what we have performed above with d3 , d4 bits are of PSW and not of accumulator. I really don't know whether he has understood it or not. Did u get my point?
 

How old is your professor??? Its the problem of most of the institutions in our country, where professors just memorizes some facts, but understands little. And so do the students. They got no other options. This is because they just refer to small & easy books where infos are limited. Please don't take it other way. I am not insulting your professor! Maybe right or wrong he is the one who educates you. I am talking about our education system. Even, I have less knowledge in engineering than you.

You think yourself, if the addition is done on PSW register, lots of flags and register banks are disturbed. Only the user defined bit 1 is allowed to be change manually. Rest all bits are changed by the processor itself. These bits are supposed to be read to know the status of calculation, not to be written.

You give this code to your professor to solve it..

Code:
org 0000h
main:
mov r0,#15h
mov a,#9ch
add a,#64h
add a,r0
end

If he says value in 'a' is 15h, then ask him how this happened, because by his own logic this addition is changing the register bank. After then r0 is added. So by default r0 will be 00h and thus 'a' = 00h. In real, accumulator will be 15h.
 

i do agree with your point because i may be having knowledge in programing a bit here & there after learning some concepts i wrote program on POV of course with your help also and i am now in 4th sem and microcontroller is the subject for this sem. I am very much interested in studying deep in uc but our proffesor gives limited knowledge(he is a new proffesor) that is why i clarify my doubts asking you or may be by seeing some videos.

- - - Updated - - -

this is the best video i have got on importance of ac flag :www.youtube.com/user/EnggClasses/videos?view=0&flow=grid
see the video on deciaml arithmetic and importance of auxillary carry flag
 

Its okay... If he is new, he needs some experience. The key factor is that you keep learning from anywhere you can. Google is a best friend! :wink: Never rely on just the syllabus. Its nothing!!!
 

ya ya i agree with you that's what i said that, i tried convincing him but in vain..:-x
 

This video is really helpful. I have seen some tutorials of EnngClasses before. They explain things very clearly.
 

hmmm..ya i got this video yesterday after i asked you the question about uses of AC flag bit
 

we know that in 8051 the memory location starts form 00h to 7fh.
out of these 00h to 1fh is byte adressable that are nothing but register banks.
20h to 2fh that are bit addresable and remaining 30h to 7fh are both bit as well as byte addresable(gneral purpose or also called as stack).
so my question is how to we access 20h to 2fh i.e bit addresable memory?? what are the instruction i don't find any on google.
like we know
Code:
setb p0.0
setb p1.0
etc.
but what is the instruction set for bit addresable memory
 

Instructions like SETB or CLR addresses a specific bit only. Refer to the following link for the RAM map.
**broken link removed**

To access any specific bit between 20H to 2FH, simply use a direct addressing referring to the bit address. Example SETB 01H. It will simply set the bit 1 of 20H in the ram memory. But if you write MOV 01H,#1H, it will not set the bit 1 of 20H because MOV or ADD addresses to a byte, not a bit. 8051 automatically interpret the instructions and decides whether the given hex address is for a bit or byte.
within 20H to 2FH, if you are addressing a specific bit, use the bit's respective address from the map (00H,01H,02H,....,7FH). If you are addressing a byte, use addresses like 20H, 21H, 22H,....,2FH. Microcontroller will automatically understand it.
 
thanks :p the website was very helpful
Code:
org 0000h
main:
setb 01h
setb 02h
setb 03h
setb 04h
sjmp main
end
is this correct??? then will the output of address location of 20h=1,21h=1,22h=1,23h=1,24h=1
 

You follow the map. 01H,02H,03H & 04H are consecutive bits of 20H byte. So byte address will not change.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top