Discussion in "Project Help" started by    diya    Sep 5, 2007.
Wed Sep 05 2007, 01:14 am
#1
Hello everyone, this is my first post , so i need help plz.

Im taking this assignment also , and i realy need help on the coding part.
this is the schematic (updated) :



what i knew from my friends threads , is that we have to do the basic part first, like 7-segment,ADC,fan control. then we go to the second part of programing , where we have to do the manual and auto part.

ok, first of all lets begin with the fan control and the switsh part.
* the fan is connected to P3.3 (INT1).
* the switsh is connected to P3.4 (T0).
* i'v read about the PWM , i understod the theoretical concept, but i didnt understand the PWM code, how does it work , and by the way is it for P3.4 or P3.3 ?.

and just to remind u , programing is tedios for me , so pleeeez i need details.

thank you for helping
 sean theara like this.
Wed Sep 05 2007, 01:41 am
#2
also , i didnt write any codes yet , i dont know how to start !

plzzzzzzz help me !
Wed Sep 05 2007, 01:58 am
#3
manual and auto comes at the end.. when you make the final interface..

the PWM code is simple...
you have a value in R7 which set the Pulse width.. i.e time for the pin to be high..
so the value is loaded into timer registers and timer starts.. when it overflows.. an interrupt occurs.. it jumps to interrupt service routine and check if the high part of the pulse is over or low..
if high is over then its the time for low of the pulse..
so it loads the value 255-R7..
because total time is 255, if R7 is high then low is 255-R7.
So it loads the timer registers with 255-R7 value and again run the timer.. and wait for next overflow.. and on next overflow everything repeats again..

This is what going on in the code.. please take a look at the code carefully to understand it better
read all the discussion carefully and try to do something
 Light like this.
Wed Sep 05 2007, 02:53 am
#4
thxx for helpin.
I'v read all the discussions.
---------------------------------------------------------------
org 0H
sjmp start
org 0BH
TIMER_0_INTERRUPT:
JB F0, HIGH_DONE ; If F0 is set then we just finished the high section of the
LOW_DONE: ; cycle so Jump to HIGH_DONE
SETB F0 ; Make F0=1 to indicate start of high section
SETB P1.0 ; Turn off LED
MOV TH0, R7 ; Load high byte of timer with R7 (pulse width control value)
CLR TF0 ; Clear the Timer 0 interrupt flag
RETI ; Return from Interrupt to where the program came from
HIGH_DONE:
CLR F0 ; Make F0=0 to indicate start of low section
CLR P1.0 ; Turn on LED
MOV A, #0FFH ; Move FFH (255) to A
CLR C ; Clear C (the carry bit) so it does not affect the subtraction
SUBB A, R7 ; Subtract R7 from A. A = 255 - R7.
MOV TH0, A ; so the value loaded into TH0 + R7 = 255
CLR TF0 ; Clear the Timer 0 interrupt flag
RETI ; Return from Interrupt to where the program came from
start:
MOV TMOD,#00H
SETB TR0 ; turn on timer 0
SETB EA ; Enable Interrupts
SETB ET0 ; Enable Timer 0 Interrupt
MOV R7, #160 ; set pulse width control to dim
LOOP:
SJMP LOOP ;go to LOOP
END
----------------------------------------------------------------

this is ur code from (cenadius ) post.
Q1\ is this is the full code for the PWM ?

now... this code will be applied to P3.4 (the SW-SPDT) , so when we press the (SW-SPDT) it will give high (or low) , then depending on the value givin to R7 (on the code) the value of Vo will be sent to P3.3 ( the fan control pin), and the fan speed will vary depending on the value givin to R7 ( the Pulse width).

Q2\ is this explanation is correct ?
i need to "mix" the reality with the code to understand :-)

Q3\ is this code going to be the TOP code for the whole program ?

note : we r using (T0) in this project

Ajay , thank u for ur helping, i realy appreciat it
Wed Sep 05 2007, 03:00 am
#5
answering your questions one by one...

A1. Yes this is the full code for PWM only!!!. This is actually a demonstrative code which is actually fully applicable in your project..

A2. The explanation is somewhat correct.. the thing is.. the above code as i said is a demonstrative code.. so you need to change the port pins.. like in above code.. P1.0 is the pin on which PWM is generated where as your FAN is connected to P3.3 so you need to change P1.0 to P3.3.. Also there is no use of switch here.. This is just for PWM nothing else..

A3. This is just a part of the whole thing.. this program is just to control the speed of FAN nothing more than that rest of the code you need to write.. also.. you need to think how to arrange the code orderly..

And it uses Timer 0 for PWM, you can see the code
 Light like this.
Wed Sep 05 2007, 03:21 am
#6
Thx for ur "great !" answers. now i understand why and how to use PWM :-) .

now lets move to ( DAUL 7-segment), were we have 4 cathod COMs.
can u give me the basic idea , i want to try to type the code by my self (expect aloot of errors :-) )

take care
Wed Sep 05 2007, 03:34 am
#7
sure.. basic idea is..
like you have a number.. say 45
first you need to separate this number into 4 and 5 and then send it to display one by one..
first send 10's place which is 4 and then activate that 7-seg after some time deactivate it.. and then send 5 on the same port activate the 0's place second segment and after some time deactivate it...

separating them.. is explained in cenadius's thread.. you can check.. and decoding is explained in the forum.. here http://www.8051projects.net/forum-t1410-post.html
Wed Sep 05 2007, 09:16 pm
#8
hi,

i wrote the program to display 45 on the 7-segment :



i tried to do the 7-segment code for the assignment , but i couldnt

Q1\ how can u make the 7-segment get the temperature from 8051 and display it continuosly ?
Q2\ i dont know what you mean by decoding the 7-segment , and why we need it , and how to make it ?

sorry but that is what im capable to do :-(



Wed Sep 05 2007, 09:25 pm
#9
i didnt write the time do activate and deactivat the first and second displayer continuosly.

Q3\ how and where to write it :-) ?
Wed Sep 05 2007, 09:39 pm
#10
you need a delay in between activation and deactivation of 7-segment.. you can try changing the delay routine as per your need. if you see flickering in the display reduce the delay..

delay:
     mov r5,#50H
back:
     mov r4,#0FFH
     djnz r4,$
     djnz r5,back
     ret


you might need to increase or decrease the delay according to the results.. change the value in R5 to see how display is coming.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am
ArnoldDiant
Fri Apr 26 2024, 03:53 am
RodneyKnorb
Thu Apr 25 2024, 07:08 pm
Williamjef
Thu Apr 25 2024, 02:08 pm
SamuelSmise
Thu Apr 25 2024, 09:56 am
DustinErele
Thu Apr 25 2024, 08:44 am