Hi,
I realized a CAN communication between s32k144 (master) and s32k148 (slave). I use the Model Based Design Toolbox (Simulink). The master sends three different IDs (3FF, 120, 1EF) at three different times. I want to read the physical values of CAN High and CAN Low. So the idea is to modify the code of slave in order to read, thanks to FreeMaster, the voltages of the two cables. I need the ADC and in particular, the ADC must be synchronized with the CAN msg. I want to use the blocks of ADC, available in Model Based Design Toolbox, to config the ADC and to guarantee the exact relationship between binary and voltage values. Does someone know how to obtain the physical values of CAN msg with Model Based Design Toolbox?
Thank you
Hello p.decesare@studenti.unipi.it,
This is an interesting project you want to do here - I'm just not sure if it's an assignment from your university (as I saw your email) and if it is, how much of this you should figure out yourself, as every such interesting project is a learning opportunity. In the case it is a university project, let me know the extents of the task and what kind of help you're allowed to ask for.
Sorry for any inconvenience and keep at it!
Kind regards,
Razvan.
Hi Constantin Razvan Chivu
I am a scholarship holder of a project at my University. I need some help because I don't understand some things of ADC. I think I adopt the hardware trigger. My idea is: when the slave receive the three CAN messages, the leds turn on and simultaneously the ADC start the conversion. I use the two ADC, one for CAN-High and one for CAN-Low. For the hardware trigger I want to use the PDB. But in the block PDB0 or PDB1 I set as Trigger Input Source software because the trigger, in my case, is the arrival of messages. My question is: how to interleave the two ADC? It is possible to configure the trigger of ADC as hardware in the sense that the flow chart is CAN-BUS -> PDB -> ADC?
Thanks for your availability.
Kind regards,
Paola
The problem with CAN-PDB-ADC is circular. You're attempting to read the CAN bus with an ADC that is triggered by the CAN bus. Your ADC trigger won't start your ADC reads until your ADC sees a signal. The only thing I can think of is
have one of your ADC modules read continuously and trigger the second ADC module to read when it detects a signal.
So top level looks like this:
Inside action block is this:
ADC0 triggers the start of PDB1 which controls ADC1. I didn't try to run this, I just threw the blocks together for visual reference.
It seems more complex than it needs to be though. If you're already reading the CAN bus with ADC0 why not just use those values? Why the timing needs? You could start a timer anytime the ADC reads a high signal if you need timing. That would allow you to read both the high and low simultaneously. Also, why do you need to read both? Can't you just read one and assume the other is an inverted mirror of it? The reason Razvan asked what the task was is so that he could solve the correct problem. Solving the problem you have right now may turn out to be a dead end and a waste of time. There may be a better problem to solve.
Dylan
Hi sparkee,
thanks for your help. Sorry if I don't explain very well my purpose that I want to reach. I want to use the ADC in order to obtain the physical values of two cables. I could use one ADC, as you mentioned. But I don't know how to syncrhonize the conversion of the ADC with the arrival of messages. I want that each time that on the bus there is a Start of Frame, the ADC starts the conversion. In this way I know the physical values of each msgID. For my purpose, it is very important to obtain the physical values of each msgID in order to extract a set of features. My setup is the follow: there is a master, a slave and finally a NXP where there is the code of ADC (I use model based design toolbox). In the model of ADC I need the information of Start of Frame, in order to obtain a correct synchronization. How Can I do this?
Thanks for your help
Best regards
Paola
I'm not sure why you need to synchronize the conversion with the message arrival but the example I gave above already accomplishes that objective.
Edit:
My apologies, I reread your original question and I now see that you want "to guarantee the exact relationship between binary and voltage values."
I assume that you're just trying to verify that the CAN message is being interpreted correctly by the CAN Rx block? If that's the case, you don't need to synchronize the ADC. Just run the ADC all the time and use the CAN Rx ISR to trigger whatever comparison you're trying to make. I don't know of an easy way to do that comparison though. You'll have to interpret your ADC into a binary value then compare that binary value to the one received by the CAN Rx block. Do you already have that part solved and now you're just trying to synchronize them so you compare to the correct message?
Hi sparkee,
I need the synchronization because, as I mentioned earlier, I want to extract from the voltage measurements of CAN-High and CAN-Low of each message, some features (maximum, minimum, etc..). It is very important that for each frame of msgID, I have the correct voltage values. I don't understand very well your solution. If you want, can you explain again?
Thank you
Best regards
Paola
I think part of the problem is simply the meaning of the word synchronize, at least for me. When I see the word synchronize, I see "happens at the same time." If I'm using the term wrong, please correct me. The problem that I see with the synchronize approach (know that I am not an expert) is that there is no way to analyze the ADC and the CAN input at the same time.
In your second message you say you want:
"when the slave receive the three CAN messages, the leds turn on and simultaneously the ADC start the conversion."
This isn't possible because if you've already received the CAN message, there's nothing to read with the ADC.
I also see some problem with the term "receive" as you've used it above. The way the CAN system works is that once a CAN message is "received" it triggers the ISR. At this point, there is nothing on the bus to read.
To my knowledge, the only way to do something similar is you must store the ADC input and wait for the CAN Rx to complete so that you can then compare the two. Try reversing your process to look for ADC to go high (or low if you're on CAN L) first, then store your ADC inputs until the CAN message is complete. When the CAN system "receives" the message, the CAN ISR will trigger and you can then compare the two. This is not "synchronized" in the way I would use the term but it will allow you to compare the ADC to the CAN message, which I believe is what you're trying to accomplish.
I have used the adc_isr_s32k example and added to it below:
The if box waits until the ADC goes high (indicating a CAN message is on the bus) then stores it using an "if action" subsystem. That output goes to a compare subsystem that is triggered by the Rx Complete ISR block which also sends the CAN message over for the compare.
I have not attempted to test any of this, I'm just giving a visual reference to what I was saying above. Hopefully one of the more seasoned NXP employees will chime in if I'm incorrect.
Hi sparkee,
thank you for your help and patience. I have some questions:
Thank you for your time and availability
Best regards
Paola