Periodically Wrong Delay

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
jbell
Flowcode V4 User
Posts: 13
Joined: Mon Jul 18, 2011 11:04 pm
Has thanked: 1 time
Contact:

Periodically Wrong Delay

Post 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.
Attachments
PowerCycler.fcf
(19.5 KiB) Downloaded 490 times
power cycler glitch.jpg
power cycler glitch.jpg (139.72 KiB) Viewed 11836 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Periodically Wrong Delay

Post 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?
Martin

jbell
Flowcode V4 User
Posts: 13
Joined: Mon Jul 18, 2011 11:04 pm
Has thanked: 1 time
Contact:

Re: Periodically Wrong Delay

Post 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?
Attachments
SimplifiedPowerCycler.fcf
(23 KiB) Downloaded 475 times

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Periodically Wrong Delay

Post 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.
Martin

jbell
Flowcode V4 User
Posts: 13
Joined: Mon Jul 18, 2011 11:04 pm
Has thanked: 1 time
Contact:

Re: Periodically Wrong Delay

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

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Periodically Wrong Delay

Post 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
Martin

Post Reply