'본좌급 분류'에 해당되는 글 168건

  1. 2010.08.16 png 파일을 canvas 를 이용하여 그려보자.
  2. 2010.08.16 다운 받은 소스 어떻게 열 수 있을까?
  3. 2010.08.10 murrine_style_draw_box assertion failed
  4. 2010.08.05 리눅스에서 블루투스를 이용한 시리얼 통신(rfcomm)
  5. 2010.08.03 쿼드... 최소 비용으로 시작해보자!
  6. 2010.08.02 아두이노 - 내장 라이브러리 사용 스테핑 모터 구동 소스.
  7. 2010.08.02 아두이노 - 스테핑 모터 컨트롤러(SLA7062M) 소스
  8. 2010.07.31 추천 RF 모듈 - 코로나 2.4g DSSS V2
  9. 2010.07.31 자작 조종기.. 소스 코드
  10. 2010.07.27 inp 파일 분석석

png 파일을 canvas 를 이용하여 그려보자.

먼저 png 파일을 리소싱한다.

이클립스 상에서 res->drawable 폴더를 만들고
new file 을 통해 리소싱.
폴더 밑에 해당 파일이 인클루딩했는지 확인한다.
이 때에, 잘 포함이 됐다면
gen -> ####.###.### -> R.java 파일 밑에
식별자가 자동으로 생성된다 
R.java 는 이클립스에서 자동으로 만들어주는 파일임을 생각하자.

어쨌든

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int icon=0x7f020000;
        public static final int obj1=0x7f020001;
        public static final int obj2=0x7f020002;
        public static final int tile1=0x7f020003;
        public static final int tile2=0x7f020004;
    }

과 같이 되고... (obj1.png , obj2.png tile1.png tile2.png 네 개의 파일을 리소싱한 상태이다)

이를 Canvas 상에서 불러 쓰기 위해서는

private Bitmap btile1,btile2,bobj1,bobj2;
...
@Override
public void onDraw(Canvas canvas)
{
btile1 = BitmapFactory.decodeResource(r, R.drawable.tile1);
btile2 = BitmapFactory.decodeResource(r, R.drawable.tile2);
bobj1 = BitmapFactory.decodeResource(r, R.drawable.obj1);
bobj2 = BitmapFactory.decodeResource(r, R.drawable.obj2);

canvas.drawBitmap(bobj2,xpos,ypos, null);

}


다운 받은 소스 어떻게 열 수 있을까?

이클립스 상에서 만들어진 안드로이드 프로젝트는 윈도우와 달리 따로 prj 파일 등이 없다.

그렇다면 어떻게 프로젝트를 열 수 있을까?

File -> Import -> General -> Existing Projects into Workspace

를 선택하고 Next 단추를 누르면

Select root directory 를 선택할 수 있다.

이 때에 Browse 를 눌러 소스를 다운 받은 디렉토리를 지정해준다.

murrine_style_draw_box assertion failed

murrine_style_draw_box assertion failed 에러

이클립스를 실행할때 나오는 에러였다.

구글링해보니

/usr/share/themes/Ambiance/gtk-2.0/gtkrc

파일 중

GtkRange::trough-under-steppers = 0 

항목을 찾아

GtkRange::trough-under-steppers = 1

로 수정

구체적으로..

$ cd //usr/share/themes/Ambiance/gtk-2.0

$ sudo vi gtkrc

:/GtkRange: 라고 타이핑 후 엔터

해당 항목까지 자판까지 j,k,l,; 을 써서 이동 후 0 위에 커서가 있을 때 r 키를 치고 1을 쳐준 후에
:wq 라고 타이핑 후 엔터


리눅스에서 블루투스를 이용한 시리얼 통신(rfcomm)


rfcomm bind 0 xx:xx:xx:xx:xx:xx #

xx:.. 는 해당 블루투스 기기의 주소
#은 채널을 의미한다

hcitool scan

주변 블루투스 기기들이 검색될 것이다.
자 리스트에 보이는가.

# sdptool records 주소

이제 /dev/rfcomm0 가 생겼다.

이를 이용해서 이제 시리얼 통신을 하면 된다.

minicom -s
실행시키고
포트 셋업 -> 시리얼 디바이스에 /dev/rfcomm0 을 쳐준다.


쿼드... 최소 비용으로 시작해보자!

쿼드 콥터는 돈이 많이 드는 취미임이 분명합니다.

그럼에도 불구하고 잘 모르고서 이것저것 사다보면 비용이 갑절로 드는 경우가 많습니다.

처음 시작하시는 분에게 중복 투자로 인한 비용적인 손해를 막기 위해서 글을 남겨봅니다.

----------------------------------------------------------------------------------------

메인보드는 diydrone 에서 판매하는 arduinoIMU 가 싸더군요 99달러.
게다가 아두이노IMU는 일반 변속기를 사용합니다. 
6축 센서+atmega328이니 기본은 합니다.

 변속기+모터+배터리 는 하비킹에서 지르세요.
유명한 케찹 모터 11.93달러 x4

하비킹 18~20A 변속기 6.77달러 x4

배터리 2200mA 3셀 25C 9.9달러

프롭은 인터보드에서 파는 정,역피치 2200원 x 4
 (여벌로 몇개 더 사세요. 프롭 금방 해먹습니다 ㅠ.ㅜ)

알루미늄 프레임은, 이곳 카페 돌도르사님에게 구매가능 개당 5천원x4

조종기+수신기는 옵틱6 + 일렉트론6 정도면 충분하며 (PPM 시그널을 뽑을 수 있도록 개조가 용이)

2.4G 조종기를 쓰고 싶다면 비싸지만 쿼드하는 사람은 다 쓴다는 스펙트럼이겠죠?
안테나가 짧아서, 편리합니다. 뭐 아싼도 숏안테나가 있군요.
만약 조종기 + 수신기를 2.4G를 사용하기 위해선 PWM2PPM 보드가 추가로 필요합니다.

다이드론에서 판매하는 스펙트럼 수신기용 보드입니다.(사이즈가 일치해서 컴팩트합니다만 비싸요.) 24.9달러
혹은 인터보드에서 판매하는 것도 있습니다. 29700원

하비킹에서 구매한 배터리용 커넥터가 필요하며 XT60 이라고 합니다. 없으면 아쉬움 5개 한팩 3.49달러

열에 강한 실리콘 와이어도 필요합니다.

아두이노 프로그램 다운로드용 FTDI 케이블 등이 필요합니다.

혹슨 스파크펀에서 파는 FTDI 용 쪽보드도 좋습니다(동일한 기능입니다). 3불 정도 싸지만 배송비가.....

아두이노 - 내장 라이브러리 사용 스테핑 모터 구동 소스.

왜인지 몰라도 탈조가 있다
마찬가지로 GND로 풀다운된 4개의 스위치에 의해 동작한다.
회로도는 아두이노 홈피에 나온 회로도를 이용


풀브릿지 칩은손쉽게 구할 수 있는 모터 구동용 칩 L298N 을 사용하자.
결선은 소스를 참조.

#include <Stepper.h>

#define    _DEBUG_PRINT_

#define    EN_PIN         (3)
#define    LED_PIN        (13)
#define    MOTOR_INPUT1_PIN      (5)
#define    MOTOR_INPUT2_PIN      (4)
#define    MOTOR_INPUT3_PIN      (6)
#define    MOTOR_INPUT4_PIN      (7)
#define    KEY1_PIN          (10)
#define    KEY2_PIN          (11)
#define    KEY3_PIN          (12)
#define    KEY4_PIN          (9)

const int analogInPin = 0;  // Analog input pin that the potentiometer is attached to

int sensorValue = 0;        // value read from the pot
Stepper step1 = Stepper(200,MOTOR_INPUT1_PIN,MOTOR_INPUT2_PIN,MOTOR_INPUT3_PIN,MOTOR_INPUT4_PIN);
short output = 0;
void setup() {
  // initialize serial communications at 9600 bps:
  pinMode(EN_PIN, OUTPUT);     
  pinMode(LED_PIN, OUTPUT);
  
  pinMode(KEY1_PIN,INPUT);
  pinMode(KEY2_PIN,INPUT);
  pinMode(KEY3_PIN,INPUT);
  pinMode(KEY4_PIN,INPUT);

  #ifdef _DEBUG_PRINT_
  Serial.begin(9600); 
  Serial.println("Start step motor contorller ver 0.1 (made by Kim Hyuk)");
  #endif // _DEBUG_PRINT_
}

int outputValue;
unsigned long  t;

int speed_table1[] = {
  10,20,30,40,50,60,70,80,90,100,      //20
  100,100,100,100,100,100,100,100,100,100, 
  100,100,100,100,100,100,100,100,100,100, 
  100,100,100,100,100,100,100,100,100,100, 
  100,100,100,100,100,100,100,100,100,100, 

  100,100,100,100,100,100,100,100,100,100, 
  100,100,100,100,100,100,100,100,100,100, 
  100,100,100,100,100,100,100,100,100,100, 
  100,100,100,100,100,100,100,100,100,100, 
  100,90,80,70,60,50,40,30,20,10};          // 200
  
void loop() {
   uint8_t i;
  // read the analog in value:
  t = millis();
  
  if(t % 500 > 200) digitalWrite(LED_PIN,LOW);
  else if(t % 500 < 200) digitalWrite(LED_PIN,HIGH);
  
  if(digitalRead(KEY1_PIN)) { // defaut == 0;
  #ifdef _DEBUG_PRINT_
    Serial.println("Key 1");
  #endif // _DEBUG_PRINT_
    digitalWrite(EN_PIN, HIGH);
    step1.setSpeed(100);
    step1.step(100);
  } else if(digitalRead(KEY2_PIN)) {
  #ifdef _DEBUG_PRINT_
    Serial.println("Key 2");
  #endif // _DEBUG_PRINT_
    digitalWrite(EN_PIN, HIGH);
    for(i =0; i< 100;i++) {
      step1.setSpeed(speed_table1[i]);
      step1.step(2);
    }
  } else if(digitalRead(KEY3_PIN)) {
  #ifdef _DEBUG_PRINT_
    Serial.println("Key 3");
  #endif // _DEBUG_PRINT_
    digitalWrite(EN_PIN, HIGH);
    for(i =0; i< 100;i++) {
      step1.setSpeed(speed_table1[i]);
      step1.step(-2);
    }
  } else if(digitalRead(KEY4_PIN)) {
  #ifdef _DEBUG_PRINT_
    Serial.println("Key 4");
  #endif // _DEBUG_PRINT_
    digitalWrite(EN_PIN, HIGH);
    step1.setSpeed(100);
    step1.step(-100);
  } else {
    digitalWrite(EN_PIN, LOW);
  }
}

아두이노 - 스테핑 모터 컨트롤러(SLA7062M) 소스

간단하게..

// SLA7260 DATASHEET , 11page 회로도와 동일하게 구성
// 각각의 핀 연결은 다음과 같다.

#define  MOPIN      (7)
#define  M1PIN      (6)
#define  M2PIN      (2)
#define  SYNCPIN    (8)
#define  CWPIN      (4)
#define  CLKPIN      (3)
#define  RSTPIN      (5)
#define  ENPIN      (13)

// 4개의 택스위치를 연결한다. 평상시 vdd로 풀업되어 있다.

#define  INPUT1  (9)    // TACK SWTICH INPUT
#define  INPUT2  (10)
#define  INPUT3  (11)
#define  INPUT4  (12)

void setup()
{
  pinMode(MOPIN,INPUT);
  pinMode(M1PIN,OUTPUT);
  pinMode(M2PIN,OUTPUT);
  pinMode(CWPIN,OUTPUT);
  pinMode(CLKPIN,OUTPUT);
  pinMode(SYNCPIN,OUTPUT);
  pinMode(ENPIN,OUTPUT);
  pinMode(INPUT1,INPUT);
  pinMode(INPUT1,INPUT);
  pinMode(INPUT1,INPUT);
  pinMode(INPUT1,INPUT);
  pinMode(RSTPIN,OUTPUT);
  
  digitalWrite(M1PIN,LOW);    // 1/16 step
  digitalWrite(M2PIN,LOW);
  
  digitalWrite(SYNCPIN,HIGH);    // sync mode
  digitalWrite(RSTPIN,LOW);
  Serial.begin(9600);
  Serial.println("SLA7206M controller start..(made by Kim H)");
}

int steps[] = {
  200,190,180,170,160,150,140,130,120,110,
  100,90,80,70,60,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,

  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,

  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,

  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,50,50,50,50,50,
  50,50,50,50,50,60,70,80,90,100,
  110,120,130,140,150,160,170,180,190,200,
};


int steps2[] = {
  200,190,180,170,160,150,140,130,120,110,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,

  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,

  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,

  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  100,100,100,100,100,100,100,100,100,100,
  110,120,130,140,150,160,170,180,190,200,
};


void loop()
{
  int i,j;
  if(digitalRead(INPUT1) == 0) {
    Serial.println("Input1 key..");
    digitalWrite(ENPIN,HIGH);
    digitalWrite(CWPIN,HIGH);
    for(i = 0;i < 200;i++) {
      for(j = 0; j < 16;j++) {
        digitalWrite(CLKPIN,HIGH);
        delayMicroseconds(steps[i]);
        digitalWrite(CLKPIN,LOW);
        delayMicroseconds(steps[i]);
      }
    }
  } else if(digitalRead(INPUT2) == 0) {
    Serial.println("Input2 key..");
    digitalWrite(ENPIN,HIGH);
    digitalWrite(CWPIN,HIGH);
    for(i = 0;i < 200;i++) {
      for(j = 0; j < 16;j++) {
        digitalWrite(CLKPIN,HIGH);
        delayMicroseconds(steps2[i]);
        digitalWrite(CLKPIN,LOW);
        delayMicroseconds(steps2[i]);
      }
    }
    
  } else if(digitalRead(INPUT3) == 0) {
    Serial.println("Input3 key..");
    digitalWrite(ENPIN,HIGH);
    digitalWrite(CWPIN,LOW);
    for(i = 0;i < 200;i++) {
      for(j = 0; j < 16;j++) {
        digitalWrite(CLKPIN,HIGH);
        delayMicroseconds(steps[i]);
        digitalWrite(CLKPIN,LOW);
        delayMicroseconds(steps[i]);
      }
    }
    
  } else if(digitalRead(INPUT4) == 0) {
    Serial.println("Input4 key..");
    digitalWrite(ENPIN,HIGH);
    digitalWrite(CWPIN,LOW);
    for(i = 0;i < 200;i++) {
      for(j = 0; j < 16;j++) {
        digitalWrite(CLKPIN,HIGH);
        delayMicroseconds(steps2[i]);
        digitalWrite(CLKPIN,LOW);
        delayMicroseconds(steps2[i]);
      }
    }
  } else {
    digitalWrite(ENPIN,LOW);
  }    
}


추천 RF 모듈 - 코로나 2.4g DSSS V2



2.4G 주파수! 8채널 수신기 및 안테나와 함께 가격은 단돈 29 달러.(와! 싸다!)

 

이 모듈은 7pin 의 in-out 을 갖는다.

 

바인딩용 4채널 커넥터 : led1, led2, tack-switch,gnd

ppm 용 3채널 커넥터 : vcc,gnd,ppm

 

다만 전원은 대략 리폴 3셀을 물려주면 되며,

ppm 레벨 또한 전원 레벨과 같아야한다.

다시 말해 1 : vcc, 0 : gnd 로 넣어줘야 한다.

 

어쨌든 가장 복잡한 부분이 쉽게 해결되었다.

 

다만 모듈에 안테나를 땜질해줘야 하므로 적어도 인두와 땜납이 필요하며 간단한 인두질은 할 줄 알아야 하겠다.

 

자작 조종기.. 소스 코드

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>

#define sbi(PORT,BIT)  PORT|=_BV(BIT)  //set bit
#define cbi(PORT,BIT)  PORT&=~_BV(BIT)  //clear bit



#include "lcd.h"

#define PARAM_LENGTH  4
typedef struct _eepromdata {
int8_t trim1;
int8_t trim2;
int8_t rev1;
int8_t rev2;
} EEP_data;

volatile EEP_data g_param;


volatile uint8_t g_timer = 0;

#define CHANNEL_NUM 8




#define  MINIMUM_VOLT  100



volatile uint8_t send_state = 0;
volatile uint16_t ch[CHANNEL_NUM];
volatile int16_t ch1,ch2,ch3;


volatile uint8_t g_model = 1;
volatile uint8_t g_buff1[10] = "M1,00.0V ";
volatile uint8_t g_buff2[10] = "000v000v ";



void DefaultParam()
{
g_param.trim1 = 0;
g_param.trim2 = 0;
g_param.rev1 = 0;
g_param.rev2 = 0;
}

volatile uint16_t g_volt = 37;

#define MAX_VAL (200)
#define MIN_VAL (-200)

void ReadADC()
{
uint16_t tmp;

int16_t t;
int16_t tmp1;
int16_t tmp2;
int16_t tmp3;

// control1, control2
ADMUX = 0x40;
ADCSR |= 0x40;
while((ADCSR&0x10)== 0x00);
ADCSR |= 0x10;
tmp = (ADCL+(ADCH<<8));
tmp1 = (tmp>>1) - 255 + g_param.trim1*2;




ADMUX = 0x41;
ADCSR |= 0x40;
while((ADCSR&0x10)== 0x00);
ADCSR |= 0x10;
tmp = (ADCL+(ADCH<<8));
tmp2 = (tmp>>1) - 255 + g_param.trim2*2;



ADMUX = 0x42;
ADCSR |= 0x40;
while((ADCSR&0x10)== 0x00);
ADCSR |= 0x10;
tmp = (ADCL+(ADCH<<8));
tmp3 = (tmp>>1)  - 255;




ADMUX = 0x43; // WATCH power
ADCSR |= 0x40;
while((ADCSR&0x10)== 0x00);
ADCSR |= 0x10;
tmp = (ADCL+(ADCH<<8));
g_volt = tmp /100 * 115 / 6;


if(g_model == 4) { // elevon 
t = tmp1 + tmp2;
if(t > MAX_VAL) ch1 = MAX_VAL;
else if(t < MIN_VAL) ch1 = MIN_VAL;
else ch1 = t;

t = tmp1 - tmp2;
if(t > MAX_VAL) ch2 = MAX_VAL;
else if(t < MIN_VAL) ch2 = MIN_VAL;
else ch2 = t;


} else {
if(tmp1 > MAX_VAL) ch1 = MAX_VAL;
else if(tmp1 < MIN_VAL) ch1 = MIN_VAL;
else ch1 = tmp1;

if(tmp2 > MAX_VAL) ch2 = MAX_VAL;
else if(tmp2 < MIN_VAL) ch2 = MIN_VAL;
else ch2 = tmp2;

}

if(g_param.rev1) ch1 = ch1*(-1);
if(g_param.rev2) ch2 = ch2 * (-1);


ch3 = tmp3;


ch[0] = 0xffff - 1500 + (ch1) * 3;
ch[1] = 0xffff - 1500 + (ch2) * 3;
ch[2] = 0xffff - 1500 + (ch3) * 3;

ch[3] = 0xffff - 1500;
ch[4] = 0xffff - 1500;
ch[5] = 0xffff - 1500;
ch[6] = 0xffff - 1500;
ch[7] = 0xffff - 1500;
}

#define TIMER3_ON sbi(ETIMSK,TOIE3)
#define  TIMER3_OFF cbi(ETIMSK,TOIE3)



SIGNAL(SIG_OVERFLOW1)
{
asm volatile("cli"); 
TCNT1 = 0xffff - 20000; // 20ms
send_state = 0;
TCNT3 = 0xfffe; // imediately
TIMER3_ON;
PORTA = 1;

asm volatile("sei"); 

if(g_timer) g_timer--;
}




SIGNAL(SIG_OVERFLOW3)
{
TCNT3 = ch[send_state];
PORTA = 0;
delay_us(50); // wait 100us
PORTA = 1;

send_state++;
if(send_state == CHANNEL_NUM) {
send_state = 0;
TIMER3_OFF;
}
}





void DisplayInfo()
{
g_buff1[1] = g_model + '0';

g_buff1[3] = g_volt/100 + '0';
g_volt = g_volt % 100;
g_buff1[4] = g_volt/10 + '0';
g_buff1[6] = g_volt%10 + '0';
LCD_puts(LCD_LINE1,(uint8_t*)g_buff1);

g_buff2[0] = ch1/100 + '0';
ch1 = ch1 % 100;
g_buff2[1] = ch1/10 + '0';
g_buff2[2] = ch1%10 + '0';

g_buff2[4] = ch2/100 + '0';
ch2 = ch2 % 100;
g_buff2[5] = ch2/10 + '0';
g_buff2[6] = ch2%10 + '0';
LCD_puts(LCD_LINE2,(uint8_t*)g_buff2);
}


volatile uint8_t g_buff3[10] = "CHN INFO ";
volatile uint8_t g_buff4[10] = "1N T:    ";


void DisplayChannel(int ch)
{
int8_t t;
if(ch == 1) {
g_buff4[0] = '1';
if(g_param.rev1) g_buff4[1] = 'R';
else g_buff4[1] = 'N';

if(g_param.trim1 < 0) {
g_buff4[5] = '-';
t = g_param.trim1 * -1;
} else {
g_buff4[5] = ' ';
t = g_param.trim1;
}

} else {
g_buff4[0] = '2';
if(g_param.rev2) g_buff4[1] = 'R';
else g_buff4[1] = 'N';

if(g_param.trim2 < 0) {
g_buff4[5] = '-';
t = g_param.trim2 * -1;
} else {
g_buff4[5] = ' ';
t = g_param.trim2;
}

}

g_buff4[6] = t/10 + '0';
g_buff4[7] = t%10 + '0';
LCD_puts(LCD_LINE1,(uint8_t*)g_buff3);
LCD_puts(LCD_LINE2,(uint8_t*)g_buff4);
}



int main()
{
uint8_t button;
asm volatile("cli"); 


sbi(TCCR1B,CS11); // clk/8 -> 1Mhz 1us timer..
sbi(TCCR3B,CS31);



TIMSK = 0X04; // timer1, overfow

DDRA = 0x01;
DDRB = 0Xff; // output for alarm
DDRC = 0Xff;
DDRG = 0x07;
DDRD = 0x2;
DDRE = 0x00;
PORTA = 0x1;

ADCSR = 0X84; 

LCD_init();
LCD_puts(LCD_LINE1,(uint8_t*)"3Ch v0.2 ");
LCD_puts(LCD_LINE2,(uint8_t*)"Kim Hyuk ");
delay_ms(250);
// EIFR |= 0X03;

g_model = eeprom_read_byte((void*)0);

if((uint8_t)g_model == 0xff) { // never read before..
g_model = 1;
}

if((PINE & 0Xf0) == 0x10){ // setup model 1
g_model = 1;
eeprom_write_byte((uint8_t*)0,g_model);
while((PINE & 0Xf0) == 0); // wait until button release..
}else if((PINE & 0Xf0) == 0x20)  { // 
g_model = 2;
eeprom_write_byte((uint8_t*)0,g_model);
while((PINE & 0Xf0) == 0); // wait until button release..
}else if((PINE & 0Xf0) == 0x40)  { // 
g_model = 3;
eeprom_write_byte((uint8_t*)0,g_model);
while((PINE & 0Xf0) == 0); // wait until button release..
}else if((PINE & 0Xf0) == 0x80)  { //  elevon mixing
g_model = 4;
eeprom_write_byte((uint8_t*)0,g_model);
while((PINE & 0Xf0) == 0); // wait until button release..
}




eeprom_read_block((void*)&g_param,(void*)(g_model*PARAM_LENGTH),PARAM_LENGTH);

if((uint8_t)(g_param.trim1) == 0xff) DefaultParam(); // never read before



ReadADC();
DisplayInfo();

asm volatile("sei");


TCNT1 = 0xffff - 20000; // 50Hz


while(1) { // start routine..

ReadADC();

if(PINE&0xf0) { // memorize when button pushed..
button |= (PINE & 0xf0);


} else { // handle when button released..

if(button != 0) {
if((button & 0xf0) == 0x10) { // button1
g_param.trim1++;
if(g_param.trim1 > 40) g_param.trim1 = 40; // MAXIMUM
DisplayChannel(1);
} else if((button & 0xf0 )== 0x20) { // BUTTTON 2
g_param.trim1--;
if(g_param.trim1 < -40) g_param.trim1 = -40; // MINIMUM
DisplayChannel(1);
} else if((button & 0xf0) == 0x40) { // BUTTON 3
g_param.trim2++;
if(g_param.trim2 > 40) g_param.trim2 = 40;
DisplayChannel(2);
} else if((button & 0xf0) == 0x80) { // BUTTON 3
g_param.trim2--;
if(g_param.trim2 < -40) g_param.trim2 = -40;
DisplayChannel(2);

} else if((button & 0xf0) == 0x30) { // both button 1,2
g_param.rev1 = 1 - g_param.rev1;
DisplayChannel(1);

} else if((button & 0xf0) == 0xC0) { // both button 3,4
g_param.rev2 = 1 - g_param.rev2;
DisplayChannel(2);
}

button = 0;
g_timer = 100; // show during 3 sec..
// eeprom_write_block((void*)&g_param,(void*)(g_model*PARAM_LENGTH),PARAM_LENGTH);

}

if(g_volt < MINIMUM_VOLT) { // low batter allert
if(g_timer == 0) {
cbi(PORTB,3); // turn on alaram during 1 sec
} else if(g_timer == 50) {
sbi(PORTB,3); // turn off alaram during 1 sec
}
}

if(g_timer == 1) {
DisplayInfo();
}
}
}
return 0;
}

inp 파일 분석석

nsp : 가스종류
nc
nc2p
dt[s]
length[m]
area[m^2]
Epsilonr
B[T]
PSI[D] 

rhoback[C/m^3]
backj[Amp/m^2]
dde
extR[Ohm]
extL[H]
extC[F]
q0

dcramped - 1 or 0 (소스가 램프파형인지 여부)
source - C or I (전압 소스 혹은 전류 소스 선택)
dc[V|amp] - dc 성분의 전압 혹은 전류값
dcramped[V/s] - (dc 램프 파형일때 초당 기울기)
ac[V|amp] - ac 성분의 전압 혹은 전류값
f0[Hz] - ac 성분의 주파수
theta0

prev 1 ··· 10 11 12 13 14 15 16 17 next