Connect the pins as follows:

Upload your firmware to the virtual microcontroller. A standard interrupt-based pulse counting code works perfectly here.

// Example logic for the simulation
volatile int pulseCount = 0;
float flowRate = 0.0;

void setup() Serial.begin(9600); attachInterrupt(0, pulseCounter, RISING); // Digital Pin 2

void loop() // Calculate flow rate based on pulse count // YFS201 Factor: 7.5 * pulseCount (approx) flowRate = (pulseCount / 7.5); Serial.print("Flow Rate: "); Serial.print(flowRate); Serial.println(" L/min"); pulseCount = 0; delay(1000);

void pulseCounter() pulseCount++;

During the simulation run, you can pause the simulation, edit the "Flow Rate" property of the YFS201 model to "10 L/min", resume, and instantly see the Serial Monitor update to reflect that flow.

The availability of an exclusive YFS201 library is more than just a convenience; it represents a shift in Hardware-in-the-Loop (HIL) simulation capabilities.

Модель добавлена в избранное

перейти

Модель добавлена в сравнение

перейти