create variable delay using rc

General discussion on mikroBasic PRO for 8051.
Post Reply
Author
Message
Roshan8051
Posts: 2
Joined: 09 Feb 2021 10:59

create variable delay using rc

#1 Post by Roshan8051 » 18 Nov 2021 08:45

Hi !
I am trying to create variable delay using R & C. (using 89S52)

where C is fixed value = 100NF & R is variable 100K resistor.

time range maximum 1 second

attaching my code but not getting success. also Attaching image

Code: Select all

program MyProject
' Declarations section
dim speed as longword
dim i as longword
dim rcin as sbit at P2_7_bit

main:
'   Main program 
p2 = $00

while true

'   Main program
    p1 = $ff
    gosub delaymy
    p1 = $00
    gosub delaymy

wend

delaymy:
        p2.6 = 1      'send pulse to discharge cap
        delay_ms(20)  '
        p2.6 = 0      'turn off pulse
'as cap will charge rcpin will goes low
'in that time increment one variavle
        while rcin = 1
        speed = speed + 1
        wend
        

      for i = 0 to speed
      delay_ms(10)
      next i

return


end.

Attachments
rc.png
rc.png (32.16 KiB) Viewed 1608 times

Post Reply

Return to “mikroBasic PRO for 8051 General”