Pages: [1]   Go Down
Author Topic: Simulating arduino board  (Read 2880 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Is there a possibility to programm sketch without connecting arduino board to my pc.

In order to just debug some calling functions ?
Logged

Silkeborg, Denmark
Offline Offline
Jr. Member
**
Karma: 2
Posts: 72
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think so.

But it could be really great to have some kind of simulator, it would make debugging much easier. I have been programming AVR using Bascom AVR, and this IDE has a very good simulator, now when moving to Arduino the only thing I am missing is a simulator.

Here is a screenshot of Bascom AVR simulator.
Logged

Thansen_DK

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12465
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is there a possibility to programm sketch without connecting arduino board to my pc.

You can use the compile > button to see if your sketch is syntactically correct. And you can press the SHIFT key while pressing compile and you get even more output.

Quote
In order to just debug some calling functions ?
Generally* you can't,

*however functions without Arduino specific calls may be testable in a standard C++ environment e.g. Visual Studio 2008. But as ints, floats, doubles, RAM etc may have other sizes, this creates its own pitfalls. ==> don't do it

« Last Edit: December 20, 2010, 03:29:22 pm by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Silkeborg, Denmark
Offline Offline
Jr. Member
**
Karma: 2
Posts: 72
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Generally* you can't,

*however functions without Arduino specific calls may be testable in a standard C++ environment e.g. Visual Studio 2008. But as ints, floats, doubles, RAM etc may have other sizes, this creates its own pitfalls. ==> don't do it

Is it something that could be done, I mean in future releases of the Arduino IDE, or is it simply impossible to do due to some technical stuff in the compiler?

Regards Thomas
Logged

Thansen_DK

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12465
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

quote]Is it something that could be done,[/quote]
Yes in theory it can be done  BUT (a very big one) it is a difficult an big job and I do not expect it to become part of the IDE in a very long time.

imho the main problem for building a simulator is that Arduino interacts with hardware - motor, servo, temp or pressure sensor, LED's etc often interrupt driven - and if you want to simulate this all it becomes at least a very big job, imagine the code for simulating a relative simple temp sensor like a DS18B20 1 wire device.

There are functions you could test e.g. in VS2008 like lookup-tables, a numeric integration, a formula for converting AD readout's to Voltages or cubic inches whatever. But most Arduino code I have seen on this forum and beyond interacts with hardware ...

But don't let my opinion stop you from building an Arduino simulator smiley


In theory there is no difference between theory and practice but in practice there is

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, not equipment, just using loop to display Serial messages on console.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12465
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, I interpreted the question different, second try check if I do understand your question correctly:
you want to debug a sketch running on an Arduino that is not connected to a PC?

If that is the question you could use a simple serial display connected to the TX pin. Or another Arduino that checks if serial output of Arduino 1 is OK.

Could you give an example of code you want to debug?
« Last Edit: December 20, 2010, 04:36:26 pm by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

NO

I just want that :

Mycomputer--------x(usb disconnected)-----arduino

And running my sketch to see only ouput serial messages.
loop()
{

   Serial.println("foo")
}
Seeing foo on my console.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12465
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
my console.
And what kind of device is your console?

something like this - http://www.arduino.cc/playground/Learning/SerialLCD
« Last Edit: December 20, 2010, 04:49:21 pm by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Silkeborg, Denmark
Offline Offline
Jr. Member
**
Karma: 2
Posts: 72
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I was not thinking about simulating external hardware.

What I was thinking was something like epanda wrote, something like registers, variables, i/o pins, and be able to step thru code to see everything works as you expect, add breakpoints and so on.

I am a noob regarding C++ thats why I could use this, C is not the easiest language to learn :-) And believe me if I could program a simulator, I would :-)

As it is now you have to print your variables to Serial to check that your sketch is doing what you expect it to do, this gives a lot of extra coding, and this code must be removed again. I just think a simulator could be a very useful feature, not only for begginers but also for the more driven programmers.

Thomas
Logged

Thansen_DK

0
Offline Offline
Full Member
***
Karma: 0
Posts: 128
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And what kind of device is your console?

console for me (french) is the Serial Monitor.

I just want to see trace output without loading the sketch into the arduino board.
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12465
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I was not thinking about simulating [glow]external hardware[/glow].

What I was thinking was something like epanda wrote, something like registers, variables, [glow]i/o pins[/glow], and be able to step thru code to see everything works as you expect, add breakpoints and so on.

How do you imagine to test I/O pins without external hardware? A simple bouncing switch is very hard to simulate, as different switches have different characteristics. Simulating hardware makes me allways think of the saying: In theory there is no difference between theory and practice but in practice there is!




Quote
I just want to see trace output without loading the sketch into the arduino board.
As far as I know it cannot be done as there is nothing that "runs" the code.
« Last Edit: December 22, 2010, 06:45:32 am by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Silkeborg, Denmark
Offline Offline
Jr. Member
**
Karma: 2
Posts: 72
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



What I am thinking about is something like you can see on the above picture.

As you can see, here you can step through the source code (sketch) while keeping an eye on your variables, locals and more, this is very usefull when debugging complicated calculations, string handling and more (At least I think that ;-) )

You can set breakpoints to stop the code in specific places to check to see if everything is as you expected at this point.

The hardware simulation is a minor thing in this matter, the I/O pins can be set to 0 or 1 by a click with the mouse, nothing more, I think this simple I/O control is good enough to test many things. A simple Analog input indicator with selectable analog port. With these "simple" hardware simulation features you can come a long way.

The above simulator is a screenshot of Bascom-AVR, and if you would like to how it works you can download a demo version (can only compile 4 Kb code)

Maybe I am the only one who will find this feature usefull, especialy as a beginner to Arduino/C++.

And just to be clear, I am not complaining about Arduino, I think Arduino is just awsome, but everything can be better ;-)

Maybe this kind of simulator I am talking about is impossible to make due to some technical issues in the Arduino IDE, the Compiler or other things, I don't know but I think it could be awesome to have it.

Thansen
Logged

Thansen_DK

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 170
Posts: 12465
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I agree that simulators are of great value including as a learning tool.

The fact that this AVR simulator exist - and looks good btw - proofs a simulator can be made, even with switches and analog input. But afaik no simulator for Arduino exists.

The main point I wanted to make is that a good simulator should  have:
- bouncing switches
- pot meters that are read out slightly differently every time
- digital temp sensors that heat up a little bit
- servo's that hick up
- power supply that drop just a bit influencing ADC
etc

It is this kind of noise that makes the difference between the analog world and the digital simulation. To handle this noise one often needs extra code or hardware. And the ultimate proof is allways in the pudding test, not in the recipe smiley
« Last Edit: December 23, 2010, 05:52:23 am by robtillaart » Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: