Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/06/06 02:47
Modified:
  02/06/06 03:00

Read: times


 
#109257 - schematic and code
Responding to: ???'s previous message
Suresh said:
I too prefer doing it with a microcontroller for accuracy.

But, to my knowledge i thought, i could use an interrupt to start dispensing. and i can program the timer.
But iam not aware of how the Timing could be adjusted manually when a microcontroller is used.

Any suggestions.

You could try the following circuit:


(Pin1 of ISP header goes to P1.7)


This could be the code (not tested so far):


                    $nomod51
                    $include (89s52.mcu)    

                    org 0
            
                    sjmp begin

                    org 002bh

                                            ;initialize
begin:              mov auxr,#00011001b     ;reset pin is input
                    mov tmod,#00000001b     ;timer 0 in modus 1
                
                                          
                                            ;Total delay is
                                            ;number 'z' (BCD- 
                                            ;switches) times
                                            ;10msec delay of
                                            ;timer 0
                                            
                                            ;reads 'start' and
                                            ;BCD switches

start_pressed?:     clr p1.4                ;strobe watchdog
                    mov c,p0.2              ;read 'start'
                    setb p1.4               ;strobe watchdog

                                            ;'start' pressed?
                    jc start_pressed?       ;No!

                                            ;'start' is pressed:            
                    mov a,p0                ;read "1"
                    swap a                  ;eases layout
                    cpl a                   ;true data
                    anl a,#00001111b        ;low nibble needed
                    mov r0,a                ;store "1" in r0
                    mov a,p2                ;read "10","100"
                    cpl a                   ;true data
                    mov r1,a                ;store it in r1
                    swap a                  ;eases layout
                    anl a,#00001111b        ;low nibble needed
                    mov b,#10               ;load #10 into b
                    mul ab                  ;a = "10" x 10
                    add a,r0                ;add r0 ("1")
                    mov r0,a                ;store it in r0
                    mov a,r1                ;now we need "100"
                    anl a,#00001111b        ;low nibble needed
                    mov b,#100              ;load #100 into b
                    mul ab                  ;a = "100" x 100
                    add a,r0                ;add r0
                    mov r0,a                ;low byte in r0
                    mov a,#0                ;carry?
                    addc a,b                ;add carry to b
                    mov r1,a                ;high byte in r1
                        
                                            ;r1=0?
                    jnz activate_relay      ;r1<>0!

                                            ;r1=0!
                    mov a,r0                ;r0=0?

                    jz start_released?      ;r0=0 and r1=0!
                                            ;means z=0!                     
                               
                                            ;r0<>0 or r1<>0!
                                            ;means z<>0!
activate_relay:     clr p0.0                ;turn on relay

                                            ;initialize timer            
timer_delay:        mov th0,#220            ;reload high byte
                    mov tl0,#15             ;reload low byte
                    setb tr0                ;start timer 0
                    clr p1.4                ;strobe watchdog

                                            ;timer busy?
timer_busy?:        jnb tf0,timer_busy?     ;timer busy!

                                            ;10msec delay over
                    clr tr0                 ;stop timer 0
                    clr tf0                 ;clear overfl. flag
                    setb p1.4               ;strobe watchdog

                                            ;decrement z
                    mov a,r0                ;                
                    clr c                   ;
                    subb a,#1               ;a=r0-1
                    mov r0,a                ;low byte of z=z-1
                                            ;into r0
                    mov a,r1                ;carry?
                    subb a,#0               ;
                    mov r1,a                ;high byte of z=
                                            ;z-1 into r1

                                            ;r1=0?
                    jnz timer_delay         ;r1<>0!

                                            ;r1=0!
                    mov a,r0                ;r0=0?

                    jnz timer_delay         ;r0<>0!

                                            ;r0=0 and r1=0!
                                            ;means z=0!
                    setb p0.0               ;turn off relay

start_released?:    clr p1.4                ;strobe watchdog
                    mov c,p0.2              ;read 'start'
                    setb p1.4               ;strobe watchdog

                                            ;'start' released?
                    jnc start_released?     ;No!

                                            ;'start' released!
                                            ;initialize waiting
                                            ;loop
                    mov r1,#103             ;'start' released
waiting_loop_1:     mov r0,#255             ;for 0.2 sec?
waiting_loop_2:     clr p1.4                ;strobe watchdog
                    mov c,p0.2              ;read 'start'
                    setb p1.4               ;strobe watchdog

                                            ;still released?
                    jnc start_released?     ;No!
                                            
                                            ;still released!
                    djnz r0,waiting_loop_2  ;repeat loop 2

                    djnz r1,waiting_loop_1  ;repeat loop 1

                    ljmp start_pressed?     ;'start' released
                                            ;for at least
                                            ;0.2sec!


                    end


Kai

List of 57 messages in thread
TopicAuthorDate
Circuit for dispensing unit            01/01/70 00:00      
   1.1 sec monoshot            01/01/70 00:00      
      this thread is apin off from an earlier            01/01/70 00:00      
         yes            01/01/70 00:00      
         timing circuit            01/01/70 00:00      
   Monostable            01/01/70 00:00      
   Yes.            01/01/70 00:00      
   Hello All            01/01/70 00:00      
      Description of the "Dispensing Unit"            01/01/70 00:00      
         using micro            01/01/70 00:00      
            Microcontroller            01/01/70 00:00      
               Pressure            01/01/70 00:00      
            What must your circuit can do?            01/01/70 00:00      
               0.1 sec            01/01/70 00:00      
                  but not with a potentiometer            01/01/70 00:00      
                     Vernier            01/01/70 00:00      
                        and calibrate it how?            01/01/70 00:00      
               Precision            01/01/70 00:00      
                  Sure!            01/01/70 00:00      
                     Price            01/01/70 00:00      
                        Less than 1€            01/01/70 00:00      
                           levels of precision            01/01/70 00:00      
                              Please have a look into datasheet!            01/01/70 00:00      
                                 somewhere here there is a link            01/01/70 00:00      
                                    Details?            01/01/70 00:00      
                                       I recall that in an earlier thread            01/01/70 00:00      
                              Ooops.            01/01/70 00:00      
                              Blown Discharge PIN            01/01/70 00:00      
                                 You can also let the smoke out of the            01/01/70 00:00      
                                    limits            01/01/70 00:00      
                                       dissapation            01/01/70 00:00      
                                          There must be a point.            01/01/70 00:00      
                                             Fusing the bonding wires            01/01/70 00:00      
                                                History making            01/01/70 00:00      
                                                Current limiting            01/01/70 00:00      
                                 I do go through            01/01/70 00:00      
            schematic and code            01/01/70 00:00      
               codes            01/01/70 00:00      
                  Instruction Description            01/01/70 00:00      
                     not quite            01/01/70 00:00      
                        Pedantic            01/01/70 00:00      
                           is that not the pot calling the kettle b            01/01/70 00:00      
                              Of course not!            01/01/70 00:00      
                  Answers            01/01/70 00:00      
                     Re: codes and shcematic            01/01/70 00:00      
                        Recommendations            01/01/70 00:00      
                           Decimal switches - how to start C            01/01/70 00:00      
      LM555 pin 2 wired wrong.            01/01/70 00:00      
         ... and the LED?            01/01/70 00:00      
            i'm sure thts not the circuit            01/01/70 00:00      
            Astable??            01/01/70 00:00      
               I wondered who'd spot that first...            01/01/70 00:00      
   Damaged?            01/01/70 00:00      
      And Andy's correction            01/01/70 00:00      
         Absolutely!            01/01/70 00:00      
   one shot in the foot            01/01/70 00:00      
      Need not to work unreliably            01/01/70 00:00      

Back to Subject List