Pages: [1]   Go Down
Author Topic: Arduino simulator written in Python (C++ better)  (Read 12291 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 3
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  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
« Last Edit: November 09, 2012, 01:03:11 am by Paulware » Logged

Yorkshire England
Offline Offline
Sr. Member
****
Karma: 2
Posts: 267
Arduino good init
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1857
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

  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.
« Last Edit: November 09, 2012, 01:03:24 am by Paulware » Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5594
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

 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...
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

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

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
« Last Edit: November 09, 2012, 01:03:39 am by Paulware » Logged

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

I heard that Fritzing.com outputs files in gerber format for pcb creation.  That may be a good alternative
« Last Edit: November 09, 2012, 01:03:55 am by Paulware » Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1729
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

~Tom~

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 634
Posts: 34532
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

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

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.
« Last Edit: November 09, 2012, 01:04:17 am by Paulware » Logged

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

Created a windows consol app to provide a simulator for an Arduino BASIC language code
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley
Logged

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

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.

Logged

Pages: [1]   Go Up
Jump to: