Converting a program from Arduino to Flowcode help.

For general Flowcode discussion that does not belong in the other sections.
kennethnilsen69
Posts: 35
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Converting a program from Arduino to Flowcode help.

Post 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

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post 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?

mnfisher
Valued Contributor
Posts: 981
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 105 times
Been thanked: 516 times

Re: Converting a program from Arduino to Flowcode help.

Post 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

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post 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
Attachments
OrionBMS_CAN Translator.fcfx
(43.92 KiB) Downloaded 49 times

mnfisher
Valued Contributor
Posts: 981
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 105 times
Been thanked: 516 times

Re: Converting a program from Arduino to Flowcode help.

Post 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..)

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post by kennethnilsen69 »

yes I use FC9. but I don't understand much of what you write. can you explain a little more?

mnfisher
Valued Contributor
Posts: 981
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 105 times
Been thanked: 516 times

Re: Converting a program from Arduino to Flowcode help.

Post by mnfisher »

A simple example - have a look at the definition of Id155_init...
init.fcfx
(10.06 KiB) Downloaded 68 times
Martin

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post by kennethnilsen69 »

Aha now I understand :-) thank you Martin. there will probably be 1000 more questions later :-)

kennethnilsen69
Posts: 35
Joined: Wed Dec 02, 2020 11:41 am
Been thanked: 2 times

Re: Converting a program from Arduino to Flowcode help.

Post 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
Last edited by kennethnilsen69 on Fri Sep 16, 2022 10:00 am, edited 1 time in total.

LeighM
Valued Contributor
Posts: 401
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 73 times
Been thanked: 218 times

Re: Converting a program from Arduino to Flowcode help.

Post by LeighM »

Looks like you have set a DLC of 4, hence data 6 won't get sent, (only the 4x 0xFF)

Post Reply