Discussion in "8051 Discussion Forum" started by    neil03    Aug 5, 2009.
Wed Aug 05 2009, 03:33 PM
#1
hi im working on a PWM signal output from a microcontroller using at89c2051.
The status of my project is that I successfully produce the desired PWM signal but, my problem is I cannot stop the process of stopping the PWM signal when I switch it to stop.
____________________________________________________________________
The algorithm of the program is simply like this

1. when switch 1 is pressed the microcontroller produce a PWM signal
2. when switch 2 is pressed the micrcontroller stop producing the signal or clearing the output pin of the MC.
____________________________________________________________________
Now as I have said above I successfully produce the desired PWM signal but when I switch it to stop. The PWM output pin remains to produce the PWM signal..Honestly this program is really working previously and I have used this program several times ago but now when I try to burn it on a new microcontroller it doesnt respond to its previous state.. I also try to change different at89c2051, 3 mc to be exact, but still im getting the same problem..
Im thinking that the maybe the programmer have a defect or something, but im not so sure and I dont want to take the risk of buying a new programmer cause it costs alot.

Can anybody help me to find what is the problem causing this and please teach me to resolve it..I have attach the program and the schematic of my project. please help me people thank you so much.
 switch1   EQU P1.2     ; switch for PWM
 switch2   EQU P1.3		; switch for stop PWM signal
 PWMPIN    EQU P3.4      ; PWM output pin 

ORG 00H
SJMP Main

org 0BH ;Vector address for Timer0
AJMP TIMER_0_INTERRUPT ;jump to ISR routine

;Main code
Main:
JB  P1.2, PWM_INI ; go to PWM setting 1
sjmp Main

PWM_INI:         ;initiate PWM
acall PWM_SETUP 
here:
JB   P1.3, STOP;
SJMP here ;

STOP:
clr PWMPIN
sjmp Main;


PWM_SETUP:
        MOV TMOD,#00H           ; Timer0 in Mode 0
        MOV R7, #240            ; Set pulse width control
        ; The value loaded in R7 is value X as
        ; discussed above.
        SETB EA         ; Enable Interrupts
        SETB ET0                ; Enable Timer 0 Interrupt
        SETB TR0                ; Start Timer
        RET

TIMER_0_INTERRUPT:
        JB F0, HIGH_DONE        ; If F0 flag 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 PWMPIN             ; Make PWM output pin High
        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
HIGH_DONE:
        CLR F0                  ; Make F0=0 to indicate start of low section
        CLR PWMPIN              ; Make PWM output pin low
        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




END






[ Edited Wed Aug 05 2009, 03:35 PM ]
Wed Aug 05 2009, 03:51 PM
#2
well schematic is not so big to have a problem in it.

You can load a simple LED blink program to see if your controller is fine or not.

I think problem seems to be in program for making it non stop PWM. the reason is.. PWM works with timer so along with clearing of PWM pin, you should also clear TR0, and TF0 so that timer stops and interrupt flags can be cleared. and to start PWM again, you have the init function.

[Topic moved to 8051 Discussion forum]
Wed Aug 05 2009, 10:07 PM
#3
You'll also have to make sure the SW1 switch is off else the pwm generation will start again.
better implement sth like this....
Main:
JNB  P1.2, Main;check if START is pressed
JNB P1.3,PWM_INI ; go to PWM setting 1 if STOP not pressed
sjmp Main

Get Social

Information

Powered by e107 Forum System
Forum Activity
Peter_Parker Avatar
Posted By Peter_Parker
Sat Jul 26 2014, 10:29 AM
Hey guys,Tried using the search button to look for...
pravin_35 Avatar
Posted By pravin_35
Sat Jul 26 2014, 01:34 AM
its reading 0x00 device ID, which means either dev...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Jul 25 2014, 05:37 PM
its reading 0x00 device ID, which means either dev...
ajay_bhargav Avatar
Posted By ajay_bhargav
Fri Jul 25 2014, 05:32 PM
I get it now.. Did not read that part, sorry for m...
PavanKh Avatar
Posted By PavanKh
Fri Jul 25 2014, 01:09 AM
hello everyone ! I'm using SIM900A GSM module to s...
pravin_35 Avatar
Posted By pravin_35
Thu Jul 24 2014, 01:28 PM
Please post a diagram of the board the PIC is moun...
ExperimenterUK Avatar
Posted By ExperimenterUK
Thu Jul 24 2014, 12:52 PM
Please post a diagram of the board the PIC is moun...
pravin_35 Avatar
Posted By pravin_35
Thu Jul 24 2014, 12:08 PM
screen shot
pravin_35 Avatar
Posted By pravin_35
Thu Jul 24 2014, 08:19 AM
What kind of sample code are you looking for? any ...
nisargpatel Avatar
Posted By nisargpatel
Thu Jul 24 2014, 06:35 AM
yes ds1307 keeps time on same crystal 32.76.. but ...

Conversation

ajay_bhargav
Thu Jul 24 2014, 01:06 AM
@R.ABHISHEK where? I dont see it. is it in forum?
Wed Jul 23 2014, 05:49 AM
R.ABHISHEK
sir,pls message on microcontroller 8051 assambly language new program
Wed Jul 23 2014, 05:47 AM
R.ABHISHEK
sir,pls message on 8051 microcontroller assambly language program new quastions
ajay_bhargav
Tue Jul 22 2014, 09:18 AM
@Pragya Android application is taken from google play. Only Author has its source with him. Application is only used in this project.
Tue Jul 22 2014, 04:58 AM
Pragya
plz send me 8051 code and android code for android based device controller via Bluetooth .Here in this project I am using Hc-06 Bluetooth module
Thu Jul 10 2014, 09:57 AM
Caleb
plz someone mail me the source code for that project
Thu Jul 10 2014, 09:57 AM
Caleb
http://www.8051projects.net/download-d188-control-your-pc-tv-remote.html
ExperimenterUK
Tue Jul 08 2014, 03:25 PM
Post questions in the forum.. this area is for chat
Tue Jul 08 2014, 08:15 AM
P.Panchanyam
Sir i want some new ideas for my final year projects ,which would help for our soceity in future
Tue Jul 08 2014, 01:39 AM
jasvinder
Dear Sir Ref. to the discussion held with under sign, the detail is as under--- We are in weighing scale field since 1986. We are assembling the scales by purchasing the material from out source ( From India and other countries). Now we decide to make our own Card in our decided shape. So we want to develop a universal card , which we can make all types of scales of up 100000 counts with 7 segment LED Display . Also with other features like Printing, Counting, RS232 Etc. And Three Pass words at different levels. And we can edit the Softwear. What else you can provide in this field, also mention. We will pay you the development , softwear and testing charges. And up-gradation charges at time to time. Our web site is modern-scales.com Kindly revert.

Downloads

Comments

Imran.pk
Fri Jul 25 2014, 07:50 PM
PavanKh
Fri Jul 25 2014, 12:56 AM
vinosentinal
Mon Jul 21 2014, 08:28 PM
niks_here
Sun Jul 20 2014, 05:38 PM
athiramsankar
Sun Jul 20 2014, 12:00 PM
salemalqahtani
Sun Jul 20 2014, 12:55 AM
nagarajan.electro
Sat Jul 19 2014, 12:49 AM
praru
Sat Jul 12 2014, 07:51 AM

Online

Guests: 47, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 01:37 AM

Members: 37481
Newest member: Imran.pk