For general Flowcode discussion that does not belong in the other sections.
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
Post
by p.erasmus » Mon Mar 01, 2021 1:45 pm
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
Regards Peter - QME Electronics
mnfisher
Valued Contributor
Posts: 1453 Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 135 times
Been thanked: 707 times
Post
by mnfisher » Mon Mar 01, 2021 1:48 pm
You could put it as a normal decimal?
0.000187
The form given is slightly odd - normally would be 1.87e-6 ?
Martin
p.erasmus
Posts: 434 Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times
Post
by p.erasmus » Mon Mar 01, 2021 2:18 pm
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
Regards Peter - QME Electronics
p.erasmus
Posts: 434 Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times
Post
by p.erasmus » Tue Mar 02, 2021 11:46 am
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
Regards Peter - QME Electronics
Steve-Matrix
Matrix Staff
Posts: 1465 Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 204 times
Been thanked: 347 times
Post
by Steve-Matrix » Tue Mar 02, 2021 1:31 pm
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.
p.erasmus
Posts: 434 Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times
Post
by p.erasmus » Tue Mar 02, 2021 1:53 pm
Thank you Steve.
Appreciate your help
Regards Peter - QME Electronics
p.erasmus
Posts: 434 Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times
Post
by p.erasmus » Wed Mar 03, 2021 2:26 pm
HI Steve,
A big thank you this worked great ,I am very happy see positive and negative temperature from the ADS1118 over SPI
Regards Peter - QME Electronics