Flowcode V5, PWM on Pic 16F1829

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Flowcode V5, PWM on Pic 16F1829

Post by Steff »

I have a small problem with the PWM on 16F1829.
I've noticed that I can not set PWM output to 100% . In the simulation 100% is really 100%, no negative Peak, output 100% on high level.
In the hardware I measure a small negative peak also at 100%. Am I doing something wrong?

Thanks for Help.
Attachments
PWMtestFCV5.fcf
(6.5 KiB) Downloaded 339 times

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: Flowcode V5, PWM on Pic 16F1829

Post by Benj »

Hi Steff,

Not sure if this help but what if you take the SetDutyCycle out of the loop and place it before the loop. What could be happening is that the glitch might be caused because your constantly reassigning the duty value at high speed.

Adding a delay to the loop could also potentially help to reduce the chance of a glitch.

Let me know how you get on.

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Steff »

Thank you for the fast answer.
The problem I have in a bigger project in which the value for the PWM is calculated constant. The posted program is just an example. But at 100% PWM, it will behave just the same.
I have rewritten the sample program, but the effect is the same.
See the new example program.
I've used PWM output with other Pic controllers, but this effect I have never noticed.
Attachments
PWMtest2FCV5.fcf
(6.5 KiB) Downloaded 358 times

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Kenrix2 »

For a true 100% on in hardware, the duty must be greater than the period. If duty=period the pwm output will go low for 1, 4 or 16 fosc/4 cycle(s), depending on your setting of the Clock source of clk/1, clk/4, clk/16 respectively.

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Steff »

This means that you can only with the PWM tool, PWM output can never be adjusted to 100% on Flowcode, or am I overlooking something?

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Kenrix2 »

If you use 255 as the period then your right, you can't get 100% on. However, if you set the period to a lower value like 254 and set the duty to 255, then you will get 100% on.

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Steff »

That fact I really overlooked. :oops:
With 254 in the period register are at 255 duty cycle 100% PWM at the output.
Thank you very much for the note.

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Small problems with the timing, FC5 Pic16F1829.

Post by Steff »

When I select the internal Oscilator with 2Mhz it shows the PWM period of 500us (PWM channel 3, period register 249, prescaler 1) in the simulation. But measured by the chip it is 2ms, which is exactly 4x more. And i think, the same procedure applies to the delay times.
I doing something wrong? Or I overlook something again?

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: Flowcode V5, PWM on Pic 16F1829

Post by medelec35 »

Hi Steff,
When you adjust the internal osc speed via Build, Project options, you must always add or alter the osccon value placed at the very start of main.
If you look at the datasheet it will show the osccon values for determining clock speed.

The Clock speed settings in flowcode do not alter the clock speed on your hardware.
It serves the purpose of setting up delays, used in calculations for simulations and setting up registers with correct values.
For internal osc, it is purely the osccon command that determines the clock speed of your hardware.
So if delays, PWM or timer interrupts are out, you know it will down to osccon if using internal osc.
Take a look here:
http://www.matrixmultimedia.com/mmforum ... 29&#p28829
It could help you to determine correct osccon value.

Martin
Martin

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Steff »

oooo Yesssss....that helps :wink:

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: Flowcode V5, TMR1 and AN3 on Pic 16F1829

Post by Steff »

I have a problem with the TMR1 counter in Pic 16F1829.
I want to display an analog value, that I reading about the An3, on an SPI display. The display I want refresh on the TMR1 interrupt (about 1 Hz).
The problem is that simulation works with all counters, but on the hardware, it does not work with the TMR1 counter. The display is always set to 0

I have written a small flashing program, without analog input and SPI display, only 2 LEDs blink alternately controlled via the TMR1 interrupt. It worked.

I think anything with the analog input comes in the way of the TMR1 interrupt. If I reading the analog value at An4 it works.
Can I use the AN3 input and the TMR1 counter (as an interrupt source) not at the same time ? I have to configure something special?

Thanks for your Help.

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Steff »

I have bypassed my previously described problem, but my problem is too stupid? Or am I doing something really wrong? Or is there no solution for this?

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: Flowcode V5, PWM on Pic 16F1829

Post by medelec35 »

Hi Seff,
AN3 shares the same pin as T1OSO which is probably being affected by This bug

so you could ask Ben if this has been fixed for V5 as well since V5 is still supported.

Martin
Martin

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: Flowcode V5, PWM on Pic 16F1829

Post by Benj »

Hello,

Hopefully this might solve the issue. Simply copy the attached file into your "Flowcode/v5/FCD" folder and restart Flowcode to load the changes.
Attachments
16F1829.fcd
(17.48 KiB) Downloaded 247 times

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by jgu1 »

Hi Ben!

Is this is a bug in FC :?: .

I have previously upon a Query, is it not possible to add corrections to the "Minor fixes" every time MM make a new correction. Please :D

Maybe not all read this thread.

Thank´s in advance. :wink:

Jorgen

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: Flowcode V5, PWM on Pic 16F1829

Post by Benj »

Hello Jorgen,

This is a bug in Flowcode, however I didn't want to have to re-generate all the v5 FCD files to fix this newly discovered problem. I am willing to fix individual FCDs and the fix will go into the next release of v6.

A centralised place with all the v5 and v6 fixes since the last release would be really nice, we have been pushing for it for years, I'll bring it up again :D

jgu1
Posts: 1333
Joined: Tue Oct 06, 2009 9:39 am
Has thanked: 1135 times
Been thanked: 299 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by jgu1 »

Hi Again Ben!

Thanks for your response. But Ben, we have already here in the forum for version 5 a " Minor fixes". it's not just using this and place the it there every time when a correction come. :P MM did it earlier.

Hope I'm not too annoying, I mean it kindly.

Best regard

Jorgen

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Steff »

Thanks for the help. I will try it soon.

Do I understand that correctly? FCV5 will soon no longer supported?
Although I have a FCV6, but I can not imagine at the moment to upgrade to this version.

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: Flowcode V5, PWM on Pic 16F1829

Post by Benj »

Hi Steff,

Flowcode v5 will drop support after v6 has been out for 2 years.

Can you explain why you prefer v5 over v6, maybe it is something we can look into and get fixed? v6 in my opinion is far superior but we are aware of some bugs which might initially put some v5 users off upgrading.

We will shortly be releasing v6.0.8 which fixes some bugs with 6.0.7 and works towards providing a cleaner and easier to use product.

Steff
Posts: 46
Joined: Wed Jun 23, 2010 1:26 pm
Has thanked: 6 times
Been thanked: 3 times
Contact:

Re: Flowcode V5, PWM on Pic 16F1829

Post by Steff »

I'm trying (with my bad english) to explain:
At the moment I'm not as far as I could complain about errors.
The difference from V5 to V6 is for me very large, can not be compared as from V3 to V5. V6 is a new program where many things are totally different as in the V5 for me.
It is not a switch, it is in many things, a new entry. The graphical innovations may be very beautiful, to me they complicate too much.
I have not tried very much, but unfortunately what I tried did not work. For example, the ICD 3 programmer I have so far not made to run.
I also tried a program that I wrote in V5 to load in V6, unfortunately that was not without error messages.
If something go fast I have to use the V5. If I had time (a lot of time) I'll try it with the V6.
From the V3 to V5, it needed no changeover time. For the V6 I think it takes a lot of time (at least I).
But I have seen that there are many tutorial movies .... I'm going to have to look at it. :-)

Post Reply