Hi!
My question is:
Programming CAN funcionalities for a CAN Tx and a CAN Rx through the MBD
toolbox I have the following issue: For the Rx box, you can receive any
message ID, while for the Tx box you have to specify which ID message
you are sending. In case I wanted to test for sending multiple ID, how
can this be done without manually changing the ID every time a message
is going to be sent?
Thanks.
Kind regards,
Juliana
Thanks both of you sparkee and constantinrazvan.chivu. Sorry for the late reply.
The problem with this, is that for my application, the transmission of messages which IDs are only known when these are received is totally necessary. I don't know the IDs of the messages either, and in case I knew them, these would be a lot (500 approx).
I was wondering if maybe building a custom box with MATLAB code this could be achieved as well. Is this a possibility?
Thanks in advance.
Hello
As I said in this thread, you can find a guide for inserting custom code. As an alternative, you could build your own block by mimicking our approach (you can copy the FCAN_Send block from our toolbox and make changes to it to achieve your goal). If time is not an issue for you, I can help you with your custom block starting 21st July.
Kind regards,
Razvan.
That would be perfect! In the meanwhile I will give it a look and try to understand the code. Thank you constantinrazvan.chivu.
Kind regards,
Juliana.
Sounds like a plan juliana.rojas3062@ctag.com ! I'll get back on this thread after our release on 20th.
Kind regards,
Razvan.
Hi Constantin,
I was about to begin with the code, but I have a few questions.
First, where can I save the block that I am going to modify in order for it to be available in the future, even if there are toolbox updates?
Second, should I modify the FCAN block or the fcan_s32k.tlc file?
Kind regards,
Juliana.
Hello juliana.rojas3062@ctag.com,
You can save this new block in a new mdl if you want -- you can start by copying our block, but don't forget to break the link between them (you can do this by right clicking on the new block -> Library link -> Disable Link and then again Library Link -> Break link, as you can't access break link the first time).
From what I understand, you don't need to modify the FCAN configuratin block, but the FCAN Send. There are some basic parts for every block - to put it briefly you have:
- the Simulink block (where you can edit the mask parameters -- by going to edit mask on the block)
- a mex file which determines your inputs and outputs (you link this mex file by right clicking on the block -> block parameters -> S-function name)
- a tlc file where you control what code gets generated by that block
- several m-files used to either control UI (how the mask interacts), either provide information that will be used in the tlc file (bringing parameters set in the mask to the tlc).
You can find examples and documentation for how to make a mex file (it's a C file with some specific functions that you can find detailed examples on Mathworks and all you have to do is build this C file using the mex command in the MATLAB terminal).
Hope this is helpful. We'll go into more details in the coming week if you need it.
Kind regards,
Razvan.
Ok so, just to see if I understood correctly, I will only need to modify the mex file of the transmission block, is that correct?
Yes, next week it's perfect. I am new to Simulink so I am trying to get familiar with what I will be doing in the midtime.
Kind regards,
Juliana
Hello juliana.rojas3062@ctag.com,
You should use multiple CAN TX blocks - each having their individual ID you want to send with.
Hope this helps,
Razvan.
Thanks for your reply. I was trying to test a bypass, so in order to do this I need to send different IDs as I receive them, meaning I won't know which IDs I will be receiving/sending. Is there a way to do this with a single box of transmission?
Thanks again,
Juliana
Do you have a list of all possible CAN IDs that you might receive? If so, you can set up a CAN Tx for each ID, then choose which one to use based on the CAN Rx ISR masking. I would agree with constantinrazvan.chivu that if the CAN IDs are unknown, it may not be possible. However, if the list of IDs is known, you should be able to accomplish this.
Hello juliana.rojas3062@ctag.com,
Now I understand why you need to have an input instead of a mask parameter - unfortunately when these blocks were developed the use cases that were brought up seem to all fit the mask parameter approach, as it is common to know what IDs you need for the messages you send. For the moment I don't know of a way you can send IDs only known at runtime, but I will give it a thought and get back to you if I come up with something. Thank you for sharing some details so we have a better understanding of what you are trying to achieve here.
Kind regards,
Razvan.