K6300 Turret Set User's Manual

NOTE: An updated version of this document can be downloaded along with examples at the following URL:
ftp://ftp.k-team.com/pub/khepera/Khe-VV6300Sys200.tgz

The K6300 Turret Set comprises two tightly related turrets :
  This is a typical example of an image acquired by the K6300 Turret Set.

Communication with Khepera, Koala or Kameleon

The K6300 Turret Set can communicate with the Khepera, Koala or Kameleon products through the K-bus, a proprietary serial bus based on an extended QSPI link. The K6300 Turret Set responds as a K-bus slave with a hardwired address (25 decimal).

Khepera

Turn off the Khepera and plug the K6300 Turret Set on its top. Be careful not to bend any pins, since these are quite fragile and might break. Once both turrets are correctly seated on the Khepera, switch the Khepera to interactive (sercom 38400) mode and turn it on. Proceed to the interactive test.

Koala

Turn off the Koala. Plug the K6300 Turret Set onto the Koala to K-bus adapter module, then connect the module to the upper K-bus connector (Jxx). When you are done, switch to the interactive (sercom 38400) mode and turn the Koala on. If for some reason you have to use the bottom K-bus connector (Jxx), you must use the alternate K6300 Turret Set's K-bus address 57 (25+32 decimal) instead of the base address 25 (please refer to the Koala's documentation for further details). Proceed to the interactive test.

Kameleon

Turn off the Kameleon. Plug the K6300 Turret Set onto the Kameleon to K-bus adapter module, then connect the module to the K-bus connector (Jxx). When you are done, switch to the interactive (sercom 38400) mode and turn the Kameleon on. Proceed to the interactive test.

Interactive test

The platform you are using (Khepera, Koala or Kameleon) should be connected to a terminal via the serial line. Make sure that you can communicate with your platform before you proceed.

In order to check that the K6300 Turret Set has been properly detected by your platform, use the "net" command. Simply type net and hit the Return or Enter key. You should get the following output :

VV6300       25      160x120 pixel camera, EF/PA-99:          Rev. 2.09
Your mileage may vary. This line contains the following information : If the net command does not list the K6300 Turret Set, turn your platform off and check your cables.

K-bus commands supported by the K6300 Turret Set

The K6300 Turret Set supports the following K-bus commands :
 
Q   Acquire an image. This command has no argument and does just return an acknowledge.
    Example : Q
    Output : q
 
B   Return the version and the revision of the K6300 Turret Set control software. The version and the revision are coded as two separate BCD numbers. This command has no argument.
    Example : B
    Output : b,1,5
 
F   Read a flag and possibly modify it. This command has a single argument, consisting of the flag number added with an operation code. The flag number is in the range 0..63 and the operation code can be either +0 (just read the flag), +64 (read and set the flag), +128 (read and clear the flag), +192 (read and change the flag).
    Example : F,72    (read flag number 8 and set it : 8+64 = 72)
    Output : f,110
 
I   Read a single line consisting of 160 pixels. This command has a single argument, consisting of the line number to read, in the range 0..119. The 160 pixels are returned as numerical values in the rage  xx.. yy.
    Example : I,15    (read the line number 15)
    Output : i,113,83,220, ... ,92   (total of 160 pixels)
 
O   Read the minimum profile.
    Example : O,255
    Output : O, ...
 
P   Read the maximum profile.
    Example : P,0
    Output : p, ...
 
R   Read a 32-bit user variable. This command has a single argument, consisting of the identifier of the variable to be read from, in the range 0..15. The 32-bit user variable is returned as four numerical values, from the most significant to the least significant byte.
    Example : R,5
    Output : r,0,250,192,64   (the variable has a value of 0x00FAC040)
 
W   Write a 32-bit user variable. This command takes five arguments; the first one is the identifier of the variable to be written to, in the range 0..15; the four other ones specify the four bytes, in the same order as that of command 'R' above.
    Example : W,2,10,0,0,2   (the variable has a value of 0x0A000002)
    Output : w
 
L   Read the line (160 pixels) processed by the user application (if any). This argument-less command returns an acknowledge followed by 160 numerical values, coding the 160 pixels of the line.
    Example : L
    Output : l,,113,83,220, ... ,92   (lower case letter 'L' followed by a total of 160 pixels)
 
C   Read the column (120 pixels) processed by the user application (if any). See command 'L' above for details.
    Example : C
    Output : c,10,26,254, ... ,2   (total of 120 pixels)
 

These commands can be issued from the terminal by prefixing them with the T,25 command (talk to turret number 25). Here are a few examples :

T,25,Q
T,25,B
T,25,F,0
T,25,I,119
T,25,O,200
T,25,P,50
T,25,R,0
T,25,W,15,0,0,0,16
T,25,L
T,25,C
...

Serial commands

The serial protocol commands supported by the K6300 Turret Set can be obtained through the list command. The following commands are of particular interest : Use the on-board help to get the detailed description of these commands (simply type "help X").

Embedding user preprocessing

The K6300 Turret Set can run user-provided preprocessing code, which could for example analyse the raw image data in order to extract the meaningful information. This code will run as a separate process and has full access to the KOS system calls.

The hosting platform (Khepera, Koala or Kameleon) can communicate with the user preprocessing code through 64 flags (command F), 16 32-bit variables (commands R and W), a preprocessed line of pixels (command L) and a preprocessed column of pixels (command C).

The preprocessing code can obtain a pointer to the array of 64 uint8 flags by calling vvl_get_flag_ptr.

The preprocessing code can obtain a pointer to the array of 16 uint32 variables by calling vvl_get_user_ptr.

KOS special system calls

The K6300 Turret Set provides the standard TIM, VAR, STR, SER and COM system calls. It has been extended with a specific set of VVL system calls which allow the user code to interact with the camera. These calls are explained in the following paragraphs.

vvl_reset (BIOS call #368)

int32 vvl_reset (void);
Call this function once before using any other vvl_... function. This initialises the module and sets up the hardware interface and the camera.

vvl_get_line_ptr (BIOS call #369)

const uint8* vvl_get_line_ptr (int32 line);
This function returns a pointer to the specified line of 160 pixels. The line argument must be in the range 0..119. If outside of this range, the function returns a pointer of value 0xFFFFFFFF (or -1).

vvl_get_mean_ptr (BIOS call #375)

const uint8* vvl_get_mean_ptr (void);
This function returns a pointer to 120 pairs of mean pixel values. The pair consists of the mean value of left half (pixels 0 through 79) and the mean value of the right half (pixels 80 through 159) of each line.

To access the left mean value of line number 25, you would access byte number 2*25+0. To access the right mean value of the same line, you would access byte number 2*25+1.

vvl_get_mean_values (BIOS call #376)

uint16 vvl_get_mean_values (void);
This function returns the overall mean values of the left half and of the right half of the image. Each half is 80 pixels wide and 120 pixels high. The left and right values are stored as the high and low byte of the returned value. To extract them, use the following piece of code :
    uint16 mean_pair  = vvl_get_mean_values ();
    uint8  left_mean  = (uint8)(mean_pair >> 8);
    uint8  right_mean = (uint8)(mean_pair);

vvl_get_image_ptr (BIOS call #370)

const uint8* vvl_get_image_ptr (void);
This function returns a pointer to the raw array of 160 x 120 bytes, directly encoding the individual pixel values. To access the pixel located at the position [x;y], use the following piece of code :
    const uint8* ptr = vvl_get_image_ptr ();
    ...
    uint8 pixel = ptr[x+y*160];

vvl_get_minmax (BIOS call #371)

uint32 vvl_get_minmax (void);
This function returns the co-ordinates of the minimum intensity pixel and of the maximum intensity pixel. The co-ordinates are encoded in the 32-bit result as [xmin;ymin;xmax;ymax]. Use the following piece of code to extract the individual co-ordinates :
    uint32 encoded = vvl_get_minmax ();
    uint8  x_min = (uint8)(encoded >> 24);
    uint8  y_min = (uint8)(encoded >> 16);
    uint8  x_max = (uint8)(encoded >> 8);
    uint8  y_max = (uint8)(encoded);

vvl_get_min_prof (BIOS call #372)

const uint8* vvl_get_min_prof (uint8 max_level);
This function computes the minimum profile of each column (there is a total of 160 columns). It searches the pixel with the lowest intensity and stores its position in the column (in the range 0..119). If the intensity of the given pixel is above the maximum level, then its position is discarded and 255 is stored instead. If every pixel should be considered, set max_level to 255.

The following piece of code prints the [y] position of each minimum pixel value, column by column :

    uint32 x;
    const uint8* profile = vvl_get_min_prof (255);
    for (x = 0; x < 160; x++) {
        printf ("x=%3d => y=%3d\n", x, profile[x]);
    }

vvl_get_max_prof (BIOS call #373)

const uint8* vvl_get_max_prof (uint8 min_level);
This function computes the maximum profile of each column (there is a total of 160 columns). It searches the pixel with the highest intensity and stores its position in the column (in the range 0..119). If the intensity of the given pixel is below the minimum level, then its position is discarded and 255 is stored instead. If every pixel should be considered, set min_level to 0. See vvl_get_max_prof for an example.

vvl_aqu_image (BIOS call #374)

void vvl_aqu_image (void);
This function takes a snapshot with the camera. The acquisition of the image takes about xx us. You must call this function before you call one of the following functions, or their result will be undefined :

vvl_get_flag_ptr (BIOS call #377)

uint8* vvl_get_flag_ptr (void);
This function returns a pointer to 64 uint8 flags (8-bit values) which can be freely used by the user. The host can check or modify these flags through the K-bus command F.

vvl_get_user_ptr (BIOS call #378)

uint32* vvl_get_user_ptr (void);
This function returns a pointer to 16 uint32 values (32-bit values) which can be freely used by the user. The host can read these flags through the K-bus command R and write them through command W.

vvl_write_reg (BIOS call #379)

void vvl_write_reg (uint8 reg, uint8 data);
This function writes the specified 8-bit data to the image register reg. The full documentation about the imager's registers can be found on the VVL site.

vvl_read_reg (BIOS call #380)

uint8 vvl_read_reg (uint8 reg);
This function reads the specified imager register reg.

Automatic Flash System File

You will find automatic flash system files in System directory, the latest and more stable version is the 2.09 version. In case of upgrade, we will send you the code under this format. To load it, just type "run sloader" and transfer the code.

C Application

In the C examples directory, user will find a package for use with Kros environment. For more information, read the FAQ on K-Team web site. You will find a set of examples and in particular a calibration software. The software looks for intersection point of a grid test card in front of the camera thanks to a threshold technique. It then stores in a lookup table their correct position. The software is done to work in low light condition (exposure and gain are fit for that). It was done on the purpose of using a distorting wide angle lens (FOV of 110 degree).

Matlab Application

In the Matlab examples directory, user will find source code for Matlab. Two applications are provided, one allows to grab, transfer to PC, colorize and display an image GrabNColorize.m and the other, Calibration.m, allows to calibrate an image in the same way as the code provided in C code hereafter cited. This applications use four elementary functions.

Miscellaneous

The SRAM is used up partly by the internal image acquisition buffer. The buffer can be used for other purposes when no acquisition has to be done. This is, for instance, used to load the image of the system when flashing it. The buffer starts at 0x00121100 and ends at 0x00133000 with the current revision (2.05) of the BIOS.

To store a program into the user flash, you have to use the sfill and flash commands. The first available segment is located at absolute address 0x00020000 (segment #2) and the standard turret has 6 x 64 KB flash memory segments reserved for the user.
 
NB :  If the program exceeds 64 KB in size, it is recommended to split it into manageable chunks written segment by segment to the memory using successive sfill and flash S2 to flash S7. The download address of each chunk should be set to 0x00121100.

Comments are welcome to support@k-team.com !