16F877A won't keep relay on 100% of the time


Closed Thread
Results 1 to 21 of 21

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    BTW, I believe "CMCON = 7" would be a moot entry. "ADCON1 = 7" makes ports A and E digital I/O rather than analog.
    You may want to read this. It explains ADCON and CMCON.
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Oct 2005
    Location
    Las Vegas, Nevada, USA
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Ok on the CMCON

    I'll remember that and keep "CMCON = 7" with "ADCON1 = 7" when switching from analog to digital I/O. However, this did not solve my problem either.

    I now know that it's the 12kHz from Mach3. Although I can't see it on the oscilloscope, the signal has a hiccup. I can hear it on my digital probe, and the probe's ever so slightly audible hiccup matches the relay's. Even the hi-low lights dim very slightly now and then.

    So off to Mach3 support for information on how to obtain a clean 12kHz from their software.

    As soon as their signal measured at 12 to 12.1kHz when they stated it would be 12.5kHz, I should have looked more closely at the signal.
    Last edited by coyotegd; - 8th September 2007 at 00:54.

  3. #3
    Join Date
    Oct 2005
    Location
    Las Vegas, Nevada, USA
    Posts
    27


    Did you find this post helpful? Yes | No

    Default Work around found

    With a terrible hiccup in the 12kHz signal, I have to test the the frequency with:

    If (Counter > 1) then

    So as long as the PIC counts anything over a 1kHz, the relay works properly. What a crappy 12kHz signal from Mach3. I hope this doesn't reflect the quality of their stepper motor control. I guess I'll find out.

    Hopefully, they the explanation is that they had to compromise the 12kHz signal for better control over the stepper motor signals.

  4. #4
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by coyotegd View Post
    With a terrible hiccup in the 12kHz signal, I have to test the the frequency with:

    If (Counter > 1) then

    So as long as the PIC counts anything over a 1kHz, the relay works properly. What a crappy 12kHz signal from Mach3. I hope this doesn't reflect the quality of their stepper motor control. I guess I'll find out.

    Hopefully, they the explanation is that they had to compromise the 12kHz signal for better control over the stepper motor signals.
    I'm not familiar with the Mach3 product but it sounds like it needs to be corrected as it's not offering a correct output. If you need to use it you could always try this in your code:

    Code:
    working var byte
    working = 2
    
    MAIN:
    count chrgpmp, 1, cntcp ' Count freq. on B0, Mach3's 12kHz
    if (cntcp >= 11) and (cntcp <= 13) then ' Freq. must be between 11 & 13kHz
    working = 2
    else
    if working > 0 then      ' Stops working variable from rolling from 0 to 255!
    working = working - 1
    endif
    endif
    if working >0 then
    lptports = 1
    else
    lptports = 0
    endif
    
    goto main
    This will make a double check every time there is a 'hiccup' in the 12kHz signal. Of course if this doesn't correct it you could always increase the "working" variable where it is defined and also in the third line of the above code.

    Hope this helps

    Rob
    Last edited by Rob; - 9th September 2007 at 13:18.

  5. #5


    Did you find this post helpful? Yes | No

    Default Does the power supply sag?

    From the symptoms described, I would be looking (with a scope) at the power supply. If the 5V relay draws slightly more current than the power supply can sustain then I would expect BrownOut Resets some short time after the relay energises.

    Just a thought.

    Brian

Similar Threads

  1. First time with external oscillator - 16F877a Not working
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th October 2009, 17:14
  2. I don't understand this code!
    By Russ Kincaid in forum mel PIC BASIC Pro
    Replies: 46
    Last Post: - 13th February 2008, 02:55
  3. Serial Relays
    By tazntex in forum General
    Replies: 3
    Last Post: - 17th May 2007, 17:42
  4. Serout2/serin2 Pbp Problem
    By SOMRU in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th December 2006, 19:55
  5. Timer in real time
    By martarse in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th July 2005, 14:24

Members who have read this thread : 0

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