10.07.2015 Views

cubloc_manual2.pdf

cubloc_manual2.pdf

cubloc_manual2.pdf

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MODBUS 마스터 모드 구현CUBLOC 을 MODBUS 마스터로 사용할 수 있는 방법에 대하여 설명합니다. MODBUS 마스터모드를 처리하기 위한 특별한 명령어는 없습니다. 마스터 모드는 RS232 데이터를 발생시키고, 수신할 수 있는 기능만 있으면, 특별한 명령어없이 처리할 수 있으므로, CUBLOC 의 GET, PUT 과 같은 RS232 송수신 명령으로 MODBUS 마스터기능을 모두 구현할 수 있습니다. 다음은 MODBUS마스터를 BASIC 으로 구현한 샘플 프로그램 입니다.두개의 CB280 의 RS232 CH1 을 서로 연결 (TX-RX, RX-TX 가 되도록)하시고, 한쪽에는Master 소스를 다른 한쪽에는 Slave 용 소스를 다운로드한뒤, 실행시켜 보세요! Slave 쪽 CB280의 포트 0~2 에 LED 를 연결하세요! 그러면 Master 쪽에서 Slave 의 LED 를 MODBUS 를 사용해서 On/Off 제어하는 것을 확인할 수 있습니다.마스터쪽에는 아래 소스를 입력하세요'Master SourceConst Device = cb280Dim RDATA As String * 80Dim a As Byte, ct As ByteDim b As String * 17Dim Port As IntegerOpencom 1,115200,3,80,80On Recv1 Gosub GETMODBUS ' Data Receive Interrupt routineSet Until 1,60,10 ' When Ending Code (10)' on Channel 1 is discovered,' create an interruptDoFor Port=2 To 4BitWrite Port, 1'Turn P0,P1,P2 ON!Delay 100NextFor Port=2 To 4BitWrite Port, 0'Turn P0,P1,P2 OFF!Delay 100NextLoop266GETMODBUS:If Blen(1,0) > 0 Then ' If buffer empty thenA=Blen(1,0) ' Store the buffer length in A!Debug "GOT RESPONSE: "B=Getstr(1,A)' Store received data in BDebug BEnd IfReturn

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!