flowcode pic16F88 and output

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

Moderators: Benj, Mods

Post Reply
mohandino
Posts: 22
Joined: Fri Jun 29, 2007 9:41 pm
Has thanked: 1 time
Contact:

flowcode pic16F88 and output

Post by mohandino »

Hi,

I whant to know if the 16F88 chip has en analog outpout and how can i use it with flowcode ( v2 i prefer ;) )

thanks

hmcleod
Posts: 6
Joined: Sun Jul 08, 2007 12:24 am
Contact:

Post by hmcleod »

I've not used many different PICs, but I don't think any of them have analogue 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:

Post by Benj »

You can create an analogue output by using a PWM output connected to a capacitor. It will take some tweaking to get the PWM frequency to match the capacitor charge rate. Then you should be able to set a mark space on the PWM and get a linear analogue voltage out.

Code: Select all

PWM O/P ------ Cap + --------- Analogue out
               Cap -
                 |
               GND

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

Post by Steve »

The voltage will vary depending on the load, so you may additionally need an opamp (for example).

Alternatively, use a DAC.

mohandino
Posts: 22
Joined: Fri Jun 29, 2007 9:41 pm
Has thanked: 1 time
Contact:

Post by mohandino »

Benj wrote:You can create an analogue output by using a PWM output connected to a capacitor. It will take some tweaking to get the PWM frequency to match the capacitor charge rate. Then you should be able to set a mark space on the PWM and get a linear analogue voltage out.

Code: Select all

PWM O/P ------ Cap + --------- Analogue out
               Cap -
                 |
               GND
Hi thanks for your help, the current needed is 2mA. How can i initialised the pwm in flowcode v2 ?

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:

Post by Benj »

Hello

In flowcode 2 you will need to create your own C or assembler functions to control the PWM.

Flowcode V3 comes with a PWM component that makes this task a lot easier.

mohandino
Posts: 22
Joined: Fri Jun 29, 2007 9:41 pm
Has thanked: 1 time
Contact:

Post by mohandino »

Benj wrote:Hello

In flowcode 2 you will need to create your own C or assembler functions to control the PWM.

Flowcode V3 comes with a PWM component that makes this task a lot easier.
OK but if you can copy the code genereted by flowcode v3 for the PWM component, i'll be happy ;)

thanks

ps : is there a solution with Add Defines pwm ?

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

Post by Steve »

The code generated by Flowcode V3's PWM component is very bloated for your needs. Also, it is designed for a different compiler than C2C and so it will not work without modification.

I suggest you look at the datasheet for the PICmicro you want to use instead. The section on PWM generation is pretty good and should explain everything you require. For example:
15.4.4 SETUP FOR PWM OPERATION
The following steps should be taken when configuring
the CCP module for PWM operation:

1. Set the PWM period by writing to the PR2 register.
2. Set the PWM duty cycle by writing to the CCPRxL register and CCPxCON<5:4> bits.
3. Make the CCPx pin an output by clearing the appropriate TRIS bit.
4. Set the TMR2 prescale value, then enable Timer2 by writing to T2CON.
5. Configure the CCPx module for PWM operation.

mohandino
Posts: 22
Joined: Fri Jun 29, 2007 9:41 pm
Has thanked: 1 time
Contact:

Post by mohandino »

hi

i found the solution see this site in french

http://isi-si.chez-alice.fr/flowcode/flowcode.htm

I've a new problem. I whant to change the light of a seven digit display by using the pwm. Is someone knows the frequence to have a output 1V< CCP1< 5V ?

thanks

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:

Post by Benj »

Thanks for the link.

You need a PWM frequency that is fast enough to acheive a good refresh rate. Then you can simply change to mark space ratio to control the brightness of the display.

Post Reply