Operation Confirm Eng

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Operation Confirm Eng as PDF for free.

More details

  • Words: 5,762
  • Pages: 18
Micom Car Rally Kit

Micom Car Operation Confirmation Manual Version3

1.00E Edition 19/06/2006 Japan Micom Car Rally Executive Committee

Operation Confirmation Manual

Important Notice Copyright *Copyright concerning this manual belongs to the Japan Micom Car Rally Executive Committee. *This manual is protected by the copyright law and the international copyright agreement.

Prohibited Use User must not do the following things. *Selling, advertisement to sell, use, trading, reproduction of this manual for the third party *Assigning the usage right or approval of this manual to the third party *Change or remove part or whole of this manual *Translate this manual without authorization *Use wherein harm might be caused to life and human body by using the content of this manual

Reprinting, reproduction Prior approval of Japan Micom Car Rally Executive Committee is necessary for reprinting and reproduction of this manual.

Liability Restrictions The information described in this manual is carefully prepared to ensure accuracy. However, Japan Micom Car Rally Executive Committee does not assume any responsibility, if any damage occurs due to the description error of this manual.

Other In this manual the model car controlled by microcomputer is defined as the micom car. The information contained in this manual represents information at the time of publication of the manual, and Japan Micom Car Rally Executive Committee is liable to occasionally change this information or specification described in this manual without prior notice. Refer to the information published on the official homepage (http://www.mcr.gr.jp/) of Micom Car Rally when manufacturing micon car.

Contact Address Head Office, Renesas Technology Micom Car Rally Executive Committee 162-0824 Tokyo Shinjukuku, Ageba cho,2-1 Karuko saka, MN Building TEL (03)-3266-8510 E-mail : [email protected]

-1-

Operation Confirmation Manual

Index (Table of contents) 1. Outline ................................................................................................................. 3 2. Preparation ............................................................................................................ 3 2.1. Installation of development environment ...................................................................................... 3 2.2. Writing of test program ............................................................................................................. 3

3. Operation test......................................................................................................... 5 3.1. LED Test................................................................................................................................ 5 3.2. Tact Switch Test ...................................................................................................................... 5 3.3. Servo Motor Test ..................................................................................................................... 5 3.4. Right Motor Test...................................................................................................................... 6 3.5. Left Motor Test ....................................................................................................................... 7 3.6. Sensor test.............................................................................................................................. 7 3.7. Direct Advance Test ................................................................................................................. 9

4. Writing of this Program...........................................................................................10 5. Program Source .....................................................................................................11 5.1. Program contents of “kit05test.c”...............................................................................................11 5.3. Program contents of “kit05test.sub”............................................................................................17

-2-

Operation Confirmation Manual

1. Outline This manual explains the operation verification method of manufactured micom car as per “Sensor board/circuit board manufacturing manual”, “Motor drive board/ circuit board (Vol.3) manufacturing manual”, “Main body assembly manufacturing manual (Vol.3 version)”. Their relation is as follows Micom car kit Ver.2 =Main body (Ver.2) +Sensor board (Ver.2) +Motor drive board (Ver.2) Micom car kit Ver.3 =Main body (Ver.2) +Sensor board (Ver.2) +Motor drive board (Ver.3) Initially the test program is written to test the function of the micom car. After that, function to test with DIP switch of CPU board is selected and each function is tested. It is necessary to install the development environment on personal computer in advance in order to write the test program. Install according to “Development environment install manual”. CPU board targets RY3048F-ONE board. Other than this board no other item is recommended.

2. Preparation 2.1. Installation of development environment Install the development environment according to “Development environment installation manual”. Development environment is down-loaded from down-loading corner of Micom Car Rally homepage or “Development environment ¥ setup.exe" of CD-ROM and "setup.exe” is executed and set up is done. When destination to install is other than C drive, it is installed according to “Setting when installing on any other than C drive of development environment installation manual”.

2.2. Writing of test program

Development environment is started up and “kit05test.c” is selected and Compile & Write buttons are clicked.

If it is compiled smoothly, the message “Please press any key when it is ready” appears without the error. Then press any key.

-3-

Operation Confirmation Manual

Connect the signal communication cable with 3 pin connector of CPU board and with 9 pin connector of the personal computer and CPU board, adjust the switch on writing (FWE) side, and turn on the power supply.

Click Start writing Button and start writing. If it is written successfully, power supply of micom car is turned "OFF" and writing switch returns to normal. When it can not be written normally, 1. Connection mistake and disconnection of signal communication cable 2. Problem on personal computer side. Communication port becomes invalid, the port number is incorrect, and other equipment (infrared ray port etc.) is already using the communication port. 3. Problem on CPU Board side. The reasons considered are, such as writing switch is not normal, RXD1 transfer switch is not on 3P connector side, CPU has exceeded the writing frequency limitation and CPU power supply voltage is not 4.5-5.5V. Resolve these problems and rewrite.

-4-

Operation Confirmation Manual

3. Operation test 3.1. LED Test DIP switch is in “0000” state and power supply for CPU is turned ON. DIP switch is ON at "1" and OFF at "0". LED0 and LED1 of the motor drive board lights alternately at every 0.5 seconds.

0 0 0 0 P60

P61

P62 P63

OFF ON Switch status

When LED does not light, defect in flat cable connecting to CPU board and motor drive board, defect in soldering of LED and soldering bridge (short), reversing of LED direction are considered to be the reasons . Ascertain and localize the cause by observational check and the tester, etc.

3.2. Tact Switch Test DIP switch is in “0001” state and power supply for CPU board is turned ON. If switch on motor drive board is not in pushed state then LED0 lights and if it is in pushed state, LED1 lights.

0 0 0 1 P60

P61

P62 P63

OFF ON Switch status

When only LED0 lights, circuit to the switch is considered to be having soldering defect and when LED1 is in on condition, solder bridge is considered. Ascertain and localize the cause by visual check and the tester..

3.3. Servo Motor Test

P60

P61

P62 P63

From now on, we call servo motor “servo” for short. DIP switch is in “0010” state and power supply for CPU board and motor is turned 0 0 1 0 ON. Servo repeats the operation of "0 degree→ right 30 degrees→ left 30 degrees" every OFF second. ON

When the servo does not operate, it is considered that circuit up to servo has defective soldering and direction of servo connector is reversed. Moreover, confirm whether power supply LED of the motor drive board glows. Ascertain and localize the cause by observational check and the tester, etc.

Switch status

When we exchanged with the servo, that is not in the kit, and if the following operation has been carried out [0 degree→ left 30 degrees→ right 30 degrees], then right and left rotation occurs resulting in the opposite servo. In that case, 417th line in the handle function is changed as follows.

417 line

Before change After change

ITU4_BRB = SERVO_CENTER - angle * HANDLE_STEP; ITU4_BRB = SERVO_CENTER+angle * HANDLE_STEP;

The right and left change places and operation becomes "0 degree→ right 30 degree → left 30 degrees".

-5-

Operation Confirmation Manual c Center adjustment of servo In most cases even if power supply is turned ON and care should be taken that it is not facing straight even though it should be 0 degrees. It becomes a different value for every micom car, because the center value of the servo is different for different servo. The Value “5000” of SERVO_CENTER of “kit05test.c” is changed and it is adjusted so as to become straight. 26 is approximately 1 degree.

#define

SERVO_CENTER

5000

/* Center value of servo

*/

If value is increased, movement direction is towards left side and if decreased it is directed to right side. Sensor board side

Increase

Decrease

Body side

3.4. Right Motor Test 0 1 0 0 P60

P61

P62 P63

OFF

DIP switch is in “0100” state and power supply for CPU board and motor is turned ON. A right motor repeats "normal rotation - brake" every 1 second.

ON

When right motor does not rotate normally, it is considered that soldering of right motor control circuit is defective. The solder bridge can be done while continuing the rotation. Ascertain and localize the cause by visual check and the tester, etc. Moreover, when the tire rotation is reversed, the cable of the motor are reversed. Replace the terminal of 1 pin with 2 pins of the connector.

Switch status

0 1 0 1 P60

P61

P62 P63

OFF ON Switch status

The power supply is turned OFF once, and DIP switch is in "0101" state and power supply for CPU board and power supply for motor is turned ON. A right motor repeats "Reversal - brake" every 1 second. When a right motor does not reverse, it is considered to be because of defective soldering and short circuit. Ascertain and localize the cause with the observational check and the tester, etc.

-6-

Operation Confirmation Manual 3.5. Left Motor Test When the DIP switch is in the state of "0110", the power supply for CPU board and the power supply for the motor turns ON. A left motor repeats "normal rotation → brake" every 1 second.

0 1 1 0 P60

P61

P62 P63

OFF

When the left motor does not carry out normal rotation, it may be due to defective soldering of the left motor control circuit. If the rotation continues, the circuit pattern can be bridged by the solder. Ascertain and localize the cause by observational check and tester etc. Moreover, when the tire rotation is reversed, the cable of the motor is opposite. Replace 1 pin and 2 pin terminal of the connector.

ON

Switch status

Once turn OFF the power supply for CPU board and motor drive board , turn the DIP switch in "0110" state and turn ON the both power supply. A left motor repeats "Reverse → brake" every 1 second.

0 1 1 1 P60

P61

P62 P63

OFF

When the left motor does not reverse, it may be due to the defective soldering or short-circuit. Ascertain and localize the cause by observational check and tester etc.

ON

Switch status

3.6. Sensor test Turn ON only the power supply for CPU board when DIP switch is in the state of “1000”. The state of the bit number 0 and 1 of the sensor board is monitored by two LED of the motor drive board as shown in the figure below. Since LED on the sensor board also glows, it is tested for same reaction. The sensitivity of the sensor is adjusted by the volume.

1 0 0 0 P60

P61

P62 P63

OFF ON

Switch status

7

6

5

4

3

2

1

0

Sensor Bit Number

Sensitivity adjustment volume

LED0 LED1

-7-

Operation Confirmation Manual

If LED on the sensor board does not glow, it is considered to be due to defective soldering, Solder Bridge, attached reverse aspect of parts etc. When LED on the motor drive board does not glow even though the LED on the sensor board is lit, there is a possibility that some defect has occurred in the sub sensor board and the connector surroundings. Ascertain and localize the cause by observation check and tester etc.

Next, the switch is changed to “1001”, bit 2, bit 3; bit 4, bit 5 if “1010”; bit 6, bit 7 if “1011” are monitored by LED of motor drive board.

Sensor bit number output to LED1 of motor drive board

Sensor bit number output to LED0 of motor drive board

OFF ON

1

0

OFF ON

3

2

OFF ON

5

4

OFF ON

7

6

Switch 1 0 0 0

1 0 0 1

1 0 1 0

1 0 1 1

Actually at this time, the state of 8 sensors is output as it is to port A. In some seminar about RY-3048Fone board, ready made 8 bit LED board is provided. The board is convenient because when the board is connected with port A, all eight can be confirmed at the same time.

-8-

Operation Confirmation Manual

3.7. Direct Advance Test Turn ON the power supply for CPU board and the power supply for the motor drive board when DIP switch is in "1100" state. After 2 seconds, the micom car advances by PWM value 50% during 2 seconds. The OFF micom car is made to run in a flat, straight line, and long places such as corridor in school, and it is tested whether it advances straight or not. When it veers, the value ON of SERVO_CENTER is adjusted as explained in "3.3. Servo Motor Test" and it is Switch status adjusted so that it goes straight. Because straight advancement becomes very important when the speed of the micom car increases, therefore must be carried out. It is OK if fine adjustment is done by minutely controlling each value. Due to the difference in PWM value and time until stopping, there are 4 patterns of direct advance test. Please adjust according to the area of the place where the test running is carried out. 1 1 0 0

P60

P61

P62 P63

Switch

PWM value

Time until stopping

OFF ON

50%

2 Seconds

OFF ON

50%

5 Seconds

OFF ON

100%

2 Seconds

OFF ON

100%

5 Seconds

1 1 0 0

1 1 0 1

1 1 1 0

1 1 1 1

-9-

Operation Confirmation Manual

4. Writing of this Program All the functions operate normally, "SERVO_CENTER" is fine controlled and when the value at which it becomes Direct Advance is obtained, the "SERVO_CENTER" value of "kit05.c" is set to just that value. For example, if it is 4856, the SERVO_CENTER definition line of kit05.c is as follows:

#define

SERVO_CENTER

4856

/* Center value of Servo

same as kit05test.c. After that, "kit05.c" is compiled, written, run tested.

- 10 -

*/

Operation Confirmation Manual

5. Program Source 5.1. Program contents of “kit05test.c” 1: 2: 3: 4: 5: 6: 7: 8: 9: 10 : 11 : 12 : 13 : 14 : 15 : 16 : 17 : 18 : 19 : 20 : 21 : 22 : 23 : 24 : 25 : 26 : 27 : 28 : 29 : 30 : 31 : 32 : 33 : 34 : 35 : 36 : 37 : 38 : 39 : 40 : 41 : 42 : 43 : 44 : 45 : 46 : 47 : 48 : 49 : 50 : 51 : 52 : 53 : 54 : 55 : 56 : 57 : 58 : 59 : 60 : 61 : 62 : 63 : 64 : 65 : 66 : 67 : 68 : 69 : 70 : 71 : 72 : 73 : 74 : 75 : 76 : 77 : 78 : 79 : 80 : 81 :

/*****************************************************************************/ /* Micom Car Rally Trace Program 2005 Version */ /* Sensor board Motor drive board test program */ /* 2005.04 Micom Car Rally Executive Committee */ /*****************************************************************************/ /* The sensor board and the motor drive board for the kit are tested. The content of the test is changed by the DIP switch of CPU board. DipSW bit3 2 1 0 0 0 0 0 LED test LED lights alternately every 0.5 seconds. 0 0 0 1 Push switch test Switch OFF:LED0 lights, Switch ON:LED1 lights 0 0 1 0 Servo test Repetition of ( 0°→ right 30°→ left 30°) 0011 0 1 0 0 Right motor test Repetition of ( normal rotation → brake ) 0101 Repetition of ( reverse → brake ) 0 1 1 0 Left motor test Repetition of ( normal rotation → brake ) 0111 Repetition of ( reverse → brake ) 1 0 0 0 Sensor test 1001 1010 1011

*/

1 1 0 0 Direct Advance test 1 1 0 1 Direct Advance test 1 1 1 0 Direct Advance test 1 1 1 1 Direct Advance test

Sensor bit1, 0 are output to LED1, 0 Sensor bit3, 2 are output to LED1, 0 Sensor bit5, 4 are output to LED1, 0 Sensor bit7, 6 are output to LED1, 0 Advances by PWM 50% Advances by PWM 50% Advances by PWM 100% Advances by PWM 100%

Stop after 2 seconds Stop after 5 seconds Stop after 2 seconds Stop after 5 seconds

/*======================================*/ /* Include */ /*======================================*/ #include <machine.h> #include "h8_3048.h" /*======================================*/ /* Symbol Definition */ /*======================================*/ /* Constant setting */ #define TIMER_CYCLE

3071

#define

PWM_CYCLE

49151

#define #define

SERVO_CENTER HANDLE_STEP

5000 26

/* Timer cycle 1ms */ /* When using atφ/8, */ /* φ/8 = 325.5[ns] */ /* ∴TIMER_CYCLE = */ /* 1[ms] / 325.5[ns] */ /* = 3072 */ /* PWM cycle 16ms */ /* ∴PWM_CYCLE = */ /* 16[ms] / 325.5[ns] */ /* = 49152 */ /* Center value of Servo */ /* 1°of value */

/*======================================*/ /* Prototype declaration */ /*======================================*/ void init( void ); unsigned char sensor_inp( unsigned char mask ); unsigned char dipsw_get( void ); unsigned char pushsw_get( void ); void led_out( unsigned char led ); void speed( int accele_l, int accele_r ); void handle( int angle ); char unsigned bit_change( char unsigned in ); /*======================================*/ /* Declaration of global variable */ /*======================================*/ unsigned long cnt0; /* For timer function unsigned long cnt1; /* Used in main

*/ */

/************************************************************************/ /* Main program */ /************************************************************************/ void main( void ) { unsigned char now_sw; /* Present DIP switch memory */ unsigned char before_sw; /* Previous DIP switch memory */ unsigned char c; /* For operation */

- 11 -

Operation Confirmation Manual 82 : 83 : 84 : 85 : 86 : 87 : 88 : 89 : 90 : 91 : 92 : 93 : 94 : 95 : 96 : 97 : 98 : 99 : 100 : 101 : 102 : 103 : 104 : 105 : 106 : 107 : 108 : 109 : 110 : 111 : 112 : 113 : 114 : 115 : 116 : 117 : 118 : 119 : 120 : 121 : 122 : 123 : 124 : 125 : 126 : 127 : 128 : 129 : 130 : 131 : 132 : 133 : 134 : 135 : 136 : 137 : 138 : 139 : 140 : 141 : 142 : 143 : 144 : 145 : 146 : 147 : 148 : 149 : 150 : 151 : 152 : 153 : 154 : 155 : 156 : 157 : 158 : 159 : 160 : 161 : 162 : 163 : 164 : 165 : 166 : 167 : 168 : 169 : 170 : 171 : 172 :

int

i;

/* Initialization of micom function */ init(); set_ccr( 0x00 );

/* For operation

*/

/* Initialization /* Enable all interrupts */

*/

/* Variable initialization */ before_sw = dipsw_get(); cnt1 = 0; /* Micom car state initialization */ handle( 0 ); speed( 0, 0 ); led_out( 0x0 ); while( 1 ) { /* DIP switch reading */ now_sw = dipsw_get(); /* Comparison with previous switch value */ if( before_sw != now_sw ) { /* If disagrees with previous value update, clear of timer value */ before_sw = now_sw; cnt1 = 0; } /* Test mode selection according to the value of the DIP switch switch( now_sw ) {

*/

/* LED test LED lights alternately every 0.5 seconds */ case 0: if( cnt1 < 500 ) { led_out( 0x1 ); } else if( cnt1 < 1000 ) { led_out( 0x2 ); } else { cnt1 = 0; } break; /* Push switch test OFF:LED0 lights, case 1: led_out( pushsw_get() + 1 ); break;

ON:LED1 lights */

/* Servo test Repetition of ( 0°→right 30°→left 30° ) */ case 2: if( cnt1 < 1000 ) { handle( 0 ); } else if( cnt1 < 2000 ) { handle( 30 ); } else if( cnt1 < 3000 ) { handle( -30 ); } else { cnt1 = 0; } break; /* Right motor test Repetition of ( normal rotation→brake ) */ case 4: if( cnt1 < 1000 ) { speed( 0, 100 ); } else if( cnt1 < 2000 ) { speed( 0, 0 ); } else { cnt1 = 0; } break; /* Right motor test Repetition of ( reverse→brake ) */ case 5: if( cnt1 < 1000 ) { speed( 0, -100 ); } else if( cnt1 < 2000 ) { speed( 0, 0 ); } else { cnt1 = 0; } break; /* Left motor test Repetition of ( normal rotation→brake ) */ case 6: if( cnt1 < 1000 ) { speed( 100, 0 ); } else if( cnt1 < 2000 ) { speed( 0, 0 ); } else { cnt1 = 0; } break;

- 12 -

Operation Confirmation Manual 173 : 174 : 175 : 176 : 177 : 178 : 179 : 180 : 181 : 182 : 183 : 184 : 185 : 186 : 187 : 188 : 189 : 190 : 191 : 192 : 193 : 194 : 195 : 196 : 197 : 198 : 199 : 200 : 201 : 202 : 203 : 204 : 205 : 206 : 207 : 208 : 209 : 210 : 211 : 212 : 213 : 214 : 215 : 216 : 217 : 218 : 219 : 220 : 221 : 222 : 223 : 224 : 225 : 226 : 227 : 228 : 229 : 230 : 231 : 232 : 233 : 234 : 235 : 236 : 237 : 238 : 239 : 240 : 241 : 242 : 243 : 244 : 245 : 246 : 247 : 248 : 249 : 250 : 251 : 252 : 253 : 254 : 255 : 256 : 257 : 258 : 259 : 260 : 261 : 262 : 263 :

/* Left Motor test Repetition of ( reverse→brake ) */ case 7: if( cnt1 < 1000 ) { speed( -100, 0 ); } else if( cnt1 < 2000 ) { speed( 0, 0 ); } else { cnt1 = 0; } break; /* Sensor test Sensor bit1,0 is output to LED1,0 */ case 8: c = sensor_inp( 0x03 ); led_out( c ); PADR = sensor_inp( 0xff ); break; /* Sensor test Sensor bit3,2 is output to LED1,0 */ case 9: c = sensor_inp( 0x0c ); c = c >> 2; led_out( c ); PADR = sensor_inp( 0xff ); break; /* Sensor test Sensor bit5,4 is output to LED1,0 */ case 10: c = sensor_inp( 0x30 ); c = c >> 4; led_out( c ); PADR = sensor_inp( 0xff ); break; /* Sensor test Sensor bit7,6 is output to LED1,0 */ case 11: c = sensor_inp( 0xc0 ); c = c >> 6; led_out( c ); PADR = sensor_inp( 0xff ); break; /* Direct Advance test Advances by PWM 50%, Stop after 2 seconds */ case 12: if( cnt1 < 2000 ) { speed( 0, 0 ); } else if( cnt1 < 4000 ) { speed( 50, 50 ); } else { speed( 0, 0 ); } break; /* Direct Advance test case 13: if( cnt1 < 2000 ) { speed( 0, 0 ); } else if( cnt1 < 7000 ) { speed( 50, 50 ); } else { speed( 0, 0 ); } break;

}

}

Advances by PWM 50%, Stop after 5 seconds */

/* Direct Advance test case 14: if( cnt1 < 2000 ) { speed( 0, 0 ); } else if( cnt1 < 4000 ) { speed( 100, 100 ); } else { speed( 0, 0 ); } break;

Advances by PWM 100%, Stop after 2 seconds */

/* Direct Advance test case 15: if( cnt1 < 2000 ) { speed( 0, 0 ); } else if( cnt1 < 7000 ) { speed( 100, 100 ); } else { speed( 0, 0 ); } break;

Advances by PWM 100%, Stop after 5 seconds */

/* If neither */ default: break;

- 13 -

Operation Confirmation Manual 264 : 265 : 266 : 267 : 268 : 269 : 270 : 271 : 272 : 273 : 274 : 275 : 276 : 277 : 278 : 279 : 280 : 281 : 282 : 283 : 284 : 285 : 286 : 287 : 288 : 289 : 290 : 291 : 292 : 293 : 294 : 295 : 296 : 297 : 298 : 299 : 300 : 301 : 302 : 303 : 304 : 305 : 306 : 307 : 308 : 309 : 310 : 311 : 312 : 313 : 314 : 315 : 316 : 317 : 318 : 319 : 320 : 321 : 322 : 323 : 324 : 325 : 326 : 327 : 328 : 329 : 330 : 331 : 332 : 333 : 334 : 335 : 336 : 337 : 338 : 339 : 340 : 341 : 342 : 343 : 344 : 345 : 346 : 347 : 348 : 349 : 350 : 351 : 352 : 353 : 354 :

} /************************************************************************/ /* Module built-in H8/3048F Initialization */ /************************************************************************/ void init( void ) { /* Input/Output setting of Port */ P1DDR = 0xff; P2DDR = 0xff; P3DDR = 0xff; P4DDR = 0xff; P5DDR = 0xff; P6DDR = 0xf0; /* DIP SW on CPU board */ P8DDR = 0xff; P9DDR = 0xf7; /* Signal communication port */ PADDR = 0xff; PBDR = 0xc0; PBDDR = 0xfe; /* Motor Drive Board Vol.3 */ /* ※ There is no input/output setting since Port 7 which is connected with Sensor board ,is exclusively for input. */ /* ITU0 Interrupt of each 1ms */ ITU0_TCR = 0x23; ITU0_GRA = TIMER_CYCLE; ITU0_IER = 0x01; /* ITU3,4 for reset synchronization PWM mode and they are for right and left motor and servo */ ITU3_TCR = 0x23; ITU_FCR = 0x3e; ITU3_GRA = PWM_CYCLE; /* Setting of cycle */ ITU3_GRB = ITU3_BRB = 0; /* PWM setting of left motor */ ITU4_GRA = ITU4_BRA = 0; /* PWM setting of right motor */ ITU4_GRB = ITU4_BRB = SERVO_CENTER; /* PWM setting of servo */ ITU_TOER = 0x38;

}

/* Count start of ITU */ ITU_STR = 0x09;

/************************************************************************/ /* ITU0 Interrupt Processing */ /************************************************************************/ #pragma interrupt( interrupt_timer0 ) void interrupt_timer0( void ) { ITU0_TSR &= 0xfe; /* Flag clear */ cnt0++; cnt1++; } /************************************************************************/ /* Sensor state detection */ /* Argument mask value */ /* Return value Sensor value */ /************************************************************************/ unsigned char sensor_inp( unsigned char mask ) { unsigned char sensor; sensor = P7DR; /* For the new sensor board, the leftmost is bit0 and rightmost is bit7 and this */ /* is opposite to the previous sensor board. The bit is replaced in order to maintain compatibility. */ sensor = bit_change( sensor ); /* replace bit */ sensor &= mask; }

return sensor;

/************************************************************************/ /* DIP switch value reading */ /* Return value Switch value 0 - 15 */ /************************************************************************/ unsigned char dipsw_get( void ) { unsigned char sw; sw = ~P6DR; sw &= 0x0f; }

return

/* DIP switch read */

sw;

/************************************************************************/ /* Push switch value read */ /* Return value Switch value ON:1, OFF:0 /************************************************************************/ unsigned char pushsw_get( void ) { unsigned char sw;

- 14 -

*/

Operation Confirmation Manual 355 : 356 : 357 : 358 : 359 : 360 : 361 : 362 : 363 : 364 : 365 : 366 : 367 : 368 : 369 : 370 : 371 : 372 : 373 : 374 : 375 : 376 : 377 : 378 : 379 : 380 : 381 : 382 : 383 : 384 : 385 : 386 : 387 : 388 : 389 : 390 : 391 : 392 : 393 : 394 : 395 : 396 : 397 : 398 : 399 : 400 : 401 : 402 : 403 : 404 : 405 : 406 : 407 : 408 : 409 : 410 : 411 : 412 : 413 : 414 : 415 : 416 : 417 : 418 : 419 : 420 : 421 : 422 : 423 : 424 : 425 : 426 : 427 : 428 : 429 : 430 : 431 : 432 : 433 : 434 : 435 : 436 : 437 : 438 : 439 : 440 :

sw = ~PBDR; sw &= 0x01; }

return

/* Port reading with switch */

sw;

/*************************************************************************/ /* LED contorl */ /* Argument switch value LED0:bit0 LED1:bit1 "0":OFF "1":ON */ /* Example) 0x3→LED1:ON LED0:ON 0x2→LED1:ON LED0:OFF */ /************************************************************************/ void led_out( unsigned char led ) { unsigned char data;

}

led = ~led; led <<= 6; data = PBDR & 0x3f; PBDR = data | led;

/*************************************************************************/ /* Speed control */ /* Argument Left motor:-100~100 , Right motor:-100~100 */ /* 0:stop, 100: normal rotation100%, -100: reverse100% */ /************************************************************************/ void speed( int accele_l, int accele_r ) { unsigned char sw_data; unsigned long speed_max; sw_data = dipsw_get() + 5; /* DIP switch read */ speed_max = (unsigned long)(PWM_CYCLE-1) * sw_data / 20; /* Left motor */ if( accele_l >= 0 ) { PBDR &= 0xfb; ITU3_BRB = speed_max * accele_l / 100; } else { PBDR |= 0x04; accele_l = -accele_l; ITU3_BRB = speed_max * accele_l / 100; }

}

/* Right motor */ if( accele_r >= 0 ) { PBDR &= 0xf7; ITU4_BRA = speed_max * accele_r / 100; } else { PBDR |= 0x08; accele_r = -accele_r; ITU4_BRA = speed_max * accele_r / 100; }

/***************************************************************** *********/ /* Servo handle operation (Handle means steering) */ /* Argument Servo operation angle:-90~+90 */ /* -90: 90° to left、0: straight, 0: 90° to right rotation */ /**************************************************************************/ void handle( int angle ) { ITU4_BRB = SERVO_CENTER - angle * HANDLE_STEP; } /************************************************************************/ /* Bit replace */ /* Argument Replaced value */ /* Return value Value after replacing */ /************************************************************************/ char unsigned bit_change( char unsigned in ) { unsigned char ret; int i;

}

for( i = 0; i < 8; i++ ) { ret >>= 1; ret |= in & 0x80; in <<= 1; } return ret;

/* right shift of return value */ /* ret bit7 = in bit7 */ /* left shift of argument */

/************************************************************************/ /* End of file */ /************************************************************************/

- 15 -

Operation Confirmation Manual 5.2. Program contents of “kit05teststart.src” 1: .CPU 300HA:20 2: 3 : RESERVE: .EQU H'FFFFFFFF 4: 5: .IMPORT _main 6: .IMPORT _interrupt_timer0 7: 8: .SECTION V 9: .DATA.L RESET_START 10 : .DATA.L RESERVE 11 : .DATA.L RESERVE 12 : .DATA.L RESERVE 13 : .DATA.L RESERVE 14 : .DATA.L RESERVE 15 : .DATA.L RESERVE 16 : .DATA.L RESERVE 17 : .DATA.L RESERVE 18 : .DATA.L RESERVE 19 : .DATA.L RESERVE 20 : .DATA.L RESERVE 21 : .DATA.L RESERVE 22 : .DATA.L RESERVE 23 : .DATA.L RESERVE 24 : .DATA.L RESERVE 25 : .DATA.L RESERVE 26 : .DATA.L RESERVE 27 : .DATA.L RESERVE 28 : .DATA.L RESERVE 29 : .DATA.L RESERVE 30 : .DATA.L RESERVE 31 : .DATA.L RESERVE 32 : .DATA.L RESERVE 33 : .DATA.L _interrupt_timer0 34 : .DATA.L RESERVE 35 : .DATA.L RESERVE 36 : .DATA.L RESERVE 37 : .DATA.L RESERVE 38 : .DATA.L RESERVE 39 : .DATA.L RESERVE 40 : .DATA.L RESERVE 41 : .DATA.L RESERVE 42 : .DATA.L RESERVE 43 : .DATA.L RESERVE 44 : .DATA.L RESERVE 45 : .DATA.L RESERVE 46 : .DATA.L RESERVE 47 : .DATA.L RESERVE 48 : .DATA.L RESERVE 49 : .DATA.L RESERVE 50 : .DATA.L RESERVE 51 : .DATA.L RESERVE 52 : .DATA.L RESERVE 53 : .DATA.L RESERVE 54 : .DATA.L RESERVE 55 : .DATA.L RESERVE 56 : .DATA.L RESERVE 57 : .DATA.L RESERVE 58 : .DATA.L RESERVE 59 : .DATA.L RESERVE 60 : .DATA.L RESERVE 61 : .DATA.L RESERVE 62 : .DATA.L RESERVE 63 : .DATA.L RESERVE 64 : .DATA.L RESERVE 65 : .DATA.L RESERVE 66 : .DATA.L RESERVE 67 : .DATA.L RESERVE 68 : .DATA.L RESERVE 69 : .DATA.L RESERVE 70 : 71 : .SECTION P 72 : RESET_START: 73 : MOV.L #H'FFFF10,ER7 74 : JSR @_main 75 : OWARI: 76 : BRA OWARI 77 : 78 : .END

; Specification of CPU ; Address in unused area ; External reference(main function) ; External reference(interrupt_timer0 function) ; Start of vector section ; 0 h'000000 reset ; 1 h'000004 System reservation ; 2 h'000008 System reservation ; 3 h'00000c System reservation ; 4 h'000010 System reservation ; 5 h'000014 System reservation ; 6 h'000018 System reservation ; 7 h'00001c External interrupt NMI ; 8 h'000020 Trap command ; 9 h'000024 Trap command ; 10 h'000028 Trap command ; 11 h'00002c Trap command ; 12 h'000030 External interrupt IRQ0 ; 13 h'000034 External interrupt IRQ1 ; 14 h'000038 External interrupt IRQ2 ; 15 h'00003c External interrupt IRQ3 ; 16 h'000040 External interrupt IRQ4 ; 17 h'000044 External interrupt IRQ5 ; 18 h'000048 System reservation ; 19 h'00004c System reservation ; 20 h'000050 WDT MOVI ; 21 h'000054 REF CMI ; 22 h'000058 System reservation ; 23 h'00005c System reservation ; 24 h'000060 ITU0 IMIA0 ; 25 h'000064 ITU0 IMIB0 ; 26 h'000068 ITU0 OVI0 ; 27 h'00006c System reservation ; 28 h'000070 ITU1 IMIA1 ; 29 h'000074 ITU1 IMIB1 ; 30 h'000078 ITU1 OVI1 ; 31 h'00007c System reservation ; 32 h'000080 ITU2 IMIA2 ; 33 h'000084 ITU2 IMIB2 ; 34 h'000088 ITU2 OVI2 ; 35 h'00008c System reservation ; 36 h'000090 ITU3 IMIA3 ; 37 h'000094 ITU3 IMIB3 ; 38 h'000098 ITU3 OVI3 ; 39 h'00009c System reservation ; 40 h'0000a0 ITU4 IMIA4 ; 41 h'0000a4 ITU4 IMIB4 ; 42 h'0000a8 ITU4 OVI4 ; 43 h'0000ac System reservation ; 44 h'0000b0 DMAC DEND0A ; 45 h'0000b4 DMAC DEND0B ; 46 h'0000b8 DMAC DEND1A ; 47 h'0000bc DMAC DEND1B ; 48 h'0000c0 System reservation ; 49 h'0000c4 System reservation ; 50 h'0000c8 System reservation ; 51 h'0000cc System reservation ; 52 h'0000d0 SCI0 ERI0 ; 53 h'0000d4 SCI0 RXI0 ; 54 h'0000d8 SCI0 TXI0 ; 55 h'0000dc SCI0 TEI0 ; 56 h'0000e0 SCI1 ERI1 ; 57 h'0000e4 SCI1 RXI1 ; 58 h'0000e8 SCI1 TXI1 ; 59 h'0000ec SCI1 TEI1 ; 60 h'0000f0 A/D ADI ; Start of program section ; Stack setting ; Jump to main() function of C language

- 16 -

Operation Confirmation Manual

5.3. Program contents of “kit05test.sub” 1: 2: 3: 4: 5: 6: 7: 8:

input kit05teststart,kit05test lib c:¥h8n_win¥3048¥c¥c38hae.lib output kit05test print kit05test start V(000000) start P,C(000100) start B(0fef10) exit

In case the installed drive is other than C drive, change “c:¥” of “lib c:¥h8n_win¥3048¥c¥c38hae.lib” to the installed drive. If A drive, then becomes “lib a:¥h8n_win¥3048¥c¥c38hae.lib”.

- 17 -

Related Documents

Operation Confirm Eng
November 2019 6
Confirm
December 2019 18
Eng
May 2020 59
Eng
May 2020 56
#194 To Confirm
December 2019 9