Related articles
I put the CANoe demonstration project used in the series on Git and update it from time to time according to the blog.
preface
-
Test software and hardware environment:
VH6501 CAN Disturbance Interface
CANoe 11 SP2
Win10 X64 -
The sampling point is the position where the node judges the signal logic level, which is extremely important for CAN/CAN FD bus. Especially when networking, multiple nodes should try to keep the same sampling point. If the sampling points of nodes in the network are inconsistent, it may lead to sampling errors at the same sampling frequency, and then the whole network will fail. Therefore, it is particularly important to test the sampling points of CAN/CAN FD nodes
Test principle
① Test principle
In the sample point test case described in this paper, the tested node plays the role of receiving node. Taking the CAN sampling point test as an example, when VH6501 detects that the bus is idle, it sends a specific interference message with higher priority to complete an interference cycle. At the end of each interference cycle transmission, fine tune the length of CRC Delimiter bit to shorten it step by step, resulting in the forward movement of the next ACK Slot (dominant bit), and increase the length of ACK Slot to ensure that the length of the whole frame message remains unchanged. When the dominant bit level moves from back to front to the DUT sampling point, it will be collected by the DUT and determine that the CRC Delimiter bit is high level. In case of format error, the DUT will immediately send the error frame and be collected by CANoe
② Sampling point setting
For example, the requirements of the ECU I demonstrated are as follows; the def_SAMPLE POINT position for nominal bit shall be 80%
The bit time distribution is shown in Figure 1 below: so I set the sampling point parameters as shown in Figure 2 below
Concept of bit time
Concept of bit time
Concept of bit time
Conceptual link of bit time
③ Test script
This test script tests the sampling of CAN-FD arbitration section. If you want to sample and test the data section, please interfere with the bit of the data section
The following code refers to the source
Code understanding:
Each time the interference is triggered, it will enter on sysvar:: candisturbanceinterface1:: trigger:: state
When the interference bit is shortened to a certain extent, it becomes an error frame and enters the on errorFrame test
/*@!Encoding:936*/ includes { } variables { CanDisturbanceFrameTrigger frameTrigger; CanDisturbanceFrameSequence frameSequence; CanDisturbanceSequence sequence; CanDisturbanceTriggerRepetitions repetitions; //Number of disturbance repetitions in a cycle long result; long validityMask; long cycleFlag; message 0x100 triggerMessage = {FDF = 1}; //The triggermessage.(ID is not important.) message 0x0 spTestMsg = {FDF = 1}; //The disturbance frame sequence which CRC DEL need to be shorten. char spTestDone[33] = "SPDone"; int init_bit_length ,last_bit_length ; } on errorFrame { if(this.msgChannel == @sysvar::CANDisturbanceInterface1::ChannelNo) { last_bit_length = frameSequence.CRCDelimiter.BitSequence[0].segmentLength[0]; write("Last CRC Delimiter Bit Length = %d",last_bit_length); testSupplyTextEvent(spTestDone); } } on sysvar sysvar::CANDisturbanceInterface1::Trigger::State { //6501 is Idle after repetition_times_in_one_cycle finish if(@this == sysvar::CANDisturbanceInterface1::Trigger::State::Idle) // Idle:0 ;Active:1;Triggered:2 { // If testing the sampling point of the high-speed data segment of CAN-FD, use frmsequence CRC data --frameSequence.CRCDelimiter.BitSequence[0].segmentLength[0]; ++frameSequence.AckSlot.BitSequence[0].segmentLength[0]; result = canDisturbanceTriggerEnable(@sysvar::CANDisturbanceInterface1::DeviceNo,frameTrigger, frameSequence, repetitions); if(result == 1) { write("Trigger is enabled,frameSequence.CRCDelimiter.BitSequence[0].segmentLength[0] = %d",frameSequence.CRCDelimiter.BitSequence[0].segmentLength[0]); } else { write("Enable trigger error Result = %d", result); } } } testcase SamplePointTest_forVH6501() { frameSequence.SetMessage(@sysvar::CANDisturbanceInterface1::DeviceNo,spTestMsg); validityMask = 0; //trigger on any CAN messages frameTrigger.SetMessage(triggerMessage,@sysvar::CANDisturbanceInterface1::DeviceNo, validityMask); frameTrigger.TriggerFieldType = @sysvar::CanDisturbance::Enums::FieldType::EndOfFrame; frameTrigger.TriggerFieldOffset = 9; //Trigger position is the third bit of IFS. init_bit_length = frameSequence.CRCDelimiter.BitSequence[0].segmentLength[0] ; write("Init CRC Delimiter Bit Length = %d",init_bit_length); repetitions.Cycles = 1; repetitions.HoldOffCycles = 0; repetitions.HoldOffRepetitions = 0; repetitions.Repetitions = 1; result = canDisturbanceTriggerEnable(@sysvar::CANDisturbanceInterface1::DeviceNo,frameTrigger,frameSequence,repetitions); if(result == 1) { write("Trigger is enabled."); } else { write("Enable trigger error Result = %d", result); } result = testWaitForTextEvent(spTestDone, 10000); if(result == 1) { write("sample point lies in %f", (double)last_bit_length / init_bit_length*100); } }
④ The test results are as follows:
summary
This chapter blog explains the understanding of sampling points and the use of VH6501 for sampling point testing
For more comprehensive VH6501 learning, please refer to the help document and official example C:\Users\Public\Documents\Vector\CANoe\Sample Configurations 11.0.55\CAN\MoreExamples\CANDisturbanceInterface
- To have the most simple life, the most distant dream, even if it is cold tomorrow, the road is far away and the horse is dead!
- If this blog is helpful to you, please click "like", "comment" and "collect" for three times! The code word is not easy. Your support is the driving force for me to stick to it.