Error in PWM

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Error in PWM

Post by tiny »

Hi Benj,

I have the version is 6.06 and today the updated version 6.07 for PIC, but the error is the same with PWM remained as in previous versions. Here is a screen shot of the error message and the test program.
Error Message.jpg
(223.19 KiB) Downloaded 1094 times
With PWM.fcfx
(9.83 KiB) Downloaded 243 times

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Error in PWM

Post by Jan Lichtenbelt »

Dear Tiny

Put never an interrupt in an endless while statement. That means place the eneable Timer1 interrupt BEFORE the while statement.

Succes

Jan Lichtenbelt

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Error in PWM

Post by tiny »

Dear Jan,

thank you for the hint, but this is not the problem. Enclosed a test routine with PWM and without timers. The fault appears also here. Either is the error in the PWM component or it is a simulation fault.
I hope somebody can help me, I need the PWM component.
Error Message 1.jpg
(207.74 KiB) Downloaded 1077 times

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Error in PWM

Post by Jan Lichtenbelt »

PWM uses Timer2. It is not allowed to disable Timer2 in the TMR1 macro.
-Probably you mean disable Timer1. But that is also not allowed in the interrupt macro.
- Or you wll stop PWM. Use disable PWM.

Kind regards

Jan Lichtenbelt

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Error in PWM

Post by tiny »

Dear Jan,

I had accidentally reversed in the test file Timer1 Timer2, my mistake, I have now attached a file uses the PWM only with bit increment and without active timer control. The error occurs on completely independent of counter or timer control, and this error was not present in the Flowcode versions 4 and 5.
In my first post on this problem I had inserted the complete control that daily up to 8 hours running without problems for about 2 years. Programmed with Flowcode 4 and then 5.5.

View Topic
http://www.matrixmultimedia.com/mmforum ... 37#p57381
Flowcode3.fcfx
(7.43 KiB) Downloaded 224 times
The error only occurs since Flowcode 6, whether or version 6.01 now 6.07.

Please for help.

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: Error in PWM

Post by GTF »

I do not receive any error messages when I run your code in simulation on Win7.

Grant

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Error in PWM

Post by tiny »

Thanks for the answers and the test. How long was the simulation going on? The fault appears and this regular with me at Counter no. 30 to 40. I have installed Flowcode 6 for me also on a Windows 7 32 bits version and this fault appears regularly also there.

Tiny

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: Error in PWM

Post by GTF »

I am running on Win 7/64. I reduced the value of TMR_Max so that I would not be waiting all day and let the count run up to 145 before I stopped the simulation.

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Error in PWM

Post by Jan Lichtenbelt »

Hi Tiny

Completely silly. At 34 simulation runs the program crashes. Ask Ben for help.

Kind regards

Jan Lichtenbelt

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Error in PWM

Post by tiny »

Thanks to GTF and Jan Lichtenbelt for helping!

Tiny

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Error in PWM

Post by Benj »

Hi Tiny,

Managed to replicate the issue. Will pass across to Jonny and see if anything jumps out.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Error in PWM

Post by Benj »

Hello,

Seems to be down to a bug in the PWM component itself when redrawing as part of a continuous loop with no delays.

Here is an updated component which limits the PWM redrawing to a max of 50Hz. Pop the file into your "Flowcode 6/Components" directory and restart Flowcode and hopefully the problem should disappear.
PWM.fcpx
(6.53 KiB) Downloaded 158 times
You should notice a significant speed increase when simulating your program thanks to the decreased amount of redraws.

Let me know how you get on.

User avatar
tiny
Posts: 200
Joined: Wed Jul 08, 2009 8:29 am
Has thanked: 51 times
Been thanked: 93 times
Contact:

Re: Error in PWM

Post by tiny »

Hi Benj,

thanks for help, PWM works fine!

Tiny

User avatar
Jan Lichtenbelt
Posts: 797
Joined: Tue Feb 17, 2009 8:35 pm
Location: Haren GN, the Netherlands
Has thanked: 128 times
Been thanked: 264 times
Contact:

Re: Error in PWM

Post by Jan Lichtenbelt »

Hi Ben,

I have a question. A PWM repetition frequency of 50 Hz sound nice, especially in the sample as given by Tiny.

But a PWM maco call (or in general any maco call) should be as short as possible. Let me explain what I mean.

If I have 2 PWM calls separated by program steps for about 30msec, the PWM call must not add additional delay time if not necessary. Is that fulfilled in the new PWM.fcpx file?


Kind regards

Jan Lichtenbelt

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: Error in PWM

Post by kersing »

Hi Jan,

I think Ben means the component will behave as before except for the simulation redraws. The PWM component was redrawing too often during simulation runs causing issues. So the underlying component has not changed, but the update on your screen during simulation will be at most 50 times a second. Ben, feel free to correct me if I'm wrong.

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Error in PWM

Post by Benj »

Hello,

Kersing is correct, no additional delay just a max refresh on the simulation graphics to avoid a bottleneck.

Post Reply