To build a robot it is often neccesery to create also a hardware. PIC programming is one of many possible options. I have chosen this way several times and hence know a good PIC simulator is very handy. I have found difficult to find any gpsim tutorial aimed on windows version of the gpsim out there. Therefor you may find one here:
This chapter will lead you in a very fast way to run your first gpsim simulation by running a .hex file.
2. install the gpsim. in my case into following directory: "c:\Program Files (x86)\gpsim\"
3. to run your code (as a hex file) in simulator (gpsim) the fastest way is this:
- open command prompt
- execute following command (correct path if neccesery).
it will start up the gpsim and at least 1 new window should be displayed - main GUI. You should stay in your command prompt window though. You may notice that command prompt has changed a little bit. Something like "**gpsim>" should be displayed at the beginning of the command prompt which tells you that gpsim is running and ready to accept your commands.
- now execute following command:
the list of all supported PIC processors is displayed. choose the one you will use for the simulation. Let's say "pic16f84".
- quit the gpsim by issuing following command:
you may notice that the beginning of the new line on command prompt has returned to its standard form - "C:\Users\Jon.Doe>" in my case.
- now you are finally able to run a simulation. To do this execute following command (correct path if neccesery):
it will run "gpsim.exe" with parameter "-pp16f84" (this tells to gpsim that your processor is pic16f84) and then follows path to your .hex file - in my case "clock_generator_v01.hex".
This chapter will show you a basic usage of the breadboard functionality which I found the most important during the simulation. We will connect a PORTB0 port of the PIC to the LED module.
1. open Breadboard window by clicking: "Windows/Breadboard"
2. click "Add library" button and enter following text into the displayed input window: "libgpsim_modules.dll" and click "OK".
3. click "Add module" button. New window is displayed. The window contains list of many different modules, eg. switch, led, etc.
4. let's choose "led" as our new module. Click on it and enter its name afterward "led1".
* if mouse is not working for the window use keyboard instead - tab to navigate from input box to OK button.
5. a picture of the let module is now displayed in the breadboard window. click on a "+" sign of the led1 element in the upper left corner to display its ports. following situation should be shown:
- by clicking on "led1" you display properties of the module.
- by clicking on "led1.in" in the lower left part you display nodes/stimulus that are connected to the input port (since its name is led1.in) of this module. since we have not made any connection yet following situation should be shown:
6. to create a node push "Add node" button and enter its name, for instance "node_led1".
7. now we are finally able to connect a PIC output port to the led1 module. the "node_led1" node serves for this purpous.
- click on "led1.in" and pusth the "Connect stimulus to node" button. double click on "node_led1" item in the displayed window.
- click on "+" sign of the p16f84 processor. list of all its ports is displayed. select "portb0" and pusth the "Connect stimulus to node" button. now select the same node as in the previous step - "node_led1".
- to check the new connection click on "+" sign of the nodes and select "node_led1" node. in the lower left part of the window both ports led1.in and portb0 should be displayed.
Maybe more convienient way to set up whole simulatin in breadboard is to code it. If this is your case you may use .stc files.
1. in the same directory as your .hex file create a new text file called for instance clock_generator_v01.stc
2. put following code into the file:
3. now you can run the simulation simply by calling: