background image

 

 

Page 23

 

 

 

 

The C language prototypes for these five functions are: 
 

void 

motor(

int 

m,

int 

p); 

void 

mav(

int 

m,

int 

vel); 

void 

mrp(

int 

m,

int 

vel,

int 

ticks); 

void 

bmd(

int 

m); 

void 

ao(); 

void 

off(

int 

m); 

 

Other Functions Commonly Used With the KIPR Link

 

msleep(

<

milliseconds

>

KIPR Link Library function that pauses the currently executing thread, resuming execution of the 
thread after a time equal to or slightly greater than the number of milliseconds specified.   

printf(

<

string

>

, . . .) 

Standard C library function for formatting output directed to standard out (which is the program 
output console screen for the KIPR Link).  If the string contains % codes then the arguments 
after the initial string (the . . .  portion of the function's arguments) will be printed in place of the 
% codes using the format specified by the matching % code.  See the Appendix or consult a C 
language reference for a listing of % codes and how they are interpreted for formatting data. 

beep() 

 

KIPR Link Library function that creates a short beep sound. 

The C language prototypes for these three functions are: 
 

void 

msleep(

int 

msecs); 

 

int 

printf(

char

 s[], ...); 

 

(

...

 represents 0 or more values corresponding to % codes present in s) 

 

void

 beep(); 

Example use of these functions (along with motor functions, motor in motor port 2): 

int 

t=

1000

, m=

2

mrp(m,

 500

,

 500

); 

// move motor at 500 ticks per second

 

printf(

"Running m%d %d mseconds\n"

,m,p); 

// use %d for int values 

msleep(t); 

// suspend the current thread for p milliseconds 

off(m);

// turn off motor 

beep(); 

// beep when thread resumes executing

 

In 1 second  the motor should move 500 ticks.  In contrast to using 

bmd

msleep 

forces the motor off 

after 1 second even if it is short of its target position.  The 

printf

 output will be 

 

Running m2 1000 mseconds

 

 
For more information on KIPR Link Library functions, consult the on-line documentation under the KISS 
IDE 

Help

 tab as well as the appendices to this Guide. 

Содержание KIPR Link

Страница 1: ...KIPR Link Manual Version BB2014 1 1...

Страница 2: ...ges to these specifications at any time without notice BOTBALL BYO BOT BOTGUY and the BOTGUY design and character are trademarks and or service marks of KISS Institute for Practical Robotics and may n...

Страница 3: ...ink___________________________________ 12 1 Connect the KIPR Link to your Computer___________________________________________ 12 2 Launch the KISS IDE__________________________________________________...

Страница 4: ..._____________________________________________ 34 Code _________________________________________________________________________ 34 5 Troubleshooting ____________________ 35 6 Appendices ______________...

Страница 5: ...Link case which will void your warranty KIPR assumes no liability for the accuracy of these instructions and following them is strictly at your own risk regarding any damage which might occur to eith...

Страница 6: ...battery and charge system Internal speaker 320 x 240 color touch screen Input and Output 1 3 axis 10 bit accelerometer software selectable 2 4 8g 8 digital I O ports hardware selectable 3 3V or 5V 8 3...

Страница 7: ...sed to charge the KIPR Link The KIPR Link should only be charged when under adult supervision and should not be left on charge unattended When off the KIPR Link should reach full charge within 90 minu...

Страница 8: ...ont View Side View Side View Bottom View Back View HDMI display port speaker side button power switch IR send receive Mounting holes have Lego Technic compatible spacing 8 analog ports 8 digital I O p...

Страница 9: ...Link is controlled by a software component called the KIPR Link Firmware The web page at http www kipr org kiss platform link firmware specifies the most recent release its download link and instruct...

Страница 10: ...rsion of the platform for Windows systems may be downloaded from http www kipr org kiss platform windows If you are using Windows XP connect the KIPR Link to the computer using the included USB cable...

Страница 11: ...ngs 3 Choose Advanced Startup a Click on Restart Now 4 Click on Troubleshoot 5 Click on Advanced Options 6 Click on Startup Settings 7 Click on Restart 8 Choose option 7 9 Log in to Windows 8 10 Plug...

Страница 12: ...n the KISS IDE icon to launch the KISS IDE and bring up its opening screen 3 Create a New Program The template selection screen will appear Click on the C Hello World Template to create a new program...

Страница 13: ...ven in the lower left corner of the window Download the program to verify this works OK 6 Locate the Program File on the KIPR Link From the Home screen on the KIPR Link press the Programs button Your...

Страница 14: ...illustrates how to use the KIPR Link library functions and the KIPR Link user interface with KIPR motors and sensors It is followed by a section that describes how to configure the camera for use with...

Страница 15: ...rmation on ANSI C programming pick up an ANSI C programming guide from your local book store A recommended beginner s book is Absolute Beginner s Guide to C 2nd Edition by Greg Perry The KISS IDE on l...

Страница 16: ...don t be surprised if correcting the first error listed is all that is needed To download your program to the KIPR Link click the KISS IDE Download button Since your program will need to be compiled o...

Страница 17: ...ion libraries are provided in the KIPR Link Firmware which enable programmers to take advantage of the features of the KIPR Link Some of the more common functions are presented in the following sectio...

Страница 18: ...ns for Sensors The two most basic library functions for using sensors with the KIPR Link are the analog10 and digital functions analog10 port Analog sensors produce a varying voltage value as resistan...

Страница 19: ...y the analog10 function from an ET sensor in port 4 won t be meaningful until the pull up resistor for port 4 is disabled There are additional functions for sensors in the KIPR Link library described...

Страница 20: ...l not hold its position when the port is disabled set_servo_position port position Moves the servo motor plugged into the specified port to the specified position Only position values between 0 and 20...

Страница 21: ...ate with a max current draw of 1A per motor port where motor speed is regulated by using Pulse Width Modulation PWM to adjust the average power supplied to the motor Voltage at full power is 5V Each p...

Страница 22: ...plied so that the motor continues moving at the specified velocity The BEMF value is periodically refreshed by briefly suspending PWM so that the motor s back EMF can be read by the KIPR Link mrp moto...

Страница 23: ...ult a C language reference for a listing of codes and how they are interpreted for formatting data beep KIPR Link Library function that creates a short beep sound The C language prototypes for these t...

Страница 24: ...ovide a color specification for the channel Live feed from the camera simplifies the process of determining how much of the spectrum is needed to produce blobs matching the color e g a particular part...

Страница 25: ...nfiguration press the Add button and enter a configuration name This will bring the channels specification screen back up with the new configuration added to the list of defined configurations The con...

Страница 26: ...ue bounding boxes around reddish colored blobs in the image When the selection corner is released to facilitate further adjustment the KIPR Link will shift the spectrum to have the current color spect...

Страница 27: ...eeds to discriminate among objects having related but distinctive colors such as the orange and red objects in the above image Pressing the Done button reverts the display to the channel listing for t...

Страница 28: ...e configuration and pressing the Default button KIPR Link Vision Library Functions These are commonly used vision functions for a complete list see the appendix camera_open resolution Opens the camera...

Страница 29: ...the object s bounding box get_object_center channel number Returns a compound data type point2 with component values determined by the most recent camera_update The point 2 data type has 2 components...

Страница 30: ...hen at its midpoint position 1024 it points at the center of the camera s field of view Motors can be directly manipulated from the KIPR Link interface which for servos provides a means for determinin...

Страница 31: ...ly centered on the camera s field of vision this program rotates the servo to keep it pointing towards the largest object for color channel 0 as the object is moved about int main int offset x y enabl...

Страница 32: ...r half a green motor light will come on Set Up Attach the camera to the KIPR Link You need to set the color model on channel 0 to track an object you can move in front of the camera the more saturated...

Страница 33: ...nter x data y get_object_center 0 0 y and y data if get_object_count 0 0 there is a blob in view display_printf 0 1 Center of largest blob d d x y ao turn off all motor lights determine the horizontal...

Страница 34: ...Assume channel 1 is for identifying QR codes If a QR code is found it is translated int main int i lngth camera_open LOW_RES activate camera camera_update get most recent camera image and process it w...

Страница 35: ...k comes on but only loads to the splash screen and keeps rebooting continuously This behavior indicates the KIPR Link Firmware has been corrupted Reload the most current version of the Firmware See Ap...

Страница 36: ...plugged in and functioning since powering on the KIPR Link should cause your PC to establish the USB connection If you are still having issues try a different USB port My KIPR Link is not recognized...

Страница 37: ...et devmgr_show_nonpresent_devices 1 Step 3 Enter start devmgmt msc to bring up Device Manager Step 4 In Device Manager under View select Show Hidden Devices Step 5 Expand the COM port listing right cl...

Страница 38: ...USB flash drive on a Mac OSX right click on the USB drive icon and choose Eject For Windows machines under Computer right click on the USB drive icon and choose Eject This procedure protects the USB d...

Страница 39: ...serial port the official cable has a keyed plug but a header plug will also work if red orientation is observed The power plug is optional and if used when the iRobot Create is turned on will trickle...

Страница 40: ...nd For this reason movement commands may be placed in tight loops without concern of overwhelming the serial connection The iRobot Create s trajectory will continue until a different movement command...

Страница 41: ...zes the distance accumulation in mm to the specified value get_create_distance Returns the distance in mm that the center of the iRobot Create has traveled since the distance accumulation was last ini...

Страница 42: ...ink are independent entities communicating via a serial connection If the connection is lost the iRobot Create will continue on its own according to the last command it received The relatively slow na...

Страница 43: ...in front of the iRobot Create Note that if the iRobot Create detects a ledge with the cliff or wheel drop sensors like being picked up the program will stop and the iRobot Create will play a sad tone...

Страница 44: ...disables serial communications until the script has finished The iRobot Create has several built in scripts mostly to serve the needs of its cousin the iRobot Roomba The Open Interface provides byte...

Страница 45: ...command speed radius follow create_write_byte speed 8 send bits 8 15 of speed create_write_byte speed and then send bits 0 7 create_write_byte 128 send hex 80 X8000 specs drive straight create_write_...

Страница 46: ...s not provide for individual control of drive motors Byte code 145 is a drive command for providing direct control where the two 16 bit two s complement integers that immediately follow it specify rig...

Страница 47: ...resent which has the effect of preventing the script from moving the Create 3 A script can control the Create whether or not the KIPR Link that provided the script remains attached For example if a us...

Страница 48: ...plied to its anode lead rises above a prescribed level typically between 1 9 and 3 2V depending on color If too much current is passed through the LED it will burn out the typical spec is 20 30mA For...

Страница 49: ...ariables The global variables can be used as semaphores so that one process can signal another Process IDs may also be stored in global variables so that one process can destroy another one s thread i...

Страница 50: ...ath or its file system hasn t been mounted e g the USB drive has not been plugged in Both cases are illustrated in the following program for a USB drive plugged into a KIPR Link The example otherwise...

Страница 51: ...tring to chkf fprintf f d data now send formatted numeric data using fprintf fclose f close the file to make sure the output is sent now read it back f fopen chkf r it exists since we just created it...

Страница 52: ...is Vcc which is set at 5V and Row 3 ground is GND Adjusting jumper settings to alter rail voltage requires opening the case voiding your warranty if this is something you have questions about call KIP...

Страница 53: ...late the leads to prevent any cross contact KIPR sensors use hot melt glue for this purpose which also stabilizes the connection and provides strain relief to flatten the glue before it hardens sandwi...

Страница 54: ...using a battery For Pin 1 negative and Pin 3 positive the green motor light is lit when the motor is powered If the polarity is reversed Pin 1 and Pin 3 then the red motor light is the one lit By con...

Страница 55: ...n 3 To make the connection between motor and plug form leads by separating the wires a small amount on each end of the cable then strip off enough insulation to be able to solder the leads to your mot...

Страница 56: ...Store https botballstore com will function properly for either setting but that may not be true for sensors you construct yourself Before opening your KIPR Link case make sure your work area is stati...

Страница 57: ...indicated by the values printed on the circuit board In the picture below the analog ports are set for 3 3V and the digital ports for 5V Step 4 Turn the top of the case back over and carefully reinsta...

Страница 58: ...ccel_z Category Sensors Format int accel_z Returns the value of the accelerometer for its vertical or z direction relative to the horizontal plane of the KIPR Link When the Link is horizontal it is ca...

Страница 59: ...Turns motor m on full speed in the backward direction Example bk 1 block_motor_done Category Motors Format void block_motor_done int m Function does not return until specified motor completes any exec...

Страница 60: ...ding from the digital hardware if the reading is zero volts or logic zero the digital function will return true Valid for digital ports 8 15 only disable_servo Category Servos Format void disable_serv...

Страница 61: ...MF a typical discrimination for a given motor is on the order of 1100 position ticks per rotation get_pid_gains Category Motors Format int get_pid_gains int motor int p int i int d int pd int id int d...

Страница 62: ...os to curr_pos ticks The speed range is 0 to 1000 ticks per second Example move_relative_position 1 275 1100L move_to_position Category Motors Format void move_to_position int m int vel int pos Moves...

Страница 63: ...int pullupTF The purpose of this function is to enable or disable the pull up resistor present on each analog port Without the pull up resistor the port is said to be floating For example set_analog_...

Страница 64: ...the actual coefficients can be floats If a motor is jerky the P and D terms should be reduced in size If a motor lags far behind they should be increased The default values are set at firmware instal...

Страница 65: ...tion is run in a thread via thread_start the thread will remain active until the function finishes or the thread is destroyed via thread_destroy If the thread hasn t been destroyed it can be started a...

Страница 66: ...n extra button Use extra_buttons_show to show the X Y and Z buttons See also extra_buttons_hide get_extra_buttons_visible y_button_clicked Category Sensors Format int y_button_clicked Gets the Y butto...

Страница 67: ...era at a time can be used and the default configuration is selected A resolution of one of LOW_RES MED_RES HIGH_RES needs to be specified Returns 1 on success 0 on failure See also camera_open camera_...

Страница 68: ...Category Vision Format double get_object_confidence int channel int object Returns the confidence between 0 0 and 1 0 that the given object on the given channel is significant If the channel or object...

Страница 69: ...stores the Create to power on configuration which will also shut off any running motors create_read_block Category Create Serial Interface Format int create_read_block char data int count Uses the ser...

Страница 70: ...t r_speed int l_speed Specifies individual left and right speeds in mm sec create_drive_straight Category Create Movement Function Format void create_drive_straight int speed Drives straight at speed...

Страница 71: ...cent movement command executed get_create_requested_velocity Category Create Movement Function Format int get_create_requested_velocity Returns the speed the Create is moving 500 to 500mm s according...

Страница 72: ...pressed 0 otherwise get_create_lcliff Category Create Sensor Function Format int get_create_lcliff Returns 1 if the left cliff sensor is over a surface that doesn t reflect IR e g black or over a cli...

Страница 73: ...r analog reading as a 12 bit value 0 to 4095 get_create_rwdrop Category Create Sensor Function Format int get_create_rwdrop Returns 1 if right wheel has dropped 0 otherwise get_create_vwall Category C...

Страница 74: ...ipt Format void create_spot Simulates a Roomba doing a spot clean create_cover Category Create Built In Script Format void create_cover Simulates a Roomba covering a room create_demo Category Create B...

Страница 75: ...the number of the song currently selected 0 to 15 get_create_song_playing Category Create Music LED Function Format int get_create_song_playing Returns 1 if a song is playing 0 otherwise create_load_...

Отзывы: