Write DXF Line

Option Explicit

Type Point3D '3차원 점의 좌표를 위한 사용자정의자료형
    X As Double
    Y As Double
    Z As Double
End Type


Public Sub WriteLineDXF(fileNo As Integer, StartPoint As Point3D, EndPoint As Point3D)

 Dim DXFCode As Integer 'DXF Group Code
 Dim DXFValue As Variant 'DXF value
 '
 DXFCode = 0
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = "LINE"
 Print #fileNo, DXFValue
 '
 DXFCode = 8
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = 0
 Print #fileNo, DXFValue
 '
 DXFCode = 62
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = 4
 Print #fileNo, DXFValue
 '
 DXFCode = 10
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = StartPoint.X
 Print #fileNo, DXFValue
 '
 DXFCode = 20
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = StartPoint.Y
 Print #fileNo, DXFValue
 '
 DXFCode = 30
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = StartPoint.Z
 Print #fileNo, DXFValue
 '
 DXFCode = 11
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = EndPoint.X
 Print #fileNo, DXFValue
 '
 DXFCode = 21
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = EndPoint.Y
 Print #fileNo, DXFValue
 '
 DXFCode = 31
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = EndPoint.Z
 Print #fileNo, DXFValue
End Sub
Sub TestFile()
 Dim fileName As String, textData As String, fileNo As Integer
 '
 Dim DXFCode As Integer 'DXF Group Code
 Dim DXFValue As Variant 'DXF value
 '
 
 fileName = "C:\MyChair.DXF" ' for Mac
 fileNo = FreeFile 'Get first free file number
 '
 '
 Open fileName For Output As #fileNo
 '
 DXFCode = 999
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = "Created by SolarView"
 Print #fileNo, DXFValue
 '
 DXFCode = 10
 Print #fileNo, Format(DXFCode, "@@@")
 DXFValue = 12.5
 Print #fileNo, DXFValue
 '
 Close #fileNo
End Sub

글쓰기 테스트3

아래 글은 Edge에서 작업한 내용임

○ 노후 건축물의 구조 안전성 기반 그린 리모델링 선별기준 개발을 통한 미래 발생 가능 재난(지진, 에너지 대란 등)에 대한 선제적 대응 효과 → 잠재적 재난에 의한 인명 및 재산 피해 최소화

글쓰기 테스트 2

아래 내용은 크롬에서 복사하여 붙인 내용임

○ 노후 건축물의 구조 안전성 기반 그린 리모델링 선별기준 개발을 통한 미래 발생 가능 재난(지진, 에너지 대란 등)에 대한 선제적 대응 효과 → 잠재적 재난에 의한 인명 및 재산 피해 최소화

글쓰기 테스트

아래 내용은 firefox에서 복사하여 붙인 내용임.

○ 자연재해(지진) 등을 고려한 그린 리모델링 대상 기존 건축물 표준모델 개발

○ 건물에너지 해석을 위한 최신 표준기상데이터 개발

○ 건물에너지 성능 시뮬레이션에서 활용 가능한 태양광발전시스템 평가방법론 구축

○ BIM 기반 구조/에너지 성능평가 기술 분석 및 활용방안 마련

[RPi]MCP3008 vs MCP3208

라즈베리파이의 GPIO에는 아날로그 신호를 처리하는 것이 없다. 그래서 아날로그 신호를 내보내는 대부분의 센서를 처리하기 위해서는 ADC(analog-to-digital converter)가 필요하다. ADC 중에는 MCP3008와 MCP3208 등이 있다. 라즈베리파이와 ADC 간의 통신은 SPI를 이용한다.

MCP3008, MCP3004, MCP3208, MCP3204

다음 웹페이지에는 MCP3008, MCP3004, MCP3208, MCP3204 에 대한 데이터시트에 가까운 정보를 제공하고 있다.

Raspberry PI – Adding analogue inputs using MCP3008, MCP3004, MCP3208, MCP3204

그리고 여기는 spidev 라이브러리를 이용하였다. ADC에서 읽은 값이 해상도가 10비트이면 0~1023, 12비트이면 0~4095라는 것을 알 수 있다.

spidev 라이브러리를 이용하여 https://kalten.tistory.com/46 처럼, 통신 여부를 검토하였더니 잘 작동하지 않아서 RPi.GPIO 라이브러리를 이용하였다.

MCP3008에서 센서의 신호처리(SPI통신)

다음은 신호처리를 위해 작성한 파이썬 코드이다. RPi.GPIO 라이브러리를 이용하였다.

import RPi.GPIO as GPIO
 
GPIO.setmode(GPIO.BCM)
 
# MCP3008 칩으로부터 SPI 신호를 읽는다. 8개 센서를 둘 수 있다.(adcnum은 0번부터 7번까지)
def readadc(adcnum, clockpin, mosipin, misopin, cspin):
        if ((adcnum > 7) or (adcnum < 0)):
                return -1
        GPIO.output(cspin, True)      # CS핀을 high로 만든다.
 
        GPIO.output(clockpin, False)  # clock핀을 low로 만든다. 
        GPIO.output(cspin, False)     # CS핀을 low로 만든다.
 
        commandout = adcnum
        commandout |= 0x18  # start bit + single-ended bit
        commandout <<= 3    # we only need to send 5 bits here
        for i in range(5):
                if (commandout & 0x80):
                        GPIO.output(mosipin, True)
                else:
                        GPIO.output(mosipin, False)
                commandout <<= 1
                GPIO.output(clockpin, True)
                GPIO.output(clockpin, False)
 
        adcout = 0
        # MCP3008은 10비트의 해상도를 갖고 있다.
        # MCP3008에서 총 12비트을 읽는다. (=one empty bit, one null bit and 10 ADC bits)
        for i in range(12):
                GPIO.output(clockpin, True)
                GPIO.output(clockpin, False)
                adcout <<= 1
                if (GPIO.input(misopin)):
                        adcout |= 0x1
 
        GPIO.output(cspin, True)
         
        adcout >>= 1       # first bit is 'null' so drop it
        return adcout      # adcout는 0부터 1023까지 값을 갖는다.
#end of def

MCP3208에서 센서의 신호처리

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)

# MCP3208 칩으로부터 SPI 신호를 읽는다. 8개 센서를 둘 수 있다.(adcnum은 0번부터 7번까지)
def readadc(adcnum, clockpin, mosipin, misopin, cspin):
        if ((adcnum > 7) or (adcnum < 0)):
                return -1
        GPIO.output(cspin, True)      # CS핀을 high로 만든다.
        GPIO.output(clockpin, False)  # clock핀을 low로 만든다. 시작한다.
        GPIO.output(cspin, False)     # CS핀을 low로 만든다.
        commandout = adcnum
        commandout |= 0x18  # start bit + single-ended bit
        commandout <<= 3    # we only need to send 5 bits here
        for i in range(5):
                if (commandout & 0x80):
                        GPIO.output(mosipin, True)
                else:
                        GPIO.output(mosipin, False)
                commandout <<= 1
                GPIO.output(clockpin, True)
                GPIO.output(clockpin, False)
        adcout = 0
        # MCP3208은 12비트의 해상도를 갖고 있다.
        # MCP3208에서 총 14비트을 읽는다. (=one empty bit, one null bit and 12 ADC bits)
        for i in range(14):
                GPIO.output(clockpin, True)
                GPIO.output(clockpin, False)
                adcout <<= 1
                if (GPIO.input(misopin)):
                        adcout |= 0x1
        GPIO.output(cspin, True)
        
        adcout <<= 1       # first bit is 'null' so drop it
        return adcout      # adcout는 0부터 4095까지 값을 갖는다.
#end of def

SPI at Rasberry Pi GPIO Pinout

SPI통신을 위한 라즈베리 파이의 GPIO 핀 배치는 다음과 같다.

SPI – Serial Peripheral Interface at Raspberry Pi

참고문헌

https://github.com/RaresPlescan/daisypi/blob/master/sense/mcp3208/adc_3.py

[rpi]심장 박동 측정

라즈베리파이로 심장 박동을 측정하려 한다.

준비물로는 라즈베리파이, 심장박동 센서( Pulsesensor.com ), ADC (MCP3208)가 필요하다. 심장박동 센서가 아날로그 신호를 내기에 이 신호를 디지털로 바꿔주는 ADC가 있어야 한다.

[통신] 파이와 ADC 간의 통신

라즈베리파이와 ADC 간의 통신은 SPI를 이용한다.

[참고자료]

Building a MicroPython heart rate monitor
Finding the beat in HR sensor data

Heart rate (HR) sensors

[rpi]Windows 10 IoT Core 개발환경 만들기

라즈베리파이3에 WINDOWS 10 IOT CORE 설치

라즈베리파이3 WINDOWS 10 IOT CORE 개발 환경 구축

여기서, 개발 PC를 “개발자 모드”로 변경한다는 것은 원격접속 기능을 사용할 수 있게 한다.

개발 환경 구축하기

WINDOWS 10 IOT CORE에 POWERSHELL로 연결하기

Enter-PSSession-ComputerName192.168.1.202 -Credential192.168.1.202\Administrator
PowerShell로 연결하기

WINDOWS 10 IOT CORE에 SSH로 연결하기

Putty 접속할 때, SSH2_MSG_UNIMPLEMENTED packet error가 발생하면, To solve the issue, open the configuration for the connection and navigate to SSH -> Kex. In the “Algorithm selection policy”, move the “Diffie-Hellman group 14” entry to the first position in the list. (SSH2_MSG_UNIMPLEMENTED packet error with PuTTY and RHEL 7.2 를 참조)한다.

SSH 접속을 위한 PuTTY의 설정 화면

WINDOWS 10 IOT CORE를 위한 VISUAL STUDIO 설정