PWM component and PIC 16F777

Forum for problems or queries regarding other Flowcode Components. Eg LEDs, Switches, LCD, Gfx LCD etc

Moderators: Benj, Mods

Post Reply
wim314
Posts: 12
Joined: Tue Dec 25, 2007 1:51 pm
Location: Belgium
Contact:

PWM component and PIC 16F777

Post by wim314 »

According to the datasheet of the PIC 16F777, this chip has 3 PWM channels. But in Flowcode I can only address 2 PWM modules. Has someone any idea how I can use the 3rd PWM channel from within flowcode?

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: PWM component and PIC 16F777

Post by Benj »

Hello Wim

Currently Flowcode can only process a maximum of 2 PWM channels. This is something that will be improved over time. At the moment you can control the 3rd PWM channel via C code. Alternatively you can use a timer based interrupt combined with a bit of control logic to bit bang out a PWM signal. Eg toggling the output pin when the interrupt is triggered a certain number of times.

wim314
Posts: 12
Joined: Tue Dec 25, 2007 1:51 pm
Location: Belgium
Contact:

Re: PWM component and PIC 16F777

Post by wim314 »

Hi Ben,

Thanks for the answer. I have printed the C-code generated by Flowcode and I will study it to know how to address the 3rd PWM of the 16F777.
Hopefully it will work. In any case, I am highly interested in a version of Flowcode which supports more than 2 PWM channels.

Best regards,
Wim

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: PWM component and PIC 16F777

Post by Mikat »

Hello.
The pwm channel 3 works simple c commands ccp3con = OxOC,it enables the pwm,and ccpr3l set the duty...
BUT i have notice that if i use a/c conversion,it disturbs the pwm3 output..
Steve,Ben could you check the a/d con,does it turn ALL the an channels input?
Because if i use only an0 a/d con,it brings port b5 high / input,so it seems to disable the ccp3 output at the time of a/d conversion..
And thats not nice...

Ben any news for that ks108 lcd?


Mika

User avatar
Steve
Matrix Staff
Posts: 3421
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: PWM component and PIC 16F777

Post by Steve »

Hello Mika,

Which chip are you using?

I've looked at the most recent version of the 16F777 FCD file and this seems to be ok, but this file may have been updated fairly recently. In the C file that is created by Flowcode, you should see the definition <MX_ADC_TRIS_REG> used in the ADC routine. If this is not present, then you might be using an older version of the FCD file.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: PWM component and PIC 16F777

Post by Mikat »

Thanks Steve,updating the Flowcode solved problem.
Can you tell me anything about the ks108 glcd,Ben was working it for some times ago..
Btw,Steve can you tell me what is the type of the glcd display,witch is use in flowcode3?
Last edited by Mikat on Mon Apr 28, 2008 12:06 pm, edited 1 time in total.

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: PWM component and PIC 16F777

Post by Benj »

Hello Mikat

Im afraid this is currently still a work in progress but hopefully there should be something along the lines of a beta Flowcode component available for this fairly soon.

WalkOver
Posts: 65
Joined: Fri Nov 23, 2007 11:24 pm
Contact:

Re: PWM component and PIC 16F777

Post by WalkOver »

Mikat wrote:Hello.
The pwm channel 3 works simple c commands ccp3con = OxOC,it enables the pwm,and ccpr3l set the duty...
BUT i have notice that if i use a/c conversion,it disturbs the pwm3 output..
Steve,Ben could you check the a/d con,does it turn ALL the an channels input?
Because if i use only an0 a/d con,it brings port b5 high / input,so it seems to disable the ccp3 output at the time of a/d conversion..
And thats not nice...

Ben any news for that ks108 lcd?


Mika
Mika, Can you put online your .fcf file ? I am very interested in the use of a third hardware pwm but I don't know the C code.

Thank you for your help.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: PWM component and PIC 16F777

Post by Mikat »

WalkOver wrote:
Mikat wrote:Hello.
The pwm channel 3 works simple c commands ccp3con = OxOC,it enables the pwm,and ccpr3l set the duty...
BUT i have notice that if i use a/c conversion,it disturbs the pwm3 output..
Steve,Ben could you check the a/d con,does it turn ALL the an channels input?
Because if i use only an0 a/d con,it brings port b5 high / input,so it seems to disable the ccp3 output at the time of a/d conversion..
And thats not nice...

Ben any news for that ks108 lcd?


Mika
Mika, Can you put online your .fcf file ? I am very interested in the use of a third hardware pwm but I don't know the C code.

Thank you for your help.
The ccp3 usage is very easy..
Put the code "ccp3con = OxOC;",without the "" in c ode block,this enables the pwm...
And the duty can be set "ccpr3l = FCV_DYTY;",,without the "" in c ode block..
The FCV_DUTY is flowcode variable named duty,so you can use any variable you like,all you have to do is make variable on fc variable manager and REMEMBER to use CAPS and FCV_ in the front of the variable...
The third pwm work fine,i had the old version of flowcode,that causes the a/d con problem...
Hope that helps..

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: PWM component and PIC 16F777

Post by Benj »

Hi Mika

Thanks for the post.

Regarding the KS108 LCD I have a prototype circuit sitting on my desk at work. Im currently looking into reducing the i/o pin count eg via serial data so it can sit on a single port.

With any luck there may be a beta component available for this soon. Do you know of any good C code examples to get me up to speed with programming these devices.

Mikat
Posts: 258
Joined: Wed Nov 29, 2006 6:32 pm
Location: Finland
Has thanked: 7 times
Been thanked: 36 times
Contact:

Re: PWM component and PIC 16F777

Post by Mikat »

Hi Ben,i sent you some files,witch are for ks108,hope those help you..
Is there any change the the upcoming component supports the ks108 at 8bit paraller mode,because seems that at least my display dont have connetions to run it serial,or is it some pins on paraller connections (havent read the datasheet so much)...

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: PWM component and PIC 16F777

Post by Benj »

Hello Mika

Thanks for the code I will look at it when I get time. The LCD im using does not have a serial option but I will implement a coding method that can either use 2 ports (eg standard straight through connections) or 1 port (serial via a logic chip and a small bit of circuitry). This second option will then probably be made into the E-Block if we choose to develop it further.

WalkOver
Posts: 65
Joined: Fri Nov 23, 2007 11:24 pm
Contact:

Re: PWM component and PIC 16F777

Post by WalkOver »

Mikat wrote:
WalkOver wrote:
Mikat wrote:Hello.
The pwm channel 3 works simple c commands ccp3con = OxOC,it enables the pwm,and ccpr3l set the duty...
BUT i have notice that if i use a/c conversion,it disturbs the pwm3 output..
Steve,Ben could you check the a/d con,does it turn ALL the an channels input?
Because if i use only an0 a/d con,it brings port b5 high / input,so it seems to disable the ccp3 output at the time of a/d conversion..
And thats not nice...

Ben any news for that ks108 lcd?


Mika
Mika, Can you put online your .fcf file ? I am very interested in the use of a third hardware pwm but I don't know the C code.

Thank you for your help.
The ccp3 usage is very easy..
Put the code "ccp3con = OxOC;",without the "" in c ode block,this enables the pwm...
And the duty can be set "ccpr3l = FCV_DYTY;",,without the "" in c ode block..
The FCV_DUTY is flowcode variable named duty,so you can use any variable you like,all you have to do is make variable on fc variable manager and REMEMBER to use CAPS and FCV_ in the front of the variable...
The third pwm work fine,i had the old version of flowcode,that causes the a/d con problem...
Hope that helps..
Thank you very much for your help. I finally managed to activate the third PWM. I just had to put a 0 on RG0 (CCP3).

Thank you very much 8)

Post Reply