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


Closed Thread
Results 1 to 21 of 21

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Your right

    You are right, but A2 is correct. When I first posted, I change my code for clarity. I probably should have used the exact same code all the way through. When I said A1 earlier, it should have been A2. Good find. Thanks for looking.

    I think everyone should STOP TRYING TO FIGURE THIS OUT. I tested the programmed PIC with a breadboarded darlington and relay and it works like a champ. No split-second low on A2 approximately every second during a proper A2 high when B0 frequency is between 11 and 13kHz.

    I must have a conflict in my power supply or other PIC peripheral connections. I'm sure I'll find the answer when I look very closely at my schematic.

    Thanks everyone.

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


    Did you find this post helpful? Yes | No

    Default Sorry, but I did get some CCP and interrupt study

    When I use a 12kHz TTL signal from my Function Generator, the relay works fine. However, when I use the 12kHz signal from Mach3, I get the spastic relay. I scoped the Mach3 signal after passing through the transceiver, it appeared to be a good 12kHz 5V to 0V signal.

    I am going to run the Function Generator signal through the parallel port as if it's Mach3's, and thereby through the tri-state transceiver. I'm narrowing it down and will find it.

    Thanks for letting me vent.

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


    Did you find this post helpful? Yes | No

    Default Can someone explain this to me

    Function Generator 12.1kHz TTL 3V signal directly on B0 and the relay works great. Ditto when the Generator's signal is run through PC parallel port input and tri-state transceiver to boost to 5V square wave.

    Mach3 PC software transmitting 3V TTL through parallel printer port. Signal placed directly on B0, spastic relay. Ditto when the signal is passed through the tri-state transceiver.

    Both signals look exactly the same on an oscilloscope. Both signals find the same ground as the PIC, relay, transceiver, parrallel port and power supply.

    I even took the signal directly from the parallel port attached to the PC in case the cable was defective.

    Arghhhhh.....

    BTW, I believe "CMCON = 7" would be a moot entry. "ADCON1 = 7" makes ports A and E digital I/O rather than analog.
    Last edited by coyotegd; - 7th September 2007 at 22:03.

  4. #4
    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.

  5. #5
    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.

  6. #6
    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.

  7. #7
    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.

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