SP: Simulating

The first chapter of the project is simulation and software development. It is highly recommended that you simulate your project beforehand to avoid mistakes or problems in later stages. Furthermore,  simulations can provide an excellent testing environment to try different scenarios for your solution. 

Simulation Environment

As with any of my previous projects, every file is available in our Github repository, so feel free to clone/download the repository and use it as you want. Here we will be using the files in "https://github.com/rubenelportero/MakingDevices/tree/master/StopWatch/v1/Simulation".

You can check my previous post to know that I usually run MPLAB with PROTEUS to simulate microchip microcontrollers. 

Here you have the schematic in Proteus:

Proteus circuit

It is important to know that the circuit in Proteus is "ideal": we do not use power supplies, transistors, or any inverter or passive components. So it is a pretty basic circuit to start developing the firmware of the microcontroller in advance.  You will see the final circuit in the following chapters. To start with the simulation, we can run the file "StopWatch.mcp" to open the project in MPLAB.

There is one last thing about the simulation: As the ISIS Proteus does not have the Idle mode implemented for our PIC18LF14k50, we need to omit the sleep instruction from the code and recompile the HEX:


These things are important to know if you do not want to die debugging the circuit, as you won't receive any error message concerning this PROTEUS limitations. 

In another hand, MPLAB offers us interesting data like memory usage in the microcontroller, which can be interesting if we are using a low-profile IC and we need to integrate everything in the code: 

Memory IC

However, I do not see the struggle of trying to fit everything in a small PIC, when you have plenty of those available, so you will be always able to select one with more specs. 

Finally, here you have a .GIF with everything running smooth:

GIF stopwatch

To end the chapter, I would like to share a direct link to the code, so you can check it. 

Thanks for reading!