APPLICATION NOTE: KONSTANTER LSP32K Interface Protocol

Similar documents
Power Level Converter 3110 PC. C. Frame format The length of the frame is 26 bytes (compatible with FAB). The form is as the following:

Delphi Generics.Collections

uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, ImgList, StdCtrls, Buttons, MPlayer;

USB to RS-232/RS422/485. US-101-I USB To Serial Operation Manual

WiFi to RS-232 adapter user manual

LAMPIRAN Listing Program

LAMPIRAN A. Foto Alat

Interdisciplinary relations in teaching of programming

USB to RS-232/RS422/485. URK-228-I USB To Serial Operation Manual

Introduction to the DLL for the USB Interface Board K8061

LAMPIRAN A. Listing Program. Program pada Borland Delphi 7.0 A-1 Program pada CodeVisionAVR C Compiler A-6

Evaluation Board for ELM4 / LSM4. Technical Reference Manual

2. Design and Development

Active RFID Reader User Manual

NATIONAL SENIOR CERTIFICATE GRADE12

unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

Sender Receiver Sender

PCIe Card Selection Guide. PCIe-CAN Card. PCIe-COM Card. Taiwan Pulse Motion Co.,Ltd. Bus Interface PCI Express x 1 LPE-C122 PCE-C122D PCE-C122T

GRADE 12 SEPTEMBER 2012 INFORMATION TECHNOLOGY P1 MEMORANDUM

ACE PLUS CORP. APCON100 series Operation Manual RS-232 to Ethernet Converter

3.1 I-7560 Pin Assignment and Specifications: Introduction

DMX-Dongle II Win16, Win32 & Dos Developer s Guide

Forcom Technology Co., Ltd. Intelligent RS-485/422 to RS-232 converter

VS-626M5 Parameter Upload/Download Software User s Manual (Preliminary) 5/18/99

Chapter 11: Input/Output Organisation. Lesson 05: Asynchronous RS232C Serial Port data transfer

+ (5~27 VDC) GND. Bluetooth V4.1 BLE RS-232 Serial Adapter. Model: BLE-232B. 1. Package content: BLE RS-232 adapter

+ (5~27 VDC) GND. Bluetooth V4.2 BLE RS-232 Serial Adapter. Model: BLE-232D-E. 1. Package content: BLE RS-232 adapter

NATIONAL SENIOR CERTIFICATE GRADE 12

PCI Express 16-Port Serial I/O Cards

USB/RS232 TO cctalk COMMUNICATION BOARD Technical Information

UJIAN AKHIR SEMESTER TEKNIK INFORMATIKA SEKOLAH TINGGI TEKNOLOGI DUTA BANGSA

EX KVIS RS232/422/485 3-in-1 Serial to USB Adapter (w/ 4KV Isolation, 15KV ESD Surge Protection)

This 4-port RS-422/485 Adapter is provided with an external switching power adapter in the package.

USB to DB25 RS232 Adapter User Manual. Features. Windows 7/ Vista / 2003 / XP / 2000 Driver Installation

Digi-Pas. Installation and Operation Guidelines for DWL5000XY, DWL5500XY and DWL5800XY Tilt Sensor Modules. Rev

Product Manual. 8-Port RS-232 USB to Serial Adapter Data Control Box. Coolgear, Inc. Version 1.1 September 2017 Model Number: USB-8COM

Wiring Section 3-3. NQ-Series communication ports support various types of (serial) communication.

Serial Bluetooth Smart Adapter - RS232, Low Energy 4.1 BLE Datasheet and Quick Reference for BLE232V2

NATIONAL SENIOR CERTIFICATE GRADE12

ZLAN5443A. User Manual

Unique Micro Design First Choice of Professional Systems Intergrators. Model 361 Terminal Keyboard Wedge User Manual

Data Communication Protocol Host Computer to FAS-A

Updating Reader Firmware

Bluetooth V4.1 BLE RS-232 Serial Adapter Model: BLE-232B Bluetooth V4.2 BLE RS-232 Serial Adapter Model: BLE-232C

LM058 Bluetooth Serial Adapter SMA Antenna 100m m Range SPP GAP + Wireless DTR DSR RTS CTS

SC20MPC: 2 Mega Pixels Serial JPEG Camera User Manual. Introduction

Serial to Ethernet Converter HL-SE02P-V1. User s Manual V3.606

User s Manual Closer to Real, Zigbee Module ZIG-100. Wireless Communication. ROBOTIS CO.,LTD

IO Expansion Shield User Manual

USB-16COMi-M 16-Port RS-422/485 USB Serial Adapter User Manual. Features and Specifications. Power Supply

Bluetooth RS-232 Adapter

USB-2COM-BB USER S MANUAL

Использование ассиметричных алгоритмов криптографического преобразования информации в приложениях Windows

Experiment Ten THE PROJECT

Universal Asynchronous Receiver Transmitter Communication

GRADE/GRAAD 11 NOVEMBER 2013 INFORMATION TECHNOLOGY P1 INLIGTINGSTEGNOLOGIE V1 MEMORANDUM

USB-COMi-TB USB to Industrial Single RS-422 / 485 Adapter Manual. Specifications and Features

C1182 Video Compression Module User Manual. Release Note: 1 st Release : Aug 01, 2012

AMS COCKPIT USERS GUIDE. AMS Cockpit Version 1.1 USERS GUIDE

RM024 DVK USER GUIDE VERSION 1.2

SUNIX DEL2S00PL meets the PCI Express Base Specification Revision 2.0. It is compatible with PCI

USB TO RS-232/RS-422/RS-485 ADAPTER

Select a Data Communication Interface

TRP-C08. USB to RS232/422/485 Isolated Converter. User s Manual. Printed Sep.2014 Rev 1.4

Serial Bluetooth Smart Adapter - RS232, Low Energy 4.2 BLE Datasheet and Quick Reference for USBLE232C

BMV Text Protocol. Table of contents

USB-1. USB-Compatible Interface for the Persistor CF-1. Oceanographic Embedded Systems NE Seavy Ave. Corvallis, OR

USBG-8COM-PRO 8-Port USB to RS-232, 422, 485 Auto Setup Adapter Manual. Features & Specifications. Specifications

15693-RW-TTL-PCB1 CONTENT 1. MAIN FEATURES PINNING INFORMATION BAUD RATE SETTING COMMUNICATION PROTOCOL...5

BeagleBone Black USB Expansion RS232 Module Cape Coolgear, Inc. Version 1.1 September 2017 Model Number:

WiFi to RS-232 adapter user manual

Hardware Manual. PCMCIA 1 Port RS EDITION APRIL 1999

NATIONAL SENIOR CERTIFICATE GRADE12

Homework. Reading. Continue mp1. Labs. Tokheim, Section Questions? Continue labs with your assigned section

Image. uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls ;

RFID MODULE Mifare Read/Write Module SL025B User Manual Version 1.1 Jun 2010 StrongLink

1. Overview Technical Specifications Applications Pin Description Connection Diagram of RS 485 / 422 Converter...

Model:UT-8814 USB/RS-232 Commercial interface converter. Instruction Manual

using the Data-Linc SRM6000 Spread Spectrum Radio Modem (version 5.39) and Wonderware InTouch 95 (version 7.0.1)

GRADE 11 NOVEMBER 2012 INFORMATION TECHNOLOGY P1 INLIGTINGSTEGNOLOGIE V1 MEMORANDUM

Serial Interfacing. Asynchronous Frame

USB Port USB Serial DB-9 RS-232 Adapter FTDI Chipset. Product Manual. Coolgear Version 1.0 January 2018 Model Number: USB2-4COM-M

Appendix. Specifications

Lumio Release Note Lumio Multi-Touch Communication Protocol

The SC03MPA camera is capable of outputting JPEG format images and PAL/NTSC video (Video is available only per request).

Connecting UniOP to the ABB 07KT97 Controllers

Bluetooth TO Serial CONVERTER E-P132-B

Source code for simulations: 1 of 11

Communication. Outline of Communication. Merits

Chapter. Modbus. In This Chapter...

labmanual Open Communication

8 Port USB to RS- 232/422/485 Octal Adapter. Product Manual. Coolgear, Inc. Version 1.1 April 2018 Model Number: USB-8COMi-RM.

Document Name : User Manual for SC10B : RS232 to Bluetooth Converter.

ICP PANEL-TEC PEX3000 II

I-7560U/7561U/7563U. User Manual WARRANTY WARNING COPYRIGHT TRADEMARKS CONTACT US

SATEL I-LINK 100 MB I/O-converter User Guide, Version 1.1

Bluetooth to RS-232 Converter. RT-132B Bluetooth Adaptor Operation Manual

Serial Bluetooth Smart Adapter - RS232, Low Energy 4.2 BLE Datasheet and Quick Reference for USBLE232DEXA

Bluetooth RS232 Serial Adapter

LM048 Bluetooth v2.0, v2.1 RS232 Serial Adapter Standalone (With Embedded Bluetooth v2.0 / v2.1 Stack)

Transcription:

APPLICATION NOTE: KONSTANTER LSP32K Interface Protocol 1 Interface Type At the DB9 connector the LSP32K Power Supply device offers a serial data interface with TTL logic level for remote control and readout of set and measured parameters. A Converter 3311 (RS232-to-TTL) is required to link a single Power Supply to the RS232 COM port of a PC. PS Converter 3311 PC VCC RXD TXD GND 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 VCC RXD TXD DTR GND RTS A Converter 3312 (USB-to-TTL) is required to link a single Power Supply to the USB port of a PC. Up to 32 devices can be linked to a PC using one Converter 3313 (RS232-to-RS485) at the RS232 COM port of a PC and one Converter 3314 (RS485-to-TTL) at each Power Supply. For identification each Power Supply in the system must be set to a different device address (0 31). 2 RS232 Communication Settings Baud Rate: 4800, 9600, 19200, 38400 bps Data Bits: 8 Stop Bit: 1 Parity: None 3 Data Frame The length of the data frame is 26 bytes (compatible with FAB). The form is as follows. 1 2 3 4-25 26 AAh Address Command Byte Related Information Contents Checking Code Directives: 1) AAh occupies one byte. 2) Address ranges from 0 to FEh and occupies one byte. 3) Command Byte ranges from 80h to 90h and occupies one byte. The content of the Command Byte is as follows: a) 80h Setting the Max Current, the Max Power, the Voltage Level of the power supply. b) 81h Reading the current value, the voltage value, the power value and the state of the power supply. The state of the power supply contains the ON/OFF state, the Over-current state and the Over-power state. c) 82h Supervising the ON/OFF of the power supply. LSP32K Interface Protocol.doc Page 1 of 12 PS/GuHo/01.2006

d) 83h Programming. 4) Byte 4 to Byte 25 are the information contents. 5) Byte 26 is the checking code and is the accumulating of the 25 previous bytes. Use of the Command Bytes 6) Setup of the Max Current, the Max Power and the Voltage Level of the Power supply (80h) Byte 1 AAh Byte 2 Address (0-FEh) Byte 3 Command Byte (80h) Byte 4 Low Byte of the Max Current Byte 5 High Byte of the Max Current Byte 6 Low Byte of the Max Voltage Byte 7 High Byte of the Max Voltage Byte 8 Low Byte of the Max Power Byte 9 High Byte of the Max Power Byte 10 Low Byte of the Voltage Setup Byte 11 High Byte of the Voltage Setup Byte 12 New Address of the Power Supply Byte 13 to 25 Preserved by the System Byte 26 Checking Code Current, Voltage and Power are all expressed by two bytes, with low byte in the front and the high byte behind. Example: The current value 3589h is expressed as 89h 35h 7) Read the current, the voltage, the power and the state of the power supply Byte 1 AAh Byte 2 Address (0-FEh) Byte 3 Command Byte (81h) Byte 4 Low Byte of the Current Byte 5 High Byte of the Current Byte 6 Low Byte of the Voltage Byte 7 High Byte of the Voltage Byte 8 Low Byte of the Power Byte 9 High Byte of the Power Byte 10 Low Byte of the Max Current Byte 11 High Byte of the Max Current Byte 12 Low Byte of the Max Voltage Byte 13 High Byte of the Max Voltage Byte 14 Low Byte of the Max Power Byte 15 High Byte of the Max Power Byte 16 Low Byte of the Voltage Setup Byte 17 High Byte of the Voltage Setup Byte 18 The State of the Power Supply Byte 19 to Byte 25 Preserved by the System Byte26 Checking Code Current, Voltage and Power are all expressed by two bytes, with low byte in the front and the high byte behind. LSP32K Interface Protocol.doc Page 2 of 12 PS/GuHo/01.2006

The State of the Power Supply is expressed by one byte. Each unit is defined as: 7 6 5 4 3 2 1 0 Position 0: State of the power supply output. 0 is OFF and 1 is ON. Position 1: Over-current State of the power supply. 0 is normal and 1 is abnormal. Position 2: Over-power state of the power supply. 0 is normal and 1 is abnormal. Position 3: Operating State. 0 is for keyboard and 1 is for PC. Note: The frame of power supply answering the PC is the same as the above. 8) Control the Output ON/OFF of the power supply Byte 1 AAh Byte 2 Address Byte 3 Command Byte Byte 4 State of the Power Supply Byte 5 to Byte 25 Preserved by the System Byte 26 Checking Code The state of the power supply is expressed by one byte. Each unit is defined as: 7 6 5 4 3 2 1 0 Position 0: State of the power supply. 0 is OFF and 1 is ON. Position 1: PC control over the power supply. 0 is the power supply self-control and 1 is the PC control over the power supply. 9) Power supply automatically transmits the max current, the max power and the voltage levels to the PC. The frame is the same as frame of the setup of the max current, the max power and the voltage levels. LSP32K Interface Protocol.doc Page 3 of 12 PS/GuHo/01.2006

Samples 1 Note: The following procedure could be translated and edited in Delphi5.0. unit Main; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Comm32, ExtCtrls; // definition of constant const POWER_ADDRESS = $00; //The address of power supply ORDER_WRITE = $80; //setting instruction ORDER_READ = $81; //read data ORDER_CONTROL = $82; //control instruction PC_CONTROL = $02; //PC control SELF_CONTROL = $00; //self control of power supply POWER_ON = $03; //open the output POWER_OFF = $02; //close the output type TForm1 = class(tform) Comm232: TComm32; cbcomm: TComboBox; cbbaud: TComboBox; Label1: TLabel; Label2: TLabel; btnopen: TButton; Memo1: TMemo; cborder: TComboBox; btnsend: TButton; Bevel1: TBevel; procedure btnopenclick(sender: TObject); procedure FormCreate(Sender: TObject); procedure cborderclick(sender: TObject); procedure btnsendclick(sender: TObject); procedure Comm232RequestHangup(Sender: TObject); procedure Comm232ReceiveData(Buffer: Pointer; BufferLength: Word); private Private declarations SendBuf:array[0..25] of Byte; //send the data delay saving instruction ReceBuf:array[0..25] of Byte; //receive the data delay saving instruction Order :Byte; //instruction AddOrder:Byte; //accessory instruction procedure TotalBytes; //checking the total bytes procedure ShowSendBuf; //show the data send out procedure ShowReceBuf; //show the data receive in public Public declarations var Form1: TForm1; implementation $R *.DFM //open COM procedure TForm1.btnOpenClick(Sender: TObject); Comm232.StopComm; Comm232.CommPort:=cbComm.Text; Comm232.BaudRate:=StrToInt(cbBaud.Text); Comm232.ByteSize:=8; //8 byte size Comm232.Parity:=0; // Parity is none LSP32K Interface Protocol.doc Page 4 of 12 PS/GuHo/01.2006

Comm232.StopBits:=0; //1 byte stop try Comm232.StartComm; btnsend.enabled:=true; except ShowMessage(Format('Falied to open %s',[cbcomm.text])); btnsend.enabled:=false; // parameter initialize procedure TForm1.FormCreate(Sender: TObject); cborder.itemindex:=0; Order:=Order_Read; //chose instruction procedure TForm1.cbOrderClick(Sender: TObject); case cborder.itemindex of 0 : Order:=Order_Read; //Read Params 1 : Order:=Order_Write; //Params Setting 2 : //PC Control Order:=Order_Control; AddOrder:=Pc_Control; 3 : //Control By Self Order:=Order_Control; AddOrder:=Self_Control; 4 : //Power Off Order:=Order_Control; AddOrder:=Power_Off; 5 : //Power On Order:=Order_Control; AddOrder:=Power_On; //send the data procedure TForm1.btnSendClick(Sender: TObject); var CurrentMax:Word; //the max of current (proportion coefficien 1000) VoltageMax:Word; //the max of voltage (proportion coefficien 1000) PowerMax :Word; //the max of power(proportion coefficien 100) CurVoltage:Word; // current voltage value (proportion coefficien 1000) CurrentMax:=3000; //3A VoltageMax:=36000; //36V PowerMax :=10800; //108W CurVoltage:=10000; //10V FillChar(SendBuf,26,0); SendBuf[0]:=$AA; SendBuf[1]:=Power_Address; SendBuf[2]:=Order; if Order = Order_Write then //setting parameter SendBuf[3]:=CurrentMax mod 256; SendBuf[4]:=CurrentMax div 256; SendBuf[5]:=VoltageMax mod 256; SendBuf[6]:=VoltageMax div 256; SendBuf[7]:=PowerMax mod 256; SendBuf[8]:=PowerMax div 256; LSP32K Interface Protocol.doc Page 5 of 12 PS/GuHo/01.2006

SendBuf[9]:=CurVoltage mod 256; SendBuf[10]:=CurVoltage div 256; SendBuf[11]:=Power_Address; if Order = Order_Control then SendBuf[3]:=AddOrder; TotalBytes; ShowSendBuf; Comm232.WriteCommData(@SendBuf,26); //COM hang procedure TForm1.Comm232RequestHangup(Sender: TObject); Comm232.StopComm; Comm232.StartComm; //receive the byte procedure TForm1.Comm232ReceiveData(Buffer: Pointer; BufferLength: Word); var i:byte; Byte25:Byte; if BufferLength <> 26 then Exit; CopyMemory(@ReceBuf,Buffer,26); if ReceBuf[0] <> $AA then Exit; if not (ReceBuf[2] in [Order_Write..Order_Control]) then Exit; Byte25:=0; for i:=0 to 24 do Byte25:=Byte25+ReceBuf[i]; if Byte25 <> ReceBuf[25] then Exit; ShowReceBuf; //caculate the total byte procedure TForm1.TotalBytes; var i:byte; SendBuf[25]:=0; for i:=0 to 24 do SendBuf[25]:=SendBuf[25]+SendBuf[i]; //show the date send out procedure TForm1.ShowSendBuf; var i:byte; Str:String; for i:=0 to 25 do Str:=Str+' '+IntToHex(SendBuf[i],2); Memo1.Lines.Add('Send :'+Str); //show the data receive in procedure TForm1.ShowReceBuf; var i:byte; Str:String; for i:=0 to 25 do Str:=Str+' '+IntToHex(ReceBuf[i],2); Memo1.Lines.Add('Rece :'+Str); end. LSP32K Interface Protocol.doc Page 6 of 12 PS/GuHo/01.2006

Samples 2 Note: The following program could be edited and translated in VC6.0. 1. The definition of Variable and Function public: BYTE Cur_Order; //commend character BYTE Add_Order; //accessory character int Rece_Count; //the byte size of receive in CByteArray SendBuf; //send the instruction of delay saving CByteArray ReceBuf; //receive the instruction of delay saving void InitData(); //initial dealy saving void CalDataTotal(); //check and caculate the total data void ShowSendData(); //show the data send out void ShowReceData(); //show the data receive in 2. Definition of constant const BufferMax = 26; //the max value of data delay saving const POWER_ADDRESS = 0x00; // The address of power supply const ORDER_WRITE = 0x80; //setting instruction. const ORDER_READ = 0x81; //read parameter const ORDER_CONTROL = 0x82; //control instruction. const PC_CONTROL = 0x02; //PC control const SELF_CONTROL = 0x00; //self-control of power supply const POWER_ON = 0x03; //open the output const POWER_OFF = 0x02; //close the output 3. Function -part 3.1 Calculate the total data void CCommDlg::CalDataTotal() BYTE i; BYTE Value1; Value1=0; for (i=0;i<=buffermax-2;i++) Value1=Value1+SendBuf.GetAt(i); SendBuf.SetAt(BufferMax-1,Value1); 3.2 Initialization of dealy saving data void CCommDlg::InitData() Rece_Count=0; SendBuf.SetSize(26); ReceBuf.SetSize(26); SendBuf.RemoveAll(); ReceBuf.RemoveAll(); for (BYTE i=0;i<=buffermax-1;i++) SendBuf.Add(0); ReceBuf.Add(0); SendBuf.SetAt(0,0xAA); SendBuf.SetAt(1,POWER_ADDRESS); SendBuf.SetAt(2,ORDER_READ); Cur_Order=ORDER_CONTROL; Add_Order=POWER_OFF; CalDataTotal(); ShowSendData(); 3.3 Show the data be send out void CCommDlg::ShowSendData() LSP32K Interface Protocol.doc Page 7 of 12 PS/GuHo/01.2006

BYTE i; BYTE Value; CString Temp; m_senddata=""; for (i=0;i<=buffermax-1;i++) Value=SendBuf.GetAt(i); Temp.Format("%2x",Value); if (Value < 16) Temp.SetAt(0,'0'); m_senddata+=temp; m_senddata+=" "; m_senddata.makeupper(); UpdateData(FALSE); 3.4 Show the data be received in void CCommDlg::ShowReceData() BYTE i; BYTE Value; CString Temp; for (i=0;i<=buffermax-1;i++) Value=ReceBuf.GetAt(i); Temp.Format("%2x",Value); if (Value < 16) Temp.SetAt(0,'0'); m_receivedata+=temp; m_receivedata+=" "; m_receivedata+="\r\n"; m_receivedata.makeupper(); UpdateData(FALSE); 3.5 Convert to hexadecimal data int Str2Hex(CString str,cbytearray &data) int t,t1; int rlen=0,len=str.getlength(); data.setsize(len/2); for(int i=0;i<len;) char l,h=str[i]; if(h==' ') i++; continue; i++; if(i>=len) l=str[i]; t=hexchar(h); t1=hexchar(l); if((t==16) (t1==16)) else t=t*16+t1; i++; data[rlen]=(char)t; rlen++; data.setsize(rlen); return rlen; LSP32K Interface Protocol.doc Page 8 of 12 PS/GuHo/01.2006

3.6 convert the data into initialization data. int Str2Hex(CString str,cbytearray &data) if((c>='0')&&(c<='9')) return c-0x30; else if((c>='a')&&(c<='f')) return c-'a'+10; else if((c>='a')&&(c<='f')) return c-'a'+10; else return 0x10; 4. Dealing 4.1 Receiving the data void CCommDlg::OnComm() if(stop)return; VARIANT m_input1; COleSafeArray m_input2; long length,i; BYTE data[1024]; CString str; if(m_comm.getcommevent()==2)//receive the data of buffer. m_input1=m_comm.getinput();//read the data of buffer m_input2=m_input1;//convert the variable of VARIANT to variable ColeSafeArray length=m_input2.getonedimsize();//confirm the length of data for(i=0;i<length;i++) m_input2.getelement(&i,data+i);//convert the data to BYTE type. for(i=0;i<length;i++)//convert the data to variable of Cstring. BYTE a=* (char *)(data+i); if(m_hex.getcheck()) str.format("%02x ",a); if ((a==0xaa) && (Rece_Count>=26)) Rece_Count=0; //Saving data to ReceBuf ReceBuf.SetAt(Rece_Count+i,a); else str.format("%c",a); Rece_Count=Rece_Count+length; UpdateData(FALSE);//update of content of edition. //dealing the received data if (Rece_Count == 26) //1. check the AAh if (ReceBuf.GetAt(0)!= 0xAA) exit(0); //2.Check the address if (ReceBuf.GetAt(1)!= POWER_ADDRESS) exit(0); //3.Check the instruction if (ReceBuf.GetAt(2) < 0x80) exit(0); if (ReceBuf.GetAt(2) > 0x82) exit(0); //4.check the code BYTE Total,i; Total=0; for (i=0;i<=buffermax-2;i++) Total=Total+ReceBuf.GetAt(i); if (Total!= ReceBuf.GetAt(BufferMax-1)) LSP32K Interface Protocol.doc Page 9 of 12 PS/GuHo/01.2006

... exit(0); //correct data dealing part ShowReceData(); 4.2 Initialization dialogue frame BOOL CCommDlg::OnInitDialog() // TODO: Add extra initialization here //initialization control part and amortize. m_com.setcursel(0); m_speed.setcursel(4); m_order.setcursel(0); m_hexsend.setcheck(1); m_hex.setcheck(1); UpdateData(TRUE); InitData(); return TRUE; // return TRUE unless you set the focus to a control 4.3 Open COM void CCommDlg::OnButton1() if(!m_comm.getportopen()) m_comm.setportopen(true);//open the interface else m_comm.setportopen(false); m_comm.setportopen(true);//open the interface UpdateData(TRUE); 4.4 Clear the receiving data void CCommDlg::OnButton2() m_receivedata.empty();// delete the data of receiving dialogue frame //m_senddata.empty();// delete the data of sendin-g dialogue frame UpdateData(FALSE); 4.5 Chose COM void CCommDlg::OnComselect() if(m_comm.getportopen()) m_comm.setportopen(false); m_comm.setcommport(m_com.getcursel()+1); 4.6 Setting Baud rate void CCommDlg::OnComspeed() CString temp; int i=m_speed.getcursel(); switch(i) case 0: i=2400; case 1: i=4800; LSP32K Interface Protocol.doc Page 10 of 12 PS/GuHo/01.2006

case 2: i=9600; case 3: i=19200; case 4: i=38400; temp.format("%d,n,8,1",i); m_comm.setsettings(temp); 4.7 Receiving data void CCommDlg::OnSend() // TODO: Add your control notification handler code here //setting data which will be send out SendBuf.SetAt(2,Cur_Order); SendBuf.SetAt(3,Add_Order); if (m_order.getcursel()==1) //setting current is 3A coeffcient of proportionality1000 SendBuf.SetAt(3,3000 % 256); SendBuf.SetAt(4,3000 / 256); //Setting voltage of 36Vcoeffcient of proportionality1000 SendBuf.SetAt(5,36000 % 256); SendBuf.SetAt(6,36000 / 256); //Setting power is 08Wcoeffcient of proportionality100 SendBuf.SetAt(7,10800 % 256); SendBuf.SetAt(8,10800 / 256); //Setting the output voltage of 3Vcoeffcient of proportionality1000 SendBuf.SetAt(9,3000 % 256); SendBuf.SetAt(10,3000 / 256); //Setting the addresspower_address SendBuf.SetAt(11,POWER_ADDRESS); if( m_comm.getportopen()) CalDataTotal(); ShowSendData(); if(m_hexsend.getcheck()) int len=str2hex(m_senddata,sendbuf); m_comm.setoutput(colevariant(sendbuf));//send the data else m_comm.setoutput(colevariant(m_senddata));//send the data else MessageBox("COM!",NULL,MB_OK); 4.8 Commend choice void CCommDlg::OnSelendokOrder() int i=m_order.getcursel(); switch(i) case 0: Cur_Order=ORDER_READ; case 1: Cur_Order=ORDER_WRITE; case 2: LSP32K Interface Protocol.doc Page 11 of 12 PS/GuHo/01.2006

Cur_Order=ORDER_CONTROL; Add_Order=PC_CONTROL; case 3: Cur_Order=ORDER_CONTROL; Add_Order=SELF_CONTROL; case 4: Cur_Order=ORDER_CONTROL; Add_Order=POWER_ON; case 5: Cur_Order=ORDER_CONTROL; Add_Order=POWER_OFF; LSP32K Interface Protocol.doc Page 12 of 12 PS/GuHo/01.2006