SimulateSensorPWM ()
{
// The current value of the frequency (100Hz)
float currentFrequency = 100.0;
// Choose ′low side switch′, PWM curve type and
// Vext as source for high value
vtsSetOutputMode ("VTS::RPM_Sensor", eVTS2848OutputModeLowsideSwitch);
vtsSetCurveType("VTS::RPM_Sensor", eVTSCurveTypePWM);
vtsSetOutputSource("VTS::SensorModule1", eVTSOutputSourceGroupChannels1To4, eVTSOutputSourceVExt);
// Set the number of repeats to unlimited
vtsSetPWMRepeats("VTS::RPM_Sensor", 0);
// Set initial frequency (100Hz) and duty cycle (50%) values
@sysvar::VTS::RPM_Sensor::PWMOutputFreq = currentFrequency;
@sysvar::VTS::RPM_Sensor::PWMOutputDC = 50.0;
// Start the stimulation
vtsStartStimulation("VTS::RPM_Sensor");
// To stimulate different sensor readings increase
// frequency of the PWM signal over time
while(currentFrequency < 200)
{
// Increase the frequency by 1Hz every 100ms
TestWaitForTimeOut(100);
currentFrequency += 1;
@sysvar::VTS::RPM_Sensor::PWMOutputFreq = currentFrequency;
}
// Stop the stimulation
StopStimulation();
}