The first chapter of this simple project is simulation and software development. It is highly recommended that you simulate your project beforehand to avoid any mistakes or problems in later stages, as the mistakes become more expensive as the time runs. In addition, simulations can provide an excellent testing environment to try different scenarios for your solution, being a time/money saver for a good engineer.
As it was shown in previous publications on the blog, here you will see how much increase the cost of your projects, when it fails at a certain stage:
So it is important to capture and solve all our problems in the design stage.
First, every file is available in our Github repository, so you can to "MakingDevices/Bytes-Counter/V0.1a/" and download the folder "simulation" complete.
With SIS Proteus, you can simulate either digital and analogue circuits, but the interesting part comes with the microcontroller: Here we will be simulating our analogue circuit together with MPLAB software, so we can simulate our microcontroller at the same time we are looking at how it works. Next picture shows the preliminary circuit for the Bytes Counter:
I named it "preliminary circuit", as the "transistors" are digital switches and, as you can see, I did not put any resistor or decoupling capacitor in the system. It is just for testing my code. To start with the simulation, we can run the file "Bytes_Counter.mcp" to open the project in MPLAB.
There is one thing about the simulation: As the ISIS Proteus does not have the Idle mode implemented (for the PIC18f14k50), we need to omit the sleep instruction of the code. (Line 190 of the file source.c) and click on the button "build all" to re-compile the HEX.
From MPLAB, we can extract interesting data like registers values during execution, memory usage in the microcontroller, special registers, EEPROM data, Assembly code...
Finally, here is a small animation that shows how the bytes counter worked smoothly even before mounting the first prototype PCB:
Thanks for reading!