2018年8月21日 改正 | |||||
|
|||||
Tablet PCの通信ソフト"TeraTerm"用マクロと手動部分
|
|||||
◆TeraTermのマクロのシーケンス・発信信号と補助ソフトの実行
・この中で、2.の後に手動で偏光撮像用のフィルターターレットに付けた太陽フィルターを外すのは手動 ・途中途中でピント合わせがコロナの拡大(D7200)、クライマックス(D5500)、偏光撮像(E-PL5)に必要。C2の10-30分前には終えておく |
|||||
"TeraTerm"からUSB-PICに送る命令と連動するファーム
|
|||||
A: PIC3に60秒間隔で撮像開始(全景画像用) B: PIC2に10秒間隔で撮像開始(クライマックスC2前、C3後) C: PIC2に1.5秒間隔で撮像開始(ダイヤモンドリングとコロナ) D: PIC1に撮像開始(偏光撮像) E: D7200で1/500秒で15秒間連写し1/8000秒にSSを増速 F: D7200で1/8000秒から1/500秒にSSを減速し15秒間連写 G: D7200で1/8000秒から1/2秒迄2EV間隔7段の多段階撮像 H: D7200で1/2秒から1/8000秒迄2EV間隔7段の多段階撮像 I : 太陽フィルター×3開 J: 太陽フィルター×3閉 K: D7200のSSを1/2秒から1/8000秒まで増速 他にサポートするコンポーネントとして 撮像サブルーチン 増速サブルーチン 減速サブルーチン これらを組み込んだファームウェアのDLはこちら リストはページの一番下に |
void PIC3Start() void PIC2_Int() void PIC2_Cont() void PIC1_Start() void USB_PIC_Cont_1st() void USB_PIC_Cont_2nd() void USB_PIC_BKT_Down() void USB_PIC_BKT_Up() void Filter_Open() void Filter_Close( void SS_UpTo_8000() void Captor() void SpeedUp() void SpeedDown() |
||||
USB-PICによるPIC1~3・D7200・フィルタの制御ピン
|
|||||
PIC1:C2後5秒してから撮像開始信号、C3の5秒前に撮像終了信号、トグル動作させる、RC7で制御 PIC2:食最大の5分前から通常10秒間隔、C2の10秒前~C3の10秒後迄1.5秒間隔で撮像、RC3,4で制御 PIC3:食最大の2×n分前から通常2分間隔、C2の10秒前~C3の10秒後迄2秒間で隔撮像、RC5,6で制御 D7200:シャッターのレリーズ信号を送る。RB6がフォーカス、RB7がレリーズ フィルター開閉:RC0, 1, 2で1ピン1サーボモータを制御 ※但し、実際PIC3はピン1本で操作できるため、I/Oの予備ピンを1つ出す事が出来る。 ●最悪通信がうまくいかないときの強制発動スイッチとして、プルアップしているRA3を使う。これはタイマーリモコンにつないで、I⇒C⇒E⇒F&G繰り返し⇒K⇒F⇒C⇒Jというシーケンスで機材を駆動するファームウェア。通常、D7200はSDKプログラムにより連写時と多段階露光時で感度をISO160とISO640に変えてる予定である。しかし、通信が効かないときはISO160固定で1/2000秒~2秒の2EV間隔7段、ダイヤモンドリング連写は1/500秒で行う。そいう言うファームを積んだPIC(18F14K50)を準備して、オンサイトで交換する。 |
|||||
|
|||||
1 /******************************************************************************* 2 Copyright 2016 Microchip Technology Inc. (www.microchip.com) 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 16 To request to license the code under the MLA license (www.microchip.com/mla_license), 17 please contact mla_licensing@microchip.com 18 * 19 Firmware has modified by M_shi_Lab 20 *******************************************************************************/ 21 22 /** INCLUDES *******************************************************/ 23 #include "system.h" 24 25 #include <stdint.h> 26 #include <string.h> 27 #include <stddef.h> 28 29 #include "usb.h" 30 31 #include "app_led_usb_status.h" 32 #include "app_device_cdc_basic.h" 33 #include "usb_config.h" 34 35 #define _XTAL_FREQ 48000000 36 37 /** VARIABLES ******************************************************/ 38 39 static bool buttonPressed; 40 static char buttonMessage[] = "Button pressed.\r\n"; 41 static uint8_t readBuffer[CDC_DATA_OUT_EP_SIZE]; 42 static uint8_t writeBuffer[CDC_DATA_IN_EP_SIZE]; 43 44 void PIC3Start(); //A 45 void PIC2_Int(); //B 46 void PIC2_Cont(); //C 47 void PIC1_Start(); //D 48 void USB_PIC_Cont_1st(); //E 49 void USB_PIC_Cont_2nd(); //F 50 void USB_PIC_BKT_Down(); //G 51 void USB_PIC_BKT_Up(); //H 52 void Filter_Open(); //I 53 void Filter_Close(); //J 54 void SS_UpTo_8000(); //K 55 void Captor(); 56 void SpeedUp(); 57 void SpeedDown(); 58 59 60 /********************************************************************* 61 * Function: void APP_DeviceCDCBasicDemoInitialize(void); 62 * 63 * Overview: Initializes the demo code 64 * 65 * PreCondition: None 66 * 67 * Input: None 68 * 69 * Output: None 70 * 71 ********************************************************************/ 72 void APP_DeviceCDCBasicDemoInitialize() 73 { 74 line_coding.bCharFormat = 0; 75 line_coding.bDataBits = 8; 76 line_coding.bParityType = 0; 77 line_coding.dwDTERate = 9600; 78 79 buttonPressed = false; 80 } 81 82 /********************************************************************* 83 * Function: void APP_DeviceCDCBasicDemoTasks(void); 84 * 85 * Overview: Keeps the demo running. 86 * 87 * PreCondition: The demo should have been initialized and started via 88 * the APP_DeviceCDCBasicDemoInitialize() and APP_DeviceCDCBasicDemoStart() demos 89 * respectively. 90 * 91 * Input: None 92 * 93 * Output: None 94 * 95 ********************************************************************/ 96 void APP_DeviceCDCBasicDemoTasks() 97 { 98 TRISB = 0b00000000; 99 TRISC = 0b00000000; 100 PORTB = 0b00000000; 101 PORTC = 0b00000000; 102 103 104 char Commander; 105 /* If the USB device isn't configured yet, we can't really do anything 106 * else since we don't have a host to talk to. So jump back to the 107 * top of the while loop. */ 108 if( USBGetDeviceState() < CONFIGURED_STATE ) 109 { 110 return; 111 } 112 113 /* If we are currently suspended, then we need to see if we need to 114 * issue a remote wakeup. In either case, we shouldn't process any 115 * keyboard commands since we aren't currently communicating to the host 116 * thus just continue back to the start of the while loop. */ 117 if( USBIsDeviceSuspended()== true ) 118 { 119 return; 120 } 121 122 /* If the user has pressed the button associated with this demo, then we 123 * are going to send a "Button Pressed" message to the terminal. 124 */ 125 if(BUTTON_IsPressed(BUTTON_DEVICE_CDC_BASIC_DEMO) == true) 126 { 127 /* Make sure that we only send the message once per button press and 128 * not continuously as the button is held. 129 */ 130 if(buttonPressed == false) 131 { 132 /* Make sure that the CDC driver is ready for a transmission. 133 */ 134 if(mUSBUSARTIsTxTrfReady() == true) 135 { 136 putrsUSBUSART(buttonMessage); 137 buttonPressed = true; 138 USB_PIC_BKT_Down(); 139 USB_PIC_BKT_Up(); 140 141 } 142 } 143 } 144 else 145 { 146 /* If the button is released, we can then allow a new message to be 147 * sent the next time the button is pressed. 148 */ 149 buttonPressed = false; 150 } 151 152 /* Check to see if there is a transmission in progress, if there isn't, then 153 * we can see about performing an echo response to data received. 154 */ 155 if( USBUSARTIsTxTrfReady() == true) 156 { 157 uint8_t i; 158 uint8_t numBytesRead; 159 160 numBytesRead = getsUSBUSART(readBuffer, sizeof(readBuffer)); 161 162 /* For every byte that was read... */ 163 for(i=0; i<numBytesRead; i++) 164 { 165 switch(readBuffer[i]) 166 { 167 /* If we receive new line or line feed commands, just echo 168 * them direct. 169 */ 170 case 0x0A: 171 case 0x0D: 172 // writeBuffer[i] = readBuffer[i]; 173 // break; 174 175 /* If we receive something else, then echo it plus one 176 * so that if we receive 'a', we echo 'b' so that the 177 * user knows that it isn't the echo enabled on their 178 * terminal program. 179 */ 180 default: 181 writeBuffer[i] = readBuffer[i]; 182 // break; 183 184 //default: 185 186 Commander = readBuffer[0]; 187 188 if(Commander=='A') 189 { 190 PIC3Start(); 191 //numBytesRead = 10; 192 //writeBuffer[10]=('A','5','0','0','0',' ','S','t','a','r','t'); 193 } 194 else if(Commander=='B') 195 { 196 PIC2_Int(); 197 //numBytesRead = 13; 198 //writeBuffer[13]=('D','5','5','0','0',' ','I','n','t',' ','S','t','a','r','t'); 199 } 200 else if(Commander=='C') 201 { 202 PIC2_Cont(); 203 //numBytesRead = 14; 204 //writeBuffer[14]=('D','5','5','0','0',' ','C','o','n','t',' ','S','t','a','r','t'); 205 } 206 else if(Commander == 'D') 207 { 208 PIC1_Start(); 209 } 210 else if(Commander=='E') 211 { 212 USB_PIC_Cont_1st(); 213 //numBytesRead = 8; 214 //writeBuffer[8]=('D','.','L','.',' ','E','N','D'); 215 } 216 else if(Commander=='F') 217 { 218 USB_PIC_Cont_2nd(); 219 //numBytesRead = 8; 220 //writeBuffer[8]=('D','.','L','.',' ','E','N','D'); 221 } 222 else if(Commander=='G') 223 { 224 USB_PIC_BKT_Down(); 225 //numBytesRead = 12; 226 //writeBuffer[12]=('B','K','T',' ','D','o','w','n',' ','E','N','D'); 227 } 228 else if(Commander=='H') 229 { 230 USB_PIC_BKT_Up(); 231 //numBytesRead = 10; 232 //writeBuffer[10]=('B','K','T',' ','U','p',' ','E','N','D'); 233 } 234 else if(Commander=='I') 235 { 236 Filter_Open(); 237 } 238 else if(Commander=='J') 239 { 240 Filter_Close(); 241 } 242 else if(Commander=='K') 243 { 244 SS_UpTo_8000(); 245 //numBytesRead = 9; 246 //writeBuffer[9]=('S','S','=','1','/','8','0','0','0'); 247 } 248 break; 249 } 250 if(numBytesRead > 0) 251 { 252 /* After processing all of the received data, we need to send out 253 * the "echo" data now. 254 */ 255 putUSBUSART(writeBuffer,numBytesRead); 256 } 257 258 } 259 } 260 CDCTxService(); 261 } 262 263 void PIC3Start() 264 { 265 int i; 266 LATCbits.LATC5 = 0; 267 LATCbits.LATC6 = 0; 268 __delay_ms(10); 269 LATCbits.LATC5 = 1; 270 for(i=1; i<=13; i++) 271 { 272 __delay_ms(100); 273 } 274 LATCbits.LATC5 = 0; 275 } 276 277 void PIC2_Int() 278 { 279 int i; 280 LATCbits.LATC3 = 0; 281 LATCbits.LATC4 = 0; 282 __delay_ms(10); 283 LATCbits.LATC3 = 1; 284 for(i=1; i<=13; i++) 285 { 286 __delay_ms(100); 287 } 288 LATCbits.LATC3 = 0; 289 290 return; 291 } 292 293 void PIC2_Cont() 294 { 295 int i; 296 LATCbits.LATC3 = 0; 297 LATCbits.LATC4 = 0; 298 __delay_ms(10); 299 LATCbits.LATC4 = 1; 300 for(i=1; i<=13; i++) 301 { 302 __delay_ms(100); 303 } 304 LATCbits.LATC4 = 0; 305 306 return; 307 } 308 309 void PIC1_Start() 310 { 311 LATCbits.LATC7=0; 312 313 LATCbits.LATC7=1; 314 __delay_ms(50); 315 LATCbits.LATC7=0; 316 317 return; 318 } 319 320 void USB_PIC_Cont_1st() 321 { 322 int i; 323 324 LATBbits.LATB6=0; 325 LATBbits.LATB7=0; 326 __delay_ms(20); 327 LATBbits.LATB6 = 1; 328 __delay_ms(20); 329 LATBbits.LATB7 = 1; 330 for(i=1; i<=150;i++) 331 { 332 __delay_ms(100); 333 } 334 LATBbits.LATB7 = 0; 335 __delay_ms(20); 336 LATBbits.LATB6 = 0; 337 __delay_ms(20); 338 SpeedUp(); 339 SpeedUp(); 340 341 return; 342 } 343 344 void USB_PIC_Cont_2nd() 345 { 346 int i; 347 348 SpeedDown(); 349 SpeedDown(); 350 351 LATBbits.LATB6=0; 352 LATBbits.LATB7=0; 353 __delay_ms(20); 354 LATBbits.LATB6 = 1; 355 __delay_ms(20); 356 LATBbits.LATB7 = 1; 357 for(i=1; i<=150;i++) 358 { 359 __delay_ms(100); 360 } 361 LATBbits.LATB7 = 0; 362 __delay_ms(20); 363 LATBbits.LATB6 = 0; 364 __delay_ms(20); 365 return; 366 } 367 368 void USB_PIC_BKT_Down() 369 { 370 int i; 371 372 for(i=1 ;i<=3 ; i++) 373 { 374 Captor(); 375 __delay_ms(300); 376 SpeedDown(); 377 __delay_ms(30); 378 379 } 380 for(i=1 ;i<=3 ; i++) 381 { 382 Captor(); 383 __delay_ms(400); 384 SpeedDown(); 385 __delay_ms(30); 386 } 387 Captor(); 388 __delay_ms(700); 389 390 return; 391 } 392 393 void USB_PIC_BKT_Up() 394 { 395 int i; 396 397 Captor(); 398 __delay_ms(700); 399 400 for(i=1 ;i<=3 ; i++) 401 { 402 SpeedUp(); 403 __delay_ms(30); 404 Captor(); 405 __delay_ms(400); 406 407 } 408 for(i=1 ;i<=3 ; i++) 409 { 410 SpeedUp(); 411 __delay_ms(30); 412 Captor(); 413 __delay_ms(300); 414 } 415 SpeedUp(); 416 417 return; 418 } 419 420 void Filter_Open() 421 { 422 int k, b; 423 424 for(k=0; k<45; k++) 425 { 426 LATCbits.LATC2 = 1; 427 { 428 __delay_us(190); 429 } 430 LATCbits.LATC2 = 0; 431 for(b=1; b<=47; b++) 432 { 433 __delay_us(400); 434 } 435 } 436 __delay_ms(200); 437 for(k=0; k<45; k++) 438 { 439 LATCbits.LATC1 = 1; 440 { 441 __delay_us(190); 442 } 443 LATCbits.LATC1 = 0; 444 for(b=1; b<=47; b++) 445 { 446 __delay_us(400); 447 } 448 } 449 __delay_ms(200); 450 for(k=0; k<45; k++) 451 { 452 LATCbits.LATC0 = 1; 453 { 454 __delay_us(190); 455 } 456 LATCbits.LATC0 = 0; 457 for(b=1; b<=47; b++) 458 { 459 __delay_us(400); 460 } 461 } 462 __delay_ms(200); 463 464 return; 465 } 466 467 void Filter_Close() 468 { 469 int k, b; 470 471 for(k=0; k<45; k++) 472 { 473 LATCbits.LATC2 = 1; 474 { 475 __delay_us(20); 476 } 477 LATCbits.LATC2 = 0; 478 for(b=1; b<=39; b++) 479 { 480 __delay_us(500); 481 } 482 } 483 __delay_ms(200); 484 for(k=0; k<45; k++) 485 { 486 LATCbits.LATC1 = 1; 487 { 488 __delay_us(20); 489 } 490 LATCbits.LATC1 = 0; 491 for(b=1; b<=39; b++) 492 { 493 __delay_us(500); 494 } 495 } 496 __delay_ms(200); 497 for(k=0; k<45; k++) 498 { 499 LATCbits.LATC0 = 1; 500 { 501 __delay_us(20); 502 } 503 LATCbits.LATC0 = 0; 504 for(b=1; b<=39; b++) 505 { 506 __delay_us(500); 507 } 508 } 509 __delay_ms(200); 510 511 return; 512 } 513 514 void SS_UpTo_8000() 515 { 516 int i; 517 518 for(i=1; i<=7; i++) 519 { 520 SpeedUp(); 521 } 522 523 return; 524 } 525 526 void SS_Down_To_500() 527 { 528 int i; 529 530 for(i=1; i<=2; i++) 531 { 532 SpeedDown(); 533 } 534 535 return; 536 } 537 538 void Captor() 539 { 540 LATBbits.LATB6=0; 541 LATBbits.LATB7=0; 542 543 LATBbits.LATB6 = 1; 544 __delay_ms(20); 545 LATBbits.LATB7 = 1; 546 __delay_ms(40); 547 LATBbits.LATB7 = 0; 548 __delay_ms(20); 549 LATBbits.LATB6 = 0; 550 __delay_ms(20); 551 552 return; 553 } 554 555 void SpeedDown() 556 { 557 int i; 558 559 LATBbits.LATB4 = 0; 560 LATBbits.LATB5 = 0; 561 562 for(i=1; i<=4; i++) 563 { 564 LATBbits.LATB4=1; 565 __delay_ms(20); 566 LATBbits.LATB5=1; 567 __delay_ms(20); 568 LATBbits.LATB4=0; 569 __delay_ms(20); 570 LATBbits.LATB5=0; 571 __delay_ms(20); 572 } 573 574 return; 575 } 576 577 void SpeedUp() 578 { 579 int i; 580 581 LATBbits.LATB4 = 0; 582 LATBbits.LATB5 = 0; 583 584 for(i=1; i<=4; i++) 585 { 586 LATBbits.LATB5=1; 587 __delay_ms(20); 588 LATBbits.LATB4=1; 589 __delay_ms(20); 590 LATBbits.LATB5=0; 591 __delay_ms(20); 592 LATBbits.LATB4=0; 593 __delay_ms(20); 594 } 595 596 return; |