Just like in real life, you may need to calibrate the library model to ensure the RMS calculation matches the simulated input voltage, particularly by adjusting the offset in the code.
#define SENSOR_PIN A0 const float VREF = 5.0; // Arduino operating voltage void setup() Serial.begin(9600); pinMode(SENSOR_PIN, INPUT); void loop() int maxValue = 0; int minValue = 1023; unsigned long startTime = millis(); // Sample the AC wave for 20ms (one full 50Hz cycle) while (millis() - startTime < 20) int readValue = analogRead(SENSOR_PIN); if (readValue > maxValue) maxValue = readValue; if (readValue < minValue) minValue = readValue; // Calculate Peak-to-Peak Voltage int peakToPeak = maxValue - minValue; // Convert ADC steps to Voltage float voltageValue = (peakToPeak * VREF) / 1023.0; // Calculate RMS Voltage based on calibration factor // In Proteus, tweak this multiplier to match your alternator settings float calibrationFactor = 75.0; float rmsVoltage = (voltageValue / 2.0) * 0.707 * calibrationFactor; Serial.print("RMS Voltage: "); Serial.print(rmsVoltage); Serial.println(" V"); delay(500); Use code with caution. Troubleshooting Proteus Simulation Lag and Errors zmpt101b library for proteus
Avoid random DLL files from unverified sites. Only download .LIB , .IDX , and scrīpt-based models. Just like in real life, you may need
In simulation, AC_IN1/2 are galvanically isolated from VCC/GND . This models the real transformer isolation. You can connect a high-voltage sine wave on the AC side and a 5V DC supply on the low-voltage side without ground loops. Just like in real life