Simulator for Arduino

Here is a link to a new blog about a Simulator for Arduino program we are developing. http://arduinoshields.blogspot.com/2011/12/simulator-for-arduino.html

Arduino has huge potential, and while there are a lot of Arduino Simulators out there, it is hard to find one which is fully functional and doesn't need to be compiled. Our program is a simple .exe program which mostly works for simple sketches. What we are looking for is feedback as to:

  • Is it worthwhile finishing off this Simulator?
  • Are there any professional simulators out there?
  • Should we make the program open-source?
  • What other features would be useful?

The two main uses we can see for a Simulator would be as a teaching tool, and as a debugging tool.

The program is available http://www.arduino.com.au/Simulator-for-Arduino.html

I like the concept. I like the design. I applaud the effort. Thumbs up in general.

I tried the freebie version.

I have looked through my 10 simplest program and cant get any to work. Yes, I use functions. Yes I use for loops and arrays. I use the conditional operator (OK, that is not "officially" documented in Arduino, but it is a normal C-construct). Shortcuts like if(val&1) do not seem to work. Even the official BlinkWithOutDelay (which is hard to explain to newcommers) isnt working. (you are mixing float/integer for the millis value?)

So apart from these essential enhancments :slight_smile: I suggest that if it is to be used for teaching that you include working examples - seems I do not have any. Your biggest challenge is to make a clear design descion on what features of the language you want to support. Otherwise you end up re-inventing the compiler. Maybe instead of reading a file you allow writing the code in your window in such a way that only the allowed constructs and keywords are possible. That way you can enforce a simpler syntax.

I relalise that this is a lot of work. Kudos to you for trying! Whether it becomes a hit or not is hard to say.

Hi, thanks for the reply. OK, functions and subroutines will be added next.

The Blink Without Delay sketch should work. There is a small issue that the millis value in the Emulation Toolbar doesn't like whole numbers but it can be changed to be xxxx.yyy. When I tested this, I changed the CurrentMillis variable (to 1001,2002,3003) in the Variable grid and then clicked the step button and the program stepped into the loop.

With the working examples, I am slowly working my way through the official Arduino examples and since these are written by various people, the syntax is all over the place which is good for testing. I understand that maybe this is too big a project, but at the moment it is fun, and it is more like an addiction than anything. I would love to test one of your sketches if it doesn't have any confidential IP. Maybe you could attach it as a file, and I will let you know when the Simulator has a handle on it.

I like the idea about editing the file. The Main program section is being changed so that this is possible. Thanks for the positive words - we have a few several purchases recently, and the Google Adwords hits went off the scale today with the keyword "Arduino Simulator" so there is definitely a need for a good Simulator (whoever gets there first!)

Shields_Arduino:
Google Adwords hits went off the scale today with the keyword "Arduino Simulator" so there is definitely a need for a good Simulator (whoever gets there first!)

Possibly people have read your post - you say there are other simulators out there - "Oh wow, must find one of them then" ... :slight_smile:

I will PM some sketches to you.

How far behind is the freebie to the main one?
Even this simple example doesnt work - or at least apart from seeing the linepointer move, and the serial ouput showing "23", I see no input/output happening? If the variable declaration is not at the top it is "ignored"

int y = 23 ;

void setup() {
  pinMode(13,OUTPUT) ;
  pinMode(12,INPUT) ; digitalWrite(12,HIGH) ;
  Serial.begin(9600) ;
}

void loop() {
  y = digitalRead(12) ;
  Serial.print(y) ;
  digitalWrite(13,y) ;
  if (y==HIGH) Serial.println("Hi") ;
  if (y==LOW)  Serial.println("Lo") ;
  delay(500) ;
}

BTW - it works fine on my physical arduino :slight_smile:

If there is a really good Arduino Simulator out there, then that will be time to stop.

Thanks for the sketch. Even though it is fairly simple, it showed up lots of issues, but v0.90 now seems to handle it OK. We ran through all the Basics and Digital examples and they all look good now. One of the sketches had a floating point number so we just converted it to an integer for the present. The Analog examples have some double for loops and a map() function I have never heard of before. With the Tone function, we were going to simulate the Tone using the windows function WindowsBeep(freq,duration) but this seems to have disappeared in Windows 7, but it is still on the backburner.

Some other changes are some major rework on the screen layout. The basic screen has the program list on the left, the variables and the Uno picture which reflects input, dataU and output. There is an Option | Swap to revert to he previous screen setup. We also added an Edit option to allow the program to be edited and then reloaded or saved to an external file. The Analog window now does some freaky resizing to make it smaller.

With the freebie version, it is identical to the main version with the addition of delays. We toyed with having the free version as an older release but figured this wasn't fair (or annoying enough).

Thanks again for the interest. This is definitely a major project, and while the program may look simple, there is some extensive code behind it now. Next release will probably be in a week or so.

Version 0.91 of the Simulator for Arduino is now released and can be viewed and downloaded here (free version or pro version for $4).Simulator The Youtube video at the end of the page was put up on Friday, and has had 65 hits since then, and one nice comment a few minutes ago.

A good simulator would certainly be welcomed and I think I would even pay for it. However, I find a bit strange that you have a paid version already while still not having a full featured version. I am happy to test for you, but not if it takes me 30s each time I load my sketch (since the simulator crashes it took me 5 mn startup time in total to create this report)...

Anyhow, these are my findings so far:

  • no support for projects that consists of more than one sketch (as does mine, so testing stops for now)
  • this peace of code gave a 'Problem' object1.run(object2.state()==SOME_STATE,...)
  • no support for #define? Error: #define LCD_L11 "SOME STRING"
  • no support for continued comment? Error: ** some text (*)
  • after a number of errors: stack overflow
  • immediately followed by a crash ('unhandled win32 exception [26700]'

Good luck, will try to test again if relevant (PM me if needed)

Regards/Frank

(*) Taken from theconstruct

/*
** some text
** some other text
*/

Thanks FrankM. I hear you, and if this version has problems, ask Msquare about v0.89. The firmware version 0.91 denotes that it is not yet a finished release version which is why the price was reasonably low. We were hoping that it would be good enough for using as a training tool, and we would like to eventually have the Simulator used for debugging.

We understand that the 30s delay is annoying (and the 5min crash time unacceptable), so if you want to email your sketch, we can upgrade the program to handle it. Some of the issues mentioned have been fixed or upgraded:

  • projects with more than one sketch - the #include works for definitions but not code - this could be implemented but not clear yet?? Arduino won't let me define a byte in a separate sketch yet.
  • object1.run(object2.state()==SOME_STATE,...) - this has been added for the string type - it would be good to have an example sketch to test this
  • #define string "abcde" - will check this - #define does work for most data types - not sure about strings -
    *** EDIT 22-Dec changed so #define will now load a string not just numbers ***
  • the comments handling has now been upgraded so comments are stripped away before processing the line and this includes the tricky /* */
  • stack overflow - yep seen that one a few times - the program must be confused somewhere
  • Win32 exception - seen that one as well - we have added an exception handling clause so an error message should now issue with the relevant offending text - this should speed up debugging

Some of the new features added are:

  • rework line processing to be more reliable and faster
  • put all the variables in one column with gray headings for different types
  • allow one breakpoint shown in red
  • remove digital pin checkboxes - use colored circles and text only (input changed to green)
  • program line always in the middle vertically
  • last two Arduino example String sketches to implement before retesting
  • subroutines were being passed an extra parameter - fixed
  • line numbers and subroutines now work together

Anyway, if you can email us a sketch (with important IP removed), I can let you know when the program can handle it. Thanks again for your comment. The email address is arduinoshields@gmail.com

A new version is available v0.92 here http://arduino.com.au/Simulator-for-Arduino.html and a training video is available here Simulator for Arduino v0.92 - YouTube

There are still a few issues we are still working on, but overall, the Simulator for Arduino works a lot better. It can run all the example sketches from Basics to Strings now.

Simulator for Arduino version 0.94A is available here http://arduino.com.au/Simulator-for-Arduino.html and a training video is available here

The Patch from 0.94A to 0.94A involves adding all the commands in the test/test4.ino sketch which include shiftOut, shiftIn, sizeof, word and double. We have had some bandwidth exceeded issues with the ISP and have just fixed the Free download which has been unavailable for a few days. Feedback has been almost off the charts - see here

Does it allow you to simulate external interrupts?

Very good question. v0.94A is not capable of this (the code was commented out - todo later), but we just added this functionality for pins 0 and 1 for the Uno, and it seems to work well. The software has been patched to v0.94B now. Thanks.

I am using emulare (http://emulare.sourceforge.net/) to simulate four communicating Arduinos. Free, and no limit on code size or what is in the code. Using Windows Vista (not listed as a supported OS for "The Simulator for Arduino").
When can I do this with "The Simulator for Arduino" ?

I just tried Emulare and selected Run with no program loaded and the program started. Also, could not find any Arduino board to test, so it really it more of an Atmel simulator in which case AVR Studio is the preferred choice. Also, no-one uses Vista so this isn't an issue.

Apart from that, Emulare looks good - it just doesn't simulate Arduino - it simulates an AVR.

For more info on Sinukator for Arduino, our forum is now up the website below - rightmost top menu item.

I bought the pro version, or better saying, I paid for it, but got nothing in order to activate it?
Anyone knows how to do it?