Page 1 of 1
Syntax help
Posted: Mon Mar 01, 2021 1:45 pm
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)
All help and pointers are appreciated

Re: Syntax help
Posted: Mon Mar 01, 2021 1:48 pm
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
Re: Syntax help
Posted: Mon Mar 01, 2021 2:18 pm
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

Re: Syntax help
Posted: Tue Mar 02, 2021 11:46 am
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

with out the use of a C call

Re: Syntax help
Posted: Tue Mar 02, 2021 1:31 pm
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.
Re: Syntax help
Posted: Tue Mar 02, 2021 1:53 pm
by p.erasmus
Thank you Steve.
Appreciate your help
Re: Syntax help
Posted: Wed Mar 03, 2021 2:26 pm
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
