Sunday, July 3, 2011

Simulating PIC with Proteus

Simulating circuits in virtual environment can save both time and cost to produce the hardware. So far, Proteus provides a wide range of PIC simulation from PIC16F to dsPIC33F. It also enables the developer to check for the functionality as well as coding errors such as logical conditioning errors when coding.

Figure 1 shows the Proteus simulation environment.

  1. Click on component mode -> P to pick the devices.




Figure 1: Selecting a device in Proteus


  1. Figure 2 will pop up. Here, type the device for simulation. In this case, type PIC18F4550 in keywords. Then, click OK.




Figure 2: Pick the device


  1. Put the device selected in the blue box. Figure 3 shows the pin layout of the PIC18F4550.




Figure 3: PIC18F4550


  1. Other devices such as LED and resistors are added by repeating steps 1 to 3.




Figure 4: Adding resistor and LED


  1. After adding the necessary devices, connect them together by clicking on the end of one device to another device. Once this has been done, you should have the same layout connection as Figure 5.




Figure 5: Full circuit for simulation


  1. Double click on PIC18F4550 will bring up Edit Component GUI. Here, you can set additional settings for your PIC. Then, load the hex code generated by the MPLAB in Program File column and click OK.


The sample source code using C18 is provided below.



Figure 6: Configuration in PIC18F4550


  1. At the far left, where the simulation panel is located, click on run to begin the simulation. Alternatively, you can pause, halt as well as simulation by frame.




Figure 7: Simulation panel

Source Code



Conclusion


This simulation will provide another platform to test and debug your PIC program in virtual environment. In addition, the developer can focus in troubleshooting their codes without having to worry about their hardware failure.

No comments:

Post a Comment