Loading ...
Sorry, an error occurred while loading the content.

Re: [jallist] Re: pin_a4 of 16f84

Expand Messages
  • Ziya
    Dear Vasile, Edwin, and Madsen I think due to problem in yahoo mailer, the mail that I have posted arrived 4 days later. I have already solved the problem in
    Message 1 of 15 , Apr 1, 2002
    • 0 Attachment
      Dear Vasile, Edwin, and Madsen

      I think due to problem in yahoo mailer, the mail that I have posted arrived 4 days later.
      I have already solved the problem in way of Vasile and Riaz's suggestions and forgot to inform you. I had no bc547 so I could not try the other suggestion made by Edwin and Madsen. Thank you for all.

      Ziya

      ----- Original Message -----
      From: Vasile Surducan
      To: jallist@yahoogroups.com
      Sent: Monday, April 01, 2002 8:48 AM
      Subject: Re: [jallist] Re: pin_a4 of 16f84



      Ziya, Wolfchild ( I hate pseudo-names on the list ! ) told you perfectly
      the problem you have: HARDWARE
      It's on the rooster mind that never, with an opened drain
      you'll drive a pnp with emiter at +12V in the way you want because you'll
      never be able to saturate the transistor. You have done a current constant
      source with the relay as reference resistor. Apply the Kirchoff law on the
      emiter circuit and you'll understand. If you don't know Ohm and Kirchoff laws
      than you have to learn both.


      If you really want in that way ( and not with a npn connected with base
      directly on pin_a4, a 10k from pin_a4 to +12V, colector to relay and
      suppressor diode, emiter to gnd, the other pin of the relay and diode to
      +12V ) then you should do:

      A 3v3 or 5v1 zenner in series with your relay from +12V. In this way
      you'll be able to shut off the transistor by gaving it the possibility of
      switching off with a -Vbe command. Of course the relay must have then less
      than 12V, better +5V coil.

      best, Vasile


      On Mon, 25 Mar 2002, ziya_erdemir wrote:

      > Dear Madsen
      >
      > I think the problem is not in the circuit, because the circuit worked
      > fine with a slightly different Jal program. Actually I have been
      > working on Vasile's clock design and I have successfully assembled
      > the circuit and it works fine (Thanks Vasile :). In that design only
      > pin_a4 was empty and I decided to add a relay to that pin . Since it
      > is open collector output pin of pic16f84, I had to use a pnp
      > transistor to drive the relay. In other words pin_a4 can not goes Vcc
      > when it is set high but goes GND when it is set low. The reason why I
      > used pnp transistor is this. For all other port of 16f84 your
      > suggestion to use npn transistor is OK.
      >
      > The circuit that I have sent before was this.
      >
      > 12V -----------------+---------+-----+
      > / | C
      > \ diode - C
      > 2.2K / 1N4001 ^ C relay coil
      > \ | C
      > / +---+-+
      > \ |
      > / |/
      > pin_a4---- /\/\/\/\/\+-----------| BC556
      > 270 |\
      > |
      > |
      > -+-GND
      >
      > Following small programs (that I sent before) just activates the
      > relay (or closes the NO pins of that relay) but does not disactivate
      > it after execution of pin_a4=high command.
      >
      > include 16f84_4
      > include jpic
      > include jdelay
      > port_a_direction = all_output
      > -- main
      > forever loop
      > delay_1S(2)
      > pin_a4 = low -- relay is activated
      > delay_1S(2)
      > pin_a4 = high -- this line should release the relay
      > end loop
      >
      >
      > However the following program (which is simplified just to
      > demonstrate the idea) is working fine in the way what I want in the
      > above program.
      >
      > include 16f84_4
      > include jpic
      > include jseven
      > include jdelay
      >
      > var byte sel_min_units = 0b1_1110
      > var byte sel_min_tens = 0b1_1101
      > var byte sel_hours_units = 0b1_1011
      > var byte sel_hours_tens = 0b1_0111
      > var byte sel_blank = 0b1_1111
      >
      > port_a_direction = all_output
      > port_b_direction = all_output
      >
      > procedure display is
      > for 200 loop
      > port_a = sel_min_units ; mux min_unit and
      > port_b = seven_from_digit( 0 ) ; display
      > delay_1ms( 3 ) ; keep it for good visibility
      > port_a = sel_min_tens ; bla-bla, the same for the rest
      > port_b = seven_from_digit( 1 )
      > delay_1ms( 3 )
      > port_a = sel_hours_units
      > port_b = seven_from_digit( 2 )
      > delay_1ms( 3 )
      > port_a = sel_hours_tens
      > port_b = seven_from_digit( 3 )
      > end loop
      > end procedure
      > -- main prog.
      > forever loop
      > sel_min_units = 0b1_1110 ; pin_a4 is set hihg here
      > sel_min_tens = 0b1_1101 ; pin_a4 is set hihg here
      > sel_hours_units = 0b1_1011 ; pin_a4 is set hihg here
      > sel_hours_tens = 0b1_0111 ; pin_a4 is set hihg here
      > sel_blank = 0b1_1111 ; pin_a4 is set hihg here
      > display
      >
      > sel_min_units = 0b0_1110 ; pin_a4 is set low here
      > sel_min_tens = 0b0_1101 ; pin_a4 is set low here
      > sel_hours_units = 0b0_1011 ; pin_a4 is set low here
      > sel_hours_tens = 0b0_0111 ; pin_a4 is set low here
      > sel_blank = 0b0_1111 ; pin_a4 is set low here
      > display
      > end loop
      >
      >
      > Anyway I solved my problem but I am very curious to know if someone
      > has logical explanation about this problem.
      >
      > Edwin
      > thank you for your little note that is very important. I have a relay
      > driving circuit drawing (see below) that I found by a search engine.
      > In that drawing one more diode is connected between collector and
      > ground. Any explanation is welcomed about existence of this second
      > diode ...
      >
      > +-----------------+-- 12vdc
      > | -
      > X Relay coil ^ diode 1N4002
      > |-----------------+
      > 4K7 / -
      > ---/\/\/\+-| NPN - 2N3904 ^ diode 1N4002
      > / \ |
      > 2K2\ |-----------------+
      > /--/ Ground
      >
      > Thank you for your comments
      >
      > regards
      >
      > Ziya
      >
      >
      > --- In jallist@y..., "Lasse Madsen" <Lasse.Madsen@E...> wrote:
      > > Not being able to see your diagram I have some suggestions to
      > you ....
      > > (if the schematic looks weird copy and paste it into notepad ! )
      > >
      > >
      > > +---------- 12vdc
      > > |
      > > X Relay coil
      > > |
      > > Rb /
      > > ---/\/\/\--| NPN - E.g. BC547
      > > \
      > > |
      > > / Ground
      > >
      > > Ube = 650mV
      > > Vcc = 5vdc (from pic)
      > > Hfe = 175 ( read datasheet from Philips page 4 Hfe/Ic
      > Characteristics )
      > > Ic = 6mA ( you specified 2k2 resistor at 12v in your example )
      > > Ib = 34,3uA ( Ic / Hfe )
      > > Urb = 4,35vdc ( 5vdc - 650mV ( Vcc - Ube ) )
      > > Rb = Urb / Ib = 126,8K ( approx 100 ~ 130K )
      > >
      > > You might want to add a diode to the above diagram ... a 1N4148
      > should do
      > > ...
      > > I also dont understand why you use a PNP transistor in your
      > design ... !?
      > >
      > >
      > > Another idea would be...
      > >
      > > +---------- 12vdc
      > > | R1
      > > +----/\/\/\-------X---------+
      > > | 2K2 Relay coil |
      > > | / Ground
      > > \
      > > / R2
      > > \ 2K2
      > > /
      > > | |
      > > Rb /
      > > ---/\/\/\--| NPN - E.g. BC547
      > > \
      > > |
      > > / Ground
      > >
      > > But personally i would recommend the first idea ....
      > >
      > > Hope it helps
      > >
      > > Best regards
      > > Lasse Madsen
      > >
      > >
      > > ----- Original Message -----
      > > From: "Ziya" <zerdemir@t...>
      > > To: <jallist@y...>
      > > Sent: Friday, March 22, 2002 1:00 PM
      > > Subject: [jallist] pin_a4 of 16f84
      > >
      > >
      > > > HI ,
      > > >
      > > > I am new in this group and Jal programming. I have two problems .
      > > >
      > > > 1. My program will read and write to eeprom of 16f84. Is there
      > any way to
      > > > insert the data to Jal program so that after compilation the hex
      > file
      > > should
      > > > contain the eeprom data to be loaded to eeprom location of 16f84
      > during
      > > the
      > > > program loading?
      > > >
      > > > 2. I connected a relay to the a4 pin (open collector) of 16f84
      > and wrote
      > > > the following simple program. relay is activated after 2 sec but
      > pin_a4 =
      > > > low does not disactivate the relay.
      > > >
      > > > include 16f84_4
      > > > include jpic
      > > > include jdelay
      > > > port_a_direction = all_output
      > > > -- main
      > > > forever loop
      > > > delay_1S(2)
      > > > pin_a4 = low -- relay is activated
      > > > delay_1S(2)
      > > > pin_a4 = high -- this line should release the relay
      > > > end loop
      > > >
      > > > relay is connected like this
      > > >...


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.