Go Down

Topic: Arduino simulator written in Python (C++ better) (Read 12699 times) previous topic - next topic

Paulware

Aug 01, 2012, 04:13 am Last Edit: Nov 09, 2012, 07:03 am by Paulware Reason: 1
 I recently got burned by the cadsoft eagle v 6.  They have discontinued their free service and it now costs $69.00 to do same.  After much constirnation I relented and purchased the package.  I noticed there is a cool package called fritzing with is free but does not simulate the circuit and there is another package called virtual breadboard http://www.virtualbreadboard.com/ which is awesome but I suspect that they may some day also stop being free and charge.

  So I was wondering if there was any traction out there for creating an open source simulator?  It would be nice to use fritzing's .xml file board definitions, but a quick glance at one of their .xml files was fruitless.

 I was thinking that python would be the language to use.  It can read .xmls files and interface with an sql database quickly.  
 
 Basically the database would contain all the components, ports, diagrams and connections.  Users would write python classes for the components they want to see simulated.  For example a, class Arduino.
Each class would have a loop and a setup procedure that would be called.  

 The loop procedure would look at all the connections and their values and set outputs.  The setup procedure would be used to initialize the component.  We could use our own python version of libraries (like wire) so that the names would be maintained with existing Arduino libraries.

 So I see how this could (possibly) be done in python.  The graphical interface I would prefer to leave to fritzing, assuming that the .xml format will some day make sense.  

  I think I can put together a python tkinter .gui to show the database and possible run a simple blink example (lm7805, 9v battery, atmega328, clock, pull-up resistor, 220 ohm resistor and led).

 Just wondering if anyone was out there interested in helping to set this up.  The key would be to make it open and easy for people to add components.
Paul

EVP

I think the general problem with this kind of thing is when your using arduino more time is spent debugging the imperfect prototype you have built not debugging a 'perfect' version. Which if the simulator works shouldn't take very long. If you want to experiment a bread board is probably better. I mean just were do you stop if you wanted to make it really useful, it would have to have an accurate simulation of all available components or it would/could be a bit waste of time for the user. It's not really possible to do that, or if it is the effort wouldn't seem worth it. ?That's not to mention and components/sensors you could make your self. How do you simulate them is it very useful to do so at this level? In many ways it just seems like doubling up lots of aspects of project development for not much return.

MichaelMeissner

Well the problem with writing in python/perl/etc. is they are interpreted languages (or 'compiled' but the dynamic typing systems limits the amount of optimization you can do), which is often orders of magnitude slower than using a more statically typed language like C, C++, or Java.

There are simulators out there for the AVR chips.  Using google, the first link that came up was: http://www.oshonsoft.com/avr.html, and there were various others.  What you would likely have to do is to move away from the Arduino IDE, and produce object files that these tools can handle.

Paulware

#3
Aug 02, 2012, 03:53 am Last Edit: Nov 09, 2012, 07:03 am by Paulware Reason: 1
 The goal is to make it open and easy for people to add components.  That way many components could be covered with little effort (spread amongst many people).  Very little time will be wasted since I picked Python as the programming language.  It constantly surprises me how quickly various tasks can be completed.

 Being interpreted actually is not a drawback it is a benefit.  Not having to compile the entire project before running is a big time savings, and determining type of object at runtime is very cool.  Actually the speed can be better than writing in C++, because optimized C++ libraries are drawn upon.  

 I mentioned another simulator www.visualbreadboard.com that I liked but I don't trust that they will always be free.  I won't be moving away from the Arduino IDE.  I appreciate the comments.  I made a quick proof of concept file I will post on sourceforge soon.

cr0sh


 I recently got burned by the cadsoft eagle v 6.  They have discontinued their free service and it now costs $69.00 to do same.


???

http://www.cadsoftusa.com/download-eagle/freeware/?language=en

Sure, there's limitations when using the free version - am I missing something else? Not that I am a huge supporter of CadSoft Eagle, I just don't understand your statement...
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Paulware

#5
Aug 02, 2012, 03:26 pm Last Edit: Nov 09, 2012, 07:03 am by Paulware Reason: 1
In 30 days you may get a message that you cannot access your .sch / .brd anymore without a license.  This is what happened to me after downloading v6

Paulware

#6
Aug 02, 2012, 03:41 pm Last Edit: Nov 09, 2012, 07:03 am by Paulware Reason: 1
I heard that Fritzing.com outputs files in gerber format for pcb creation.  That may be a good alternative

Tom Carpenter


In 30 days you may get a message that you cannot access your .sch / .brd anymore without a license.  This is what happened to me after downloading v6

That suggests you are using the wrong license file. In Eagle, if you go to "Help->EAGLE License..." and then select "Run as Freeware", it will select the free license.
~Tom~

Grumpy_Mike

Quote
Being interpreted actually is not a drawback it is a benefit. 

And the down side is that you can't tell if there is a syntax error until that bit of code is executed.

Quote
Actually the speed can be better than writing in C++, because optimized C++ libraries are drawn upon. 

No that is not correct, you have to do the function anyway C will always be faster.

Paulware

#9
Nov 09, 2012, 06:55 am Last Edit: Nov 09, 2012, 07:04 am by Paulware Reason: 1
I'm thinking that a free C++ compiler would work better for this.  It would be nice to make an open-source version.  I heard Visual Breadboard is now charging and other arduino simulators are also charging.

Paulware

Created a windows consol app to provide a simulator for an Arduino BASIC language code
http://www.youtube.com/watch?v=V1dJEOE03Ok&feature=plcp

ANJ6621

I appreciate Paulware's idea there should be a free simulator for arduino just like it's IDE .. I'll be happy to help in. :)

Paulware

Awesome.  The simulator is written in C++ and located here: https://github.com/Pualware/ArduinoSimulator
I'm willing to create UML design documents, refactor or whatever, to make it more usable.
Any suggestions?

Next I was going to add a potentiometer.


Go Up