What am I doing wrong? 16F628A


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2010
    Posts
    88

    Default What am I doing wrong? 16F628A

    Hi Guys,

    It should be pretty straight forward, but I'm at a loss. Trying to use a 16F628A and tried searching online for similar issues, but have been unsuccessful in resolving the matter.

    I wrote out a large amount of code. Found that one of the outputs on the PIC wasn't doing what it was suppose to do. To make a long story short, I wrote a small bit of code to test the outputs I wanted to control and it's still not working. I tried programming new chips, and get the same result.

    My problem: porta.4 (pin 3) does not want to turn on. It stays low and does not activate to control a transistor. I replaced the transistor (in case it was bad), and get the same result. Can someone tell me what I'm missing.

    Thanks,
    Tony

    Code:
    #CONFIG
       __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _LVP_OFF & _CP_OFF & _PWRTE_ON & _MCLRE_OFF & _BOREN_OFF
    #ENDCONFIG
    
    Reset:
    
      CMCON = 7                     ' Analog comparators off
      VRCON = 0                     ' A/D Voltage reference disabled
      TRISA = %11000001             ' sets pin as input (1) or output (0)
      TRISB = %00110011             ' sets pin as input (1) or output (0)
      PORTA = %00000000             ' sets outputs as high (1) or low (0)
      PORTB = %00000000             ' sets outputs as high (1) or low (0)
    
    ' -----[ Variables ]-------------------------------------------------------
     
        rightrelay    var   porta.1  ' right relay output
        leftrelay     var   portb.2  ' left relay output
    
        rightfet      var   porta.4  ' right fet output
        leftfet       var   porta.2  ' left fet output
    
    high leftrelay
    high rightrelay
    
    action:
    
    low leftfet
    high rightfet
    
    pause 500
    
    low rightfet
    high leftfet
    
    pause 500
    
    goto action

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: What am I doing wrong? 16F628A

    PortA.4 is an open drain port. You must use a pullup resistor in order to drive your transistor.

    Cheers

    Al.
    All progress began with an idea

  3. #3
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: What am I doing wrong? 16F628A

    Hi;

    To complement aratti answer, that information is on the Datasheet.
    Thanks and Regards;
    Gadelhas

  4. #4
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default Re: What am I doing wrong? 16F628A

    I'm using an npn, so using a pull-up resistor turns on my transistor. Any other thoughts, or an equivalent chip to the 628A that does not have an open drain output?

    Thanks,
    Tony

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: What am I doing wrong? 16F628A

    Use the pullup and reverse your high and low. up is down and down is up...
    Last edited by mackrackit; - 17th January 2014 at 01:28.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,529


    Did you find this post helpful? Yes | No

    Default Re: What am I doing wrong? 16F628A

    Or use a PNP, or invert the signal with another transistor or use an 16F88, 16F819, 16F1826 etc etc.
    If buying new, go for the enhanced 16F1xxx series, cheaper and better in all respects I can think of.

    Selecting 8-bit chips with 18 pins in the Microchip Advanced Part Selector, gives 17 different parts, pick one and look at the datasheet.

    /Henrik.

  7. #7
    Join Date
    Jan 2010
    Posts
    88


    Did you find this post helpful? Yes | No

    Default Re: What am I doing wrong? 16F628A

    Unfortunately, I'm using an npn to control a p-channel mosfet, so I can't change the layout. Thank you for the link. That is extremely helpful.

    Tony

Similar Threads

  1. What am I doing wrong?
    By tazntex in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th July 2010, 15:43
  2. What am I doing wrong?
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th October 2009, 19:46
  3. Would you like to look what is wrong?
    By hardcore in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd December 2008, 16:51
  4. what do i do wrong?
    By Automan in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 2nd November 2008, 12:27
  5. What am I doing wrong ?
    By malc-c in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 9th June 2006, 23:12

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts