• Increase font size
  • Default font size
  • Decrease font size

gpsim tutorial

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:

Basics

This chapter will lead you in a very fast way to run your first gpsim simulation by running a .hex file.

1. gpsim download page can be found here. if you want to download a windows installer use this link instead.

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).

 "c:\Program Files (x86)\gpsim\bin\gpsim.exe" 

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:

 processor list 

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:

 quit 

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):

"c:\Program Files (x86)\gpsim\bin\gpsim.exe" -pp16f84 c:\_cc5x\_Projects\Clock_generator\clock_generator_v01.hex

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".

Breadboard

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:

- led1
- led1.in

- 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:

Stimulus led1.in

Not connected

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.

STC file

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:

processor pic16f84
 
 load clock_generator_v01.hex
 frequency 32768
 
 # Processor position:
 p16f84.xpos = 50
 p16f84.ypos = 50
 
 # Modules:
 module library libgpsim_modules.dll
 
 module load led led1
 led1.color = green
 led1.xpos = 100
 led1.ypos = 350
 
 module load led led2
 led2.color = green
 led2.xpos = 100
 led2.ypos = 400
 
 # Connections:
 node n_led1
 attach n_led1 portb0 led1.in
 
 node n_led2
 attach n_led2 portb1 led2.in

 #scope.ch0 = "portb0"
 #scope.ch1 = "portb1"
 #scope.ch2 = "portb2"

 #break at interruption
 #break e 0x0004

 #break at specific instruction execution
 #break e 0x003f

 #break on write to 0x1A
 break w 0x1A
 

3. now you can run the simulation simply by calling:

"c:\Program Files (x86)\gpsim\bin\gpsim.exe" -c c:\_cc5x\_Projects\Clock_generator\clock_generator_v02.stc

 

Comments  

 
0 #108 3win8 casino 2019-02-19 15:57
Now you need to wait and see the returns. This is not a period to boast your impressive string of vocabulary.
Try to sprinkle the keywords naturally throughout your article content.
Quote
 
 
0 #107 joker123 download 2019-02-19 10:03
You should get them involved by asking them
of how they are. You've got to give a puppy the confidence he to be
able to complete the duties until he's it on his own. Do not
tell her what you believe is going to proceed.
Quote
 
 
0 #106 scr888 group 2019-02-18 07:19
Hi there to every body, it's my first pay a visit of this web site; this blog contains amazing and actually good stuff in support of visitors.
Quote
 
 
0 #105 scr888 no deposit 2019-02-18 07:01
Pretty section of content. I just stumbled upon your weblog and in accession capital to assert that I acquire in fact enjoyed
account your blog posts. Anyway I'll be subscribing to your feeds and even I achievement you access consistently
quickly.
Quote
 
 
0 #104 scr888 download 2019-02-17 10:55
But is the relevancy among the same with entire page, they do not know.
These sites will an individual to rank older. It may sound like there are lots of new articles directories popping up every
business day.
Quote
 
 
0 #103 918 Kiss link 2019-02-17 02:23
It's really very complex in this full of activity life to listen news on Television,
so I only use world wide web for that purpose, and take the hottest news.
Quote
 
 
0 #102 918kiss 2019-02-16 20:36
Internet casinos give the different bonuses to the players.
Keno is counted among the easiest games anyone can ever come close to.
Along with the entertainment, these games are a great source of earning money online.
Quote
 
 
0 #101 scr888 hack software 2019-02-16 18:00
Good way of describing, and nice piece of writing to get information concerning my presentation focus, which
i am going to present in college.
Quote
 
 
0 #100 ace333 apk download 2019-02-15 22:33
Unquestionably believe that which you stated.
Your favorite reason appeared to be on the web the simplest thing to be aware of.

I say to you, I certainly get irked while people think about worries
that they just do not know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect ,
people could take a signal. Will likely be back to get
more. Thanks
Quote
 
 
0 #99 scr888 jatuh random 2019-02-15 20:47
I am curious to find out what blog platform you have been working with?
I'm experiencing some minor security issues with my latest blog and I'd like
to find something more safe. Do you have any solutions?
Quote
 

Add comment

No bad words.


Security code
Refresh


Design by i-cons.ch / etosha-namibia.ch