Frequency Counter

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
Will643
Posts: 3
Joined: Thu Feb 02, 2012 10:04 pm

Frequency Counter

Post by Will643 »

Hi

I am trying to program a 16f88 PIC using Flowcode v4 to display a frequency to 4 decimal points. I am using an interrupt and tmr0 and can get a result displayed on an LCD as a whole number but not with decimal points as the counter result is an integer. Any help would be appreciated to get the result as a string or a float so i can display the result with a decimal point.

Thanks
Will

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Frequency Counter

Post by JonnyW »

Hello. How are you storing the frequency - as an integer?

An integer is always a whole number - there is never any need to add a decimal point. If this is a particular requirement you can do:

Code: Select all

buffer = IntToString$(frequency)
buffer = buffer + "."
To add a '.' after the number.

If you are dividing by another number to get a fractional value, you can do this to a floating point result:

Code: Select all

freq = fdiv(int2float(multiplier), int2float(divisor))
Then you can use a float and use FloatToString$() in a string calculation box to display this. I would not do this in an interrupt though as floating point calculations and string conversions are slow.

Note in v5 this code can all be done in a single calculation box as:

Code: Select all

freq = int2float(multiplier) / divisor
buffer = FloatToString$(freq)
I hope this is what you are after or is something to go on.

Jonny

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times

Re: Frequency Counter

Post by jadiflow »

Johnny, if I may:

I have a problem with the FloatToString$ function.
It seems to work OK until the argument to FloatToString$ is larger than 32k.
Above a value of 32k, incorrect values are printed.
Is there a limit to the FloatToString$ function preventing it to convert values above 32k?

jan

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: Frequency Counter

Post by Benj »

Hi Jan,

Replied to you here.
http://www.matrixmultimedia.com/mmforum ... =7&t=10457

Please don't multi post if you can help it. :?

Post Reply