liveinjeonju
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
liveinjeonju [2012/04/29 09:19] – created donghee | liveinjeonju [2018/07/18 14:10] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | + | < |
- | # 하드웨어 만들기 | + | # 예상지역 |
- | | + | |
- | - EPS | + | |
- | - PAYLOAD | + | |
- | - 솔라셀 | + | |
- | # 소프트웨어(주요기능) | + | # 완주고산 |
+ | - 고산면 살기가 좋음 | ||
- | 1. EPS 제어(충전, | + | # 서신동 |
- | 1. RF에서 RX로 신호를 받아서 메시지 등록, | + | - 전주의 |
- | 1. 다른칩 죽었는지 서로 감시 | + | |
- | 1. 시간되면 LED 깜박임 | + | |
- | 1. 인공위성정보 비콘으로 보냄 | + | |
- | 1. 전체 reset 하는 command. | + | |
- | 1. 인자 업데이트 | + | |
- | #### RF/BEACON | ||
- | 1. 비콘의 TX | ||
- | - 입력: 배터리 레벨, VBUS, 솔라패널 전류, 베터리 충전 여부, COMS, PAYLOAD 모듈동작상태, | ||
- | - 처리: RF칩에서 받아 들이는 신호로 만들기. | ||
- | - 출력: RF칩에 신호보내기. | ||
- | |||
- | #### RF/COMS | ||
- | 1. COMS RX | ||
- | - 입력: RF칩에서 신호 받음 | ||
- | - 처리: 입력 받은 신호를 I2C로 가공 | ||
- | - 출력: OBC에 I2C로 받은 신호 전달.(예약 메시지) | ||
- | 1. OBC 감시 | ||
- | - 입력: OBC에서 신호를 받는다. | ||
- | - 처리: OBC에 신호가 있는지 없는지 체크 | ||
- | - 출력: 입력 신호가 없으면 OBC에 리셋을 날려줌. | ||
- | |||
- | #### OBC | ||
- | 1. EPS 전원제어 (베터리, 수퍼캡 충전 방전) | ||
- | - 입력: 베터리 전압, 베터리 충전상태, | ||
- | - 처리: | ||
- | |||
- | 1. 안테나 deployment 실행 | ||
- | - 처리: 20분이 지나면 안타나 deployment 핀 신호 인가 | ||
- | - 출력: deployment 완료 플래그 설정 (플래쉬메모리) | ||
- | |||
- | 1. COMS, BEACON, PAYLOAD 감시 | ||
- | |||
- | 1. 메시지 스케쥴링 예약: COMS RX에서 메시지 받기 | ||
- | - 입력: 예약 메시지 신호 받기 | ||
- | - 처리: 시간을 파싱하여, | ||
- | - 출력: 예약 완료 메시지 RX에 보내기 | ||
- | 1. 메시지 예약 실행 | ||
- | - 입력: 시간, 슈퍼캡이 충전 되어 있는가?, 밤/낮, 회전상태 | ||
- | - 처리: 시간 보면서 예약 테이블에 스케쥴링된 메시지 실행 | ||
- | - 출력: PAYLOAD에 I2C로 메시지 보내기 | ||
- | 1. 메시지 예약 삭제 | ||
- | |||
- | #### LED: 모스코드 | ||
- | 1. I2C로 받은 메시지를 LED 키기. | ||
- | - 입력: OBC에서 받은 메시지 | ||
- | - 처리: I2C로 받은 메시지를 모스 코드로 바꾼다. | ||
- | - 출력: 모스신호에 따라 LED 키기 | ||
- | 2. PWM 으로 LED 제어 | ||
- | - ? | ||
- | |||
- | ## 코드 | ||
- | morse, uart0 | ||
- | |||
- | // | ||
- | // MSP-FET430P140 Demo - USART1, Ultra-Low Pwr UART 9600 Echo ISR, 32kHz ACLK | ||
- | // | ||
- | // Description: | ||
- | // USART1 RX interrupt triggers TX Echo. | ||
- | // ACLK = UCLK1 = LFXT1 = 32768, MCLK = SMCLK = DCO~ 800k | ||
- | // Baud rate divider with 32768hz XTAL @9600 = 32768Hz/ | ||
- | // //* An external watch crystal is required on XIN XOUT for ACLK *// | ||
- | // | ||
- | // | ||
- | // MSP430F149 | ||
- | // ----------------- | ||
- | // /|\| XIN|- | ||
- | // | | | 32kHz | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | // M. Buccini | ||
- | // Texas Instruments Inc. | ||
- | // Feb 2005 | ||
- | // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A | ||
- | // | ||
- | |||
- | # | ||
- | #include " | ||
- | |||
- | char message[255]; | ||
- | uint8_t step = 0; | ||
- | uint8_t sending = 0; | ||
- | |||
- | void main(void) | ||
- | { | ||
- | volatile unsigned int i; | ||
- | WDTCTL = WDTPW + WDTHOLD; | ||
- | P6DIR |= 0x01; | ||
- | |||
- | WDTCTL = WDTPW + WDTHOLD; | ||
- | P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD | ||
- | ME1|= UTXE0 + URXE0; | ||
- | UCTL0 |= CHAR; // 8-bit character | ||
- | UTCTL0 |= SSEL0; | ||
- | UBR00 = 0x03; // 32k/9600 - 3.41 | ||
- | UBR10 = 0x00; // | ||
- | UMCTL0 = 0x4A; // Modulation | ||
- | UCTL0 &= ~SWRST; | ||
- | IE1 |= URXIE0; | ||
- | |||
- | // _BIS_SR(LPM0_bits + GIE); // Enter LPM3 w/ interrupt | ||
- | _EINT(); | ||
- | |||
- | while (1) { | ||
- | if (sending == 1) { | ||
- | for(i=0; i < step;i++ ) { | ||
- | ascii(message[i]); | ||
- | } | ||
- | step=0; | ||
- | sending=0; | ||
- | } | ||
- | } | ||
- | } | ||
- | |||
- | #pragma vector=USART0RX_VECTOR | ||
- | __interrupt void usart0_rx (void) | ||
- | { | ||
- | |||
- | while (!(IFG1 & UTXIFG0)); | ||
- | TXBUF0 = RXBUF0; | ||
- | message[step] = RXBUF0; | ||
- | step++; | ||
- | if (RXBUF0 == 13) // CR | ||
- | { | ||
- | P6OUT ^= 0x01; | ||
- | sending = 1; | ||
- | } | ||
- | } | ||
- | |||
- | |||
- | |||
- | #include " | ||
- | |||
- | //uint8_t done = 0b10000000; | ||
- | uint8_t done = 0x80; | ||
- | |||
- | uint8_t output_pin; | ||
- | |||
- | void delay(void) | ||
- | { | ||
- | volatile unsigned int i; | ||
- | i = 15000; | ||
- | do (i--); | ||
- | while (i != 0); | ||
- | } | ||
- | |||
- | void mark(uint8_t t) | ||
- | { | ||
- | volatile unsigned int i; | ||
- | for(i = 0; i < t; i++) | ||
- | { | ||
- | P6OUT &= ~0x01; | ||
- | delay(); | ||
- | } | ||
- | P6OUT |= 0x01; // Turn Off | ||
- | delay(); | ||
- | } | ||
- | |||
- | void space(uint8_t t) | ||
- | { | ||
- | volatile unsigned int i; | ||
- | for(i = 0; i < t; i++) | ||
- | { | ||
- | P6OUT |= 0x01; | ||
- | delay(); | ||
- | } | ||
- | } | ||
- | |||
- | void morse(uint8_t m) | ||
- | { | ||
- | while (m != done) { | ||
- | | ||
- | | ||
- | m = m << 1; | ||
- | } | ||
- | space(3); | ||
- | } | ||
- | |||
- | |||
- | void ascii(char c) { | ||
- | uint8_t number_code[] = { | ||
- | // 0b11111100, | ||
- | // 0b10000100, | ||
- | 0xfc, 0x7c, 0x3c, 0x1c, 0xc, 0x4, 0x84, 0xc4, 0xe4, 0xf4 | ||
- | }; | ||
- | |||
- | uint8_t alphabet_code[] = { | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | 0x60, 0x88, 0xa8, 0x90, 0x40, 0x28, 0xd0, 0x8, 0x20, 0x78, 0xb0, 0x48, 0xe0, 0xa0, 0xf0, 0x68, 0xd8, 0x50, 0x10, 0xc0, 0x30, 0x18, 0x70, 0x98, 0xb8, 0xc8 | ||
- | }; | ||
- | |||
- | if (c >= ' | ||
- | morse(number_code[c- ' | ||
- | } else if (c >= ' | ||
- | morse(alphabet_code[c - ' | ||
- | } else if (c == ' ') { | ||
- | space(7); | ||
- | } else { | ||
- | morse(done); | ||
- | } | ||
- | } | ||
- | |||
- | ---------- | ||
- | #### 타이머 | ||
- | **watchdog timer** | ||
- | |||
- | # | ||
- | |||
- | void main(void) | ||
- | { | ||
- | WDTCTL = WDT_MDLY_32; | ||
- | IE1 |= WDTIE; | ||
- | P6DIR |= 0x01; // Set P1.0 to output direction | ||
- | |||
- | _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt | ||
- | } | ||
- | |||
- | // Watchdog Timer interrupt service routine | ||
- | #pragma vector=WDT_VECTOR | ||
- | __interrupt void watchdog_timer(void) | ||
- | { | ||
- | P6OUT ^= 0x01; // Toggle P1.0 using exclusive-OR | ||
- | } | ||
- | |||
- | |||
- | **그냥 타이머** | ||
- | # | ||
- | |||
- | void main(void) | ||
- | { | ||
- | WDTCTL = WDTPW + WDTHOLD; | ||
- | P6DIR |= 0x01; // P1.0 output | ||
- | CCTL0 = CCIE; // CCR0 interrupt enabled | ||
- | CCR0 = 50000; | ||
- | TACTL = TASSEL_2 + MC_2; // SMCLK, contmode | ||
- | |||
- | _BIS_SR(LPM0_bits + GIE); // Enter LPM0 w/ interrupt | ||
- | } | ||
- | |||
- | // Timer A0 interrupt service routine | ||
- | #pragma vector=TIMERA0_VECTOR | ||
- | __interrupt void Timer_A (void) | ||
- | { | ||
- | P6OUT ^= 0x01; // Toggle P1.0 | ||
- | CCR0 += 50000; | ||
- | } | ||
- | |||
- | PWM | ||
- | |||
- | // | ||
- | // MSP-FET430P140 Demo - Timer_A, PWM TA1-2, Up Mode, 32kHz ACLK | ||
- | // | ||
- | // Description: | ||
- | // Timer_A configured for up mode. The value in CCR0, 512-1, defines the PWM | ||
- | // period and the values in CCR1 and CCR2 the PWM duty cycles. Using 32kHz | ||
- | // ACLK as TACLK, the timer period is 15.6ms with a 75% duty cycle on P1.2 | ||
- | // and 25% on P1.3. Normal operating mode is LPM3. | ||
- | // ACLK = TACLK = LFXT1 = 32768Hz, MCLK = default DCO ~800kHz. | ||
- | // //* External watch crystal on XIN XOUT is required for ACLK *// | ||
- | // | ||
- | // | ||
- | // ----------------- | ||
- | // /|\| XIN|- | ||
- | // | | | 32kHz | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | // | ||
- | // M. Buccini | ||
- | // Texas Instruments Inc. | ||
- | // Feb 2005 | ||
- | // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A | ||
- | // | ||
- | |||
- | # | ||
- | |||
- | void main(void) | ||
- | { | ||
- | WDTCTL = WDTPW + WDTHOLD; | ||
- | P1DIR |= 0x0C; // P1.2 and P1.3 output | ||
- | P1SEL |= 0x0C; // P1.2 and P1.3 TA1/2 otions | ||
- | CCR0 = 512-1; | ||
- | CCTL1 = OUTMOD_7; | ||
- | CCR1 = 384; // CCR1 PWM duty cycle | ||
- | CCTL2 = OUTMOD_7; | ||
- | CCR2 = 128; // CCR2 PWM duty cycle | ||
- | TACTL = TASSEL_1 + MC_1; // ACLK, up mode | ||
- | |||
- | _BIS_SR(LPM3_bits); | ||
- | } | ||
- | |||
- | |||
- | #### Low power mode (3 or 4) | ||
- | |||
- | |||
- | #### 핀인터럽트 | ||
- | | ||
- | | ||
- | |||
- | external interupt | ||
- | latch up? | ||
- | ---- | ||
- | port 1,2,3 이 가능 . | ||
- | |||
- | |||
- | #### ADC | ||
- | // | ||
- | // MSP-FET430P140 Demo - ADC12, Sample A0, Set P1.0 if A0 > 0.5*AVcc | ||
- | // | ||
- | // Description: | ||
- | // Software sets ADC10SC to start sample and conversion - ADC12SC | ||
- | // automatically cleared at EOC. ADC12 internal oscillator times sample (16x) | ||
- | // and conversion. In Mainloop MSP430 waits in LPM0 to save power until ADC12 | ||
- | // conversion complete, ADC12_ISR will force exit from LPM0 in Mainloop on | ||
- | // reti. If A0 > 0.5*AVcc, P1.0 set, else reset. | ||
- | // | ||
- | // MSP430F149 | ||
- | // | ||
- | // / | ||
- | // | | | | ||
- | // --|RST | ||
- | // | | | ||
- | // Vin--> | ||
- | // | ||
- | // M. Buccini | ||
- | // Texas Instruments Inc. | ||
- | // Feb 2005 | ||
- | // Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.21A | ||
- | // | ||
- | |||
- | # | ||
- | |||
- | void main(void) | ||
- | { | ||
- | WDTCTL = WDTPW + WDTHOLD; | ||
- | ADC12CTL0 = SHT0_2 + ADC12ON; | ||
- | ADC12CTL1 = SHP; // Use sampling timer | ||
- | ADC12IE = 0x01; // Enable interrupt | ||
- | ADC12CTL0 |= ENC; // Conversion enabled | ||
- | P6SEL |= 0x02; // P6.0 ADC option select | ||
- | P6DIR |= 0x01; // P1.0 output | ||
- | |||
- | for (;;) | ||
- | { | ||
- | ADC12CTL0 |= ADC12SC; | ||
- | _BIS_SR(CPUOFF + GIE); // LPM0, ADC12_ISR will force exit | ||
- | } | ||
- | } | ||
- | |||
- | // ADC12 interrupt service routine | ||
- | #pragma vector=ADC12_VECTOR | ||
- | __interrupt void ADC12_ISR (void) | ||
- | { | ||
- | if (ADC12MEM0 < 0x7FF) | ||
- | P6OUT &= ~0x01; | ||
- | else | ||
- | P6OUT |= 0x01; // Set P1.0 LED on | ||
- | _BIC_SR_IRQ(CPUOFF); | ||
- | } | ||
- | |||
- | #### UART & Serial port | ||
- | // | ||
- | // MSP-FET430F149 Demo - ADC12, Sample A1, Send the level at Serial Port | ||
- | // | ||
- | // Description: | ||
- | // Software | ||
- | // Analog voltage level to the serial port as two bytes. | ||
- | // | ||
- | // | ||
- | // | ||
- | // MSP430F149 | ||
- | // | ||
- | // / | ||
- | // | | | | ||
- | // --|RST | ||
- | // | | | ||
- | // Vin--> | ||
- | // | | | ||
- | // | | ||
- | // | | 9600 - 8N1 | ||
- | // | | ||
- | // | ||
- | // referencedesigner.com | ||
- | // Some of the Original codes are from Texas Instruments | ||
- | // | ||
- | |||
- | # | ||
- | |||
- | unsigned int delay ( unsigned int x) | ||
- | { | ||
- | unsigned int i,j; | ||
- | for (i = 0; i<= x; i++) | ||
- | { | ||
- | for(j=0; | ||
- | } | ||
- | return 0; | ||
- | } | ||
- | |||
- | |||
- | void main(void) | ||
- | { | ||
- | |||
- | WDTCTL = WDTPW + WDTHOLD; | ||
- | ADC12CTL0 = SHT0_2 + ADC12ON; | ||
- | ADC12CTL1 = SHP; | ||
- | ADC12IE = 0x01; // Enable interrupt | ||
- | ADC12MCTL0 = 0x01 ; | ||
- | ADC12CTL0 |= ENC ; // Conversion enabled | ||
- | P6SEL |= 0x02 ; // P6.1 ADC option select | ||
- | P6DIR |= 0x04; // P6.2 is output for LED | ||
- | |||
- | // Serial Port Settings | ||
- | |||
- | P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD | ||
- | ME1 |= UTXE0 + URXE0; | ||
- | UCTL0 |= CHAR; // 8-bit character | ||
- | UTCTL0 |= SSEL0; | ||
- | UBR00 = 0x03; // 32k/9600 - 3.41 | ||
- | UBR10 = 0x00; // | ||
- | UMCTL0 = 0x4A; // Modulation | ||
- | UCTL0 &= ~SWRST; | ||
- | IE1 |= URXIE0; | ||
- | |||
- | for (;;) | ||
- | { | ||
- | // This should actually happen in a timer interrupt where | ||
- | // we may like to sample only once in, say 1 second | ||
- | delay(500); | ||
- | ADC12CTL0 |= ADC12SC; | ||
- | _BIS_SR(CPUOFF + GIE); // LPM0, ADC12_ISR will force exit | ||
- | } | ||
- | } | ||
- | |||
- | // ADC12 interrupt service routine | ||
- | |||
- | #pragma vector=ADC12_VECTOR | ||
- | __interrupt void ADC12_ISR (void) | ||
- | { | ||
- | unsigned short lResultRSSI ; | ||
- | unsigned char part1, part2; | ||
- | |||
- | if (ADC12MEM0 < 0x7FF) | ||
- | P6OUT &= ~0x04; | ||
- | else | ||
- | P6OUT |= 0x04; // Set P6.2 - LED on | ||
- | _BIC_SR_IRQ(CPUOFF); | ||
- | |||
- | | ||
- | |||
- | part1 = (lResultRSSI & 0x00FF); // lsb | ||
- | part2 = (lResultRSSI & 0xFF00) >> 8; // msb | ||
- | |||
- | while (!(IFG1 & UTXIFG0)); | ||
- | TXBUF0 = part2; // We send MSB first | ||
- | |||
- | while (!(IFG1 & UTXIFG0)); | ||
- | TXBUF0 = part1; | ||
- | } | ||
- | |||
- | |||
- | #### PWM | ||
- | - hardware pwm: http:// | ||
- | - PWM DC Motor Control Using Timer_A of the MSP430: http:// | ||
- | |||
- | #### I2C | ||
- | - EEPROM (메시지, | ||
- | | ||
- | |||
- | #### SPI | ||
- | |||
- | #### 타이머 인터럽트: | ||
- | |||
- | #### pulseIn? RF? | ||
- | |||
- | #### delay 구현 조사 | ||
- | |||
- | static void __inline__ delay(register unsigned int n) | ||
- | { | ||
- | __asm__ __volatile__ ( | ||
- | "1: \n" | ||
- | " dec %[n] \n" | ||
- | " jne 1b \n" | ||
- | : [n] " | ||
- | } | ||
- | |||
- | void delay_ms(unsigned int n) | ||
- | { | ||
- | while (n--) | ||
- | { | ||
- | delay(F_CPU/ | ||
- | } | ||
- | } | ||
- | |||
- | #### RTC | ||
- | Software Realtime Clock | ||
- | http:// | ||
</ | </ |
liveinjeonju.1335691170.txt.gz · Last modified: 2018/07/18 14:09 (external edit)