Thursday, 21 September 2017

Server websocket Omron (Fins Tcp)













Contents


Introduction.


The server node address must be assigned automatically

Componentes and configuration.

Informations Raspberry pi
Linux 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 8.0 (jessie)
Release: 8.0
Codename: jessie
Informations Orange pi zero
Linux 4.11.3-sun8i #8 SMP Tue Jun 13 14:17:33 CEST 2017 armv7l GNU/Linux
Distributor ID: Debian
Description: Debian GNU/Linux 8.7 (jessie)
Release: 8.7
Codename: jessie


Install

Packages to install:
sudo apt-get install libssl-dev
sudo apt-get install libcurl4-openssl-dev

Application:
  • Copy the folder comFinsOmron in your raspberry.
  • Go to the folder comFinsOmron.
  • Open the file requests.txt and configure your reading requests
  • Run the command: sudo ./comOmron "IpServerPLC" portPLC portWS.
  • where:
    IpServerPLC is the ip address of your PLC
    portPLC is the port of the server PLC (9600)
    port WS is the websocket port
    sudo ./comOmron "192.168.2.53" 9600 1900
    The application read 20 words at the address DM0 each 175ms and 20 words at the address DM100 each 250ms
    The port websocket (portWS) must be opened in your firewall.
Web Application:
  • Copy the folder webOmronWS in your websites folder (/var/www/html).
  • Open the file websocket.js and put the ip address of your raspberry(line 98) .
  • In your browser, go to the address http://localhost/webOmronWS/index.html
To work in secure mode:
  • Change the name of the file certSecure.pem in cert.pem.
  • Change the name of the file keySecure.pem in key.pem.
  • Open the file websocket.js and change "ws://ipRaspberryPi/" in "wss://ipRaspberryPi/" (line 98)
  • (ipRaspberryPi is the ip address of your raspberry)
  • In your browser, go to the address https://ipRaspberryPi:portWS
  • Clic on exception and accept
  • In your browser, go to the address https://localhost/webOmronWS/index.html 
  • To test the example, you need an Internet access.

Extracting variables in javascript.

The function "processFrameReceived(frame)" in the file "websocket.js" extract all the variables read from the PLC.

Writing Variables in javascript.

WINT16, memory area, address, value (to write an integer 16 bits INT, UINT)
Sending the string “WINT16,DM,8,32294” write 32294 at the address DM8

WINT32, memory area, address, value (to write an integer 32 bits DINT, DUINT)

WFLOAT32, memory area, address, value (to write a float 32 bits FLOAT)
Sending the command "WFLOAT32,DM,5,147.25" write 147,5 at the address DM5(2 words)

WCOIL, memory area, word address , num bit, value (to write an relay 1 bit)
Sending the string “WCOIL,CIO,101,3,0” write 0 in the output 101,3
Sending the string “WCOIL,DM,10,12,1” write 1 in the bit 12 of the word DM10

Each command is returned by the server

Download.

You can download the zip file at Download

More...

You can see more at this link
See also this blog Modbus RTU to Pusher server