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

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

Periodically Wrong Delay

Postby jbell » Tue Dec 01, 2015 11:22 pm

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 243 times
power cycler glitch.jpg
power cycler glitch.jpg (139.72 KiB) Viewed 6294 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8332
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2381 times
Been thanked: 3393 times
Contact:

Re: Periodically Wrong Delay

Postby medelec35 » Tue Dec 01, 2015 11:50 pm

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?
These users thanked the author medelec35 for the post:
jbell (Wed Dec 02, 2015 1:07 am)
Rating: 5.56%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Periodically Wrong Delay

Postby jbell » Wed Dec 02, 2015 12:32 am

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 234 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8332
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2381 times
Been thanked: 3393 times
Contact:

Re: Periodically Wrong Delay

Postby medelec35 » Wed Dec 02, 2015 8:52 am

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
config1.png (75.59 KiB) Viewed 6278 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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: Periodically Wrong Delay

Postby jbell » Thu Dec 03, 2015 3:59 pm

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.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8332
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2381 times
Been thanked: 3393 times
Contact:

Re: Periodically Wrong Delay

Postby medelec35 » Thu Dec 03, 2015 8:58 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.