NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Everything Else » Nerdkits Simulator

August 28, 2013
by countryguy828
countryguy828's Avatar

Somewhat thinking outloud here...

Is there some sort of simulator software out there to test programs with before downloading to the nerdkit?

If not how hard would it be to create some such software?

Dave

August 28, 2013
by pcbolt
pcbolt's Avatar

Dave -

AVR studio has emulator capabilities. I'm not sure how well they work though. I played around with the AVR debugger and an Dragon programmer (using the debugWire interface) awhile back and one of the things that's almost impossible to simulate is timing and interrupts. For instance using just a "delay_us(10)" statement will step through tons of NOP statements unless it's disabled. The one thing I found helpful if I wasn't at home to test code on a chip, was to write code and compile it with a "gcc" and see if it ran in a console screen. Then later on I could import it into my project code, make some tweaks and upload it to a chip for testing.

August 31, 2013
by countryguy828
countryguy828's Avatar

Hi Guys,

I tossed together a sketch of what I had in mind for a Simulator. Here is a screenshot. Nerd Kit Sim

Dave

August 31, 2013
by Noter
Noter's Avatar

That looks pretty cool but it's a lot less work just to test programs on the real thing especially when you start using sensors. How would you simulate a temperature sensor? And if you do what about the hundreds of other sensors? Then it gets even more complex when you start using SPI, I2C, or one wire busses to talk to smart devices like a real time clock or external eeprom. And timing or interrupts like pcbolt mentioned would need consideration too. Pretty hard to beat the real nerdkit and it fits in your pocket for road trips.

The biggest drawback to the nerdkit out of the box is flipping the program/run switch and resetting power to start the the new program. When you get tired of that get an ISP programmer and it's all automatic, just type 'make' hit return on the PC when you're ready and it's all done for you. Doesn't get much easier than that.

September 01, 2013
by countryguy828
countryguy828's Avatar

Guess my idea isn't too practical. In an attempt to get some new discussion going I posted this to see what other's ideas were on this idea. I may continue to play with it a little more. For me sometimes I'm away from home and can only take laptop not the whole pile of parts so it was an idea I could test code with. After I had the interface done in visual basic I realized...Maybe I should have done this in Java so non windows guys could use it. Then again its been two years since I touched Java...

Dave

September 01, 2013
by Noter
Noter's Avatar

You would probably spend all your time working on the simulator instead of a nerdkit program anyway. No doubt it would give you something to do when you're away from home but maybe you'd get more bang from studying and learning to program your cell phone when you're not around the nerdkit. I have a lot of fun interfacing my cell phone to my nerdkit projects.

September 03, 2013
by JimFrederickson
JimFrederickson's Avatar

While I think that the Simulation Project would be interesting, I think you may get
to a point of kind of "chasing your tail"...

Maybe a better example of what I mean is that "the Simulation Project could take up so
much time to get it right that maybe that is all that you do for a very long time".
(Rather than have time for other projects.)

Trying to effectively incorporate the code necessary to do a simulation as well as
taking account of AVR MCU differences between models may take quite a bit of effort.

Then the simulation vs real hardware testing differences may take more time as well.

That being said...

I have a small box, about 6" x7", that incorporates the AVR, LCD, and Keyboard. That
is what I use for most of my developement. (I have another box that is about 2" x 4"
which is the same sans keyboard and LCD.)

There are times though, for many projects that I need the pins to do other things
and/or when I am traveling, like you, don't want o carry alot of extra things.

For situations as the above I have done something similar to what you have Prototyped
out.

So I have a "virtual keyboard and virtual LCD that are on the PC and connected to the
AVR VIA a Serial Interface.

I tried using C, VB, and Java.
(Having written the code in all of them initially)

But those did not enable seamless operations between Linux and Windows. (Most of my
Computer Systems now are Linux, and I needed, yes needed :) , the ability to go
between the two without having to write the same code twice.)

Ultimately I went with Python. (I would have preferred to stay with Java, but I
didn't find any "seamless support for serial communications that I liked".)

I am not a Python "Fan Boy" per se'. There are lot of things I don't like about
Python.

The things I do like though are it's great ability to have the same program run on
Windows or Linux seamlessly, it is MUCH FASTER that I had thought initially it would be, it is more flexible/extensible than any other Language/Environment that I have
seen.

I use:

Python 2.7 and 3.3 (transitioning.)
wxPython for the GUI
PySerial for Serial Communications

I go back and forth between Geany and Programmer's Notepad for editing. (Probably will
end up with Geany just because there are Windows and Linux Versions.)

September 03, 2013
by pcbolt
pcbolt's Avatar

Dave -

You're project sort of tweaked my curiosity and I had a look at the Atmel Studio 6.0 simulator. There is a video HERE that shows the very basics of what you need to do to set things up. I didn't realize you could have an external file that could simulate inputs for you...that's pretty cool. Unfortunately the video doesn't go in to that kind of detail. It looks like it would be fun to play around with when you're on the road.

Post a Reply

Please log in to post a reply.

Did you know that a thermometer can be made "faster" by using a bit of math? Learn more...