Högskolan i Halmstad
Halmstad University - For the Development of Organisations, Products and Quality of Life

Components

Hardware, software and getting started in mechatronical systems

Hardware

Lego
The lego kitPDF (pdf, 10 kB) concist of  lego girders, lego plates, gearwheels, shafts etc.

Sensors
Sensors are read-forks, photo diods and microswitches. But, the camera can also beseen as a sensor.

Aktuatorer
The actuators consist of 6V dc-motors and 5V servon.

Camera
The camera is a colorvision camera with 640x480 pixel(VGA) resolution. The camera concist of a CMOS-chip Omnivisonexternal link and is mounted on a chip Quasarelectronicexternal link with a  6-mm lens.

DSP
The DSP is a Texas Instrument TMS320C6211 Starter-Kit.external link

IO-card
The IO-card is a extension card which is developed at Halmstad university. The card is connected via the pin-list to the DSP-card and is mounted above the DSP Starter-Kitet.

Software

Software for  DSP
The recommende debugger/editor/compiler enviroment is Code Composer Studio DSK Tools2.external link

IO-card drivers
Some IO card drivers are available. Adressing of IO-units.PDF (pdf, 3 kB)

Getting started using Code Composer

Create a new projekt in Code Composern
Connect the DSP using the printer cable and connect the volage supply befor startin code composer.The reset active diodon the DSP-card has to lighten up shortly. Click on Project-New give the new project a name and place it right directory. Check if the target is correct  (TMS320C62xx) and project type is Executable. Click finish.

Adding files to the project
A linkning file has always to be included. Here is the memory use defined. Copy this to your catalogue and add this to your project by:click  Project-Add Files to Project. Choose Linker Command File in Files of type rutan and then choose the lnk.cmd-file. A c-fil with a main function has also to be in a project. Choose File-New-Source file  and create a main-function and save it using File-Save as.  This file has to be added to the project in the same way as the linker-file. Remark: it is not aoutomatically added to the project only by opening it in the neviroment. C-files and assembly files are included/added in the same manner. A interrupt-vector has also to be included.

Compiling and linking the files
To compile and link the files togehter use Project-Build . The are all included neccesary files compiled amd linked.

Loading code to the DSP
To be on the safe side start by resetting the DSP  Debug-Reset CPU. Then load the code with File-Load Program and by choosing your out-file.

Starting the program
Click on Debug-run.

Stopping the program
Click on Debug-halt.

Getting started with the camera


Tip of how to take a picture with the camera and saving it as a file. Remark: Do NOT use this as a starting shell for your final application.

Add files to the project
Connect the camera according to the recommendations and connect the printer cable and power supply to the DSP. Start the Code Composer. Create a new project and copy the files the same directory. Add the files to the project. A En lib-file (img62x.lib) should also be added and is found at  C:\ti\c6000\imglib\lib.

Starting the program
Compile the project, hopefully without any error messages and then you  load the program into the DSP.

Enable a breakpoint on line 53 GrabbImageRGB(PictRGB,GRABB_SYNCHRONOUS); in the main function. Use the rigth button for this and Toggle breakpoint which led a red icon on the left side ow the row.

Press run or F5 and the program will start. The program will run to the breakpoint. But the camera will not stop taking pictures and copying them to the memory on the IO-board. This is still done at 60 pic/s. The picture copied to the SRAM is the one which was found when GrabbImageRGB was run.

Loading a picture
The picture will now be at that place in the memory which was given by the ConfigImageType function,  see line 24 in the main.c-file. In this first example is the first pixel positioned in the SDRAM on the address 0x80050000. Now we want to load it and take a look at it. This can be done using view6000 and a config-file. Copy this files to the same directory and open the file view6000.cfg (using e.g. notepad). Check the start address and compare it to the one given in ConfigImageType. Doubbleclick on view6000.exe.

The loading process is approximately 30 sec. This depends on the size of the picture. But do not try to edit in Code Composer or something else in the meanwhile. This is not supported by the program. When the DOS-window closes has the program created a ppm file. This can be read by using Paint Shop Pro.

Convertion to .bmp
Unfortunately can Matlab not handle the ppm file format so with Paint Shop Pro yuo have to convert the picture to a bmp file. In Paint Shop Pro yuo press file-save as and choos save as bmp file.

To get a picture from the DSP memory you need the program view6000 together with a configuration file. The resulting picture is of ppm type and can be opened with Paint Shop Pro and converted to e.g. bmp.

IO-card units


Here is a small example of how to reach the IO using drivers. Always initiate the DSP. In robotnic.h the avalable functions can be found. Use the files in directory drivers and not those for tip of getting a image". These are only intended for taking a picture with the DSP, and nothing else.

Starting a timer on the DSP
A tip of how to start a timer on the DSP. There are two timers on the DSP, timer0 och timer1, use timer0 (but not timer1, since this is to be used in  the communication). In starting a timer four steps have to be made:

  • A reference to the function. .ref   _timer0_isr See on the top in vecs.c
  • Generate a branch to the function on INT14: b _timer0_isr a bit further down in vecs.c
  • Writing a function, which in this example is called interrupt void timer0_isr(void) see main.c
  • Writing a function to start the timer-interrupt Start_Timer0

Remark: the reserved word interrupt must be used in front of the function. The function can not return a value and can not accept an input argument. A trick to solve is ofcorse to use global variables.

The period time used by the interrupts is changed on the line*(unsigned volatile int *)TIMER0_PRD = 0x200000; /* set for a period*/ see the function Start_Timer0.

Burning the flash-memory
To run in the competition the code should be loaded it to the flash memory. But, by doing this there is no possibility of debugging your code. So, this has only to be done in the end of the course. Tip to load to code into the flash.

Page editor: Tommy Salomonsson
Page last updated 2008-07-23
Halmstad University  |  Box 823  |  S-301 18  Halmstad, Sweden  |  Tel: +46 35-16 71 00  |  registrator@hh.se |  Visiting address: Kristian IV:s väg 3