QC対応USBから9Vを取り出す(1)
Quick Charge 2.0の充電器を持っていたので、ScansnapやTEPRAといった
9V系のアクセサリを直接USBから駆動するための回路を検討した。
こちらの方がすでに実装しているので、PIC用に回路図をアレンジする。
PortをHiZにせず、1/0にて、0.6Vと3.3Vを生成するようにする。
レギュレータU1は、9V出力後もマイコンに過電圧がかからないように、
ドロップアウトの少ないものを選定する。
R1-R3は入手しやすい抵抗値で仮決め(公差大丈夫か?)
PICにソフト実装。はじめてXC8でコーディング。といってもたいした事をしてるでもなく。
// PIC12F509 Configuration Bit Settings // CONFIG #pragma config OSC = IntRC // Oscillator Selection bits (internal RC oscillator) #pragma config WDT = OFF // Watchdog Timer Enable bit (WDT enabled) #pragma config CP = OFF // Code Protection bit (Code protection off) #pragma config MCLRE = OFF // GP3/MCLR Pin Function Select bit (GP3/MCLR pin function is digital input, MCLR internally tied to VDD) // #pragma config statements should precede project file includes. // Use project enums instead of #define for ON and OFF. #include <xc.h> #include <pic.h> #include <stdio.h> #include <stdlib.h> #define _XTAL_FREQ 4000000 /* *R1 2.0kohm connect to D- and GND *R2 1.2kohm connect to D- and GP4 *R3 5.6kohm connect to D- and GP0 *R4 2.0kohm connect to D+ and GND *R5 1.2kohm connect to D+ and GP5 *R6 5.6kohm connect to D+ and GP1 * */ main() { TRIS=0x00; GPIO=0x00; __delay_ms(100) ; GP0=1; GP1=1; GP4=0; GP5=0; __delay_ms(1250) ; GP0=1; GP1=0; GP4=0; GP5=0; __delay_ms(1) ; GP0=1; GP1=1; GP4=1; GP5=0; __delay_ms(100) ; exit(0);
12F509に書き込み実施し、タイミングを確認。
うまくいってそう。