Home

K-Junior Operating System Manual - K

image

Contents

1. in this file you declare your variables your functions and you write your code KJunior c file containing the sources of the control and access function to the K Junior robot hardware KJunior h file containing the functions prototypes you use and the K Junior parameters quartz frequency baudrate 18f66k22 h file containing the registers addresses of the processor variables c file containg the internal variables constants h file containing the constants definitions versions txt description of the modifications done at every version these files must not be modified by ordinary users programming the behaviours of K Junior but expert users who would like to modify and improve the functions of K Junior OS Other files are available in the directory Libs for using the extension modules I O interface board linear camera Gripper etc K Junior v2 OS Manual Usage and functions page 9 EE VUN 6 FUNCTIONS 6 1 Definition Here s a small explanation before starting with the list of the available functions for the K Junior OS General notation of the available functions a f b ais the returned value is the function bis the parameter Variable notations Char is a 8bits signed integer variable 1 octet 128 to 127 unsigned char is a 8 bits unsigned variable 1 octet
2. 1 075mm 24 x 43mm 43mm for the example The echo beyond this value will return O K Junior v2 OS Manual Usage and functions page 21 ASN 8 4 Functions of the Linear camera module The sensor of the linear camera is composed of 3 detection areas which hold 34 pixels each with 256 grey levels The pixels value grey levels 0 to 255 of each area is defined in different tables of 34 unsigned int8 values as follows unsigned char HemLinCam Pixels Zone1 34 unsigned char HemLinCam Pixels Zone2 34 unsigned char HemLinCam Pixels Zone3 34 To use in your code to have access to the pixels value void HemLinCam_Init void Goal Initialize the turret Parameter None Return None Example HemLinCam_Init Notice It s the first function to call at the beginning of your Code to initialize the LinCam turret char HemLinCam Read Version void Goal Read the firmware version OS of the LinCam turret connected on the Bus Parameter None Return Unsigned int8 Firmware version number Example NumVer HemLinCam Read Version Notice This function can be used to verify the presence of the turret If OxFF is returned then no turret is plugged void HemLinCam Set Threshold unsigned char Value Goal Define the threshold value for the pixels reading Parameter Unsigned int8 0 to 255 Return None Example HemLinCam Set Threshold 100 Define the Thr
3. KJunior get proximity or KJunior get brightness unsigned int16 KJunior get Battery Goal Read the Battery Voltage of the K Junior Parameter None Return 0 all switch turn Off to 7 all switch On Example KJunior get switch state Return the state of the Dip switch ee KN K Junior v2 OS Manual Usage and functions page 15 ASN NENNEN 6 5 Delay and Timer functions void KJunior delay s unsigned int Delay Goal Put a delay in second temporization Parameter Time to wait in seconds 0 to 65535 Return None Example KJunior delay s 120 Wait 2 minutes void KJunior delay ms unsigned int Delay Goal Put a delay in millisecond temporization Parameter Time to wait in ms 0 to 65535 Return None Example KJunior delay ms 5000 Wait 5s void KJunior delay us unsigned int Delay Goal Put a delay in microsecond temporization Parameter Time to wait in us 0 to 65535 Return None Example KJunior delay us 500 wait 500 us A 32 bits timer provides the time in millisecond elapsed since the robot is turned on unsigned int32 KJunior get time void Goal Get the value of the elapsed time in ms Parameter None Return Unsigned int32 0 to 4294967295 Example Timer KJunior_get_time Timer elapsed time in ms void KJunior set time unsigned int32 Time Goal Initialize or force the elapsed time of the timer f
4. KJunior send tv value 2 10 void KJunior send tv value unsigned char addr unsigned char data Goal Send a data and an address value on the IR emitter using the RC5 code Parameter addr 0 to 31 data 0 to 63 Return Nothing Example KJunior_send_tv_value 2 10 Send a message on the IR emitter with an address of 2 and a Data of 10 Every closest K Junior will received this message ____ K Junior v2 OS Manual Usage and functions page 13 void KJunior set speed signed int8 LeftSpeed signed int8 RightSpeed Goal Set the speed of the motor left first value and right second value Parameter 20 to 20 0 Stop Return None Example KJunior_set_speed 5 5 set a speed of 5 on the left motor and 5 on the right motor The robot will turn on itself in this example Notice The PWM command has a fixed frequency of 20kHz and variable duty cycle from 0 to 100 fixed by the consigne where 20 set a PWM ratio of 100 void KJunior_beep unsigned char Freq Goal Make a continuous sound with the Buzzer at the selected frequency sound Parameter Frequency 0 to 48 where 0 is Off and 48 is 1 975kHz Return None Example KJunior_beep 13 Make a sound of 262Hz Do on the Buzzer of the KJunior Please refer to section 3 2 3 in the K Junior user manual to calculate the corresponding frequency void KJunior led left inti State Goal Turn ON or OFF the LED Left
5. 0 to 255 intl is a bit variable boolean 0 or 1 intis a 16bits signed integer variable 32768 to 32767 unsigned int is 16bits unsigned integer variable 0 to 65535 unsigned int16 is a 16bits unsigned integer variable 0 to 65535 Signed int8 is a 8bits signed integer variable 128 to 127 ____ K Junior v2 OS Manual Usage and functions page 10 ASN 6 2 Configuration functions of the robot void KJunior_init void Goal Initialize KJunior Parameter None Return Nothing Example KJunior init Notice This function must be at the beginning of every program to initialize the KJunior robot with this default configuration automatic reading of the IR sensor activated RS232 management activated Automatic reading of the TV receiver activated TV remote control activated void KJunior config auto refresh sensors inti Bit Goal Configure the IR sensor reading Parameter MANUAL or REFRESH by default Return Nothing Example KJunior config auto refresh sensors MANUAL Notice This function configures if the automatic reading of the IR sensors are activated parameter REFRESH or not parameter MANUAL void KJunior config auto refresh tv remote int1 Bit Goal Configure the automatic reading of the TV remote receiver Parameter MANUAL or REFRESH by default Return Nothing Example KJunior config auto refresh tv remote MANUAL Notice
6. Define the contrast level of the display Parameter Unsigned int8 0 to 255 0 to 100 of the maximal contrast Return None Example HemLCD_Set_Contrast 200 define the contrast to 200 80 Notice below 150 the characters display are no more visible with a too small back light The contrast value must adapt according to the back light void HemLCD_Clear_Screen void Goal Clear the screen Parameter None Return None Example HemLCD_Clear_Screen clear all the word display on the screen K Junior v2 OS Manual Usage and functions page 26 END J N D void HemLCD Clear Line1 void Goal Clear the line 1 Parameter None Return None Example HemLCD Clear Line1 void HemLCD Clear Line2 void Goal Clear the line 2 Parameter None Return None Example MHemLCD Clear Line2 void HemLCD Read Interruptors void Goal Read the value of the 3 push button Parameter None Return None Example HemLCD Read Interruptors Notice The state of the 3 push buttons are put in the variables SW1 SW2 and SW3 void HemLCD Line1 Left char Data Goal Display the line 1 aligned on the left Parameter Table of character use the table of the Line1 Return None Example strcpy Line1 MENU define the content of the Line1 table HemLCD_ Line1_Left Line1 Display the MENU text aligned on the left of the Line 1 Notice You must use
7. Example KJunior ext write PINB7 1 set the RB7 pin to 1 45V Notice This Input Output is connected to the external connector Power supply and I C Bus see KJunior schematics K Junior v2 OS Manual Usage and functions 17 END J N UD 6 8 compiler specific functions Like any C compiler the CCS compiler has a very big set of functions in addition of the ANSY functions like the bus access random number generation delay etc You can find the details of these functions in the user manual of the CCS compiler ____ K Junior v2 OS Manual Usage and functions page 18 SNORE 7 EXAMPLES Many examples with comments are available free to use in your project in the support CD rom A RTF file KJuniorGlossaireFonctionsC rtf are available too in the KJuniorOS KJuniorOS Sources directory it allows you to quickly choose the needed function and to copy it to your code See the C compilation tutorial in the programming tools Section of the CD rom 8 MODULES LIBRARIES 8 1 Definition As the Hemisson turrets are compatible with the K Junior all the turrets libraries are compatible too Then all the following functions have the same named as the Hemisson turrets functions In your own KJunior OS code you can use some management and access functions of the turrets GenlO LinCam USsensor Gripper etc via the I C bus of the Robot
8. Input Goal Read the state of a digital Input Parameter 0 to 11 digital input number Return or 1 state of the digital input Example EtatD2 HemGenIO Read Digital 2 Return the state of the digital input n2 Notice This function will automatically configure the selected as a Input void HemGenIO Write Digital char Output intl State Goal Set the the state of a digital output of the turret Parameter1 0 to 11 digital output number Parameter2 0 or 1 State of the selected output Return None Example HemGenIO Write Digital 9 1 Set the digital ouput n9 to 45V Notice This function will automatically configure the selected I O as an Output unsigned char HemGenIO Read Analog char Input Goal Read the value of an analog Input Parameter 0 to 4 Analog input number Return Unsigned int8 0 OV and 255 5V Example ValueA3 HemGenIO Read Analog 3 Return the analog value of the input number 3 i e if ValueA3 150 Voltage of A3 150 x 5 255 2 94V ____ K Junior v2 OS Manual Usage and functions 20 ASN 8 3 Functions of the Ultrasonic detector module void HemUltraSon_Init void Goal Initialize the turret Parameter None Return None Example HemUltraSon_Init Notice It s the first function to call at the beginning of your Code to initialize the USsensor turret char HemUltraSon Read Version void Goal Read the firm
9. These functions are defined in the h files available in the Libs directory of the CD rom These libraries for the management and access functions are located in the different sub directories with the same summary denomination as the turret Gen O e g for the Input Output module These directories contain the following files Hemxx h file having the sources and the define of the turret access function Example xx c file containing an example of turret utilisation and explanation to use it in your project To use these functions in your project place the Hemxx h of the turret in your project directory and add include Hemxx h in your KJOs c project file K Junior v2 OS Manual Usage and functions page 19 ALUN ee 8 2 Functions of the I O interface board module void HemGenIO_Init void Goal Initialize the turret Parameter None Return None Example HemGenIO_Init Notice It s the first function to call at the beginning of your Code to initialize the GenlO turret char HemGenIO Read Version void Goal Read the firmware version OS of the GenlO turret connected on the IC Bus Parameter None Return Unsigned int8 Firmware version number Example NumVer HemGenIO Read Version Notice This function can be used to verify the presence of the turret If OXFF is returned then no turret is plugged intl HemGenIO Read Digital char
10. rtf file in a RTF format available in the KJuniorOS KJuniorOS Sources directory of the Cd rom Professor Installation which you have copy in your PC You can easily choose the needed functions and copy them to your code See the C compilation tutorial in the Programming tools section of the CD Rom If you have purchased the K Junior Didapack please use the EMP given with the pack A tutorial will help you to realize your first C language Software ____ K Junior v2 OS Manual Usage and functions page 32 Tel 41 24 423 89 50 Fax 41 24 423 89 60 K Junior v2 OS Manual Usage and functions 33
11. void HemLinCam Read Pixels Tresholded void Goal Read the value of every pixel after the threshold Parameter None Return None Example MHemLinCam Read Pixels Tresholded Reading of the thresholded pixel n17 of the cen tral area If HemLinCam Pixels Zone2 17 255 Notice After the reading the values are stocked in the different value tables HemLinCam Pixels Zone1 HemLinCam Pixels Zone2 and HemLinCam Pixels Zone3 Each table has a size of 34 pixels which correspond respectively to the left central and right of the picture When the pixels threshold reading is made the pixels with a grey level gt than the threshold will have a value of 255 and the other lt threshold will reset to 0 void HemLinCam Set Led State inti State Goal Turn On or Off the Led Parameter ON 1 or OFF 0 Heturn None Example MHemLinCam Set Led State ON Turn On the camera LED ____ K Junior v2 OS Manual Usage and functions page 23 SUNOS 8 5 Functions of the Vocal synthesizer module void HemTextToSpeech_Init void Goal Initialize the turret Parameter None Return None Example MHemTextToSpeech Init Notice It s the first function to call at the beginning of your Code to initialize the TextToSpeech turret char HemTextToSpeech Version void Goal Read the firmware version OS of the TextToSpeech turret connected on the Bus Parameter None Retu
12. GROUNDFRONTLEFT GROUNDFRONTRIGHT Return 12bits value O nothing to 4095 an obstacle is very near Example KJunior get proximity FRONT Return the proximity value of the Front IR sensor signed int16 KJunior get brightness char Sensor Goal Get the brightness value of a IR sensor Parameter FRONT FRONTLEFT FRONTRIGHT LEFT RIGHT REAR GROUNDLEFT GROUNDRIGHT GROUNDFRONTLEFT GROUNDFRONTRIGHT Return 12 bits value O dark to 4095 big luminosity Example KJunior get brightness REAR Return the brightness value of the Rear sensor unsigned char KJunior get switch state Goal Read the state of the dip switch Parameter None Return 0 all switch turn Off to 7 all switch On Example KJunior get switch state Return the state of the Dip switch unsigned char KJunior get tv data void Goal Get the data received on the TV receiver Parameter None Return 6 bits value 0 to 63 Example KJunior get tv data Return the coded value of the pressed TV remote button or from another K Junior i e the value will be 2 if the button 2 of the numeric pad is pressed unsigned char KJunior get tv addr void Goal Get the address received on the TV receiver Parameter None Return 5 bits value 0 to 31 Example KJunior get tv addr Return the address of the TV remote or of another K Junior i e the value will be 2 if another K Junior send a command like
13. K JUNMIOFr Ve OS MANUAL USaGe FUNCTIONS FeBrvuary EDITION K JONIOR K J v2 OS Manual Usage and functions page 1 END Y Parc Rue Galil 9 YVERDON LES BAINS 1400 SWITZERLAND w Ww k team com Tel 41 24 423 88 50 Fax 41 24 423 89 60 NOTICE The information included in this manual is subject to change without prior notice K Team cannot be held responsible for any technical or writing omissions nor any consequent damage that may arise In the same way the product names mentioned in this manual and in the CD Rom for identification purposes may be trademarks whether registered or not belonging to their respective owners ____ K Junior v2 OS Manual Usage and functions page 2 CHAPTER 1 INTRODUCTION Page 5 CHAPTER 2 THE COMPILER 6 CHAPTER USING THE C COMPILER PCW CCS Page 7 CHAPTER 4 USING THE K JUNIOR UPLOADER Page 8 4 1 Safety usage litte Page 8 4 2 Reload the Bootloader c REN 3 CHAPTER 5 KJUNIOR OS vicsuc Page 9 SEIS UICE eaaa Page 9 dixe Ln CHAPTER 6 FUNCTIONS eo sssnvRipnp ee ERR EXE MUXEREREMEME S FPE NEC Pages 10 17 6 1 De
14. Parameter ON 1 or OFF 0 Return None Example KJunior_led_left ON Turn ON the Left LED of the robot void KJunior_led_frontleft inti State Goal Turn ON or OFF the LED Front Left Parameter ON 1 OFF 0 Return None Example KJunior_led_frontleft ON Turn ON the Front Left LED of the robot void KJunior led frontright State Goal Turn ON or OFF the LED Front Right Parameter ON 1 or OFF 0 Return None Example led frontright ON Turn ON the Front Right LED of the robot ee KNOG K Junior v2 OS Manual Usage and functions page 14 SNORE void KJunior led right inti State Goal Turn ON or OFF the LED Right Parameter ON 1 or OFF 0 Return None Example KJunior led right Turn ON the Right LED of the robot void KJunior led onoff inti State Goal Turn ON or OFF the LED On Off Parameter ON 1 or OFF 0 Return None Example KJunior led onoff ON ON the On Off of the robot void KJunior manual refresh sensors Goal Refresh manually the IR sensors Parameter None Return None Example KJunior manual refresh sensors refresh the value of the IR sensors Notice This function is useful only after disabling the automatic refresh sensor mode with the function KJunior config auto refresh sensors Then use one of the two functions to read the IR sensors
15. This function configures if the TV remote receiver is refreshing automatically Parameter REFRESH or not Parameter MANUAL void KJunior config rs232 control inti Bit Goal Activate or note the Serial Remote Control Parameter DISABLE or ENABLE by default Return Nothing Example KJunior config rs232 control DISABLE Notice This function activates parameter ENABLE or not parameter DISABLE the RS232 Serial Remote Control Warning if this mode is activated you can use the printf function i e to view some values with a terminal Goal you can t read anything from the serial port getc gets etc are not available all the data will be read by the Serial Remote Control process void KJunior config tv remote control inti Bit Goal Activate or not the TV Remote Control mode Parameter DISABLE or ENABLE by default Return Nothing Example KJunior config tv remote control DISABLE Notice This function activates parameter ENABLE or not parameter DISABLE the TV Remote Control mode remote control of the motors with a TV remote K Junior v2 OS Manual Usage and functions page 11 ASN 6 3 Flags reading function intl KJunior flag sensors refreshed void Goal To know if the IR sensors were refreshed Parameter None Return The bit is set if the sensors just have been refreshed Example KJunior flag sensors refreshed Notice Y
16. btain a specific version of the PWC compiler including a compiler debugger limited to the PIC18F66k22 and an editor in full version You can obtain this version of the PCH compiler by contacting K Team If you wish you can obtain an external PIC ICD_U programmer to program again the microprocessor Currently we do not assure any support for another C compiler If you already have another C compiler for PIC you need to adapt the source code of the K Junior OS _____ K Junior v2 OS Manual Usage and functions page 6 SNORE 3 USAGE OF THE PIC C COMPILER The following steps are required to install the PIC C compiler from CCS create a directory PICC in the directory Program Files of Windows In this directory copy the licence pcm crg you received Run the setup file SetupPcw exe you received or available in the directory PCW CCS of the CD ROM nstallation Professor delivered with the DIDAPACK from K TEAM When the install procedure is finished you may modify and compile the K Junior OS as follows Copy on your PC the directory K JuniorOS Sources from the Support CD ROM or download the last version on the K Team web site Start the PIC C compiler short cut on the Windows desktop or in the menu bar Start Programmes PIC C Click on Project then Open and select the file KJOs pjt in the directory K JuniorOS K JuniorOS S
17. e2 Heturn None Example strcpy Line2 MENU define the content of the Line2 table HemLCD Line2 Centered Line2 Display the MENU text centered of the Line 2 Notice You must use the predefined characters table of Line1 and Line2 void HemLCD Line2 Right char Data Goal Display the line 2 aligned on the right Parameter Table of character use the table of the Line2 Return None Example strcpy Line2 MENU define the content of the Line2 table HemLCD Line2 Right Line2 Display the MENU text aligned on the right of the Line 2 Notice You must use the predefined characters table of Line1 and Line2 ee KNOG K Junior v2 OS Manual Usage and functions page 28 NN 8 7 Functions of the Gripper module void HemGripper Init void Goal Initialize the turret Parameter None Return None Example HemGripper TInit Notice It s the first function to call at the beginning of your Code to initialize the Gripper turret char HemGripper Read Version void Goal Read the firmware version OS of the Gripper turret connected on the Bus Parameter None Return Unsigned int8 Firmware version number Example NumVer HemGripper_Read_Version Notice This function can be used to verify the presence of the turret If OxFF is returned then no turret is plugged Unsigned int16 HemGripper Read Arm Position void Goal Read the positio
18. ed char Example Flag HemGripper Read Arm Disable Unsigned char HemGripper Read Gripper Disable void Goal Read the flag which indicate if the Gripper must be turn off or not when the open position is reach Parameter None Return Unsigned char Example Flag HemGripper Read Gripper Disable Unsigned int16 HemGripper Read Battery Voltage void Goal Read the Voltage level of the battery Parameter None Return Unsigned int16 Example Voltage HemGripper Read Battery Voltage Unsigned char HemGripper Read Battery Capacity void Goal Read the value of the available remaining capacity of the Battery Parameter None Return Unsigned char Example Capactity HemGripper Read Battery Capactity void HemGripper Set Arm Position unsigned int16 value Goal Set the Arm position to reach without speed control Parameter unsigned int16 Return None Example Set Arm Position 1500 void HemGripper Set Gripper Position unsigned int16 value Goal Set the Gripper position to reach without speed control Parameter unsigned int16 Return None Example Set Gripper Position 1500 _ K Junior v2 OS Manual Usage and functions page 30 Mm NNO void HemGripper Set Arm Consign unsigned int16 value Goal Set the Arm position to reach using the speed defined with the KJunior Set Arm Speed function Parameter unsigned
19. eshold to 100 Notice When the pixels threshold reading is made the pixels with a grey level gt than 100 will have a value of 255 and the other lt 100 will reset to 0 unsigned char HemLinCam Read Threshold void Goal read the setting threshold value Parameter None Return Unsigned int8 0 to 255 Example Seuil HemLinCam Read Threshold void HemLinCam Set Exposition Time unsigned char Value Goal Define the exposure time in ms Parameter 1 to 10 Return None Example HemLinCam Set Exposition Time 2 Notice Warning with the too big value the pixels will be saturate very fast ee ii ____ K Junior v2 OS Manual Usage and functions page 22 SNORE unsigned char HemLinCam_Read_Exposition_Time void Goal read the exposure time Parameter None Return Unsigned int8 0 to 255 Example ExpoMs HemLinCam Read Exposition Time Return the exposure time in ms void HemLinCam Read Pixels void Goal Read the value of every pixels Parameter None Return None Example HemLinCam Read Pixels Reading ot the pixel n37 of the central area If HemLinCam Pixels Zone2 17 20 Notice After the reading the values are stocked in the different value tables HemLinCam Pixels Zone1 HemLinCam Pixels Zone2 and HemLinCam Pixels Zone3 Each table has a size of 34 pixels which correspond respectively to the left central and right of the picture
20. finition Page 10 6 2 Configuration functions of the robot litte Page 11 6 3 Flags reading Page 12 6 4 Input and Output TUDollofis rrr oe tee os Pages 13 14 6 5 Delay and Timer Page 15 6 6 I O functions of the external connectors Page 16 6 7 Real time tasks 17 6 8 compiler specific functions quU Page 17 CHAPTER 7 EXAMPLES Page 18 CHAPTER 8 MODULES LIBRARIES Pages 18 24 8 1 Definition T eesssss Page 19 8 2 Functions of the VO interface board module ROS Page 20 8 3 Functions of the Ultrasonic detector module Page 21 8 4 Functions of the Linear camera module Pages 22 23 8 5 Functions of the Vocal synthesizer 24 8 6 Functions of the LCD screen module 24 26 8 7 Functions of the Gripper module Page 27 29 APPENDIX Page 30 K Junior v2 OS Manual Usage and functions 3 K Junior v2 OS Manual Usage and functions page 4 ASN 1 INTRODUCTION K Junior is
21. int16 Return None Example HemGripper Set Arm Consign 500 void HemGripper Set Gripper Consign unsigned int16 value Goal Set the Gripper position to reach using the speed defined with the KJunior Set Gripper Speed function Parameter unsigned int16 Return None Example MHemGripper Set Gripper Gripper 1500 void HemGripper Set Arm Speed unsigned char value Goal Configure the speed to use for a Arm movement with speed control Parameter unsigned char Return None Example HemGripper Set Arm Speed 100 void HemGripper Set Gripper Speed unsigned char value Goal Configure the speed to use for a Gripper movement with speed control Parameter unsigned char Return None Example HemGripper Set Gripper Speed 50 void HemGripper Arm Disable unsigned char value Goal Configure the flag to define if the Arm must turn off its motor when a stable Position is reach Parameter unsigned char Return None Example HemGripper Arm Disable 0 void HemGripper Gripper Disable unsigned char value Goal Configure the flag to define if the Gripper must turn off its motor when a stable Position is reach Parameter unsigned char Return None Example MHemGripper Gripper Disable 1 K Junior v2 OS Manual Usage and functions 31 END J N UD APPENDIX All the described functions in this manual are summarised in the KJuniorCFunctionsGlossary
22. n of the Arm 0 7000 Parameter None Return Unsigned int16 Example Position HemGripper Read Arm Position Unsigned int16 HemGripper Read Gripper Position void Goal Read the position of the Gripper 0 5100 Parameter None Return Unsigned int16 Example Position HemGripper Read Gripper Position Unsigned int16 HemGripper Read Arm Consign void Goal Read the position consign of the Arm 0 7000 Parameter None Return Unsigned int16 Example Consign HemGripper Read Arm Consign Unsigned int16 HemGripper Read Gripper Consign void Goal Read the position consign of the Gripper 0 5100 Parameter None Return Unsigned int16 Example Consign HemGripper Read Gripper Consign Unsigned char HemGripper Read Arm Speed void Goal Read the speed of the Arm used for the consign movements 0 255 Parameter None Return Unsigned char Example Speed HemGripper Read Arm Speed K Junior v2 OS Manual Usage and functions page 29 EE Unsigned char HemGripper_Read_Gripper_Speed void Goal Read the speed of the Gripper used for the consign movements 0 255 Parameter None Return Unsigned char Example Speed HemGripper Read Gripper Speed Unsigned char HemGripper Read Arm Disable void Goal Read the flag which indicate if the Arm must be turn off or not when a stable position is reach Parameter None Return Unsign
23. or the KJunior get time function Parameter Unsigned int32 0 to 4294967295 Return None Example KJunior set time 0 Initialize the timer to 0 ms ___ K Junior v2 OS Manual Usage and functions page 16 SUN C 6 6 I O functions of the external connectors intl KJunior ext read PINB6 void Goal Read the digital Input Output RB6 of the microcontroller Parameter None Return 0 or 1 Example KJunior ext read PINBO Return the state 0 or 1 of RB6 pin Notice This Input Output is connected to the external connector Power supply and Bus see KJunior schematics intl KJunior ext read PINB7 void Goal Read the digital Input Output RB7 of the microcontroller Parameter None Return 0 or 1 Example KJunior ext read PINB7 Return the state 0 or 1 of RB7 pin Notice This Input Output is connected to the external connector Power supply and Bus see KJunior schematics void KJunior ext write PINBO inti Bit Goal Set the value of the digital output RB6 of the microcontroller Parameter 0 or 1 Return None Example KJunior ext write PINB6 1 set the RB6 pin to 1 45V Notice This Input Output is connected to the external connector Power supply and I C Bus see KJunior schematics void KJunior ext write PINB7 inti Bit Goal Set the value of the digital output RB7 of the microcontroller Parameter 0 or 1 Return None
24. ou must reset the flag after with the KJunior flag sensors reset function void KJunior flag sensors reset void Goal Reset the IR sensor flag Parameter None Return Nothing Example KJunior flag sensors reset intl KJunior flag rs232 filtering void Goal To know if the Serial Remote Control mode is activated or not Parameter None Return 1 if the mode is activated and O if not Example i KJunior flag rs232 filtering intl KJunior flag tv data refreshed void Goal To know if the TV receiver was refreshed or not Parameter None Return 1 if some data was received on the TV receiver Example KJunior flag tv data refreshed Notice You must reset the flag after with the flag tv data reset function intl KJunior flag tv data emitting void Goal To know if the emitting is complete or not Parameter None Return 1 if some data are still emitting or O it s done Example KJunior flag tv data emitting void KJunior flag tv data reset void Goal Reset the TV receiver flag Parameter None Return None Example flag tv data reset K Junior v2 OS Manual Usage and functions page 12 ASN 6 4 Input and Output functions Signed int16 KJunior_get_proximity char Sensor Goal Get the value of the proximity sensor Parameter FRONT FRONTLEFT FRONTRIGHT LEFT RIGHT REAR GROUNDLEFT GROUNDRIGHT
25. ources copied in your PC Click on Project then Open and select the file KJOs c Add your code Click on the object compile or press the F9 key of your keyboard to compile If there is no error in your code the compiler will generate a file KJOs hex compiled program that can be uploaded with the K Junior Uploader into K Junior see next CHAPTER ____ K Junior v2 OS Manual Usage and functions page 7 EE V UNOR 4 USAGE OF THE K JUNIOR UPLOADER Once your program is compiled find the file KJOs hex created by the compiler Use the K Junior Uploader to upload this OS compiled program into the Flash memory of the microprocessor of the K Junior robot With the K Junior Uploader you can upload a program through the USB serial port into the microprocessor of the K Junior robot Please refer to the K Junior UserManual to configure the Uploader software see section 5 1 The data program uploading sent from the K Junior Uploader are processed and saved by a software named KJ Bootloader that K Team loaded into the Flash memory of the PIC when the K Junior was assembled 4 1 Safety usage A bad manipulation may erase the Bootloader program from the memory In this case the upload through the USB serial port will not be possible anymore usage K Junior Uploader If you load a program you compiled C compiler Assembly etc make sure you
26. provided with a processor from Microchip the PIC18F66k22 This processor is used in many applications therefore there is already a big community with many users Microchip provides a free assembler for the PICs But this low level language is not well suitable for a fast development in robotics It is rather a specific language for the low level layers In this manual we will introduce the particular case of C language to you which is to our opinion the most suitable The whole K Junior OS Operating System embedded system on the K Junior was developed in this language We distribute the source codes under the LGPL license which means that you can use it freely and without restraint except for commercial purpose Let s see more in detail the programming part This document is suitable for people having already some basic knowledge in C language ____ K Junior v2 OS Manual Usage and functions page 5 EE SNORE 2 THE COMPILER Nowadays there are on the market many C compilers for PIC micro processors on the market more or less expensive but also more or less reliable After having tested many among others K Team recommends the PCH C compiler from CCS for its quality support and price ratio and is multi platforms support It is one among the best in the market it comprises many high level integrated functions along with a friendly user interface Following commercial agreements with CCS you can o
27. r v2 OS Manual Usage and functions page 24 eee Notice Speak the saved sentence number 20 which is loaded with the software en it ____ K Junior v2 OS Manual Usage and functions page 25 ENNENBER AJUNICO 8 6 Functions of the LCD screen module The LCD screen turret is made up a screen of 2 lines of 12 characters each and 3 push button The text for each line is define by two characters table of 12 bytes char Line1 12 char Line2 12 The state of the push button is stocked in the following variable intl SW1 SW2 SW3 void HemLCD_Init void Goal Initialize the turret Parameter None Return None Example HemLCD_Init Notice It s the first function to call at the beginning of your Code to initialize the LinCam turret char HemLCD Read Version void Goal Read the firmware version OS of the LCD turret connected on the Bus Parameter None Return Unsigned int8 Firmware version number Example NumVer HemLCD Read Version Notice This function can be used to verify the presence of the turret If OXFF is returned then no turret is plugged void HemLCD Set Backlight unsigned char Value Goal Define the back light intensity of the screen Parameter Unsigned int8 0 to 255 0 to 100 Return None Example MHemLCD Set Backlight 20 define the back light to 20 8 void HemLCD Set Contrast unsigned char Value Goal
28. respect following rule The memory zone from 0x1F00 to 0x1FFF Bootloader reserved zone must never be written The compiled filed hex issed from K TEAM respect this rule If you erase by mistake this memory zone during a bad manipulation and you have an external programmer reload the KJ Bootloader hex file included in your K Junior Support CD ROM see next CHAPTER Refer to the K Junior Uploader section in the K Junior UserManual of the CD ROM to do this upload 4 2 Reloading the BootLoader by the means of an external programmer If you have a serial programmer for the PIC18F66k22 microprocessor PicStart from Microchip ICD U from CCS for example you can reflash the memory of the K Junior s PIC and reload the KJ Bootloader hex file included in the K Junior Support CD Rom or on the K team website and recover the serial upload functionality ____ K Junior v2 OS Manual Usage and functions page 8 END J N UD C 5 K JUNIOR OS 5 1 What s that We can say that K Junior OS is for K Junior what Windows or Linux is for your PC The K Junior OS manages the resources of K Junior and it enables you to access the embedded hardware 5 2 It s structure The source code of the K Junior OS can be found on the K junior Support CD Rom or on the K Team web site under Support gt Download gt K Junior This OS is composed of several files KJOs c main file containing the main
29. rn Unsigned int8 Firmware version number Example NumVer HemTextToSpeech Version Notice This function can be used to verify the presence of the turret If OXFF is returned then no turret is plugged void HemTextToSpeech Speed char Value Goal Define the speed teechting Parameter Unsigned int8 0 to 255 Return None Example HemTextToSpeech_Speed 1 Notice Set a small value to speak the sentence slowly void HemTextToSpeech_Pitch char Value Goal Define the pitch value hue of the pronunciation Parameter Unsigned int8 0 to 255 Return None Example HemTextToSpeech_Pitch 2 Notice Set a small value to speak the sentence high pitched void HemTextToSpeech_Speak char Phrase char Taille Goal Play a loaded sentence Parameter 1 Character table which contains the sentence to speak in text format Parameter 2 Size of the sentence to speak in a unsigned int8 value 0 to 255 Return None Example char Phrase 256 sprintf Phrase Hello my name is KJunior HemTextToSpeech_Speak Phrase sizeof Phrase Notice The sentence Hello my name is KJunior is speak in function of the speed and the pitch settings void HemTextToSpeech_Speak_PreDef char Num Goal Speak a sentence which is saved in the turret Parameter Number of the saved sentence to speak 0 to 32 Return None Example MHemTextToSpeech Speak PreDef 20 ____ K Junio
30. the predefined characters table of Line1 and Line2 void HemLCD Line1 Centered char Data Goal Display the Line1 centered Parameter Table of character use the table of the Line1 Return None Example strcpy Line1 MENU define the content of the Line1 table HemLCD Line1_Centered Line1 Display the MENU text centered of the Line 1 Notice You must use the predefined characters table of Line1 and Line2 void HemLCD Line1 Right char Data Goal Display the line 1 aligned on the right Parameter Table of character use the table of the Line1 Return None Example strcpy Line1 MENU define the content of the Line1 table HemLCD_ Line1_Right Line1 Display the MENU text aligned on the right of the Line 1 Notice You must use the predefined characters table of Line1 and Line2 ____ K Junior v2 OS Manual Usage and functions page 27 EE J N UD C void HemLCD_Line2_Left char Data Goal Display the line 2 aligned on the left Parameter Table of character use the table of the Line2 Return None Example strcpy Line2 MENU define the content of the Line2 table HemLCD_ Line2_Left Line2 Display the MENU text aligned on the left of the Line 2 Notice You must use the predefined characters table of Line1 and Line2 void HemLCD Line2 Centered char Data Goal Display the Line2 centered Parameter Table of character use the table of the Lin
31. ware version OS of the USsensor turret connected on the Bus Parameter None Return Unsigned int8 Firmware version number Example NumVer Hem UltraSon Read Version Notice This function can be used to verify the presence of the turret If OXFF is returned then no turret is plugged unsigned char HemUltrason Read Brightness void Goal read the value of the brightness sensor Parameter None Return Unsigned int8 Example Lum Hem UltraSon Read Brightness Return the analog value of the brightness sensor void HemUltraSon Start Mesure void Goal Start a distance acquisition Parameter None Return None Example MHem UltraSon Start Mesure Notice This function includes a delay of 65ms emitting and receiving time of the Ultrasons unsigned int16 HemUltrason Read Value char EchoNumber Goal Read the distance value of the selected Echo unit cm Parameter 0 to 7 Number of the Echo Return Unsigned int16 0 to 65535 Example 0151 HemUltraSon Read Value 0 Return the centimetre distance of the first echo void HemUltraSon Init Range Register unsigned char Value Goal Initialize the maximal range of the sensor Parameter unsigned int16 0 to 65535 Return None Example MHem UltraSon Init Range Register 24 maximal range distance limited to 1075 mm see the calculation below Notice The maximum range in mm is defined by Dmax Parameter x 43mm 43 mm

Download Pdf Manuals

image

Related Search

Related Contents

CHAthION CLASSIC  Theorem Proving Support - User Manual  Documento PDF - AMS Tesi di Dottorato  Innovaphone IP305  Samsung C24A650X Manuel de l'utilisateur  ColorBlast 6 User Guide  PPMS VSM Ulf User`s Manual    Ametek - Jofra HPC400 Handheld Pressure Calibrator  0602738 Dynamomètre 200kg électronique - Alliance  

Copyright © All rights reserved.
Failed to retrieve file