Page 2 of 2

Re: Converting a program from Arduino to Flowcode help.

Posted: Fri Sep 16, 2022 9:57 am
by kennethnilsen69
sorry DLC 4 is just a typo. I use 8 :-) But I found out that I had to use FCV_ in front of the variable (FCV_ID155_INIT[1]) so now it works as it should :-)

Re: Converting a program from Arduino to Flowcode help.

Posted: Fri Sep 16, 2022 10:30 am
by kennethnilsen69
A new question.
If, for example, I want to send out the entire id155_INIT[8], I can do it like this:
FC_CAN_SetTxIdent_1(0, 0x155);FC_CAN_SetTxData_1(0, 8, FCV_id155_INIT[0], FCV_id155_INIT[1], FCV_id155_INIT[2], FCV_id155_INIT[3], FCV_id155_INIT[4], FCV_id155_INIT[5], FCV_id155_INIT[6], FCV_id155_INIT[7]);FC_CAN_SendBuffer_1(0);

but as long as I send out the entire variable unchanged, there will be a lot of writing and I wonder if there is an easier way to do this.

I try:
FC_CAN_SetTxIdent_1(0, 0x155);FC_CAN_SetTxData_1(0, 8, FCV_id155[8]);FC_CAN_SendBuffer_1(0);
But it does not want to accept this. FC then says "error: too few arguments to function 'FC_CAN_SetTxData_1'"

Re: Converting a program from Arduino to Flowcode help.

Posted: Fri Sep 16, 2022 11:26 am
by BenR
Hello,

Sorry the long hand method is currently the only way. If you put the code inside a macro then you would just have to call the macro whenever you want to send the data.

We could add a function to allow the data to be loaded from and to an array so I'll get this on the list.

Re: Converting a program from Arduino to Flowcode help.

Posted: Fri Sep 16, 2022 2:35 pm
by kennethnilsen69
BenR wrote:
Fri Sep 16, 2022 11:26 am
Hello,

Sorry the long hand method is currently the only way. If you put the code inside a macro then you would just have to call the macro whenever you want to send the data.

We could add a function to allow the data to be loaded from and to an array so I'll get this on the list.
Thanks Ben. it would have been a nice function to have. In the meantime, I'll do as you suggest :-)

Re: Converting a program from Arduino to Flowcode help.

Posted: Wed Sep 28, 2022 1:20 pm
by kennethnilsen69
Does anyone have a suggestion for how I write this calculation in a FC calculation box

unsigned long odo = ((unsigned long)id599[0] << 24)
| ((unsigned long)id599[1] << 16)
| ((unsigned long)id599[2] << 8)
| (id599[3]);
odo /= 10;
id55E[6] = odo >> 8;
id55E[7] = odo & 0x00ff;

Re: Converting a program from Arduino to Flowcode help.

Posted: Wed Sep 28, 2022 2:55 pm
by BenR
Hello,

I would recommend using the type conversion component to do this. Should be way more efficient than doing 32-bit typecast bit shifts.

TypeConversion::SetByte(0, id599[3])
TypeConversion::SetByte(1, id599[2])
TypeConversion::SetByte(2, id599[1])
TypeConversion::SetByte(3, id599[0])
odo = TypeConversion::GetLong()

odo = odo / 10

TypeConversion::SetLong(odo)
id599[6] = TypeConversion::GetByte(1)
id599[7] = TypeConversion::GetByte(0)

Re: Converting a program from Arduino to Flowcode help.

Posted: Thu Sep 29, 2022 8:16 am
by kennethnilsen69
Thanks Ben, I have added the TypeConversion component but get this error message in the Calculation

Re: Converting a program from Arduino to Flowcode help.

Posted: Thu Sep 29, 2022 8:22 am
by kennethnilsen69
I figured it out Ben. I was just missing an s at the end of in TypeConversion's name