Page 1 of 1
Error when compiling to target
Posted: Fri Sep 26, 2025 5:16 pm
by Billduck1302
This is the message. Is there a way to troubleshoot based on the last message "error code 0x1", or " invalid operands to binary | (have 'MX_FLOAT {aka volatile float}' and 'float')"? The correct programmer port is selected. Thanks in advance.
"C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell>"C:\Program Files (x86)\Flowcode\Common\Compilers\avrv5\bin\avr-gcc.exe" -mmcu=atmega328p -Os -ffunction-sections -fdata-sections -funsigned-char -o "C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell\June19,25_LeafCell_V2.elf" "C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell\June19,25_LeafCell_V2.c" -lm -Wl,-gc-sections
C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell\June19,25_LeafCell_V2.c: In function 'main':
C:\Users\Klsa\OneDrive\Desktop\1PROGRAMMING\Flowcode_V10\LoadTestSingleCell\June19,25_LeafCell_V2.c

34: error: invalid operands to binary | (have 'MX_FLOAT {aka volatile float}' and 'float')
C:\ProgramData\MatrixTSL\FlowcodeV10\FCD\AVR\batchfiles\avra.bat reported error code 0x1
"
Re: Error when compiling to target
Posted: Fri Sep 26, 2025 6:03 pm
by chipfryer27
Hi
It doesn't seems to like your decision in Main
Cell_1_Voltage_Float OR Cell_2_Voltage_Float < 3.0
If you use a Logical OR (||) it compiles.
Cell_1_Voltage_Float || Cell_2_Voltage_Float < 3.0
Regards
Re: Error when compiling to target
Posted: Fri Sep 26, 2025 6:20 pm
by LeighM
Well spotted, also it will need to be more explicit..
(Cell_1_Voltage_Float < 3.0) || (Cell_2_Voltage_Float < 3.0)
Re: Error when compiling to target
Posted: Fri Sep 26, 2025 10:58 pm
by Billduck1302
Thank you so much. I am just learning about Injectors, when using the F8 key.
Can it be done that, when prompted to read an analog input, that I could type in the bite when I have the command "Get Average Int".
By the way, this is a program to test the capacity of Nissan Leaf cells.(2S2P)
Leight, what do you mean y more explicit?
Re: Error when compiling to target
Posted: Sat Sep 27, 2025 2:34 am
by chipfryer27
Hi
One of the great features of Flowcode is to "step through" your program.
This could be in simulation, where you have the option to view any variable you choose, or if using Ghost enabled hardware you can step through and view everything in real time. Highly recommended debug tool.
I think what Leigh was refering to, was that you need to break down your decision into two separate calculations, each in their own parentheses, to be "OR'd".
Hope this helps.
Re: Error when compiling to target
Posted: Sat Sep 27, 2025 12:10 pm
by LeighM
Yes, that's it.
You need to be aware of the syntax/format of IF expressions.
IF something, where something is true or false.
In C, false is 0 (zero) and true is non-zero.
So sometimes "IF variable" will be a valid statement, assuming variable is an int (not float).
And will treat the statement as true if the variable is not zero.
Your "IF this OR that < 3" would be true if "this" is non-zero OR "that" is less than 3.
So it's better to explicitly say "this <> 0" to avoid confusion.
Hope that helps.
(and that I've not mistyped on my phone

Ps. If you want to dig deeper, look up operator precedence
Re: Error when compiling to target
Posted: Mon Sep 29, 2025 10:00 am
by Steve-Matrix
There has always been a bit of confusion with the terms "AND", "OR" and "NOT" within Flowcode, because these refer to "bitwise" operators rather than "logical" operators. These were used in the very first version of Flowcode when the logical AND/OR/NOT were not supported (we introduced this in v3).
There is a post about this on our old forums:
https://www.flowcode.co.uk/mmforums/vie ... php?p=8157
In the new version of Flowcode, which should be released soon, the operators "AND", "OR" and "NOT" are still supported (as bitwise operators for backwards compatibility) but we now promote using the C-style syntax that explicitly refers to the bitwise or the logical operators (e.g. "&&" and "&").
Here's a screenshot of the new dropdown for mathematical functions, which groups together similar mathematical operators:

- flowcode operators.png (22.92 KiB) Viewed 1920 times
Note also there is a similar issue with "equals". In C code, the single "=" is used when assigning values to variables and the double equals "==" is a 'relational' operator that is used when comparing values (e.g. "is x equal to 5"). Flowcode has always allowed the single "=" to mean "is equal to" in a decision even though this is incorrect in most modern computer languages (we originally copied this dual use from BASIC). Recent versions of Flowcode have also allowed the double "==" when comparing values (as per C, JavaScript, etc).
We continue to allow this dual use for the single "=", but now the suggested relational operator when comparing values is "==" as this makes it easier for Flowcode users to understand and learn C code.