Home

Modbus Slave Daemon

image

Contents

1. tmp 0 RetValue Open Slot slot if RetValue 570 printf open Slot d failed Nn slot return l 18024 Initial slot while 1 Float inverse Big Endian it depends on your SCADA short 1 1 iMemory_AI 0 short amp 1 iMemory_AI 1 wy Float Little Endian short amp 1 iMemory ao 0 lene Analog value using floating point data type to represent Floating point data size is 4 bytes It uses two registers to store floating point data short amp 1 1 iMemory ao 1 f float 6 amp 1 if tmp f printf set value f n T8024 VoltageOut slot channel f tmp usleep 100 Close Slot slot return 0 ICPDASO Modbus Server User Manual 8 2 2 2 Get Al 1 8017HW The following graph shows the how to Get Al value between modbus server and getai program via shared memory e Shared Memory Store Al Value to shared memory 9 Get Data from shared getai program E Function Code 04 LI Get Al Value from Al 9 Read Input Registers Modbus Client Response data Al value Figure 2 2 2 getai program get ai value from Al Device I 8017HW e getai program put Al value to share memory gt O to e is Looping 9 modbus server get Al value from shared memory 9 modbus client send requeset to modbus server 9 modbus server send response to modbus client Example setao c Sour
2. DASO Modbus Server User Manual 14
3. Software Guide ICP DAS Modbus Server Version 1 0 Version 1 0 lastupdate 2010 11 17 Warranty All products manufactured by ICP DAS Inc are warranted against defective materials for a period of one year from the date of delivery to the original purchaser Warning ICP DAS Inc assume no liability for damages consequent to the use of this product ICP DAS Inc reserves the right to change this manual at any time without notice The information furnished by ICP DAS Inc is believed to be accurate and reliable However no responsibility is assumed by ICP DAS Co Lid for its use nor for any infringements of patents or other rights of third parties resulting from its use Copyright Copyright 2010 by ICP DAS Co Ltd All rights are reserved Trademark The names used for identification only maybe registered trademarks of their respective companies License The user can use modify and backup this software on a single machine The user may not reproduce transfer or distribute this software or any copy in whole or in part ICPDASO Modbus Server User Manual 1 Contents Chapter 1 lilTOQUCDON sais ea krabo aa kasko kaa Ka ksa ka kda suka iaa 1 1 Install Modbus server on your LinPAC LinCon ento 4 Chapter 2 Using shared memeoy in YOU pIOgram sssssscecssssssseee 2 1 Using POSIX Shared MEMON eln kakao alo kaosa la o 6 22 Analoo VO DEMO sss Dr nolo E o A e hess 7 22 SECAO E SOLA ad 22 2 eet A
4. a0 2000 It will open shared memory dev shm mbs ao and mapping it to iMemory AO by default Then you can access shared memory via array Array s range is from 0 1999 iMemory AO 90x1234 0x5678 0 1 2 Ss 1999 Example iMemory_AO 1 0x01234 Set value 0x01234 to address 1 of IMemory AO printf 04x n iMemory _AO 3 GET value from address 3 of IiMemory AO ICPDASO Modbus Server User Manual 6 2 2 Analog UO DEMO 2 2 1 Set AO I 8024W The following graph shows how to SET AO value between modbus server and setao program via shared memory Shared Memory Get Data from shared memory Store data in shared memory Function Code 06 la Modbus Write Single register Modbus Server Client AO Device Figure 2 2 1 9 modbus client send request to modbus server 9 modbus server put the AO value to shared memory 9 setao program fetch ao value from share memory O setao program set ao value to AO device I 8024W Example setao c Source code include lt stdio h gt include lt stdlib h gt aa Include icpdas mbs h include icpdas mbs h include msw h int ment void 4 OPEN AO AI DO DI Share Memory SHM_INIT a0 2000 Use SHM_INIT Marco to open shared memory int RetValue slot channel float tmp 0 0 float f 0 0 unsigned long 1 slot 2 ICPDASO Modbus Server User Manual 7 channel 0
5. ce code include lt stdio h gt include icpdas_mbs h include msw h int main int argc char argv int RetValue slot channel gain mode float f unsigned long 1 slot 3 channel 0 gain 0 mode 0 OPEN Share Memory SHM INIT AI 2000 ICPDASO Modbus Server User Manual 9 E Op n device file RetValue Open_Slot slot if RetValue gt 0 printf open Slot d failed 1n slot return FAILURE RetValue 18017_Init slot while VAS f I8017 SetChannelGainMode slot channel gain mode 1 Get AI Value I8017 GetCurAdChannel Float Cal slot 1 unsigned long 8f Float inverse Big Endian depends on your SCADA iMemory_AT 0 short amp 1 1 iMemory_AI 1 short 81 Float Little Endian iMemory AI 0 Y short amp 1 iMemory AI 1 short 1 1 Analog value using floating EE E E point data type to represent asleep Floating point data size is 4 bytes It use two register to store rose Set floating point data return 0 ICPDASO Modbus Server User Manual 10 2 3 Digital UO Demo 2 3 1 Set DO and Read DI i 87054W The following graph shows the how to Get Al and Set AO value between modbus server and get di set do program via shared memory Get DO value from Shared Memory shared memory Get Data Set Data Set DI value t
6. ify parameters to fit your system STEP 3 Creat a symbolic link in etc rc2 d directory In s etc init d mbserver etc rc2 d S99MBServer NOTE Modbus server must be executed after serial port initialization Hardware Connection LinPAC LinCon Modbus Server supports Modbus RTU and Modbus TCP protocol For TCP protocol You can connect modbus client and server by using the ethernet cable with RJ 45 connector For RTU protocol 9 pins D sub cable is necessary The pin assignment is Ordering Information CA 0910F 9 pin Female Female D sub cable 1M Cable ICPDAS Modbus Server User Manual 5 Chapter 2 Using shared memeoy in you program 2 1 Using Posix Shared memory When you start the modbus server it will allocate four shared memory on LinPAC LinCon Shared memory are located at dev shm mbs ao dev shm mbs ai dev shm mbs do and dev shm mbs di Shared memory Size Use dev shm mbs ao 2000 sizeof int AO dev shm mbs ai 2000 sizeof int Al dev shm mbs do 2000 sizeof int DO dev shm mbs di 2000 sizeof int DI POSIX provides a standardized API for using shared memory POSIX Shared Memory uses the function shm open from sys mman h http www opengroup org onlinepubs 009695399 basedefs sys mman h html If you never used POSIX shared memory we also provide a simple MACRO SHM_INIT in icpdas mbs h to help you using shared memory Example SHM INIT
7. inks Step 2 Step 3 Step 4 LinPAC 8x8x ftp ftp icodas com pub cd linpac napdos Ip 8x8x addons modbus server LinPAC 8x4x ftp ftp icodas com pub cd linpac napdos Ip 8x4x addons modbus server Copy the mbserver10 file to your LinPAC LinCon and change the file permission to 755 or above chmod 755 mbserver10 Before executing LinPAC LinCon Modbus Server you have to check what s the index number of your TTY devices dmesg grep ttyS In general LinCon support 2 serial ports ttySO COM2 RS 232 Recommend ttyS1 COM3 RS 485 and 3 serial ports are availabled on LinPAC ttySO COM1 RS232 Reserved for console terminal ttyS1 COM3 RS232 RS 485 ttyS34 COM4 RS232 Recommend You can use following command to start Modbus Server mbserver10 Modbus server provides the following arguments Set NetID Default is 1 Set Port Number for Modbus TCP default is 502 Enable Daemon mode default is disable Set serial port device name for modubs rtu default is dev ttyS34 Set Baud rate default is 9600bps ICPDAS Modbus Server User Manual 4 f Set data format default is 8N1 Example mbserver10 n 1 s dev ttyS34 b 115200 f 8N 1 Running automatically at boot time STEP 1 Copy mbserver file to etc init d of your LinPAC LinCon STEP 2 Edit mbserver script file specify mbserver10 directory and mod
8. o trom shared to shared get di set do shared memory memory memory Function Code 01 Get DI Function Code 05 Set DO program M Modbus Ge Get DI Get DO Value Client Server Response DI DO Device Figrue 2 3 1 x I 87054w provides both DO and DI function Example get di set do c Source code include lt stdio h gt include lt stdlib h gt include icpdas_mbs h include msw h char szSend 80 szReceive 80 DWORD dwBuf 12 float fBuf 12 void change_bit int val int num char bitval val val 1 lt lt num bitval lt lt num ICPDASO Modbus Server User Manual 11 void set di char b EX unsigned char mask 0x01 DI value is 21 10101000 ITE if b mask 0 for i 0 i 8 1 iMemory_DI i 1 1 0 1 0 1 H H o else o 1 2 3 4 5 6 7 iMemory_DI i 0 Memory_DI de mask lt lt 1 int main int i wRetVal int tval 0 int tval2 0 SHM INIT DO 2000 SHM INIT DI 2000 Check Open Slot wRetVal Open Slot 0 if wRetVal gt 0 printf open Slot failed Nn return 1 Check Open_Coml wRetVal Open Com COM1 115200 Data8Bit NonParity OneStopBit if wRetVal gt 0 printf open port failed Nn return 1 ICPDASO Modbus Server User Manual 12 Choose Slot3 ChangeToSlot 4 while 1 for i 0 i lt 8 i if iMemor
9. t AA EENEG AO NN 11 2 3 1 Set DO and Read DI i 87054W 11 3 1 Set and Rea i Dis 2 4 Download Demo Pl a as 14 ICPDASO Modbus Server User Manual 2 Chapter 1 Introduction This manual is written for modbus users of ICPDAS LinPAC and LinCon series This document will guide you Howto setup Modbus Server on your devices How to write program with shared memory ICPDAS Modbus Server is a modbus slave server that provides shared memory to share data with other process Shared Memory is an efficient means of passing data between programs One program will create a memory portion which other processes if permitted can access The use of shared memory in an application requires implementation of just a few interfaces bundled into the standard C language library ICPDAS Modbus Server provides POSIX shared memory mechanism POSIX shared memory is a variation of mapped memory The following figure shows that Modbus Server communicating to other process via POSIX shared memory Modbus TCP Modbus RTU Modbus Slave Daemon Read Write Slot User Processes Posix Shared Memory 3 9 am 1 7000 17000 en ICPDASO Modbus Server User Manual 3 1 1 Install Modbus server on your LinPAC LinCon Software Installation If your LINPAC LinCon is former released you have to install the Modebus Server by manual Step 1 ICPDASO Modbus Server supports LinPAC 8x8x and 8x4x you can download from the following l
10. y DO i e a ajbiniskeit 1 1 Get DO value from shared else memory iMemory_DO 0 iMe change_bit amp tval i 0 mory 7 and save to variable tval if tval tval2 digital output DigitalO0ut_87K dwBuf 0 1 COM Port dwBuf 1 00 Address dwBuf 2 0x87054 ID dwBuf 3 0 CheckSum disable dwBuf 4 100 TimeOut 100 msecond dwBuf 6 0 string debug wRetVal DigitalOut_87K dwBuf fBuf szSend szReceive DO Output printf DO Value Su n dwBuf 5 tval2 tval usleep 100 digital Input Digitalln_87K dwBuf 0 1 COM Port dwBuf 1 00 Address dwBuf 2 0x87054 ID dwBuf 3 0 CheckSum disable dwBuf 4 100 TimeOut 100 msecond dwBuf 6 0 string debug DigitalIn 87K dwBuf fBuf szSend szReceive D nput get di value and put value to share memory set_di dwBuf 5 printf DI Value d n dwBuf 5 Get DI value and usleep 100 Set its value to i Shared Memory Close Com COM1 ICPDASO Modbus Server User Manual 13 Close SlotAll return 0 2 4 Download Demo Files You can download example file from gt ftp ftp icpodas com pub cd linpac napdos lp 8x8x addons modbus demo gt ftp ftp icpodas com pub cd linpac napdos lp 8x4x addons modbus demo ICP

Download Pdf Manuals

image

Related Search

Related Contents

Bedienungsanleitung TV  The Other YN-622C User Guide  Benq W1070  SN1AT74 UM.book  1 - ソニー製品情報  Traitement des sols à la chaux, mode d`emploi  PDF format (v.02.12.2005)  DEEP FRYER  USER MANUAL - Radioterminal  User`s Manual - Lakewood Automation  

Copyright © All rights reserved.
Failed to retrieve file