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.
Periodically Wrong Delay
Moderator: Benj
Periodically Wrong Delay
- Attachments
-
- PowerCycler.fcf
- (19.5 KiB) Downloaded 528 times
-
- power cycler glitch.jpg (139.72 KiB) Viewed 13064 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Periodically Wrong Delay
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?
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
Re: Periodically Wrong Delay
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?
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 511 times
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Periodically Wrong Delay
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: 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.
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: 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
Re: Periodically Wrong Delay
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.
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.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: Periodically Wrong Delay
You're welcome.
I wrote the post before V6 was developed, but it should equally apply to V as it did to V5
Martin
If you follow the signature on my posts it will take you through basic configuration settings.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.
I wrote the post before V6 was developed, but it should equally apply to V as it did to V5
Martin
Martin