Page 1 of 1

Error in PWM

Posted: Fri Mar 28, 2014 10:35 pm
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

Re: Error in PWM

Posted: Sat Mar 29, 2014 10:47 am
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

Re: Error in PWM

Posted: Sat Mar 29, 2014 3:46 pm
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

Re: Error in PWM

Posted: Sat Mar 29, 2014 8:47 pm
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

Re: Error in PWM

Posted: Sat Mar 29, 2014 11:16 pm
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 225 times
The error only occurs since Flowcode 6, whether or version 6.01 now 6.07.

Please for help.

Re: Error in PWM

Posted: Sun Mar 30, 2014 3:32 am
by GTF
I do not receive any error messages when I run your code in simulation on Win7.

Grant

Re: Error in PWM

Posted: Sun Mar 30, 2014 3:56 pm
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

Re: Error in PWM

Posted: Sun Mar 30, 2014 4:55 pm
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.

Re: Error in PWM

Posted: Sun Mar 30, 2014 7:38 pm
by Jan Lichtenbelt
Hi Tiny

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

Kind regards

Jan Lichtenbelt

Re: Error in PWM

Posted: Sun Mar 30, 2014 8:37 pm
by tiny
Thanks to GTF and Jan Lichtenbelt for helping!

Tiny

Re: Error in PWM

Posted: Mon Mar 31, 2014 12:21 pm
by Benj
Hi Tiny,

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

Re: Error in PWM

Posted: Mon Mar 31, 2014 5:31 pm
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.

Re: Error in PWM

Posted: Mon Mar 31, 2014 7:45 pm
by tiny
Hi Benj,

thanks for help, PWM works fine!

Tiny

Re: Error in PWM

Posted: Mon Mar 31, 2014 9:32 pm
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

Re: Error in PWM

Posted: Tue Apr 01, 2014 12:04 am
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

Re: Error in PWM

Posted: Tue Apr 01, 2014 9:21 am
by Benj
Hello,

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