Page 1 of 2
Converting a program from Arduino to Flowcode help.
Posted: Fri Aug 26, 2022 8:29 am
by kennethnilsen69
Hi, I have an Arduino program that I need to convert to Flowcode, but my knowledge of the Arduino platform is not good enough for this. Is there anyone out there who wants to take this job. I would be happy to pay you for this
Please send me a PM or an email to
kennethnilsen69@gmail.com if you are interested
Re: Converting a program from Arduino to Flowcode help.
Posted: Wed Sep 14, 2022 1:34 am
by kennethnilsen69
I am trying to use this byte line in FC's C-Code box
byte id155_init[8] = { 0xFF, 0x97, 0xD0, 0x94, 0x00, 0x08, 0x00, 0x6F };
I create an id155_init variable and write the line like this in the C-Code box:
FCV_id155_init[8] = { 0xFF, 0x97, 0xD0, 0x94, 0x00, 0x08, 0x00, 0x6F };
I get this error when I compile it
OrionBMS_CAN Translator.c:5575:2: error: 'FCV_id155_init' undeclared (first use in this function)
OrionBMS_CAN Translator.c:5575:2: note: each undeclared identifier is reported only once for each function it appears in
OrionBMS_CAN Translator.c:5575:22: error: expected expression before '{' token
OrionBMS_CAN Translator.c:5605:2: warning: 'return' with a value, in function returning void
Error returned from [xc16-gcc.exe]
C:\Program Files (x86)\Flowcode\Common\Compilers\pic16\batchfiles\pic16_C30_comp.bat reported error code 0x1
Does anyone have any suggestions on how I can achieve this?
Re: Converting a program from Arduino to Flowcode help.
Posted: Wed Sep 14, 2022 8:00 am
by mnfisher
Flowcode variables are all capitalised - so need FCV_ID155_INIT would be my guess.
Note you can set this on the initial value box when you declare the variable ( in v9) without using a C box...
If you upload the fcfx file we can look.
Martin
Re: Converting a program from Arduino to Flowcode help.
Posted: Wed Sep 14, 2022 11:11 am
by kennethnilsen69
here is my fcfx file
the point of [8] is that the variable should contain all 8 bytes so that I can send and refer to specific byte in the variable
Re: Converting a program from Arduino to Flowcode help.
Posted: Wed Sep 14, 2022 11:22 am
by mnfisher
You need to initialise the variable in the variable setup.
I don't think you can declare a variable and then use an initialiser later
Int x [] ={2,2,3};
Is good.
Int x[3];
x[] = {1,2,3};
No good.
Are you using v9? If so the thing to do is set an initial value in FC
Martin
(sorry sent from phone so some case may be wrong..)
Re: Converting a program from Arduino to Flowcode help.
Posted: Wed Sep 14, 2022 11:28 am
by kennethnilsen69
yes I use FC9. but I don't understand much of what you write. can you explain a little more?
Re: Converting a program from Arduino to Flowcode help.
Posted: Wed Sep 14, 2022 11:41 am
by mnfisher
A simple example - have a look at the definition of Id155_init...
Martin
Re: Converting a program from Arduino to Flowcode help.
Posted: Wed Sep 14, 2022 11:45 am
by kennethnilsen69
Aha now I understand

thank you Martin. there will probably be 1000 more questions later

Re: Converting a program from Arduino to Flowcode help.
Posted: Thu Sep 15, 2022 4:26 pm
by kennethnilsen69
Ok so now I have created a variable id155_init[8] with data { 0xFF, 0x97, 0xD0, 0x94, 0x00, 0x08, 0x00, 0x6F }
Now if I want to retrieve/Save data 1 from/to the variable id155 (which is 0x97) How do I do that?
I have tried to retrieve it like this and put it in data 6 in this CAN message without success:
FC_CAN_SetTxIdent_1(0, 0x659);FC_CAN_SetTxData_1(0, 4, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, id155_init[1], 0x00);FC_CAN_SendBuffer_1(0);
If I do this, all the data in the CAN message is changed, not just data 6.
Ok so now I have created a variable id155_init[8] with data { 0xFF, 0x97, 0xD0, 0x94, 0x00, 0x08, 0x00, 0x6F }
Now if I want to retrieve data 1 from the variable id155 (which is 0x97) How do I do that?
I have tried to retrieve it like this and put it in data 6 in this CAN message without success:
FC_CAN_SetTxIdent_1(0, 0x659);FC_CAN_SetTxData_1(0, 4, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, id155_init[1], 0x00);FC_CAN_SendBuffer_1(0);
If I do this, all the data in the CAN message is changed, not just data 6. and none of them are 0x97
In arduino, data is retrieved like this. For an example
id155_init[0] = 0xFF
id155_init[1] = 0x97
id155_init[2] = 0xD0
id155_init[3] = 0x94
id155_init[4] = 0x00
id155_init[5] = 0x08
id155_init[6] = 0x00
id155_init[7] = 0x6F
I found that the correct thing in FC is:
FCV_id155_init[0] = 0xFF
FCV_id155_init[1] = 0x97
FCV_id155_init[2] = 0xD0
FCV_id155_init[3] = 0x94
FCV_id155_init[4] = 0x00
FCV_id155_init[5] = 0x08
FCV_id155_init[6] = 0x00
FCV_id155_init[7] = 0x6F
Re: Converting a program from Arduino to Flowcode help.
Posted: Thu Sep 15, 2022 10:10 pm
by LeighM
Looks like you have set a DLC of 4, hence data 6 won't get sent, (only the 4x 0xFF)