Simulating a circuit which has an ATmega328, is it a waste of time?

Thread Starter

abi17124

Joined Mar 5, 2017
7
I'm trying to judge if it would be viable to simulate my code and circuit on a software such as Proteus(or anything else? Suggestions welcome :)) since it has a lot of constraints: Time/Money/Part Availability in my region. Also if you guys had the option of Simulating than testing and building a large circuit to get the best/most efficient one out, which would you pick(Leaving out the love for building prototypes)? Simulating or building(in terms of least time consuming and most cost efficient)
 

crutschow

Joined Mar 14, 2008
38,458
You might simulate the auxiliary/glue circuits, but I don't think it's worth trying to simulate code in software.
That's likely better tested on the prototype system.

Linear circuits and/or simple digital circuits can be simulated using Spice, such as the free LTspice simulator from Linear Technology, which several on these forums use.
Personally I never build any circuits, even simple ones, without first simulating them.
It picks up a lot of design errors before you build the prototype breadboard.
 

ErnieM

Joined Apr 24, 2011
8,415
I've only found simulation of micros good for some initial debugging of the code, it has limited uses when simulating any sort of complicated system.

Simulating hardware is similar, you can do simple things but even say an RS232 converter may be best left to the bench.

My favorite simulator is solder: build a breadboard and get an in circuit software debugger to observe your actual code running on your actual hardware. This is rather simple to do with PIC devices as even a humble PICkit II or III can do this.
 

tracecom

Joined Apr 16, 2010
3,944

Oh honey, I got your picture hangin' on the wall
But it can't see or come to me when I call your name
I realize it's just a picture inside a frame
Ooh, I read your letters when you're not near me
But they don't move me, and they don't groove me like when I hear
Your sweet voice whispering in my ear
Don'cha know, ain't nothing like the real thing, baby
Ain't nothing like the real thing.
 
Last edited:

eetech00

Joined Jun 8, 2013
4,705
I always use electronic simulation for hw before breadboarding, but I never completely skip bread boarding.

I use simulation for uC to initially debug code..but also perform in circuit debugging using a development board and real uC. I'll also create a small stand alone test circuit to test basic uC funtionality..if practical..
 

MrSoftware

Joined Oct 29, 2013
2,273
I think it depends entirely on how you like to work, and what you're building. Simulate a few things and then decide if you like it better than just building a prototype.

Simulation can be very useful, especially if the hardware is difficult to come by or time consuming to set up. Sometimes the simulator can provide better debugging tools that the real hardware. Years ago my job was writing graphics drivers for graphics chips that were still in development. A software model (simulator) of the graphics processor was written at the same time the hardware was being development, and we used the software model to write the graphics drivers against. The simulator also helped the hardware guys discover logic errors before the chips were manufactured, saving time and tons of money. When the graphics chips were finally available, the software drivers were already written, and in most cases the hardware was up and running the same day that the first new chips arrived from the factory. Of course things aren't perfect and there were a few days of intense debugging and making adjustments for the few things that the hardware did differently than the simulator, but the simulator sped up the driver development by months.

I occasionally write code for phones, and the development environment includes simulators for various phone and phone operating systems. This makes it possible for you to test your code on multiple simulated devices, before you spend the time and energy to acquire the real hardware. I've never simulated anything arduino, but if you wanted to write code to run on various different arduino boards, then simulating on various different boards would be a nice way to find problems before you acquire the hardware. Also some bugs on hardware are difficult to catch. For example if you overflow the stack, you can get all kinds of funky behavior and no clear error. Maybe a simulator would give you an clear error.

Simulating isn't always perfect, but it can be helpful.
 

ErnieM

Joined Apr 24, 2011
8,415
My favorite simulator is between my ears.
I would state that is where I keep my designer, but then we're just quibbling over terminology.

Bottom line I trust my measurements more than I trust my calculation, but in the end they both must agree.

As the late great Ronald Reagon once said "trust, but verify."
 

dl324

Joined Mar 30, 2015
18,302
You're among good company in preferring the solder simulator; it was Bob Pease's simulator of choice too.
As the late great Ronald Reagon once said "trust, but verify."
I liked him as an actor, though I recently read that he was a B-actor. Didn't like him as a President. I thought I was going to do time at Folsom Prison when his retroactive tax law changes left me with a 5 figure tax due bill. In the end, I was able to come up with the cash and didn't have to become a tax protester.
 

Thread Starter

abi17124

Joined Mar 5, 2017
7
I've only found simulation of micros good for some initial debugging of the code, it has limited uses when simulating any sort of complicated system.

Simulating hardware is similar, you can do simple things but even say an RS232 converter may be best left to the bench.

My favorite simulator is solder: build a breadboard and get an in circuit software debugger to observe your actual code running on your actual hardware. This is rather simple to do with PIC devices as even a humble PICkit II or III can do this.
Thanks for your reply Ernie, I've seen that Proteus does simulate a lot of micro controller families, I was wondering what kind of complications do you face? And by judging from the general consensus of this thread it looks like simulating uC's is pointless, if so, why does Proteus have such a package anyway?
 

ErnieM

Joined Apr 24, 2011
8,415
It's not so much I face complications but rather the limited abilities of the simulator I use, which is the build in simulator as part of th Microchip MPLAB development nvironment. That simulates code very well, but not things outside of the micro controller box.

For that I use the real hardware on a breadboard where MPLAB is running as a debugger in real time for my real code in my real hardware.

It skips over all the drawbacks of simulation.

Pure simulation is useful to see how your code works in limited circumstances. Just Google "my code works in the simulator but not in..." and you will see what I mean.
 
Top