C CODE doesn't work with V3

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

Moderators: Benj, Mods

Post Reply
MIKE_31
Posts: 15
Joined: Wed Aug 08, 2007 12:11 pm
Location: FRANCE

C CODE doesn't work with V3

Post by MIKE_31 »

Hi,
I write this following program but the C Code doesn't work
LCD display always "48' why ??

Thank
----------------------------------------
//Appel de la Routine Composant
Appel de la Routine Composant:

LCDDisplay(0)::Init
----------------------------------------

----------------------------------------
//Appel de la Routine Composant
Appel de la Routine Composant:

LCDDisplay(0)::Efface
----------------------------------------

----------------------------------------
//Calcul
Calcul:

RANG = 51
TOTO = 3
OUT = 48
----------------------------------------

----------------------------------------
//Boucle
Boucle:

Tant que1
<LOOP>

----------------------------------------
//Code C
Code C:

FCV_OUT = FCV_OUT + 1;
----------------------------------------

----------------------------------------
//Appel de la Routine Composant
Appel de la Routine Composant:

LCDDisplay(0)::Γ‰crit_Num(OUT)
----------------------------------------

----------------------------------------
//Pause
Pause:

1 s
----------------------------------------

----------------------------------------
//Appel de la Routine Composant
Appel de la Routine Composant:

LCDDisplay(0)::Efface
----------------------------------------

</LOOP>
----------------------------------------

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

Post by Steve »

I can think of 2 possibilities:

1) The watchdog timer config bit is enabled, meaning your program restarts before OUT increments

2) The clock sped is set wrong and the delay of 1s is actually much larger.

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 »

The Flowcode simulation will not work as you are using C code to increment the OUT variable. It should work fine on hardware.

MIKE_31
Posts: 15
Joined: Wed Aug 08, 2007 12:11 pm
Location: FRANCE

re POW in C Code

Post by MIKE_31 »

Yes Benj,

Thank a lot,It's better using hardware.......

I have a other question :

Is it possible to have the function pow(x,y) in flowcode ??
If i use it I have a message error ?
How can i use X^Y ??

Thank for you replay........


Mike

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 Mike

You can do power calculations as follows.

Create your two variables eg A and B.

Variable A may need to be an Int 16 bit variable to hold the result.

Then assign values to A and B with a calculation icon.

Then create a while loop with "B" in the loop while text box (do not include the brackets). This means that the loop will run while B is greater then 0.

Inside the loop create the following calculation "A = A * A"

Then create another calculation to decrment variable B "B = B - 1"

Hope that this helps.

Post Reply