SimulateSensorPWM ()
{
// The current value of the frequency (100Hz)
float currentFrequency = 100.0;
// Choose voltage stimulation and a PWM curve type
vtsSetStimulationMode("VTS::RPM_Sensor", eVTSStimulationModeVoltage);
vtsSetCurveType("VTS::RPM_Sensor", eVTSCurveTypePWM);
// PWM signal will toggle between 0V and 5V
vtsSetPWMVoltageLow("VTS::RPM_Sensor", 0.0);
vtsSetPWMVoltageHigh("VTS::RPM_Sensor", 5.0);
// 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::PWMFreq = currentFrequency;
@sysvar::VTS::RPM_Sensor::PWMDC = 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::PWMFreq = currentFrequency;
}
// Stop the stimulation
vtsStopStimulation("VTS::RPM_Sensor");
}