728x90
반응형

내가 사용하는 코드.

#define FLASH_START_ADDRESS 0x0800FC00
#define FLASH_SAVE_TIME 5000 //5SEC

 

typedef struct
{
uint8_t fan_save; //fan level
uint8_t Heater_save; // bit1 : heater2, bit0 : heater1
uint8_t power_save;
uint8_t auto_save;
int8_t temp1;
int8_t temp2;
_Bool  heater_enable_flag;
sensortypeenum sensor_type;
}flashstruct;

 


void flash_erase(void)
{
uint32_t PageError;
__IO uint32_t data32 = 0, MemoryProgramStatus = 0;
HAL_FLASH_Unlock();

EraseInitStruct.TypeErase = FLASH_TYPEERASE_PAGES;
EraseInitStruct.PageAddress = FLASH_START_ADDRESS;
EraseInitStruct.NbPages = 1;

if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
{
Error_Handler();
}
HAL_FLASH_Lock();
}

void flash_read(void)
{
flashstruct t;
memcpy(&t, (flashstruct*)FLASH_START_ADDRESS, sizeof(t));
memcpy(&flash, &t, sizeof(t));
}


void flash_save_process(void)
{
unsigned int* p_w = (unsigned int*)&flash;
int byte_align = 0;
if (sys.flash_save_count <= FLASH_SAVE_TIME) sys.flash_save_count++;
if (sys.flash_save_count == FLASH_SAVE_TIME)
{
flashstruct x;
memcpy(&x, &flash, sizeof(flash));
flash_read();
if (memcmp(&x, &flash, sizeof(flash)) != NULL)
{
memcpy(&flash, &x, sizeof(x));
if ((sizeof(flash) % 4) > 0) byte_align = 1; //구조체가 64비트 단위가 아닌경우 마지막 떨거지들에 대한 처리
flash_erase();
HAL_FLASH_Unlock();
for (int i = 0; i < sizeof(flash) / 4 + byte_align; i++)
{
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, (FLASH_START_ADDRESS + (i * 4)), p_w[i]);
}

HAL_FLASH_Lock();
}
}
}

 

 

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

다음은 Github copilot이 만든 코드

 

static FLASH_EraseInitTypeDef EraseInitStruct = {0};
flashstruct flash;
static uint32_t flash_save_counter = 0;

void flash_erase(void)
{
    uint32_t PageError;
    HAL_FLASH_Unlock();

    EraseInitStruct.TypeErase = FLASH_TYPEERASE_SECTORS;
    EraseInitStruct.Sector = FLASH_SECTOR_7;
    EraseInitStruct.NbSectors = 1;
    EraseInitStruct.VoltageRange = VOLTAGE_RANGE_3;

    if (HAL_FLASHEx_Erase(&EraseInitStruct, &PageError) != HAL_OK)
    {
        Error_Handler();
    }
    HAL_FLASH_Lock();
}

void flash_read(void)
{
    flashstruct temp;
    memcpy(&temp, (flashstruct*)FLASH_START_ADDRESS, sizeof(temp));
    memcpy(&flash, &temp, sizeof(temp));
}

void flash_save_process(void)
{
    unsigned int* p_data = (unsigned int*)&flash;
    int byte_align = 0;

    if (flash_save_counter <= FLASH_SAVE_TIME) 
        flash_save_counter++;

    if (flash_save_counter == FLASH_SAVE_TIME)
    {
        flashstruct temp;
        flash.key = FLASH_KEY;
        memcpy(&temp, &flash, sizeof(flash));
        
        // 현재 저장된 값과 비교
        flash_read();
        if (memcmp(&temp, &flash, sizeof(flash)) != 0)
        {
            memcpy(&flash, &temp, sizeof(temp));
            
            // 4바이트 정렬 체크
            if ((sizeof(flash) % 4) > 0) 
                byte_align = 1;
            
            flash_erase();
            HAL_FLASH_Unlock();
            
            // 4바이트 단위로 프로그래밍
            for (int i = 0; i < sizeof(flash) / 4 + byte_align; i++)
            {
                HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, 
                                (FLASH_START_ADDRESS + (i * 4)), 
                                p_data[i]);
            }
            
            HAL_FLASH_Lock();
        }
        flash_save_counter = 0;
    }
}

void LoadSettings(void)
{
    flash_read();
    
    // 유효성 검사
    if(flash.key == FLASH_KEY) {
        start_temp = flash.start_temp;
        sysState.heater1.tempSet = flash.heater1_temp;
        sysState.heater2.tempSet = flash.heater2_temp;
        
        // 범위 검증
        if(start_temp < START_TEMP_MIN || start_temp > START_TEMP_MAX)
            start_temp = 0.0f;
        if(sysState.heater1.tempSet < TEMP_MIN || sysState.heater1.tempSet > TEMP_MAX)
            sysState.heater1.tempSet = TEMP_DEFAULT;
        if(sysState.heater2.tempSet < TEMP_MIN || sysState.heater2.tempSet > TEMP_MAX)
            sysState.heater2.tempSet = TEMP_DEFAULT;
    }
    else {
        // 기본값 설정
        start_temp = 0.0f;
        sysState.heater1.tempSet = TEMP_DEFAULT;
        sysState.heater2.tempSet = TEMP_DEFAULT;
    }
}

void SaveSettings(void)
{
    flash.start_temp = start_temp;
    flash.heater1_temp = sysState.heater1.tempSet;
    flash.heater2_temp = sysState.heater2.tempSet;
    flash_save_process();
}

728x90
반응형

'프로그램 > ST 32Bit' 카테고리의 다른 글

STM32CubeIDE Multiple definition 에러 해결 방법  (0) 2024.11.08
STM32L MCU 터치 사용  (0) 2024.05.25
터치 인식 조절  (0) 2024.01.02
STM32L072 터치 감도 및 인식 속도 조절  (0) 2023.10.27
728x90
반응형

GPT를 프로로 업그래이드 하여 사용했다. 업무에 도움이 되기도 했고 GPT 때문에 고생도 했다. GPT 사용하면서 자꾸 의지를 하여서 프로그램 실력이 감퇴 하는것 같았다.

오른쪽 위에 내 ICON을 클릭하자. 목록이 나오면 플랜 업그레이드 클릭

 

Plus 아래 내 구독을 관리하세요 라는 글자가 있다. 클릭 해주자.

 

위와 같은 창이 열리면 위쪽 관리를 눌러서 구독 취소를 선택

 

 

 

 화면에는 글자를 읽고 그에 맞게 선택후 다음페이지 누르다 보면 해지 완료됨.

 

 

 

 

해지시 많은것을 물어봄.... 하다 보면 종료됨.

 

 

아래쪽 관리에 들어가면 해지 전에 얼마나 사용했는지 알수 있음.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90
반응형
728x90
반응형

pads에서 부품이 모듈 단위로 회로가 그려져 있으며 각 부품 위치와 부품 번호 증분 값이 동일 할때 자동으로 모듈 단위 배치를 해주는 스크립트 이다.

 

채굴기 관련 보드 설계에서 사용했다. 배치가 편하게 수정 된다.

배선은 모듈 4가지 모듈을 사용했는데 각각 1개씩만 배선후 복사 붙여 넣기로 쉽게 작업을 했다.

 

이거 찾고 만드는데 약 5일정도 소요 된듯 하다. 5일이면 그냥 artworks 끝났을텐데 다음버전이나 조금씩 위치 변경 등등 여러 가지 발생 상황을 가정했을때 꼭 만들어 놓아야 하겠다고 판단하여 만들어 놨다.

 

Dim doc As Document
Dim tgtName As String
Dim refName As String
Dim tgtComp As Component
Dim refComp As Component
Dim dx As Double
Dim dy As Double
Dim rotation As Double

Dim page_count As Double
Dim part_count As Double
Dim input_number As String
Dim r_input_number As String
Dim ic_input_number As String
Dim rd_input_number As String

Dim x_position As Double
Dim y_position As Double
Dim c_start_number As Double
Dim r_start_number As Double
Dim ic_start_number As Double
Dim rd_start_number As Double
Dim x_inc As Double
Dim y_inc As Double
Dim c_inc As Double
Dim r_inc As Double
Dim ic_inc As Double
Dim rd_inc As Double

Dim step_count As Double




Sub Main
x_position = -32
y_position = 0
x_inc = -32
y_inc = 0
c_start_number = 40
c_inc = 30
r_start_number = 15
r_inc = 4
ic_start_number = 3
ic_inc = 2
rd_start_number = 5
rd_inc = 4
step_count = 0
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))


x_position = -16
y_position = 0
x_inc = -32
y_inc = 0
c_start_number = 25
c_inc = 30
r_start_number = 13
r_inc = 4
ic_start_number = 2
ic_inc = 2
rd_start_number = 3
rd_inc = 4
step_count = 0
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
step_count = step_count + 1
Call move1(CStr(c_start_number+(c_inc * step_count)),CStr(r_start_number+(r_inc * step_count)),CStr(ic_start_number+(ic_inc * step_count)), CStr(rd_start_number+(rd_inc * step_count)),(x_position+(x_inc * step_count)),(y_position+(y_inc * step_count)))
'Call move("40","15","3","5",-32,0) //C, R, IC, RD, X OFFSET, Y OFFSET
'Call move("70","19","5","9",-64,0) //C, R, IC, RD, X OFFSET, Y OFFSET
'Call move("100","23","7","13",-96,0) //C, R, IC, RD, X OFFSET, Y OFFSET
'Call move("130","27","9","17",-128,0) //C, R, IC, RD, X OFFSET, Y OFFSET
'Call move("160","31","11","21",-160,0) //C, R, IC, RD, X OFFSET, Y OFFSET
'Call move("190","35","13","25",-192,0) //C, R, IC, RD, X OFFSET, Y OFFSET
End Sub


Sub move(ByVal cstart As String, ByVal rstart As String, ByVal icstart As String, ByVal rdstart As String, ByVal xoffset As Double, ByVal yoffset As Double)

Dim ret As Integer

'part_count = 0
'input_number = InputBox("RefDes : ", "C") 'ref number Input
'If input_number = "" Then
'Exit Sub
'End If
'r_input_number = InputBox("RefDes : R ", "R") 'ref number Input
'If r_input_number = "" Then
'Exit Sub
'End If
'ic_input_number = InputBox("RefDes : regulator ", "IC") 'ref number Input
'If ic_input_number = "" Then
'Exit Sub
'End If
    'rd_input_number = InputBox("RefDes : regulator ", "RD") 'ref number Input
'If rd_input_number = "" Then
'Exit Sub
'End If
input_number = cstart
r_input_number = rstart
ic_input_number = icstart
rd_input_number = rdstart

    tgtname = "c" + input_number 'Step 1 c part 10
   
    dx = 0 + xoffset 'x position
    dy = 10 + yoffset 'y position
    rotation = 270 'rotation
Call ApplyMove()


tgtname = "c" + CStr(Val(input_number) + 1) 'next part 11
    dx = 0 + xoffset
    dy = 8 + yoffset
    rotation = 90
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 2) 'next part 12
    dx = 5 + xoffset
    dy = 8 + yoffset
    rotation = 90
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 3) 'next part 13
    dx = 5 + xoffset
    dy = 10 + yoffset
    rotation = 90
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 4) 'next part 14
    dx = -5 + xoffset
    dy = 8 + yoffset
    rotation = 270
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 9) 'next part 19
    dx = 2.5 + xoffset
    dy = -46.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 10) 'next part c20
    dx = 2.5 + xoffset
    dy = -6.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 11) 'next part c21
    dx = 1.5 + xoffset
    dy = 6.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 12) 'next part c22
    dx = 4.5 + xoffset
    dy = -6.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 13) 'next part c23
    dx = 4.5 + xoffset
    dy = -46.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 14) 'next part c24
    dx = 3.5 + xoffset
    dy = 6.5 + yoffset
    rotation = 0
Call ApplyMove()

    tgtname = "r" + r_input_number 'Step 1 c part R8
   
    dx = -5 + xoffset 'x position
    dy = 10 + yoffset 'y position
    rotation = 270 'rotation
Call ApplyMove()


tgtname = "r" + CStr(Val(r_input_number) + 1) 'next part R9 (R11)
    dx = -0.5 + xoffset
    dy = 6.5 + yoffset
    rotation = 0
Call ApplyMove()

    tgtname = "ldo" + ic_input_number 'Step 1 c part
   
    dx = -2.5 + xoffset 'x position
    dy = 9 + yoffset 'y position
    rotation = 180 'rotation
Call ApplyMove()


tgtname = "ldr" + CStr(Val(ic_input_number)) 'next part
    dx = 2.5 + xoffset
    dy = 9 + yoffset
    rotation = 90
Call ApplyMove()

    tgtname = "rd" + rd_input_number 'Step 1 c part
   
    dx = 0 + xoffset 'x position
    dy = -10.5 + yoffset 'y position
    rotation = 180 'rotation
Call ApplyMove()


tgtname = "rd" + CStr(Val(rd_input_number)+1) 'next part
    dx = 0 + xoffset
    dy = -29.5 + yoffset
    rotation = 180
Call ApplyMove()

End Sub

Sub move1(ByVal cstart As String, ByVal rstart As String, ByVal icstart As String, ByVal rdstart As String, ByVal xoffset As Double, ByVal yoffset As Double)

Dim ret As Integer

'part_count = 0
'input_number = InputBox("RefDes : ", "C") 'ref number Input
'If input_number = "" Then
'Exit Sub
'End If
'r_input_number = InputBox("RefDes : R ", "R") 'ref number Input
'If r_input_number = "" Then
'Exit Sub
'End If
'ic_input_number = InputBox("RefDes : regulator ", "IC") 'ref number Input
'If ic_input_number = "" Then
'Exit Sub
'End If
    'rd_input_number = InputBox("RefDes : regulator ", "RD") 'ref number Input
'If rd_input_number = "" Then
'Exit Sub
'End If
input_number = cstart
r_input_number = rstart
ic_input_number = icstart
rd_input_number = rdstart

    tgtname = "c" + input_number 'Step 1 c part 25
   
    dx = -2 + xoffset 'x position
    dy = -48 + yoffset 'y position
    rotation = 270 'rotation
Call ApplyMove()


tgtname = "c" + CStr(Val(input_number) + 1) 'next part 26
    dx = 3 + xoffset
    dy = -48 + yoffset
    rotation = 270
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 2) 'next part 27
    dx = 3 + xoffset
    dy = -50 + yoffset
    rotation = 90
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 3) 'next part 28
    dx = 6.5 + xoffset
    dy = -46.5 + yoffset
    rotation = 180
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 4) 'next part 29
    dx = -0.5 + xoffset
    dy = -50.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 9) 'next part c34
    dx = 2.5 + xoffset
    dy = 6.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 10) 'next part c35
    dx = 2.5 + xoffset
    dy = -33.6 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 11) 'next part 36
    dx = 2.5 + xoffset
    dy = -46.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 12) 'next part 37
    dx = 4.5 + xoffset
    dy = -33.6 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 13) 'next part 38
    dx = 4.5 + xoffset
    dy = 6.5 + yoffset
    rotation = 0
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 14) 'next part 39
    dx = 4.5 + xoffset
    dy = -46.6 + yoffset
    rotation = 0
Call ApplyMove()

    tgtname = "r" + r_input_number 'Step 1 c part
   
    dx = 1.5 + xoffset 'x position
    dy = -50.5 + yoffset 'y position
    rotation = 180 'rotation
Call ApplyMove()


tgtname = "r" + CStr(Val(r_input_number) + 1) 'next part
    dx = 0.5 + xoffset
    dy = -46.5 + yoffset
    rotation = 0
Call ApplyMove()

    tgtname = "ldo" + ic_input_number 'Step 1 c part
   
    dx = 0.5 + xoffset 'x position
    dy = -48.5 + yoffset 'y position
    rotation = 270 'rotation
Call ApplyMove()


tgtname = "ldr" + CStr(Val(ic_input_number)) 'next part
    dx = 5.5 + xoffset
    dy = -49 + yoffset
    rotation = 0
Call ApplyMove()

    tgtname = "rd" + rd_input_number 'Step 1 c part
   
    dx = 0 + xoffset 'x position
    dy = -10.5 + yoffset 'y position
    rotation = 180 'rotation
Call ApplyMove()


tgtname = "rd" + CStr(Val(rd_input_number)+1) 'next part
    dx = 0 + xoffset
    dy = -29.5 + yoffset
    rotation = 180
Call ApplyMove()

End Sub

Sub ApplyMove()
    Dim doc     As Document
    Dim tgtComp As Component

    Set doc     = Application.ActiveDocument
    Set tgtComp = doc.Components(tgtName)

    tgtComp.Move dx, dy 'component move
    tgtComp.Orientation = rotation 'coponent rotation
    
    
    'MsgBox "[" & tgtName & "] moved by (" & dx & ", " & dy & ")"
End Sub

728x90
반응형

'Hardware' 카테고리의 다른 글

PADS 에서 Script 사용.  (0) 2025.04.28
PADS 창 짤리는 문제  (0) 2024.10.17
변경된 회로 Pads에 적용하기  (1) 2024.10.08
PADS에서 다층 기판 셋팅하기  (0) 2024.10.07
PADS에서 ORCAD Netlist 불러오기.  (4) 2024.10.07
728x90
반응형

Dim doc As Document
Dim tgtName As String
Dim refName As String
Dim tgtComp As Component
Dim refComp As Component
Dim dx As Double
Dim dy As Double
Dim rotation As Double

Dim page_count As Double
Dim part_count As Double
Dim input_number As String



Sub Main
Dim ret As Integer

part_count = 0
input_number = InputBox("RefDes : ", "Target") 'ref number Input
    tgtname = "c" + input_number 'Step 1 c part
   
    dx = 0 'x position
    dy = 10.5 'y position
    rotation = 270 'rotation
Call ApplyMove()

tgtname = "c" + CStr(Val(input_number) + 1) 'next part
    dx = 0
    dy = 10.5
    rotation = 270
Call ApplyMove()

    
End Sub

Sub ApplyMove()
    Dim doc     As Document
    Dim tgtComp As Component

    Set doc     = Application.ActiveDocument
    Set tgtComp = doc.Components(tgtName)

    tgtComp.Move dx, dy 'component move
    tgtComp.Orientation = rotation 'coponent rotation
    
    
    MsgBox "[" & tgtName & "] moved by (" & dx & ", " & dy & ")"
End Sub

728x90
반응형
728x90
반응형

 

https://www.amd.com/ko.html

 

AMD에 오신 것을 환영합니다

AMD는 데이터 센터 AI, AI PC, 지능형 에지 장치, 게임 등의 개발을 위한 선도적인 고성능 적응형 컴퓨팅 솔루션을 제공합니다.

www.amd.com

위에 amd 홈페이지로 드어감.

다운로드 및 지원에 가서 Vivado ML 개발자 툴을 선택

스크롤을 돌려 페이지 아래로 내려간다.

웹상에서 설치 하는 파일이 있다. 인터넷 상태가 좋으니 그냥 웹에서 설치 파일을 다운로드 하자.

새로운 창이 열리고 이메일 주소와 비밀 번호를 넣으라는 창이 열린다. 가입이 안돼어 있다면 가입을 해주자.

 

 

로그인을 하면 위와 같은 창이 나온다. 아래로 내려주자.

 

다운로드 버튼을 눌러주자.

다운로드가 완료 돼면 실행 해주자. 실행하면 관리자 모드로 실행 할거냐고 물어보면 예를 눌러주자.

이런 창이 뜨면 액세스 허용을 눌러주자.

빠른 설치를 위해 설정에 들어가자. 안해도 무방.

CPU 점유율을 최대로 해주자. 안해도 무방.

OK 클릭.

백신을 비활성화 하라고 하네. 안좋은거 같지만. 빠른 설치를 위해 잠시 정지...

가입했던 이메일 주소와 비밀번호를 넣으라고 한다. 넣고 Next를 눌러주자.

Vivado를 선택하고 Next를 누르자. Vitis로 설치하자.

그냥 Next 클릭.

Vitis Embedded Development 와 Power Design Manager (PDM) 두개를 체크 해줬다. 이게 뭔지 나도 잘 모른다. 전부 설치하고 Next 클릭.

라이센스 동의 하란다. 이걸 다 읽어봐야 하나... 그냥 다 I Agree  해주고 Next 해줬다.

어디에 설치하고 누구만 사용할거냐고 물어본다. 그냥 Next눌러줘도 된다. 난 심심해서 All users 클릭후 Next 했다.

폴더 없다고 폴더 만들거냐고 물어본다. Yes 클릭 해주자.

Install 눌러주고 기다리자.

열심히 다운로드 한다. 이론... 3시간 걸린다고 하네... 딴짓을 해야겠군..

4분남음........... 2시간 32분 걸려 다운 완료... 이제 설치 하네........ 한참 걸림.........

설치도 다해감...

이런 창이 떴네.... 라이센스 등록 해주라는 이야기 인듯함...

Trial 버전 말고 우선 접속해보장..

 

submit을 누르란다...

처음에는 더 많이 있었는데 등록 한것은 안나온다...

위와 같은 창이 열리면 우선 free만 선택해서 Generate Node-Locked License를 눌러서 하드 디스크에 저장하는것으로 하고 라이센스 파일을 다운 받았다.

 

 

우여곡절 끝에 다 설치함...

728x90
반응형

'프로그램 > FPGA' 카테고리의 다른 글

Z7-NANO XC7Z010 (7010) SPEC  (0) 2025.04.07
Z7-NANO XC7Z010  (0) 2025.03.24
728x90
반응형

Z7-NANO_Datasheet_Microphase.pdf
1.42MB
Z7-NANO_R21.pdf
0.36MB

 

인터넷에서 찾고 다른 사람에게 받고 한 자료이다.

핀맵은 회로도를 참고 해야 한다.

딱히 스펙이랄게 없다.

 

728x90
반응형

'프로그램 > FPGA' 카테고리의 다른 글

Vivado 설치  (0) 2025.04.22
Z7-NANO XC7Z010  (0) 2025.03.24
728x90
반응형

보낼 명령어를 입력하는 창을 만들자.

TextBox를 위치시키고 속성 창에서 Name는 input_textBox로 변경, Anchor을 Bottom, Left, Right 선택

 

Button을 하나 오른쪽에 위치 시키고 Name을 send_button으로 변경 하자.

 

Anchor을 다음과 같이 Right, Bottom만 선택 하자.

 

Text는 SEND로 변경 해주자. SEND 버튼을 누르면 데이터가 전송 된다.

 

이제 SEND Button을 두번 클릭 하여 코드 창으로 들어가자.

 

아래 화면과 같이 나온다.

 

우선 serial 데이터를 받아서 창에 표시를 해주기 위해 아래처럼 문장 하나를 추가 해주자.

comport.DataReceived += new SerialDataReceivedEventHandler(comport_DataReceived); <= 이것 추가.

쓰레드 충돌을 피해서 데이터를 창에 표시하기 위해 아래와 같이 추가 해주자.

 

send Button까지 모드 코드가 들어가 있다 모두 추가 해주자.

        private void comport_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            this.Invoke(new EventHandler(serial_received)); //쓰레드 충돌을 피하기 위해 Invoke 사용
        }

        private void serial_received(object s, EventArgs e)
        {
            string receivedata = comport.ReadExisting(); //수신된 데이터를 receivedata 버퍼로 읽어오기
            string time = DateTime.Now.ToString("HH:mm:ss.fff");    //현재 시간 만들기.
            display_textbox.AppendText($"RX-{time} : {receivedata}");   //수신 시간과 데이터를 display_textbox에 표시하기.
        }
        private void send_button_Click(object sender, EventArgs e)
        {
            if (comport.IsOpen)
            {
                string inputdata = input_textBox.Text + "\r\n";
                comport.Write(inputdata);   //데이터 보내기
                string time = DateTime.Now.ToString("HH:mm:ss.fff");    //현재 시간 만들기.
                display_textbox.AppendText($"TX-{time} : {inputdata}");   //송신 시간과 데이터를 display_textbox에 표시하기.
                input_textBox.Clear();
            }
        }

 

다음 사진을 보면 TX로 시작 하는것은 보낸 데이터 이고 RX로 시작하는 것은 수신 데이터 이다.

 

 

이상 종료 합니다.

728x90
반응형
728x90
반응형

왼쪽 도구상자에서 TextBox를 가지고 오자.

 

폼에 위치 시킨후 마우스 오른쪽 보튼을 눌러 속성 창을 열어 주자.

 

오른쪽 아래 속성창이 열린것을 확인 할수 있다. 속성창에서 ReadOnly를 찾아서 True로 변경 해주자.

 

다음은 Multiline를 찾아서 True로 변경 해주자.

 

다음은 TextBox크기를 크게 만들어주고 ScrollBars를 Verical로 변경 해주자.

 

TextBox Name을 display_textbox로 변경 하주자.

 

화면을 늘리거나 줄일때에도 변화가 없게 하기 위해 Anchor을 찾아서 오른쪽에 버튼을 누른다.

 

조그만 창이 뜨면 오른쪽 아래처럼 모두다 선택 해주자.

 

실행해서 보면 다음과 같이 나온다.

 

오른쪽 위 최대화를 누르면 다음과 같이 나오는것을 확인 할수 있다.

 

728x90
반응형
728x90
반응형

도구 상자에서 Button 을 하나 가져와서 만든다.

 

아래 화면 처럼 버튼을 위치 시키고 오른쪽 아래 속성창에서 (Name) 항목을 찾아서 open_value로 명칭을 변경하자. 변경 하지 않아도 무관하나 그냥 내가 이해하기 쉬우려고 했다.

 

다음으로는 Text 항목에 가서 Open으로 변경 해줬다. (코드로 변경 해도 무관.)

 

이제 지금까지 만든 Button 위에서 마우스 왼쪽 버튼을 두번 클릭 하자.

 

두번 클릭하면 아래와 같이 코드 창이 열리고 버튼을 클릭 했을때 실행 하는 함수가 나온다.

 

그러면 아래와 같이 코드를 넣어주자.

 

            try
            {
                if (open_button.Text == "Open")
                {
                    comport.PortName = this.Comport_ComboBox.SelectedItem.ToString();   //comport setting
                    comport.BaudRate = int.Parse(this.Baudrate_comboBox.SelectedItem.ToString());   //baudrate setting
                    comport.DataBits = int.Parse(this.Databits_comboBox.SelectedItem.ToString());   //databit setting
                    comport.Parity = (Parity)Enum.Parse(typeof(Parity), Paritybits_comboBox.SelectedItem.ToString());   //paritybits setting
                    comport.StopBits = (StopBits)Enum.Parse(typeof(StopBits), Stopbits_comboBox.SelectedItem.ToString());   //stopbit setting
                    comport.Open(); //comport open
                    open_button.Text = "Close"; //no err시 
                }
                else
                {
                    comport.Close();
                    open_button.Text = "Open";  //text 초기화
                }
            }
            catch
            {
                open_button.Text = "Open";  //text 초기화
                MessageBox.Show("통신에 이상이 있습니다.");
            }

 

위 코드를 붙여 넣고 실행하여 설정을 변경해서 통신 포트를 열거나 닫을수 있게 되었다.

 

시리얼 통신 포트를 USB에 연결하고 프로그램을 실행하면 잡힌 통신 포트가 목록에 추가 되어 있다.

 

 

 

 

 

 

 

 

나머지 사진처럼 통신 포트를 열거나 닫을수 있다.

728x90
반응형
728x90
반응형

어쩌다 보니 Z7-NANO 7010 이라는 키트가 생겨 버렸다..

일거리가 늘어남...

 

이넘을 어디서 부터 어떻게 씹어 먹어야 하나...

 

OS를 해야 한다...

 

728x90
반응형

'프로그램 > FPGA' 카테고리의 다른 글

Vivado 설치  (0) 2025.04.22
Z7-NANO XC7Z010 (7010) SPEC  (0) 2025.04.07
728x90
반응형

단종품 이라고 함.

 

메뉴얼

UM_MC93CV402_V2.00_EN.pdf
2.30MB
UM_MC93CV402_V2.00_KO.pdf
2.56MB

WaveStudio 사용법

WaveStudio_kor_v1.22.pdf
0.99MB

WaveStudio 파일

setup.exe
0.41MB
WaveStudioSetup.msi
4.72MB

Vctrl

readme.txt
0.00MB
vctrl.exe
0.11MB
vctrlw.exe
0.18MB / 0.18MB

 

참고 source

cmd.c
0.01MB
hal.c
0.00MB
hal.h
0.00MB
vcmd.c
0.00MB

728x90
반응형
728x90
반응형

main.c에서 선언된 포트를 직접 변경 해도 되겠지만 기본적으로 선언된 값을 변경하는 방법은 설정에 있다.

CONFIG_BLINK_GPIO 글자를 선택후 F12키를 누른다.

sdkconfig.h라는 파일에 #define  CONFIG_BLINK_GPIO 5라고 선언 되어 진 부분으로 이동할것이다.

여기서 5라는 값을 변경하고 Build를 누르면 변경된 값이 적용이 되는게 아니라 다시 5로 나온다. 즉. 변경이 안된다.

 

F1키를 누른후 Command 창에 menuconfig를 입력하고 선택 하자.

선택한 창이 열리면 Example Configuration 글자를 클릭하면 Blink Gpio number가 나오는데 여기서 변경 하면 변경이 된다.

 

 

728x90
반응형

'프로그램 > ESP32' 카테고리의 다른 글

ESP32.... blink example main에서 main.c 파일 이름 변경법.  (0) 2025.02.24
VS CODE 실행시 이전 작업  (0) 2025.02.24
ESP32 프로젝트 만들기  (0) 2024.05.14
blink 예제 설명  (0) 2023.10.20
ESP32 예제 실행  (1) 2023.10.17
728x90
반응형

 

blink_example_main.c 이름 변경후 CMakeLists.txt 파일에 가서 "blink_example_main.c" 이름도 변경 해줘야함.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90
반응형

'프로그램 > ESP32' 카테고리의 다른 글

ESP32 예제에 선언된 포트 변경법.  (0) 2025.02.24
VS CODE 실행시 이전 작업  (0) 2025.02.24
ESP32 프로젝트 만들기  (0) 2024.05.14
blink 예제 설명  (0) 2023.10.20
ESP32 예제 실행  (1) 2023.10.17
728x90
반응형

왼쪽 아래 Manage 버튼 클릭

셋팅을 클릭

검색창에 restore winows 입력후 Window: Restore Windows (Applies to all profiles) 부분에 all을 None으로 변경후 vs code를 닫았다가 다시 열면 다음과 같이 Project를 불러오지 않음.

 

728x90
반응형

'프로그램 > ESP32' 카테고리의 다른 글

ESP32 예제에 선언된 포트 변경법.  (0) 2025.02.24
ESP32.... blink example main에서 main.c 파일 이름 변경법.  (0) 2025.02.24
ESP32 프로젝트 만들기  (0) 2024.05.14
blink 예제 설명  (0) 2023.10.20
ESP32 예제 실행  (1) 2023.10.17
728x90
반응형

C:/ST/STM32CubeIDE_1.16.1/STM32CubeIDE/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.12.3.rel1.win32_1.0.200.202406191623/tools/bin/../lib/gcc/arm-none-eabi/12.3.1/../../../../arm-none-eabi/bin/ld.exe: ./Core/Src/gpio.o:D:/01. JOB/REPEATER/Debug/../Core/Inc/ModbusRTU_Slave.h:17: multiple definition of `ModbusRegister'; ./Core/Src/ModbusRTU_Slave.o:D:/01. JOB/REPEATER/Debug/../Core/Inc/ModbusRTU_Slave.h:17: first defined here

Console 창에 이런 메시지가 떴다.. 해결 방법은 Alt + Enter 를 누르거나 

위 그림처럼 프로젝트 명에서 마우스 오른쪽 버튼을 눌러 Properties를 들어가자.

위 그림처럼 -fcommon을 넣어주고 다시 컴파일 하자.

728x90
반응형

'프로그램 > ST 32Bit' 카테고리의 다른 글

내부 FLASH 읽고 쓰기. 구조체 방법.  (0) 2025.06.19
STM32L MCU 터치 사용  (0) 2024.05.25
터치 인식 조절  (0) 2024.01.02
STM32L072 터치 감도 및 인식 속도 조절  (0) 2023.10.27
728x90
반응형

VX 버전

pads 종료후 진행

C:\MentorGraphics\PADSVX.2\SDD_HOME\Programs 폴더 이동

powerlogic.ini, powerpcb.ini, blazerouter.ini 파일을 메모장으로 연다.

각각에 파일에 [general] 글밑에 Dialog_Font_Fix=1 을 추가 해준다.

 

실행해보면 정상적으로 나옴.

728x90
반응형
728x90
반응형

기존 회로

 

변경된 회로

변경된 회로에서 Netlist를 만들어 준다.

https://dadaprofit.tistory.com/83

 

ORCAD에서 Netlist 만들기.

프로젝트 창에서 SCHEMATIC1 폴더를 클릭후 화면 가운데 위쪽에 아이콘중 문서 모양에 N이 들어가 있는 아이콘을 클릭하거나Tools에 Create Netlist를 클릭 하자.위와 같이 Create Netlist 창이 열리면 오른

dadaprofit.tistory.com

 

확인을 눌러 파일이름을 ORCAD-1.asc로 만들었다.

temp라는 비여있는 다른 새로운 파일을 만든후 열어준다.

PADS에서 수정된 ORCAD-1.asc 파일을 Import 시켜 준다.

https://dadaprofit.tistory.com/85

 

PADS에서 ORCAD Netlist 불러오기.

Pads를 실행후 File에 Import를 클릭 하자. 앞에서 만들어 놓은 Netlist파일을 선택후 열기를 눌러주자. 파일을 불러오면 위와 같이 노트패드가 열리고 에러나 경고가 표시된다. 아무것도 없는 상태

dadaprofit.tistory.com

수정된 asc 파일을 선택후 열기 누른다.

새로운 파일에 Import 된것을 확인 할수 있다. 수정사항이 잘 반영 되었는지 확인후 파일을 저장 하고 닫는다.

이제 원래 본 파일을 실행하여 연다.

원래 파일이 열렸다.

이제 수정된 회로를 적용 하겠다.

상단 메뉴바에서 Tools에 Compare/ECO를 클릭 한다.

위와 같이 Compare/ECO Tools 창이 열리면 다음 순서를 실행 해주자.

1. 제일 위에 Original Design to Compare and Update 안에 Use Current PCB Design을 체크 해주자.

2. New Design with Changes 창에 변경된 회로를 적용한 PADS 파일을 선택 해준다.

3. Output Options에 두가지 체크 해주고 Browse를 눌러 어디에 어떤 이름으로 저장 할지 설정 해준다. 필자는 D:\blog\pads폴더에 temp.eco로 저장을 해주겠다.

4. Run을 클릭

기존에 있는 파일이면 덮어 쓸것인지 물어보는데 예를 눌러주자.

바로 위와 같은 창이 뜨는데 아래 보면 ECOGEN : Differences found가 나와야 한다. 만약 다르게 나오면 잘못 된것이다. 다시 처음 부터 확인 하면서 해보시길..

Show Report를 클릭하면 무엇이 변경 되었는지 나온다.

맞는지 확인하자.

Close를 눌러 화면을 닫자.

Cancel을눌러 화면을 닫자.

이제 다른 사항을 적용 해주자.

File에 Import를 클릭하자.

화면처럼 파일 형식을 eco로 선택 하자.

Compare/ECO Tools에서 만들었던 temp.eco 파일이 보인다. 선택후 열기 버튼을 누르자.

에러가 없다고 나온다. 정상적으로 불러 들였다. 확인을 클릭 하자.

새로운 회로가 적용되어서 Net가 다른 부분은 삭제 되고 새로운 Net가 연결되어 있다.

다시 Routing을 하여 완료 하면 된다.

 

728x90
반응형

'Hardware' 카테고리의 다른 글

PADS 에서 Script 사용.  (0) 2025.04.28
PADS 창 짤리는 문제  (0) 2024.10.17
PADS에서 다층 기판 셋팅하기  (0) 2024.10.07
PADS에서 ORCAD Netlist 불러오기.  (4) 2024.10.07
ORCAD에서 PL 뽑기.  (0) 2024.10.07
728x90
반응형

PADS에서 LAYER선택을 누르면 Top, Bottom이 바로 온다. 현재 2Layer 모드 이다. 이것을 다층으로 변경 해보자.

Setup에 Layer Definition을 클릭 하자.

위와 같이 창이 열리면 Modify를 클릭 하자.

위와 같이 창이 열리면서 4라고 입력 되어 있다. 여기서 20층까지 설정 할수 있다.

4가 입력된 상태에서 OK를 눌러서 4층 기판으로 설정하자. 4층에서 다시 2층으로 셋팅은 안되니 조심하자.2층으로 셋팅 된다. pcb inport한 라이브러리에 문제가 있어서 안돼었었다...

위와 같은 창이 열리는데 기존 Top Layer는 1번 Layer로 위치 되고 기존 Bottom Layer는 4번째 Layer로 위치 된다고 나온다. 그냥 OK 클릭하자.

처음에 Layers Setup 창에 1번이 Top, 2번이 Bottom이였던것이 2번에 Inner Layer2, 3번에 Inner Layer3이 추가 되고 4번에 Bottom으로 변경 된것을 확인 할수 있다.

OK를 눌러 셋팅을 완료 하자.

Ctrl + Alt + C를 누르거나 Setup에 Display Colors를 클릭하자.

Color Setup 창을 보면 Inner Layer 2 와 Inner Layer 3는 모두 검은색으로 되어 있을수 있다. 색상을 지정 하지 않으면 화면에 표시가 안된다. 변경을 해주자.

대충 설정 했다.

다른때에도 사용하기 위해 Save를 눌러 저장을 해주자.

이제 다른 프로젝트에서도 Color를 불러와서 동일하게 셋팅 할수 있다.

배선을 하면서 왼쪽 상단에 Layer를 선택하면서 다층 기판 작업을 할수가 있다.

대충 작업을 완료 해 놓은 상태 이다. 배선 색상이 다른것은 다른 층에 있다는 이야기 이다.

728x90
반응형

'Hardware' 카테고리의 다른 글

PADS 창 짤리는 문제  (0) 2024.10.17
변경된 회로 Pads에 적용하기  (1) 2024.10.08
PADS에서 ORCAD Netlist 불러오기.  (4) 2024.10.07
ORCAD에서 PL 뽑기.  (0) 2024.10.07
ORCAD에서 Netlist 만들기.  (1) 2024.10.07
728x90
반응형

Pads를 실행후 File에 Import를 클릭 하자.

 

앞에서 만들어 놓은 Netlist파일을 선택후 열기를 눌러주자.

 

파일을 불러오면 위와 같이 노트패드가 열리고 에러나 경고가 표시된다. 아무것도 없는 상태에서 불러 왔을 경우를 에러 또는 경고가 없어야 정상이다. 무엇인가 뜬다면 어딘가 잘못 돤것이다. ORCAD에서 Footprint값을 pads에 parts값으로 정확히 넣었는지 확인 하자.

 

Pads에서 위와 같은 문구가 뜨는데 그냥 확인을 누르면 된다.

 

PADS에 Netlist가 있는 ASCII파일을 잘 Import 되어  있는것을 확인 할수 있다.

Parts를 전체 선택후 마우스 오른쪽 버튼을 누른후 Disperse를 클릭 하면 보기 좋게 정렬 된다.

728x90
반응형

'Hardware' 카테고리의 다른 글

변경된 회로 Pads에 적용하기  (1) 2024.10.08
PADS에서 다층 기판 셋팅하기  (0) 2024.10.07
ORCAD에서 PL 뽑기.  (0) 2024.10.07
ORCAD에서 Netlist 만들기.  (1) 2024.10.07
ORCAD에서 PADS 라이브러리 입력하기.  (1) 2024.10.07
728x90
반응형

프로젝트 창에서 SCHEMATIC1을 클릭후 그림상에 마우스 위치에 있는 ICON을 누르거나 Tools에 Bill of Materials..를 클릭 하자.

위와 같은 창이 열린다. Open in Excel을 체크 해주고 확인을 누르면 Excel 창이 열리고 부품목록이 나온다. 만약 PCB Footprint 값도 나오게 하고 싶으면 Heater 라인과 Combined property string 라인에 다음과 같이 추가 하면 된다.

추가한후 OK를 누르면 Excel 창이 열리고 다음과 같이 출력 된다.

Part에 맞게 레퍼런스 넘버가 정렬 되어 나온다. 이넘을 이용해서 PARTLIST를 만들면 된다.

주의사항으로는 Part 이름이 조금만 달라도 다른 부품으로 인식한다. 그리고 PCB Footprint에서 0이 먼저 시작하면 표시가 안된다..

728x90
반응형
728x90
반응형

프로젝트 창에서 SCHEMATIC1 폴더를 클릭후 화면 가운데 위쪽에 아이콘중 문서 모양에 N이 들어가 있는 아이콘을 클릭하거나

Tools에 Create Netlist를 클릭 하자.

위와 같이 Create Netlist 창이 열리면 오른쪽 위에 Other 를 클릭후 Formatters에서 orPadspcb.dll 또는 orpads2k.dll을 클릭 해주자. 난 orPadspcb를 사용함.. 크게 상관 없는듯 했음.

그리고 확인을 누르면 Netlist File 1: 밑에 주소(D:\Blog\SCHEMATIC폴더에 ORCAD.asc라는 아스키  파일이 만들어짐.

확인 클릭시 위와 같은 창이 뜨면 그냥 확인 눌러주면 됨.

해당 폴더에 가면 ORCAD.asc 파일이 만들어 진것을 확인 할수 있음.

 

728x90
반응형
728x90
반응형

회로도 부품에 PADS Parts을 입력하기 위한 방법은 여러 가지가 있는데 하나씩 넣거나 수정하는 방법은 해당 부품을 더블 클릭 한다.

만약 위와 같이 화면이 나온다면 Filter by : 선택 창을 변경 해주자.

Orcad-Capture를 선택 하자.

 

PCB Footprint가 나오는것을 확인 할수 있다.

pads에서 사용하는 Parts 이름을 확인후 넣어주자. (Decals 이름 아님!!!)

(DIP14가 있는것을 확인했다. 잘못 넣으면 PADS에서 읽어 들일때 에러가 발생 한다.)

 

Orcad에서 PCB Footprint에 DIP14를 넣어주었다.

다른것들도 넣어주자. 하나씩 더블 클릭 할수도 있지만 전체 정보를 열어 놓고 변경 하자.

 

프로젝트 창에 가서 해당 회로도를 클릭후 마우스 오른쪽 버튼을 눌러 Edit Object Properties를 클릭 하자.

 

위와 같은 창이 열리는 것을 확인 할수 있다. 이제 PCB Footprint 라인에 Pads에 Parts 이름을 넣어주자. (Ctrl + C, Ctrl + V)

 

위와 같이 PCB Footprint 값을 모두 넣었다.

 

 

 

728x90
반응형
728x90
반응형

ORCAD에서 대충 다음과 같은 회로를 만들었다.

레퍼런스 넘버를 순차적으로 정렬해보자.

 

프로젝트 창으로 이동후 마우스로 해당 회로도를 한번 클릭하여 선택 한다.

 

가운데 상단에 U?를 클릭 한다.

 

위와 같은 창이 열리면 Action에 Reset part references to "?" 를 클릭 하고 확인을 눌러준다.

 

위와 같은 창이 열리면 그냥 확인을 클릭 해준다.

 

회로도에 가보면 레퍼런스 넘버 숫자가 ?으로 변경 된것을 확인 할수 있다.

다시 프로젝트 창으로 가서 회로도 선택이 안되어 있다면 클릭후 U?를 클릭 한다.

 

위창에서 Incremental reference upadate를 클릭후 확인을 누른다. (Annotation Type을 변경하여 순서를 변경 할수 있다.)

 

위와 같은 창이 열리면 확인을 눌러주자.

 

회로도에 가보면 레퍼런스 넘버가 위에서부터 왼쪽에서 오른쪽으로 번호가 들어가 있는것을 확인 할수 있다.

 

 

 

728x90
반응형

'Hardware' 카테고리의 다른 글

PADS에서 다층 기판 셋팅하기  (0) 2024.10.07
PADS에서 ORCAD Netlist 불러오기.  (4) 2024.10.07
ORCAD에서 PL 뽑기.  (0) 2024.10.07
ORCAD에서 Netlist 만들기.  (1) 2024.10.07
ORCAD에서 PADS 라이브러리 입력하기.  (1) 2024.10.07
728x90
반응형

728x90
반응형
728x90
반응형

아래 위치에서 카피했다. 참 잘 해놓으신듯 하다. 지워 질수도 있다고 판단되어 꼭 보관하고 싶어 제 블로그로도 이동합니다.  아래 블로그 들어가셔서 참고하세요.

태양 위치 (고도, 방위각) 계산 - Python 코드 포함 : 네이버 블로그 (naver.com)

 

태양 위치 (고도, 방위각) 계산 - Python 코드 포함

안녕하세요. '라이징n폴링'입니다. 태양은 일정한 움직임으로 우리 주변에 항상 존재하기 때문에...

blog.naver.com

 

 

파이썬 프로그램임.

import math
from datetime import datetime

#   태양의 위치 구하는 예시는 서울 지역의 2019년 6월 22일(하지)를 기준으로 작성하였습니다.
#   각도 단위 변경
d2r = math.pi/180
r2d = 180/math.pi

#   서울 위도, 경도
local_latitude  = 37.478    #   위도
local_longitude = 127.148   #   경도
standard_longitude  = 135   #   UTC +9 일본 좌표

#   날짜 / 시간
year    = 2020
month   = 6
day     = 22
local_hour  = 12    #   위치 시간
local_min   = 0     #   위치 분

# 1. Equation of Time (균시차)  : 균시차는 시간각(Hour Angle)을 구하기 위해 필요한 값임.
#   수식 : ET = 229.2 * (0.000075 + 0.001868 * cosB - 0.032077 * sinB - 0.014615 * cos2B - 0.04089 * sin2B), B = (n-1)(360/365), (n = Day of year)
day_of_year = datetime(year, month, day).timetuple().tm_yday
B = (day_of_year - 1) * 360/365
EOT = 229.2 * (0.000075
               + 0.001868 * math.cos(d2r * B)
               - 0.032077 * math.sin(d2r * B)
               - 0.014615 * math.cos(d2r * 2 * B)
               - 0.04089 * math.sin(d2r * 2 * B))
print(day_of_year)
print(EOT)

#   2. Hour Angle (시간각)  : 시간각은 천구(celestial sphere) 상에서 '자오면(meridian plane)'과 '지축과 태양의 위치를 연결하는 면'이 이루는 각도를 의미함.
#   수식 : w = (LT * 60 + 4 * (LL - LST) + ET) / 60 * 15 - 180(도)
#   각도는 태양이 정남향 일때가 0도로 기준이 되고 여기에서 동쪽으로 갈수록 [-], 서쪽으로 갈수록 [+] 값을 가짐.
local_hour_decimal = local_hour + local_min / 60
delta_longitude = local_longitude - standard_longitude
solar_time_decimal = (local_hour_decimal * 60 + 4 * delta_longitude + EOT) / 60
solar_time_hour = int(solar_time_decimal)
solar_time_min  = (solar_time_decimal * 60) % 60
hour_angle = (local_hour_decimal * 60 + 4 * delta_longitude + EOT) / 60 * 15 - 180

print("Solar Time is %.2f hour (equal to %d hour %02d minute)" % (solar_time_decimal, solar_time_hour, solar_time_min))
print("Hour Angle is %.3f" % hour_angle)

#   3. Solar Declination (태양 적위) : 국어사전에 의하면 태양 적위는 "태양의 방향과 북극의 방향이 이루는 각의 여각"으로 정의됨. 다른곳에서는 "태양의 중심과 지구의 중심을 연결하는 선과 지구 적도면이 이루는 각"으로 표현함.
#   북반구에 위치하면 [+], 남반구에 위치하면 [-]
#   하지때는 각도가 북반구에 위치해서 23.45도, 동지때는 각도가 남반구에 위치해서 -23.45도임.
#   태양 적위를 구하는 수식은 다음과 같습니다. 아래 식에서 &가 태양 적위 입니다.
#   & = 23.45 * sin[360/365 * (284 + Day of Year)] (도)
solar_declination   = 23.45 * math.sin(d2r * 360 / 365 * (284 + day_of_year))
print(solar_declination)

#   4. Solar Altitude (태양 고도) : 태양과 지표면이 이루는 각.
#   sinB = cosLcos&cosw + sinLsin&, L : local latitude, & : Solar declination, w : hour angle

term_1 = math.cos(d2r * local_latitude) * math.cos(d2r * solar_declination) * math.cos(d2r * hour_angle) \
+ math.sin(d2r * local_latitude) * math.sin(d2r * solar_declination)
solar_altitude = r2d * math.asin(term_1)
print(solar_altitude)

#   5. Solar Azimuth (태양 방위각) : 태양과 남향이 이루는 각도, 남향을 기준으로 동쪽에 있으면 [+], 서쪽에 있으면 [-]
#   cosy = (sinB * sinL - sin&) / (cosB * cosL), B : Solar altitude, L : Local latitude, & : Solar declination

term_2 = (math.sin(d2r * solar_altitude) * math.sin(d2r * local_latitude) - math.sin(d2r * solar_declination)) \
            / (math.cos(d2r * solar_altitude) * math.cos(d2r * local_latitude))
solar_azimuth = r2d * math.acos(term_2)
print(solar_azimuth)




728x90
반응형
728x90
반응형

일출 일몰 시간을 알기 위해 검색 하던중 다음 사이트에서 자료를 보고 얻어왔다.

현재 테스트 중인데 문제점은 찾아야 하고 사용할수 있도록 수정해야함.

https://blog.naver.com/hy5236kr/140185719136

 

GPS 좌표와 Local Time을 이용한 일출/일몰시간 계산

먼저 소개했던 태양의 고도를 계산하는 알고리즘보다 더 정확한 결과를 얻어냈습니다. 물론 인터넷에서 찾...

blog.naver.com

 

위 사이트에서 복 붙이 안돼서 이곳에 남김.

 

//#include "stdafx"

#include <iostream>
#include <math.h>
#include <time.h>
using namespace std;
#define PHI 3.14159265f
#define TWO_PHI 6.28318530f //2*PHI
#define SUN_DIAMETER 0.53f //Sunradius degrees
#define AIR_REF (34.0f/60.0f) //athmospheric refraction degrees (지구대기 굴절각)

typedef unsigned char uint8_t;
typedef unsigned short uint16_t;

typedef struct _DAYLIGHT_STRUCT_
{
uint8_t sunRise_hour;
uint8_t sunRise_minute;
uint8_t sunSet_hour;
uint8_t sunSet_minute;
}DAYLIGHT;

// Get the days to J2000
// h is UT in decimal hours
// getJulianDay only works between 1901 to 2099 - see Meeus chapter 7
// 이 함수는 J2000 1월 1일 12시 DT를 기준으로 날수(Day Number)를 구합니다. (Meeus의 책 챕터 7을 참고하세요)
// 입력값은 년,월,일,시간(실수값)입니다.
double getJulianDay(int year, int month, int day)
{
double temp = -7.0f * ((double)year + ((double)month + 9.0f) / 12.0f) / 4.0f + 275.0f * (double)month / 9.0f + (double)day;

// type casting necessary on PC DOS and TClite to avoid overflow
temp += (double)(year * 367);
return (temp - 730531.5f + 12.0f / 24.0f);
};

// the function below returns an angle in the range
// 0 to 2 * pi
//
// 들어온 값을 항상 0~2pi 값안으로 normalize 시킵니다.

double getRangeRadian(double x)
{
double b = x / TWO_PHI;
double a = TWO_PHI * (b - (long)(b));

if (a < 0) a = TWO_PHI + a;
return a;
};

// Calculating the hourangle
// 시간각을 계산합니다.
// lat : 위도 decli : 적위
double getHourAngle(double lat, double declin)
{
double fo, dfo;

// Correction : different sign at S HS
dfo = PHI / 180.0 * (0.5 * SUN_DIAMETER + AIR_REF);

if (lat < 0.0) dfo = -dfo;

fo = tan(declin + dfo) * tan(lat * PHI / 180.0);

if (fo > 0.99999) fo = 1.0; // to avoid overflow //

fo = asin(fo) + PHI / 2.0;

return fo;
};

// Find the ecliptic longitude of the Sun
// 태양의 황경을 구합니다.
double getSunLongitude(double days, double* Longitude)
{
double g;

// mean longitude of the Sun (태양의 평균 황경)
*Longitude = getRangeRadian(280.461 * PHI / 180.0 + .9856474 * PHI / 180.0 * days);

// mean anomaly of the Sun (태양의 평균근접이각)
g = getRangeRadian(357.528 * PHI / 180.0 + .9856003 * PHI / 180.0 * days);

// Ecliptic longitude of the Sun (태양의 황경계산)
return getRangeRadian(*Longitude + 1.915 * PHI / 180.0 * sin(g) + .02 * PHI / 180.0 * sin(2 * g));
};

static void convertDtime2Rtime(double dHour, unsigned char* hour, unsigned char* minute)
{
*hour = (uint8_t)dHour;
*minute = (uint8_t)((dHour - (double)*hour) * 60);
}

// 메인함수
int main(void)
{
int year, month, day;
double latitude, longitude;
double tzone;

double meanLongitude;
double lambda, obliq;
double alpha, delta;

double LL, days;
double equation, ha, sunRiseTime, sunSetTime;

DAYLIGHT sunTime;
uint16_t dSunRiseT = 0, dSunSetT = 0, dNowT = 0;

uint8_t hour, minute;

// 관측장소의 경도(단위 degree), 위도(단위 degree), 타임존(단위시간) 값을 입력받습니다.
//year = 2013;
//month = 3;
//day = 28;
year = 2024;
month = 6;
day = 11;

//latitude = 37.4681f; //한국내 임의 위치의 위도 입력
//longitude = 127.0282f; //한국내 임의 위치의 경도 입력
latitude = 35.0518f; //한국내 임의 위치의 위도 입력
longitude = 129.0221f; //한국내 임의 위치의 경도 입력
tzone = 9.0f; //한국은 Time Zone이 +9임

days = getJulianDay(year, month, day);

// 태양의 황경
lambda = getSunLongitude(days, &meanLongitude);
// Obliquity of the ecliptic (s황도기울기 계산)
obliq = 23.439 * PHI / 180.0 - .0000004 * PHI / 180.0 * days;

// Find the RA and DEC of the Sun (태양의 적격, 적위 계산)
alpha = atan2(cos(obliq) * sin(lambda), cos(lambda)); //태양의 적경
delta = asin(sin(obliq) * sin(lambda)); //태양의 적위

// Find the Equation of Time
// in minutes
// Correction suggested by David Smith
// 균시차 계산
LL = meanLongitude - alpha;

if (meanLongitude < PHI) LL += TWO_PHI;

equation = 1440.0 * (1.0 - LL / TWO_PHI);
ha = getHourAngle(latitude, delta);

sunRiseTime = 12.0 - 12.0 * ha / PHI + tzone - longitude / 15.0 + equation / 60.0;
sunSetTime = 12.0 + 12.0 * ha / PHI + tzone - longitude / 15.0 + equation / 60.0;

if (sunRiseTime > 24.0) sunRiseTime -= 24.0;
if (sunSetTime > 24.0) sunSetTime -= 24.0;

convertDtime2Rtime(sunRiseTime, &sunTime.sunRise_hour, &sunTime.sunRise_minute);
convertDtime2Rtime(sunSetTime, &sunTime.sunSet_hour, &sunTime.sunSet_minute);

hour = 18; minute = 48; //임의의 Local Time을 설정하여 테스트

cout << "Now Time : " << (int)hour << ':' << (int)minute << '\n';
cout << "Sunrise : " << (int)sunTime.sunRise_hour << ':' << (int)sunTime.sunRise_minute << '\n';
cout << "Sunset : " << (int)sunTime.sunSet_hour << ':' << (int)sunTime.sunSet_minute << '\n';

if (dNowT <= dSunRiseT || dNowT >= dSunSetT)
{
cout << "Night\n";
}
else
{
cout << "Day\n";
}
return 0;
}

아래는 프로제트 파일 첨부함.

GPS_POSITION.zip
19.82MB

728x90
반응형
728x90
반응형

Visual Studio를 실행한후에 새 프로젝트 만들기를 클릭한다.

 

모든언어에서 C#선택, 모든 플랫폼에서 Windows 선택후 아래로 스크롤 하면 Windows Forms 앱(.NET Framework) 선택후 다음 클릭

 

프로젝트 이름을 넣고 저장 위치를 선택. 솔루션 및 프로젝트를 같은 디렉터리에 배치를 체크 해준다.

 

프로젝트가 만들어지고 다음과 같이 기본 창이 열린다. 도구 상자가 없다. 표시 해주자.

보기에 도구상자를 클릭하면 도구 상자가 나온다. 또는 (Ctrl+Alt+X 를 누르면 된다.)

 

도구 상자가 나왔다. 혹시 도구 상자에 글씨가 없으면 Form창을 클릭 하고 다시 보면 나올것이다.

 

도구 상자가 사라지지 않게 고정하자. 아래 화면에서 처럼 자동 숨기기 버튼을 한번 눌러 고정 할수 있다.

 

여기까지 하면 다음과 같은 창이 열려 있을것이다.

 

이번에는 디자인에 Form1이라는 이름을 변경 해보자. 우선 속성창이 나오게 하자.

1안. Form1 창을 마우스 왼쪽 버튼으로 한번 클릭후 Alt + Enter 키를 누르면 오른쪽 아래 속성창이 뜬다.

 

2안. 오른쪽 솔루션 탐색기에서 Form1.cs를 마우스 오른쪽 버튼을 누른후 속성을 누르면 속성창이 뜬다.

       (화면에 폼에서 마우스 오른쪽 버튼을 눌러도 됨.)

 

오른쪽 아래 만들어진 속성 창에서 아래로 스크롤 하면 Text 글자 옆에 Form1 이라고 있는데 이글씨를 변경하면 바뀐다.

 

아래와 같이 변경되는것을 확인 할수 있다.

 

이번에는 Serial 통신 프로그램 글자 앞에 Icon을 변경 해보자.

 

먼저 인터넷에서 적당한 Icon 파일을 다운 받자.

https://icon-icons.com/

 

Free Icons PNG, ICO, ICNS and SVG

Are you a designer? Share your work with people all over the world. Start upload

icon-icons.com

 

 

위 사이트에 가서 lan 이라고 검색을 해보자. 검색후 아래 아이콘 두개를 다운 받을것이다.

 

 

아이콘을 클릭하면 아래와 같이 나온다. 이창에서 ICO를 선택하고 Download ICO를 클릭 해주자. 다른 하나도 동일하게 다운 로드 해주자.

 

오른쪽 아래 속성창에서 아래로 내리면 Icon 글자가 나올것이다. 아래 화면처럼 글자 옆에 ... 버튼을 눌러주자.

 

창이 열리면 다운 받았던 아이콘 파일을 선택 후 열기 버튼을 눌러주자.

 

앞에 아이콘이 변경 된것을 알수 있다.

 

일반적으로 Serial 통신을 위해서는 설정 해야 하는것이 있다.

통신포트, Baud Rate, Data Bits, Parity Bits, Stop Bits 가 있다.

이것을 설정 할수 있도록 만들어 보자.

 

먼저 통신포트 설정 부분을 해보자.

이제 통신 설정 부분을 진행 하자.왼쪽 도구상자에 보면 ComboBox가 있다. 클릭한후에 오른쪽 폼에 그려 주자.

 

ComboBox를 놓았으면 ComboBox를 한번 클릭후 오른쪽 아래 속성창에서 Text란에 Comport라고 입력 해주자.

그러면 ComboBox안에 Comport라고 나올것이다. 프로그램을 실행 하면 Comport라고 나올것이다. 궁금하면 F5를 눌러 실행 해보자.

 

다음은 ComboBox를 클릭후 오른쪽 아래 속성 창에서 (Name)를 찾아보면 comboBox1 이라고 적혀 있을것이다.

comboBox1은 프로그램시 사용하는 고유 이름이다. 이해하기 쉽게 하기 위해 변경 Comport_ComboBox라고 변경 해주자.

 

다음은 통신 속도 Baud Rate 설정 창을 만들어 보자.

도구상자에서 ComboBox를 클릭하여 위와 같이 동일하게 하나 더 만들어 주자.

만든후 속성창에 Text에는 보통 많이 사용하는 값을 써 놓자.

 

다음 속성창에 (Name)칸에는 Baudrate_comboBox라고 넣어주자.

위와 동일하게 Data Bits, Parity Bits, Stop Bits를 만들어 주자.

(Name)에는Data Bits는 Databits_comboBox, Parity Bits는 Paritybits _comboBox , Stop Bits는 Stopbits_comboBox라고 넣어주자.

위와 같이 임의로 만들었으나 이것이 각각 무엇을 뜻하는지 사용자가 알기 어렵다.

그래서 이름을 붙여주자.

왼쪽 도구 상자에서 Label을 클릭하여 Form에 그려주자.

 

label1 글자를 마우스로 선택후 오른쪽 아래 속성창에 Text 에서 통신 포트로 변경 해보자.

여기까지 되었다면 통신 속도, 데이터, 패리티, 정지 까지 만들기 위해 label을 4개 더 만들고 Text를 변경하여 만들자.

만든후에는 마우스로 해당 개체를 누른후 이동하여 정당한 위치에 놓도록 하자.

F5 키를 눌러 실행해보면 아래와 같이 나오는데 아래에 데이터는 아무것도 없다. 추가 해주어야 한다.

프로그램을 중지 하자. 실행창에 오른쪽 X를 누르거나 Visual Studio 창에 빨간 정지 버튼을 누르거나 Visual Studio 창이 선택 된 상태에서 키보드 Shift + F5키를 눌러 정지 하자.

ComboBox에 데이터를 추가 해주자. 개별적으로 속성 창에서 추가 해주는 방법이 있으나 프로그램에서 추가를 하겠다.

Form을 더블 클릭 해주자.

위에서 마우스로 더블 클릭 하면 아래와 같이 프로그램 창이 열리고 Form1_Load로 이동한다.

 

프로그램에서 아래와 같이 입력하면 통신 속도가 입력이 됨. 

 

통신 포트 만 빼고 데이터, 패리티, 정지를 모두 넣어주자.

 

모두 입력 했다. 복붙을 위해 아래 복사 할수 있게 넣어 놓는다.

 

            Baudrate_comboBox.Items.Clear();        //통신 속도 콤보 박스 데이터 삭제 (안해도 됨)
            Baudrate_comboBox.Items.Add("2400");    //Select Index = 0
            Baudrate_comboBox.Items.Add("4800");    //Select Index = 1
            Baudrate_comboBox.Items.Add("9600");    //Select Index = 2
            Baudrate_comboBox.Items.Add("14400");   //Select Index = 3
            Baudrate_comboBox.Items.Add("19200");   //Select Index = 4
            Baudrate_comboBox.Items.Add("28800");   //Select Index = 5
            Baudrate_comboBox.Items.Add("56000");   //Select Index = 6
            Baudrate_comboBox.Items.Add("57600");   //Select Index = 7
            Baudrate_comboBox.Items.Add("115200");  //Select Index = 8
            Baudrate_comboBox.Items.Add("230400");  //Select Index = 9
            Baudrate_comboBox.SelectedIndex = 8;    //115200 선택, 폼에서 입력 해서 안해줘도 무방함.
            Databits_comboBox.Items.Clear();        //데이터 비트 콤보 박스 데이터 삭제 (안해도 됨)
            Databits_comboBox.Items.Add("5");       //Select Index = 0
            Databits_comboBox.Items.Add("6");       //Select Index = 1
            Databits_comboBox.Items.Add("7");       //Select Index = 2
            Databits_comboBox.Items.Add("8");       //Select Index = 3
            Databits_comboBox.SelectedIndex = 3;    //8bit 선택, 폼에서 입력해서 안해줘도 무방함.
            Paritybits_comboBox.Items.Clear();      //패리티 비트 콤보 박스 데이터 삭제 (안해도 됨)
            Paritybits_comboBox.Items.Add("Even");  //Select Index = 0
            Paritybits_comboBox.Items.Add("Mark");  //Select Index = 1
            Paritybits_comboBox.Items.Add("None");  //Select Index = 2
            Paritybits_comboBox.Items.Add("Odd");   //Select Index = 3
            Paritybits_comboBox.Items.Add("Space"); //Select Index = 4
            Paritybits_comboBox.SelectedIndex = 2;  //None 선택, 폼에서 입력해서 안해줘도 무방함.
            Stopbits_comboBox.Items.Clear();        //스톱 비트 콤보 박스 데이터 삭제 (안해도 됨)
            Stopbits_comboBox.Items.Add("1");       //Select Index = 0
            Stopbits_comboBox.Items.Add("1.5");     //Select Index = 1
            Stopbits_comboBox.Items.Add("2");       //Select Index = 2
            Stopbits_comboBox.SelectedIndex = 0;    //1선택, 폼에서 입력해서 안해줘도 무방함.

 

다음은 통신 포트를 추가 하도록 하겠다.

위에 방법으로 넣을수도 있지만 그렇게 하면 어떤것이 있는것인지 알수 없기에 검색해서 있는것만 표시 하도록 하겠다.

먼저 시리얼 통신을 위해 변수 선언을 해준다. 아래 사진에 위치에 SerialPort comport = new SerialPort(); 를 입력 해준다.

 

위에 입력했던 아래부분에 다음과 같이 입력 해준다.

            foreach (string serial_port_list in System.IO.Ports.SerialPort.GetPortNames())
            {
                try
                {
                    comport.PortName = serial_port_list;
                    comport.Open();
                    if (comport.IsOpen)
                    {
                        this.Comport_ComboBox.Items.Add(serial_port_list);
                        comport.Close();
                    }
                }
                catch { }
            }

 

다음 Comport Serial 장비를 PC에 연결하고 프로그램을 실행 해보자. 아래 그림을 보면 COM4로 장비가 하나 잡혀 있는것을 확인 할수 있다.

728x90
반응형
728x90
반응형

파이썬 프로그래에서는 C처럼 int, double, float등등 변수 구분해서 선언 하지 않음.

자료형에 따라서 자동으로 변수 할당이 됨.


#정수형 자료
print("정수형 자료")
num = 2
print(num)
print(type(num))    #변수 형식 출력

 

출력 :

정수형 자료
2
<class 'int'>


#실수형 자료
print("실수형 자료")
print(10/3)     #나누기 값 출력
print(type(10/3))   #형식 출력
print(10//3)    #나누고 정수만 출력
print(10%3)     #나누고 나머지만 값만 출력

출력 :
실수형 자료
3.3333333333333335
<class 'float'></class 'float'>
3
1


#복소수형 자료
print("복소수형 자료")
a = 1+3j    #실수부 : 1, 허수부 : 3
print (a.real, a.imag)  #실수, 허수 출력
print(type(a))  #a변수 형식 출력

 

출력 :
복소수형 자료
1.0 3.0
<class 'complex'></class 'complex'>

#문자형 자료
print('"Isn\'t, " they said.')
print("'Isn\'t,' they said.")
print("대한민국 \"만세!!!\"")

 

출력 :
"Isn't, " they said.
'Isn't,' they said.
대한민국 "만세!!!"

#문자열 연결하기, 문자열 반복 출력하기
print("대한"+"민국")
print(3*"대한"+"민국")

출력 :
대한민국
대한대한대한민국


#문자열 인덱스
str = "Python"
print(str[0])   #앞에서 첫번째
print(str[2])   #앞에서 세번째
print(str[-1])  #뒤에서 첫번째
print(str[-2])  #뒤에서 두번째

출력 :
P
t
n
o

728x90
반응형

'프로그램 > python' 카테고리의 다른 글

VSCODE에 Python 설치하기.  (0) 2024.06.04
파이썬 다운로드 & 설치  (0) 2024.05.31
728x90
반응형

VSCODE를 시작한다. 아래 화면을 보면 여기서 Create a Python file을눌러 시작해도 된다. 그러나 정리를 위해서 EXPLORER에서 시작 하겠다.

 

왼쪽 상단에 EXPLORER 클릭. Open Folder를 클릭하여 프로젝트를 저장하고 공부할 폴더를 선택 하자.

 

D 드라이브에 Python_test 폴더를 만든후 그곳에 hello라는 폴더를 하나더 만든후 그곳을 설정 했다.

다음과 같은 메시지가 뜨면 Yes를 눌러주자. (이폴더에 있는 파일을 신뢰 하냐고 물어봄)

 

왼쪽 창 HELLO 밑에 부분에서 마우스 우측 버튼을 누르고 New File...을 클릭한다.

 

hello.py 로 파일이름을 정하고 파일 내용은 print("hello") 라고 입력한다.

 

모두다 입력 했으면 F5 키를 눌러서 실행하자. 실행하면 아래와 같은 창이 뜨는데 엔턴을 눌러주자.

 

그러면 아래와 같이 hello 글씨가 출력 되는것을 확인 할수 있다.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

728x90
반응형
728x90
반응형

VSCODE를 실행후 왼쪽에 Extensions를 클릭하자. (마우스 손가락이 있는 부분이다.)

 

검색창에 python이라고 입력하면 여러개가 나온다. 그중 Microsoft에서 발행한 두가지를 설치 하자. 아래 표시를 해놓았다.

 

표시된 부분에서 Install을 눌러 두가지 모두 설치 하자. 위에 Python Install을 누르면 아래 있는 Python Debugger도 같이 설치 될것이다. 만약 안된다면 Install을 눌러 둘다 설치 하자.

 

아래 두가지 모두 설치가 된 화면이다.

 

 

 

설치는 여기까지.

728x90
반응형

'프로그램 > python' 카테고리의 다른 글

파이썬 변수 선언  (0) 2024.06.10
파이썬 다운로드 & 설치  (0) 2024.05.31

+ Recent posts