Vector CANoe CAPL系列相关文章导览,下面链接可直接跳转
Vector CANoe VT System系列板卡文章导览,下面链接可直接跳转
引言
本章节继续聊VT1004A负载和测量板卡的功能,板卡详细内容见VT_System_Manual_EN.pdf,内容为个人理解,如有错误,欢迎指正
VT1004A
每块板卡有4个通道,有如下功能
Functions for Each Channel
Various signal paths to the original loads and bus bars are switched via relays. The relays may be used, for example, to generate short circuits to ground or to battery voltage via a bus bar, or to break the line to an original load (broken wire simulation).
通过继电器切换通往原始负载和母线的各种信号路径。例如,继电器可用于产生接地短路或通过母线与电池电压短路,或断开与原始负载的线路(断线模拟)。
Relay for short circuits between the input lines
用于输入线路间短路的继电器
Electronic load for predefined current or resistance with electronic overload protection
预定义电流或电阻的电子负载,带电子过载保护功能
Voltage measurement with calculation of instantaneous, average and effective values
电压测量,可计算瞬时值、平均值和有效值
Determination of PWM signal parameters (frequency, duty cycle, high and low voltage levels)
确定 PWM 信号参数(频率、占空比、高低压电平)
Furthermore, it is possible to reverse the two-line connections of the two bus bars via relays (combined for all channels of a module).
此外,还可以通过继电器(模块所有通道的组合)反向连接两条母线的双线。
VT1104
是在VT1004A基础上的60V版本
VT1104 FPGA
暂时没有这个可编程板卡,等遇到了再补充
前后面板图
Usage
Basic Connection Scheme
Connecting the ECU
这里的功能和VT2004A有点类似,有4个通道,每个通道有两个接线端,和ECU通过这两个接线端连接,即使ECU只有一个输入引脚,也必须采用双线连接,这种情况下,传感器的地接到另一个引脚上。
典型应用场景:
VT1004A/VT1104 pin a | VT1004A/VT1104 pin b | |
---|---|---|
Reference potential ground (e.g. high side switch in ECU) | ECU connection | Ground(ECU ground!) |
Reference potential
V
b
a
t
t
V_{batt}
Vbatt (e.g. low side switch in ECU) | V b a t t V_{batt} Vbatt | ECU connection |
Signal Path Switching
图上所标即是板卡功能
Bus Bars
Measurement
Voltage Measurement
可以获取瞬时值、平均值、均方根值、最大/最小值。
有4种模式:
- 未滤波的line
a
和lineb
之间的电压差 - 带有10kHz低通滤波器的line
a
和lineb
之间的差分电压 - line
a
与 ECU 接地之间的电压 - line
b
与 ECU 接地之间的电压
Digital Input
每50us连续采样一次,可为每个通道设置一个阈值,用于区分高电平和低电平状态。CANoe 可获得当前状态和包含最后 20 个采样值的数组。
PWM Measurement
测量PWM信号的频率、占空比和高/低电平。
Electronic Load
电子负载,电路图左下角那里
接插件定义
看手册3.4章节
Technical Data VT1004A
手册中都有,这里再贴一下
General
Input Signals and Switches
Electronic Load
Voltage Measurement
精度取决于两个部分(值的百分比 + 偏移),和VT2516A板卡类似
Digital Input
PWM Measurement
Low Impedance Mode
High Impedance Mode
VT1104的技术资料看手册吧,就不贴图了
CAPL实例
VT System Configuration
连接板卡,不知道咋操作的,看这里里面有详细说明
VT System Control
模式操作等我们还是在CAPL和Panel里面操作系统变量来
CAPL函数库
(搜索这个文件CAPLfunctionsVTSystemOverview.htm,有详细介绍,包括函数使用示例等)
System Variables
system-defined
前面System Configurations
里面勾选了哪些,就会注册成系统变量,在这里显示出来
创建variables
根据需要创建如下variables以便于后续panel和capl进行调用
制作Panel
编写CAPL脚本
模式枚举
variables
{
// Defines the modes in which each channel can be
enum VT1004Modes { None, ShortCircuit, Measurement };
// Stores the mode in which each channel is
enum VT1004Modes VT1004Ch1Mode = None;
enum VT1004Modes VT1004Ch2Mode = None;
enum VT1004Modes VT1004Ch3Mode = None;
enum VT1004Modes VT1004Ch4Mode = None;
// Used to refresh measurement values
msTimer refreshTimer;
}
切换模式
switchModeVT1004 ( int channel, enum VT1004Modes mode )
{
if( channel == 1 )
{
if( VT1004Ch1Mode != mode )
{
VT1004Ch1Mode = mode;
if( mode == ShortCircuit )
{
// Nothing to do here
}
else if( mode == Measurement )
{
// Configure VT module channel for measurement
// See the CANoe help for details
// Set measurement mode to constant voltage measurement
sysvar::VTS::Load_Ch1.SetMeasurementMode(0);
// Set the threshold voltage to 3V
sysvar::VTS::Load_Ch1.SetPWMThreshold(3);
// Set the duration of each measurement
sysvar::VTS::Load_Ch1.SetPWMMeasurementDuration(0.05);
}//end if
}//end if
}
else if( channel == 2 )
{
// add code ...
}
}
short circuit
on sysvar sysvar::VT1004::Ch1_ShortCircuit
{
// Go to short circuit mode on this channel (switchMode function handles the VT configuration change)
if( VT1004Ch1Mode == ShortCircuit )
switchModeVT1004( 1, Measurement );
else
switchModeVT1004( 1, ShortCircuit );
// Send setting from the panel to the VT module
@sysvar::VTS::Load_Ch1::RelayShortCircuit = @sysvar::VT1004::Ch1_ShortCircuit;
}
Measurement
放到timer里面去采集,如果没有实物,可以配合VT2004或者VT2516来组合搭建测试环境
if( VT1004Ch1Mode == Measurement )
{
float voltage = 0.0;
float freq = 0.0;
freq = @sysvar::VTS::Load_Ch1::PWMFreq;
@sysvar::VT1004::Ch1_Frequency = freq;
voltage = @sysvar::VTS::Load_Ch1::Cur;
@sysvar::VT1004::Ch1_Voltage = voltage;
if( abs(voltage < 3.0) ) @sysvar::VT1004::Ch1_VoltageLED = 0;
else if( voltage < -3.0 ) @sysvar::VT1004::Ch1_VoltageLED = 2;
else if( voltage > 3.0 || abs(freq) > 1.0 ) @sysvar::VT1004::Ch1_VoltageLED = 1;
}//end if
编译返回canoe主界面测试,在测试前请先确认接线!!!
VT2004和VT1004联动测试
这里写了一个VT2004A和VT1004A配合的实现VT2004A输出VT1004A采集的testcase
variables
{
}
void MainTest()
{
/* Test description:
// These test cases uses two VT modules. It is assumed that the first channels
// of both modules are interconnected.
// Testgroup 1 tests the voltage transfer between the two modules
// Testgroup 2 tests the PWM transfer between the two modules
*/
// Helper variables
int i=0;
TestGroupBegin("Voltage Tests", "Performs several voltage transfer tests");
// Run the test
for( i=1; i<=8; i++ )
VoltageGenerationAndMeasurementTest(i);
TestGroupEnd();
TestGroupBegin("Frequency Tests", "Performs several frequency transfer tests");
// Run the test
for( i=1; i<=6; i++ )
PWMGenerationAndMeasurementTest(i*250);
TestGroupEnd();
}
testcase VoltageGenerationAndMeasurementTest ( double voltage )
{
// Add test case information to the test report
char buf[64];
snprintf( buf, 64, "Voltage transfer test at %dV", (int)voltage );
TestCaseTitle ("Test", buf);
TestCaseDescription("This test case uses two VT modules. It is assumed that the first channels of both modules are interconnected. While the VT2004 is configured to generate a constant voltage of 7V on channel 1 the VT1004 is configured for voltage measurement (also on channel 1). The test case then checks if the voltage generated by the VT2004 module can bemeasured at the VT1004's input");
// Step 1: Activate voltage generation on the VT2004 module (channel 1)
// Set simulation mode to voltage generation
sysvar::VTS::Stimulus_Ch1.SetStimulationMode(1);
// Set the output curve type to be a constant
sysvar::VTS::Stimulus_Ch1.SetCurveType(0);
// Choose an output voltage (use @ to access the variable)
@sysvar::VTS::Stimulus_Ch1::Voltage = voltage;
// Start generating the signal
sysvar::VTS::Stimulus_Ch1.StartStimulation();
// Step 2: Activate voltage measurement on the VT1004 module (channel 1)
// Set measurement mode to constant voltage measurement
sysvar::VTS::Load_Ch1.SetMeasurementMode(0);
// Step 3: perform the actual test
// Wait 100 ms to make sure the above settings take effect
TestWaitForTimeout(100);
// Check if a voltage of +- 1V around given parameter can be measured
if( abs(voltage-@sysvar::VTS::Load_Ch1::Cur) > 1.0 ) {
// Test failed. No voltage or a wrong voltage was measured
TestStepFail("No voltage or a wrong voltage was measured");
return;
}//end if
// Testcase was successfull
}
testcase PWMGenerationAndMeasurementTest ( double f )
{
// Add test case information to the test report
char buf[64];
snprintf( buf, 64, "PWM transfer test at %d Hz", (int)f );
TestCaseTitle ("Test", buf);
TestCaseDescription("This test case uses two VT modules. It is assumed that the first channels of both modules are interconnected. While the VT2004 is configured to generate a constant PWM signal on channel 1 the VT1004 is configured for PWM measurement (also on channel 1). The test case then checks if the frequency generated by the VT2004 module can bemeasured at the VT1004's input");
// Step 1: Activate PWM generation on the VT2004 module (channel 1)
// Set simulation mode to voltage generation
sysvar::VTS::Stimulus_Ch1.SetStimulationMode(1);
// Set the output curve type to be a PWM signal
sysvar::VTS::Stimulus_Ch1.SetCurveType(1);
// Specify the PWM signal (frequency, low and high voltage, duty cycle)
@sysvar::VTS::Stimulus_Ch1::PWMFreq = f;
sysvar::VTS::Stimulus_Ch1.SetPWMVoltageLow(0.0);
sysvar::VTS::Stimulus_Ch1.SetPWMVoltageLow(5.0);
@sysvar::VTS::Stimulus_Ch1::PWMDC = 40;
// Start generating the signal
sysvar::VTS::Stimulus_Ch1.StartStimulation();
// Step 2: Activate PWM measurement on the VT1004 module (channel 1)
// Set measurement mode to constant voltage measurement
sysvar::VTS::Load_Ch1.SetMeasurementMode(0);
// Set the threshold voltage to 3V
sysvar::VTS::Load_Ch1.SetPWMThreshold(3);
// Set the duration of each measurement
sysvar::VTS::Load_Ch1.SetPWMMeasurementDuration(0.05);
// Step 3: perform the actual test
// Wait 100 ms to make sure the above settings take effect
TestWaitForTimeout(500);
// Check if a frequency of 7V (+- 1V) can be measured
if( abs(f-@sysvar::VTS::Load_Ch1::PWMFreq) > 200.0 ) {
// Test failed. No frequency or a wrong frequency was measured
TestStepFail("No frequency or a wrong frequency was measured");
return;
}//end if
// Testcase was successfull
}
项目实例
根据实际工况进行处理,不外乎上面的几种情况,只是和具体项目上的信号功能对应,如有问题,请关注,点赞,收藏,后台私信~~~
当前使用场景也比较单一,文中可能有部分内容未提及,或有误,请指出,谢谢!
公众号
欢迎关注公众号,加入专业技术交流。