Page 1 of 1

Periodically Wrong Delay

Posted: Tue Dec 01, 2015 11:22 pm
by jbell
Hi Folks,

I'm making a power cycling box that uses 4 thumbwheels to set seconds and minutes of on/off period. I figured I could bang this thing out in a couple of days with a PIC and Flowcode. Everything came together pretty well and it works OK except that every fourth "OFF" period is a fraction of what it should be. A scope shot is attached.

I'm using a big 'ol PIC18F4520 with an external 20MHz oscillator can, and have verified that the clock frequency is set correctly. The program is very simple and works fine in simulation. There's obviously some detail I'm overlooking. Any help greatly appreciated.

Re: Periodically Wrong Delay

Posted: Tue Dec 01, 2015 11:50 pm
by medelec35
Can you eliminate the calculation values by just assigning TotalONtime and TotalOFFtime with a fixed number.
Perhaps there is rolling over of the variables.
Perhaps it could help by stating what switches you have enabled and what the total on and off times should be?

Re: Periodically Wrong Delay

Posted: Wed Dec 02, 2015 12:32 am
by jbell
Hi Medelec,

Thanks for your prompt reply.

I'm working with 20 second on/off times for this test with the thumbwheel switches set for that value. Most of the time I get the correct 20/20 period (as shown on the scope shot) so I'm fairly sure the switches are being read correctly and my calculation formulas are correct.

Taking your suggestion to simplify and isolate things, I deleted all 8 of the input blocks that read the switches and changed the formulas in both calculation blocks to a fixed value of 20 seconds. When I ran it again I still got a reduced fourth off period just like in the original scope shot. The newly modified .fcf is attached. Your suggestion was a good one, with the switches and formulas out of the picture what's left?

Re: Periodically Wrong Delay

Posted: Wed Dec 02, 2015 8:52 am
by medelec35
Hi jbell,
I did think it could be something thing like watchdog enabled but you stating frequency is correct took me away from that path.
However I was puzzled when I looked at configuration settings as they are not set up correctly:
config1.png
(75.58 KiB) Downloaded 7670 times
For example watchdog timer is enabled.
Osc is the wrong settings etc.
But that does not explain how the 20sec delay is correct for a few cycles at a time

Can you see how different your configuration settings are different from the above image.
If you can post the hex file I can look at that as well.

Re: Periodically Wrong Delay

Posted: Thu Dec 03, 2015 3:59 pm
by jbell
Hi Medelec,

Sorry I haven't gotten back to you, I've been dragged-of to another hot project and have had to shelve this one for awhile. I read your paper on things to check and found it very useful. Disabling the watchdog makes sense, but if you could elaborate on the oscillator being the wrong setting I would appreciate it for when I can get back on this project.

Thanks for all your help.

Re: Periodically Wrong Delay

Posted: Thu Dec 03, 2015 8:58 pm
by medelec35
You're welcome.
jbell wrote:but if you could elaborate on the oscillator being the wrong setting I would appreciate it for when I can get back on this project.
If you follow the signature on my posts it will take you through basic configuration settings.
I wrote the post before V6 was developed, but it should equally apply to V as it did to V5

Martin