frg-fossee / eSim-Cloud

A web-based system for designing and simulating electronic (eSim) and Arduino circuits.

Home Page:https://esim-cloud.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error message appearing even though LED is connected properly

rinon13 opened this issue · comments

Description: A pop up error message "LED is not Connected properly" is showing on right hand side of screen even though LED is connected properly.

Steps to Reproduce:

image

  1. Connect circuit as shown above.
  2. Copy .ino code
int  POS_PIN = 13;
int NEG_PIN = 12;

void setup(){
    pinMode(POS_PIN, OUTPUT);
    pinMode(NEG_PIN, OUTPUT);
    digitalWrite(NEG_PIN, LOW);
}

void loop(){
    digitalWrite(POS_PIN, HIGH);
    delay(500);
    digitalWrite(POS_PIN, LOW);
    delay(500);
}
  1. Press "Start Simulation"
  2. Error message will appear on top right of screen

Expected behavior: Error message should not appear when LED is connected to digital pins which are programmed correctly (.ino code is written correctly) i.e POSITIVE pin is given HIGH and NEGATIVE pin is given LOW

Error example:

LED_Error_Message

  • OS: Ubuntu 22.04.1 LTS
  • Browser: Firefox 110

Tested on:

Reason for error:

  1. When "Start Simulation" is pressed, LED's simulation function is called before Arduino's simulation function.
    (LED is of type output)
    (Code at eSim-Cloud/ArduinoFrontend/src/app/Libs/Workspace.ts) (Line 1045)
// Sequence to be followed while calling initSimulation
    const seqn = ['output', 'general', 'controllers', 'drivers', 'power', 'input', 'misc'];
    // For each component call initsimulation function
    for (const key of seqn) {
      for (const items of Utils.componentBox[key]) {
        for (const item of items) {
          if (window.scope[item]) {
            for (const ele of window.scope[item]) {
              if (ele.initSimulation) {
                ele.initSimulation();
              }
            }
          }
        }
      }
    }
  1. When LED tries to read the values of connected Arduino pins, they have not been initialized yet.
  2. This causes the checks to see if LED is connected properly to not be satisfied.

Additional information:

The error message only stays for a short while and will go away after the values of the Arduino pins have been initialized.

Error_Gone2

Fixed in #467