Syntax help

For general Flowcode discussion that does not belong in the other sections.
Post Reply
User avatar
p.erasmus
Posts: 434
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Syntax help

Post by p.erasmus »

Hi Team.

in a normal C programming project I can define a number with and exponent like
#define _GAINFACTOR 1.87e-6
const GAIN = 1.87e-6
what is the recommend way in Flowcode , trying to create a constant with 187e-6 did not work or even 187exp(-6) :oops: :oops:
All help and pointers are appreciated

:D
Regards Peter - QME Electronics

mnfisher
Valued Contributor
Posts: 1046
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 107 times
Been thanked: 538 times

Re: Syntax help

Post by mnfisher »

You could put it as a normal decimal?

0.000187

The form given is slightly odd - normally would be 1.87e-6 ?

Martin

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: Syntax help

Post by p.erasmus »

Martin
The form given is slightly odd - normally would be 1.87e-6 ?
You are correct with that it is the old diabetes eyes miss such things lately

Yes I use the decimal form just thought there is a elegant way in Flowcode :D
Regards Peter - QME Electronics

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: Syntax help

Post by p.erasmus »

Hi Team.

I am struggling to understand how to compliment a byte a 16 bit variable ,
the value in the 16 bit variable is the two's compliment therefore it is necessary to subtract one from it and then do a compliment

I have been using this in CX8 in MPLAB by
int a = 10; /* 10 = 1010 */
int c = 0;
c = ~(a);

How can I do this in FC or even better obtaining the value from a two's compliment value :shock: with out the use of a C call :D
Regards Peter - QME Electronics

Steve-Matrix
Matrix Staff
Posts: 1310
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 175 times
Been thanked: 299 times

Re: Syntax help

Post by Steve-Matrix »

In a calculation, the operator "NOT" is the ~ operator. It works in simulation and here's the code Flowcode produces.

Code: Select all

    // Name: Calculation, Type: Calculation:
    // a = 10
    // c = 0
    FCV_A = 10;
    FCV_C = 0;

    // Name: Calculation, Type: Calculation:
    // c = NOT (a)
    FCV_C = ~(FCV_A);
You might need to ensure you use unsigned bytes or unsigned ints.

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: Syntax help

Post by p.erasmus »

Thank you Steve.
Appreciate your help
Regards Peter - QME Electronics

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: Syntax help

Post by p.erasmus »

HI Steve,
A big thank you this worked great ,I am very happy see positive and negative temperature from the ADS1118 over SPI :D
Regards Peter - QME Electronics

Post Reply