12f675 very confused


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2007
    Posts
    16

    Default 12f675 very confused

    I have made the program below to run a simple leak test fixture. The problem I am having is that the machine randomly gets lost and the two bottom seal variables lock in the 0 or off position and do not function unless the power is taken away and the chip is reset. I have tried several different versions of the program to try and fix the problem and by everything i know and have read this should neevr happen in this situatyion. Any help would be much appreciated.
    \\code\\
    CMCON = %00000111 ' set all pins to digital
    GPIO = %00000000 ' set all pin states to off
    TRISIO = %00001000 ' All pin states to out except MCLR for trigger
    WPU = %00000000 ' Shut off weak pull ups
    INTCON = %00000000
    'Register Initializations'


    'Variables'
    SWING_EXT VAR GPIO.0 ' Set variable names for pins
    SWING_RET VAR GPIO.1
    BOT_SEAL_RET VAR GPIO.4
    BOT_SEAL_EXT VAR GPIO.5
    MAIN_TRIGGER VAR GPIO.3


    a0 VAR BYTE ' Byte variables for button
    I VAR WORD ' Word variable for looping
    'Variables'

    '************************************************* ***************************
    '************************************************* ***************************


    INITIALIZE:
    A0 = %00000000 ' INITIALIZE BUTTON BYTE TO ZERO
    BOT_SEAL_RET = 1
    PAUSE 500
    BOT_sEAL_RET = 0
    PAUSE 500

    MAIN:
    SWING_EXT = 1
    PAUSE 500
    GOTO MAIN_TRIG_CHECK
    GOTO MAIN


    MAIN_TRIG_CHECK:
    BUTTON MAIN_TRIGGER, 1, 255, 0, A0, 1, START_OP
    GOTO MAIN_TRIG_CHECK

    START_OP:
    SWING_EXT = 0
    PAUSE 500
    SWING_RET = 1
    PAUSE 500
    GOTO TEST

    TEST:
    BOT_SEAL_EXT = 1
    PAUSE 500
    GOTO TEST_TRIG_CHECK
    GOTO TEST

    TEST_TRIG_CHECK:
    BUTTON MAIN_TRIGGER, 1, 255, 0, A0, 1, START_OVER
    GOTO TEST_TRIG_CHECK


    START_OVER:
    BOT_SEAL_EXT = 0
    pause 100
    BOT_SEAL_RET = 0
    pause 100
    SWING_RET = 0
    pause 100
    swing_ext = 0
    GOTO INITIALIZE


    END
    \\code\\

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Are you using this now on the actual machine, or just with LEDs? I am thinking reverse transients from relays or DUT, (device under test). All inductive devices must use snubber diodes and do not forget to use bypass caps on the PIC, which should be isolated from DUT.
    How are your Config statments set?
    You have analog stuff still turned on, ANSEL and ADCON0 need to be set.
    ANSEL = 0
    ADCON0 = 0
    PCON = %00000011 ' BOD off, No POR flag set
    Last edited by Archangel; - 20th July 2009 at 17:02.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jan 2007
    Posts
    16


    Did you find this post helpful? Yes | No

    Default 12f675 very confused

    I am using this code on the machine itself right now. The load for all the outputs of the PIC are N-channel mosfets that turn on 12 solenoid valve coils. I have flyback diodes on all the coils to protect the PIC from voltage spikes form the coils. I turnned off the analog registers as you suggested but the problem still exists.

    It seems to be more of an issue when i press the main trigger to quickly comming into the initaialize part of the program. Dont know if thats the cause or just a coincidence. Thank you for your timely help.

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


    Did you find this post helpful? Yes | No

    Default

    Do you have resistors from the MOSFET gates to the Zero rail?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Hi,

    What I see is you have forgotten to reset the A0 Button var. just before EACH Button Command ...

    Generally it's a fatal error in such loops ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    What I see is you have forgotten to reset the A0 Button var. just before EACH Button Command ...

    Generally it's a fatal error in such loops ...

    Alain
    Hi Alain, I never use the button command, I wondered about that, I bet that is it too . . .
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. 12F683 vs 12F675.
    By sccoupe in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 11th July 2009, 04:58
  2. LANC code 12F675
    By MikeDD in forum General
    Replies: 4
    Last Post: - 9th May 2008, 05:44
  3. Instant Interupts with a 12f675
    By wlundonly in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 26th January 2008, 01:52
  4. 12F675 won't reprogram or erase
    By modifyit in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 19th May 2006, 05:07
  5. 12f675 serial pic2pic
    By tagan in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th March 2006, 22:55

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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