Simulator. Which one is better?

Tell me what application can be used to develop and simulate a project at the same time. Where it can be done conveniently and clearly?

Подскажите, в каком приложении можно одновременно разрабатывать и моделировать проект. Где это можно сделать удобно и наглядно.

I'm partial to Wokwi:

Autodesk Tinkercad (https://www.tinkercad.com) is also very complete and also gives you the ability to display a diagram of your sketch. You can take a look at that too...

edit: this program is free to use :grinning:

Wokwi is free and good at the things that it can do. However, you must be aware of its limitations.

  1. For analog stuff it is is hopeless. One common thing is to use an analog pin with multiple buttons and a stack of resistors so the program can determining which button is pressed. This is not possible with Wokwi.

  2. multiple Arduinos within a schematic is not supported. Sometimes it is nice to have one Arduino generating test cases and another processing that and delivering an output. Again this is not possible with Wokwi.

I've seen some student projects here simulated with Proteus and that seems good but, looking at the licensing costs, it is clear that educational establishments get a cheap deal which is unavailable to hobbyists.

I use wokwi, I can't say enough good things about it. My experience with any others is so long ago I can only hope they have improved.

I do miss sometimes the ability to have multiple Arduino boards, so I post mainly to ask what simulators there are that support multiple boards in one project, and to wonder how well they work… and if they keep up with real time.

Wokwi has an unsupported (last time I tried) ability to use external serial connections.

I shouldn't say unsupported, it's only that try as I did I could not get two wokwi projects to talk to each other using serail communication.

I would be happy enough to be able to do just that, but obvsly having two in one project with all the implications of doing would be best.

a7

I used Wokwi first time today.

Does it allow read/write of port registers? I was not able.
I had to dumb down my code.

I didn't try but how about using PROGMEM in Wokwi?

This worked:

// GFS_button  works on Wokwi 3/5/25
// this is NOT beginner code
// written for Uno Rev 3, uses port register read and mask of board pin 7

const byte buttonPin = 7;  // PIND bit 7
byte  pin7history = 0xFF;
byte  prevMillis;

void setup()
{
  Serial.begin( 115200 );
  Serial.println( F( "\n\nButton\n " ));
  
  pinMode( buttonPin, INPUT_PULLUP );
}


void button()
{
  if ( prevMillis != (byte) millis())
  {
    pin7history = pin7history << 1;
    pin7history += digitalRead( buttonPin );
    prevMillis = (byte) millis();
  }
}

void loop()
{
  button();

  switch ( pin7history )
  {
    case 0x7F :
    Serial.print( F( "button release " ));
    Serial.println( millis());
    pin7history = 0xFF;
    break;

    case 0x80 :
    Serial.print( F( "button press " ));
    Serial.println( millis());
    pin7history = 0;
    break;
  }
}

Yes, the port registers all work. It compiles to the same binaries and tries to simulate the 8 bit AVR silicon logic with GitHub - wokwi/avr8js: Arduino (8-bit AVR) simulator, written in JavaScript and runs in the browser / Node.js

This works for me:

// GFS_button  works on Wokwi 3/5/25
// this is NOT beginner code
// written for Uno Rev 3, uses port register read and mask of board pin 7

const byte buttonPin = 7;  // PIND bit 7
byte  pin7history = 0xFF;
byte  prevMillis;

void setup()
{
  Serial.begin( 115200 );
  Serial.println( F( "\n\nButton\n " ));
  
  pinMode( buttonPin, INPUT_PULLUP );
}


void button()
{
  if ( prevMillis != (byte) millis())
  {
    pin7history = pin7history << 1;
//    pin7history += digitalRead( buttonPin );
    pin7history += (PIND & bit( buttonPin )) != 0;
    prevMillis = (byte) millis();
  }
}

void loop()
{
  button();

  switch ( pin7history )
  {
    case 0x7F :
    Serial.print( F( "button release " ));
    Serial.println( millis());
    pin7history = 0xFF;
    break;

    case 0x80 :
    Serial.print( F( "button press " ));
    Serial.println( millis());
    pin7history = 0;
    break;
  }
}

There are a few bits it doesn't do right: Electrical simulation (try digitalRead() of an analog signal, or feeding an analog signal through a switch, and reading with analogRead()) and some interrupt input issues like comparator interrupt, input capture or counter with TOP=0 interrupts that (I suppose) might be expensive to check for in each instruction loop.

1 Like

When I first went onto Wokwi

Tested and run:

// GFS_button  3/5/25
// this is NOT beginner code
// written for Uno Rev 3, uses port register read and mask of board pin 7

const byte buttonPin = 7;  // PIND bit 7
byte  pin7history = 0xFF;

void setup()
{
  Serial.begin( 115200 );
  Serial.println( F( "\n\nButton\n " ));
  
  pinMode( buttonPin, INPUT_PULLUP );
}


void button()
{
  static byte  prevMillis = 0xFF;
  
  if ( prevMillis != (byte) millis())
  {
    pin7history = pin7history << 1;
    pin7history += (( PIND & 0x80 ) ? 1 : 0 );
    prevMillis = (byte) millis();
  }
}

void loop()
{
  button();

  switch ( pin7history )
  {
    case 0x7F :
    Serial.print( F( "button release " ));
    Serial.println( millis());
    pin7history = 0xFF;
    break;

    case 0x80 :
    Serial.print( F( "button press " ));
    Serial.println( millis());
    pin7history = 0;
    break;
  }
}

Hi @Greed,

I must say I agree with most of what have already being said. As a wokwi regular user (after testing others very long ago) I also agree that the choice must be made based on strenghts and weaknesses in your area of interest and your needs.

I use wokwi because:

  • Simulates most of the development boards I use
  • Integrates pretty well with VSCode + PlatformIO for intereactive code - compile - test cycle.
  • You can share easily your current state of project for others to see without them having to install nothing, just access your published project with a web browser.

What wokwi lacks or what are it's weaknesses? IMHO:

  • First and most important: It's model is in crisis. A growth and popularity consequence crisis, but a crisis. It reflects in the availability of server time for compilations, the time it takes them to solve simulators issues, and others. They already started shifting the paradigm including different levels of payed suscriptions, but is yet far from solved.
  • The analog electronic related simulations are far from reality.
  • A very limited options to sort and clasify your projects in the site makes it very difficult to find your project, for you and for others.

The best thing is you can give it a free tour ride and check it for yourself!

Good Luck!

Gaby.//

1 Like

Also works for me:

I think I did have some browser issues where the button didn't seem press in the animation, (chrome on mac, the button didn't change its image when pressed) but it wasn't repeatable and I'm not sure.

It's not /completely/ impossible--there's the custom chip interface where you could simulate a resistor ladder in C-code. For example:

It is in no way as easy as placing a couple physical resistors and letting ohms's law/Kirchoff's law do the work.

2 Likes

OK. I didn't think of this work around of defining a new component for a specific analog circuit. As you have pointed out, it would not be trivial to set up when compared with other simulators which directly integrate analog functionality.

I think you might like to try what is done in this video (I didn't, but I'm pretty sure your Wokwi skills are better than mine):

1 Like

You can know that! I will give it another try, thx.

a7

This is more of curiosa, a simulator that has a lot of cool features but needs bug fixing etc, and just one developer. Crumb is available at Steam. The gui is in 3d, looks great but can become sluggish, at least on intel graphics as well as when pushing the update frequency (of course).

One bug was a ZC circuit, when I removed the input from the comparator, it would continue to output ZC. Gotta love wireless.

Hi @ledsyn ,

Yes, I was just about to mention it, more like for curiosity and the nice 3D graphics than the power and possibilities, but as I said, nice to watch the rendering and to keep an eye on it while it evolves. Today seems to be far more oriented to electronics than MCUs dev boards, isn't it?

Good Luck!
Gaby.//

Hi @Brazilino ,

Oh, I think that's a nice keeper!! Thank you very much!

Good Luck!

Gaby.//

Crumb tries to balance both worlds with an Arduino emulator as well. You can actually copy code into Crumb, but nothing fancy like exotic libraries. I hope there will be more development into Crumb, bug fixing, and more components.

Hi @ledsyn ,

Yes, I also wish them well. But being a "solo act" makes it a little hard to put it clean and neat, not even thinking about keeping up to date as every day we have a new mcu, dedicated chip, etc.

Gool Luck!

Gaby.//

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.