16F1507 problem with PWM channel 4 in V7

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Post Reply
stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

16F1507 problem with PWM channel 4 in V7

Post by stylo »

I have constructed a 4 channel PWM colour changing program in V7
My understanding is that the 16F1507 has 4 identical 10 bit PWM channels
but in my program channels 1,2, and 3 are fine and work in10 bit but the fourth channel appears to work only in 8 bit.
Am I missing something, any help most appreciated.
Stylo

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: 16F1507 problem with PWM channel 4 in V7

Post by QMESAR »

stylo wrote: My understanding is that the 16F1507 has 4 identical 10 bit PWM channels
but in my program channels 1,2, and 3 are fine and work in 10 bit but the fourth channel appears to work only in 8 bit.
Am I missing something, any help most appreciated.
Can you post your flowchart that we can see the code also how do you determine that the CH4 is only 8 Bits ?

stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

Re: 16F1507 problem with PWM channel 4 in V7

Post by stylo »

Hi Peter
Thanks for responding
It may help if I explain the program.
The program takes a 4 bit input from a radio connected 15 button remote.
Each number 1 to 16 places a pre programed 4 channel lighting set up (including a fade speed)
Into the PIC Chip 16F1507 the program then either lowers or lifts each of the 4 lighting channels, by comparing each channel with its previous setting.
The four channels are all set up the same (10 bit ) but only channels 1,2 and 3 work at 10 bit (1024 count) the fourth channel runs in 8 bits (256 count) and rolls over 4 times when counting from 1 to 1024.
Have attached my UNFINISHED flow chart
Attachments
Light Engine, 4 ch, 9.11.16.fcfx
(37.06 KiB) Downloaded 271 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: 16F1507 problem with PWM channel 4 in V7

Post by QMESAR »

Hi stylo,

I will try to look into this as I have a interest in these small pic's ,I am no way and expert with them yet that being the reason I ask your FC Flowchart to see if I can understand the problem or find how to get all channels running the same, I will be back this might take a day or 3 :D

Will be happy if one of the more experienced people will shed light on this in the mean time

good luck hope we solve this soon

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: 16F1507 problem with PWM channel 4 in V7

Post by QMESAR »

Hi stylo,

Looking at the Flowchart my thinking at the moment is
1 I have used similar devices and all PWM's work exactly the same and I would expect the 1507 not to be different
2 if the FC componet run PWM 1,2 and 3 Correctly it is unlikely that the FC component is the problem on PWM4

I would do the Following

I would make a simply Flowchart with the 4 PWM and set then to the exact same duty cycle and measure the duty cycle if this show a 25% difference between PWM4 and the others then it could be the FC component on PWM4 if they are the same then it up to debug the variables that you use to set the Duty cycle ,

I unfortuenately can not run this test as I am far away from my lab and will only be at my lab after 30 Nov 2016 however I would like to see the results from such a test

maybe you try this and inform us :D

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: 16F1507 problem with PWM channel 4 in V7

Post by Benj »

Hi Stylo,

A couple of comments on things I've spotted in your program.

The PWM components are all set to timer 2 but PWM1 has a different prescaler setting to the other PWM components, you will get the prescaler you enable last unless you assign a different timer.

Second the PWM enable macros are inside the loop, these should ideally be before the loop or you're constantly re-initialising the module every cycle.

I'm not sure if either of these are to do with the weirdness on PWM channel 4. I've looked at the code and it seems like it should be working fine.

Code: Select all

	#if (MX_PWM_CHANNEL_X == 3)
			PWM3DCH = duty >> 2;			//8MSB HHHHHHHH
			PWM3DCL = duty << 6;			//2LSB LL000000
	#endif

	#if (MX_PWM_CHANNEL_X == 4)
			PWM4DCH = duty >> 2;			//8MSB HHHHHHHH
			PWM4DCL = duty << 6;			//2LSB LL000000
	#endif

stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

Re: 16F1507 problem with PWM channel 4 in V7

Post by stylo »

Thanks guys,
I have taken your observations on board; will now go and hopefully sort the problem out.
I think benj’s comment to make a separate SIMPLE PWM test program and work on that first is always an excellent idea.
I will keep you posted, but it may be a day or two as I have other commitments.
Thanks again
stylo

stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

Re: 16F1507 problem with PWM channel 4 in V7

Post by stylo »

Hi Guys
Problem solved. My fault!, I think?http://ww.matrixmultimedia.com/mmforums ... 6b12dc9336#
The fourth channel “Ch_4” had Byte instead of Integer (pre fix “B” instead of “Z”) in the “Properties Macro”……..”Set duty cycle 10 bit” changed it by going to “Expression”……..“Ch_4”…….. “Edit” and changed It to “Int”
Should it have automatically put in int when I chose 10 bit in the 4th channel in my original program?
Thanks again for all your help,
Stylo

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: 16F1507 problem with PWM channel 4 in V7

Post by QMESAR »

Great news :D

stylo
Posts: 23
Joined: Mon Mar 02, 2009 9:30 am
Been thanked: 3 times
Contact:

Re: 16F1507 problem with PWM channel 4 in V7

Post by stylo »

Sorry about the garbage in the first line of my email. Brain disengaged :(
Stylo

Post Reply