You may want to read this. It explains ADCON and CMCON.BTW, I believe "CMCON = 7" would be a moot entry. "ADCON1 = 7" makes ports A and E digital I/O rather than analog.
http://www.picbasic.co.uk/forum/showthread.php?t=561
You may want to read this. It explains ADCON and CMCON.BTW, I believe "CMCON = 7" would be a moot entry. "ADCON1 = 7" makes ports A and E digital I/O rather than analog.
http://www.picbasic.co.uk/forum/showthread.php?t=561
Dave
Always wear safety glasses while programming.
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.
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:
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.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
Hope this helps
Rob
Last edited by Rob; - 9th September 2007 at 13:18.
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
Bookmarks