• 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 #159 sky77762 2019-03-22 05:46
Imagine if you tell two friends about something and
they tell two friends therefore forth. Decide the size
of the article you are writing and divide it into stages.
There are many free directories, plus much more paid online
directories.
Quote
 
 
0 #158 rollex 11 2019-03-18 07:14
There are free tools rrn existence that should
use through photovoltaic cells good looking blog.
Have a subscriber channel that is appropriately tagged and stay busy.
Adsense can air ads directly associated your website content.
Quote
 
 
0 #157 scr888 whatsapp 2019-03-18 00:59
Always make sure your content is relevant to you, your logo and your content.
Building reciprocal Links is definitely an important tool for linking popularity.
This will get ranked high quickly.
Quote
 
 
0 #156 casino slot machines 2019-03-17 02:06
I really love your site.. Pleasant colors & theme. Did you create this site yourself?
Please reply back as I'm hoping to create my very own website and
would love to learn where you got this from or just what the theme is called.

Appreciate it!

Review my web-site :: casino slot machines: https://casinomegaslotos.com/
Quote
 
 
0 #155 3win8 download 2019-03-16 23:36
What advice is it possible to give to writers here on Hvac?
What household can survive that sort of thing for for a long
time? It may take several months for some gymnasts to master visualization.
Quote
 
 
0 #154 live22 2019-03-15 20:28
Must not cherry pick from different sections to develop a doctrine that God
never intended. These statistics about agoraphobia are quite
scary. Allow these obstacles stop you reaching your goals.
Quote
 
 
0 #153 scr 888 2019-03-15 11:10
The standard reader does not take period to look at whole article
but they analyze for key factors of your article.
Or, at least a regarding click-throughs that heighten potential risk of a dealing.
Quote
 
 
0 #152 rollex11 2019-03-14 22:01
Hi, of course this piece of writing is really fastidious and I have learned lot of things from it concerning blogging.
thanks.
Quote
 
 
0 #151 download 2019-03-14 19:14
My programmer is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the costs. But he's tryiong none the
less. I've been using Movable-type on various websites for about a year and am
nervous about switching to another platform. I have heard great
things about blogengine.net. Is there a way I can import all my wordpress posts into it?
Any help would be really appreciated!

Review my blog post - download: http://highcontdigen.reblog.hu/new/post/?blogid=37020
Quote
 
 
0 #150 live casino video 2019-03-13 03:01
They will probably be in the forum posting and helping members out
deadly. That is things i am here to a person to with.
The different options are days, weeks and months working and sweating and see minimal
results.
Quote
 
 
0 #149 sky777 apk 2019-03-12 14:37
She will be judging you long prior to taking any steps towards her.
It is to keep the customer's trust when you create a presentation. Research - good research
is significant to buying a really good dress.
Quote
 

Add comment

No bad words.


Security code
Refresh


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