External CAN Component Missing Parameter

Post here to discuss any new features, components, chips, etc, that you would like to see in Flowcode.
Post Reply
User avatar
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

External CAN Component Missing Parameter

Post by p.erasmus »

Dear Ben/Team.

I am urgently in need to Send a RTR CAN message from a MIAC in an project however as you will know / see below that the SetTXData does not allow us to set the RTR bit in the buffer configuration ,when the Buffer is send it is always send as a Standard or Extended message .
Therefore we can not send a STD or XTD CAN RTR message :)

I suppose in the CAN component properties it can also be done if the parameter is added there however this means that this specific Buffer will always be an RTR Message Buffer,I would think it is better if the parameter is avaialble when populating tit with DATA and we then have the option that the Buffer is a RTR frame buffer or not ,Please help me by adding this to the CAN compoment it is very urgent, I need to run this machine on 20.10.2022.

I appreciate your help :)

P1.JPG
P1.JPG (65.73 KiB) Viewed 3160 times
From then Data sheet
P2.JPG
P2.JPG (82.24 KiB) Viewed 3160 times
Regards Peter - QME Electronics

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: External CAN Component Missing Parameter

Post by p.erasmus »

Dear Team,

I tried as a work around to set the RTR bit manually however it seems the TXBnDLC register are not in the definition file.


P1.JPG
P1.JPG (92.66 KiB) Viewed 3137 times
Thanks again for your help.
Regards Peter - QME Electronics

Steve-Matrix
Matrix Staff
Posts: 1384
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 184 times
Been thanked: 322 times

Re: External CAN Component Missing Parameter

Post by Steve-Matrix »

Hi Peter,

It might work if you call the underlying function with a C icon similar to the following:

Code: Select all

FC_CAN_SPI_CAN_Write_1(0x35, 0x4F);
For the function name, search for "FC_CAN_SPI_CAN_Write" in the C code currently generated by your Flowcode project because the "_1" suffix may be different.

The "0x35" is, I think, the address of the TXB0DLC register. And the "0x4F" sets the RTR bit and sets the data byte count to 8. I assume the data count needs to be 8. You will need to set this back to "0x0F" again to sent 'normal' messages.

I have not tried this myself and it might not work for you, but hopefully it will.

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: External CAN Component Missing Parameter

Post by p.erasmus »

Hi Steve,

Thank you for the sugestion ,Please help the byte count should be 1 so it is datalenght 1 and RTR set

Thanks for your help However is it not better when this is allowed to be selected from the Component ?
Regards Peter - QME Electronics

Steve-Matrix
Matrix Staff
Posts: 1384
Joined: Sat Dec 05, 2020 10:32 am
Has thanked: 184 times
Been thanked: 322 times

Re: External CAN Component Missing Parameter

Post by Steve-Matrix »

Hi Peter,

You're correct - it's probably better to have an option for RTR in the component itself. But hopefully my suggestion gives you a workaround until the component has been redeveloped.

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: External CAN Component Missing Parameter

Post by p.erasmus »

Hi Steve,

I understand this Thank you so much.
I could only find the following in my C Code it seems your suggestion is correct with " FC_CAN_SPI_CAN_Write_1" Please just check for with your experienced eyes

Regards
P1.JPG
P1.JPG (86.45 KiB) Viewed 3116 times
Regards Peter - QME Electronics

BenR
Matrix Staff
Posts: 1895
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 491 times
Been thanked: 664 times

Re: External CAN Component Missing Parameter

Post by BenR »

Hello,

If you were using internal CAN then I would suggest doing the following to allow you to control the RTR bit, I don't want to do too much immediatley as I don't want to break other users programs and I need to get a better grip on this bit and what it does.

To have the RTR bit clear sent the data count value as normal when calling the SetTXData macro. Range 0-8.

To have the RTR bit set simply send the data count | 0x40 and this will set the RTR bit in the register for you. Range 64-72.

Might also work for the external CAN, I'll see if there's a mask on the data cound size that would cause a problem.

Let us know how you getting on.


edit, looks like my hack should also work for the external CAN mode.

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: External CAN Component Missing Parameter

Post by p.erasmus »

Hi Ben,

Thank you for your reply ,
I will try tomorrow on the actual machine,
I am surprised that the component does not handle RTR message as it is a part of the CAN standard and is used quite a bit in industry
anycase if this will solf my problem I will be ver happy :D

Thanks again I will try

Regards
Regards Peter - QME Electronics

User avatar
p.erasmus
Posts: 434
Joined: Thu Dec 03, 2020 12:01 pm
Location: Russia / Россия
Has thanked: 104 times
Been thanked: 88 times

Re: External CAN Component Missing Parameter

Post by p.erasmus »

Dear Ben/Steve

Thank you for your help I managed to send a RTR Message
just as an information
o have the RTR bit clear sent the data count value as normal when calling the SetTXData macro. Range 0-8.

To have the RTR bit set simply send the data count | 0x40 and this will set the RTR bit in the register for you. Range 64-72.
This has no effect the bit is always 0 (do not know why :D )

However Calling the SPI function did the job

Code: Select all

FC_CAN_SPI_CAN_Write_1(0x35, 0x4F);
Thank you so much to you guys
Regards Peter - QME Electronics

Post Reply