Arduino Simulator

Is there a good debugger or simulator to single step though your arduino code virtually? I would like to see the information going in and out of each register. This would be really helpful when debugging code that is close to maxing out the MEGA.

It's quite unusual to need to look at the working registers when using C (which I assume you are). IO regs are a different matter though, it's very useful to look at them.

Anyway AFAIK there are no simulators for Arduino, there are some for AVR chips in general but I think you'd have to be developing you code with AVR Studio.

There are some monitors, do a search for "monitor" on the forum.


Rob

I'd like to suggest an unit-based testing approach.
I have tried some emuletors (like emulino and so on) and I think them are unable to track the whole system in its complexity.
It is better to test the single part of your C code with some unit testing.
If the single part do not work alone, there is no chance you can get them working right together :slight_smile:

Test driven development is your best friend in embedded stuff, in my own opinion:

Take a look to the Aiko library: GitHub - geekscape/Aiko: Original Aiko repository is now broken out into individual projects (see readme.markdown) it has a lot of unit tests and it is easy to understand.

You can try VirtualBreadboard, www.virtualbreadboard.com

There is no single step debugging yet, but its on its way very soon.

VBB:
You can try VirtualBreadboard, www.virtualbreadboard.com

There is no single step debugging yet, but its on its way very soon.

I have tried it but I find difficult to include other files and external libreries.
do you have released a new version?

VirtualBreadboard (www.virtualbreadboard.com ) now supports Single Step Debugging, Breakpoints, step over, stepout, local variable views, stackframe views.

I have tried it but I find difficult to include other files and external libreries.

yes, true that there is not 100% arduino coverage especially for 3rd party arduino libraries.

You are limited to including "arduino" cpp files, ie not pure C++.

What you can do though is stub-out custom libraries with test return values by adding your own C++ stubbed implementation of the custom 3rd party library you are wanting to use. This is inline with the unit test approach earlier in this thread. Basically you write your own emulation layer of how the 3rd party library will behave. This emulation can be just as stubbed return value or a complete functional emulation.

So the VBB simulations can still be very useful even with unsupported libraries especially with the debugger which just takes Arduino development to another plane of existance IMO :slight_smile:

There are two Arduino simulator apps for iPhone/iPad in Tunes store at

http://itunes.apple.com/us/app/arduino-simulator-learn-diy/id438426863?mt=8

http://itunes.apple.com/us/app/arduino-simulator-full-pack/id447001317?mt=8

Presently the capabilities are limited and are evolving.
Some info on capabilites is at http://schogini.com/tutorials/arduino/#C3

Amazing... same question in different sub forums, by different people. I replied there too, give it a go.

http://arduino.cc/forum/index.php/topic,69931.0.html

There's Simulavr. Also, not arduino, but Atmel AVR sim. I haven't tried it, so I don't know how capable it is. But I'd love to hear from anyone who has.

We are developing a new Simulator here http://www.arduino.com.au/Simulator-for-Arduino.html

So far the simulator can single step through simple program's and registers can be viewed by clicking On the variables button. It should be fully operational soon. Any comments or new sketches to run through the simulator would be appreciated.

On the downside, the simulator cannot do for statements, subroutines or second level conditional statements yet. It can do most of the rest and should be ok for simple sketches.

Please let me know when it can do all the language elements in the reference page.
Which ones are missing now?
I'm interested!

Hi, thanks for the interest.

At present, all language elements except for the elements below are supported. All the if/for/while/switch/else statements have been tested multiple times and are fairly solid now. The last few versions have been mainly on the language processing since the feedback was that this needed improving. The feedback now is to improve the Uno/Mega pictures and finish all the digital pins and maybe make the Mega picture smaller.

Math
min() max() abs() constrain() map() pow() sqrt() // Note constrain() is implemented
Trigonometry
sin() cos() tan()
Bits and Bytes
lowByte() highByte() bitRead() bitWrite() bitSet() bitClear() bit()

Since this program can consume a lot of time, we have decided to only upgrade when milestones are reached so the next upgrade is planned for late this month of next month depending on interest. Minor fixes will be done where possible. The Free version can be downloaded from here. The Free version is now v0.94C and supports the <time.h> addon library (updated yesterday).

Any one here familiar with paravirtuallization? Instead of emulating the CPU, one actually writes the functions to function over the existing CPU. This kind of thing is probably more appropriate in something like arduino (They do this with FreeRTOS and other RTOSes). Note: One should include memory limits in such a paravirtuallization mechanism. Any way I'll start something for the arduino (possibly based on fritzing?)

What are the limits on the free version? 100 lines? Delay on loading?

Yes, the limits on the free version are a 60s timer on opening a sketch (or editing it) and a Code limit of 100 lines. the 100 line limit was chosen since most of the example sketches are under 100 lines.

Apart from that, the free version and Pro version are identical.