Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PROTEUS 8 PROFESSIONAL: CONTROLLER RECEIVED COMMAND WHILST BUSY.

Status
Not open for further replies.

magicxrps

Newbie
Joined
Mar 29, 2023
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
32
Hello, the nature of my work is to simulate an automatic power factor correction system using Arduino Nano in Proteus 8 Professional in which my program is coded in Arduino IDE. However, upon simulating the circuit, the errors "Controller received command whilst busy", "[HD44780] Controller received data whilst busy", and "Simulation is not running in real time due to excessive CPU load" are appearing. How could I mitigate these issues?

Code:
[CODE=cpp]CODE:

#include <math.h>
#include <LiquidCrystal.h>
LiquidCrystal LCD(13, 12, 11, 10, 9, 8);
float Power_Factor, load_voltage, load_current, real_power, angle_rad, total_capacitance, Q_reqd, New_PF, I_secondary;
float peak_voltage = 0;
float peak_current = 0;
int f = 60;
float vSensor = A0;
float iSensor = A1;
unsigned long time_diff;
const int XOR = 0;
const int capacitor_pin[] = {1, 2, 3, 4, 5, 6, 7};
void setup() {
  LCD.begin(20, 4);
 
  LCD.setCursor(0,0);
  LCD.print(F("AUTOMATIC"));
  LCD.setCursor(1,0);
  LCD.print(F("POWER FACTOR"));
  LCD.setCursor(2,0);
  LCD.print(F("CORRECTION"));
  LCD.setCursor(3,0);
  LCD.print(F("SYSTEM"));
  unsigned long initialization_time = millis();
  while (millis() - initialization_time < 2000){
  }
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(0, INPUT);
  for (int i = 0; i < 7; i++) {
    pinMode(capacitor_pin[i], OUTPUT);
    digitalWrite(capacitor_pin[i], LOW);
  }
  time_diff = 0;
}
void CapacitorCombinations(int j) {
  static unsigned long CapComb_time = 0;
  if(millis() - CapComb_time >= 450){
    CapComb_time = millis();
    String base_2 = String(j, BIN);
    while (base_2.length() < 7) {
      base_2 = "0" + base_2;
    }
    for (int k = 0; k < 7; k++){
      if (base_2.charAt(k) == '1') {
        digitalWrite(capacitor_pin[k], HIGH);
      }   
      else {
      digitalWrite(capacitor_pin[k], LOW);
      }
    }
  }
}
void ComputePF() {
  static unsigned long PF_time = 0;
  if(millis() - PF_time >= 300){
    PF_time = millis();
    time_diff = (pulseIn(XOR, HIGH, 1000000L))/1000000;
    angle_rad = 2*PI*f*time_diff;
    Power_Factor = cos(angle_rad);
  }
}
float ReqdCapacitance(float PF, float V, float I) {
  static unsigned long ReqdCap_time = 0;
  if(millis() - ReqdCap_time >= 350){
    ReqdCap_time = millis();
    float C_reqd, X_c, P;
    C_reqd = 0;
    P = V*I*PF;
    Q_reqd = P*(tan(PF)-tan(0.96));
    X_c = (V*V)/Q_reqd;
    C_reqd = 1/(2*PI*f*X_c);
  return C_reqd;
  }
}
float CapacitorActivation(float Cap_Reqd) {
  static unsigned long ActivateCap_time = 0;
  if(millis() - ActivateCap_time >= 400){
    ActivateCap_time = millis();
    float capacitor_bank[7] = {1e-6, 2e-6, 4e-6, 8e-6, 16e-6, 32e-6, 64e-6};
    int cap_combination = 0;
    total_capacitance = 0;
    for (int l = 0; l < 128; l++){
      total_capacitance = 0;
      for (int m = 0; m < 7; m++){
        if (l & (1 << m)){
          total_capacitance += capacitor_bank[m];
        }
      }
      if (total_capacitance >= Cap_Reqd){
        cap_combination = l;
        break;
      }
    }
    return cap_combination;
  }
}
float CorrectedPF(float PF, float V, float I) {
  static unsigned long CorrectedPF_time = 0;
  if(millis() - CorrectedPF_time >= 500){
    CorrectedPF_time = millis();
    float P, C_reactance, C_reactive_pow, L_reactive_pow, Q_new, theta_new;
    P = V*I*PF;
    C_reactance = 1/(2*PI*f*total_capacitance);
    C_reactive_pow = (V*V)/C_reactance;
    L_reactive_pow = (V*I)*sin(acos(PF));
    Q_new = L_reactive_pow - C_reactive_pow;
    theta_new = atan(Q_new/P);
    New_PF = cos(theta_new);
    return New_PF;
  }
}
void DisplayNoLoad()  {
  static unsigned long NoLoad_time = 0;
  if(millis() - NoLoad_time >= 100){
    NoLoad_time = millis();
    LCD.clear();
    LCD.setCursor(1,0);
    LCD.print(F("NO LOAD"));
    LCD.setCursor(2,0);
    LCD.print(F("CONNECTED"));
  }
}
void DisplayInitialParameters() {
  static unsigned long InitialParameters_time = 0;
  if(millis() - InitialParameters_time >= 300){
    InitialParameters_time = millis();
    LCD.clear();
    LCD.setCursor(0,0);
    LCD.print(F("PF: "));
    LCD.print(Power_Factor, 2);
    LCD.setCursor(1,0);
    LCD.print(F("VOLTAGE: "));
    LCD.print(load_voltage);
    LCD.print(F("V"));
    LCD.setCursor(2,0);
    LCD.print(F("CURRENT: "));
    LCD.print(load_current, 2);
    LCD.print(F("A"));
    LCD.setCursor(3,0);
    LCD.print(F("POWER: "));
    LCD.print(real_power);
    LCD.print(F("W"));
  }
}
void DisplayCorrectedPF() {
  static unsigned long FinalParameters_time = 0;
  if(millis() - FinalParameters_time >= 600){
    FinalParameters_time = millis();
    LCD.clear();
    LCD.setCursor(0,0);
    LCD.print(F("Required Qc: "));
    LCD.print(Q_reqd, 2);
    LCD.print(F("VAR"));
    LCD.setCursor(1,0);
    LCD.print(F("Required C: "));
    LCD.print(total_capacitance, 2);
    LCD.print(F("C"));
    LCD.setCursor(2,0);
    LCD.print(F("Corrected PF: "));
    LCD.print(New_PF, 2);
  }
}
void DisplayNoCorrectionNeeded()  {
  static unsigned long NoCorrection_time = 0;
  if(millis() - NoCorrection_time >= 700){
    NoCorrection_time = millis();
    LCD.clear();
    LCD.setCursor(0,6);
    LCD.print(F("PF: "));;
    LCD.print(Power_Factor, 2);
    LCD.setCursor(1,9);
    LCD.print(F("NO"));
    LCD.setCursor(2,5);
    LCD.print(F("CORRECTION"));
    LCD.setCursor(3,7);
    LCD.print(F("NEEDED"));
  }
}
float ReadVoltage()  {
  static unsigned long peak_voltage_time = 0;
  if(millis() - peak_voltage_time >= 100){
    peak_voltage = analogRead(A0)*(5.0/1023.0);
    if(peak_voltage < 0.0 || peak_voltage > 5.0){
      return;
    }
    peak_voltage_time = millis();
    return peak_voltage;
  }
  return -1.0;
}
float ReadCurrent()  {
  static unsigned long peak_current_time = 0;
  if(millis() - peak_current_time >= 100){
    peak_current = analogRead(A1)*(5.0/1023.0);
    if(peak_current < 0.0 || peak_current > 5.0){
      return;
    }
    peak_current_time = millis();
    return peak_current;
  }
  return -1.0;
}
void ComputeLoadCurrent() {
  static unsigned long LoadCurrent_time = 0;
  if(millis() - LoadCurrent_time >= 200){
    LoadCurrent_time = millis();
    float Vrms_current, V_Rburden;
    Vrms_current = peak_current/sqrt(2);
    V_Rburden = Vrms_current + 1.4;
    I_secondary = V_Rburden/5.0;
    load_current = I_secondary*(20/1);
  }
}
void ComputeLoadVoltage() {
  static unsigned long LoadVoltage_time = 0;
  if(millis() - LoadVoltage_time >= 200){
    LoadVoltage_time = millis();
    float Vrms_voltage, V_drop;
    Vrms_voltage = peak_voltage/sqrt(2.0);
    V_drop = 1.4 + (I_secondary)*1000.0;
    load_voltage = (Vrms_voltage + V_drop)*(230.0/5.0);
  }
}
void ComputeRealPower() {
  static unsigned long RealPower_time = 0;
  if(millis() - RealPower_time >= 250){
    RealPower_time = millis();
    real_power = load_voltage*load_current*Power_Factor;
  }
}
void loop() {
  ComputeLoadCurrent();
  delay(50);
  ComputeLoadVoltage();
  delay(50);
  if(load_current < 0.0){
    DisplayNoLoad();
    delay(50);
  }
  else if(load_current > 0.0){
    ComputePF();
    delay(50);
    ComputeRealPower();
    delay(50);
    DisplayInitialParameters();
    delay(50);
 
    if (Power_Factor < 0.96){
      float Required_Capacitance = ReqdCapacitance(Power_Factor, load_voltage, load_current);
      delay(50);
      int Activate_Capacitor = CapacitorActivation(Required_Capacitance);
      delay(50);
      CapacitorCombinations(Activate_Capacitor);
      delay(50);
      CorrectedPF(Power_Factor, load_voltage, load_current);
      delay(50);
      DisplayCorrectedPF();
      delay(50);
    }
    else {
      DisplayNoCorrectionNeeded();
      delay(50);
    }
  }
}
[/CODE]


Any help would be appreciated!

Attached are the dialog box of the issues and my circuitry.
Circuit.png

Issues.png
 
Last edited:

Hello
The error means that your display is receiving a new command while executing the current one. I think this is due to timing issue between the commands send to the HD44780 or due to the simulation and your project might work fine in real world.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top