Showing posts with label modbus. Show all posts
Showing posts with label modbus. Show all posts

Saturday, May 27, 2017

Automation and Control technologies part-2

Sensors and actuators used for automation

Motion (orientation/inclination) sensors
  • Accelerometer

Measure acceleration in one or many directions. Position can be deduced by integration. Mostly used methods are mass spring method and gas pocket method.
                           Applications are,
ü  Self-balance robot
ü  Mobile phones(navigation and gaming)
ü  Smart hand bands
  • Gyroscope(Rate)

Measures rate of rotation along 3 axes. Integration is required to get rotation angles.    
                           Applications are,
ü  GPS navigation systems
ü  Image stabilization
ü  Inertial measurement units
ü  Platform stabilization
  • Compass
  • Tilt sensor

Detect tilting angle (35~65 degrees in right and left inclination).

Force/Pressure/Strain sensors

  •  Force sensitive resistor: Changes resistance with the force applied. Used in walking robot.      
  • Strain gauge: Produces voltage that is proportional to the force applied.
  • Flexion bend sensors: Resistance changes with the bend angle.10kΩ [0], 40kΩ [90].Used to measure bend of a joint, weight sensors, Availability checking.
  • Air pressure sensor: Can measure air pressure up to 150 PSI. This sensor is used in TPMS-tyre pressure management system, Flow sensing devices, Helicopters, Submarines, etc.

Position sensors

  • IR range sensor
Range/distance is determined by the angle between horizontal plane and IR beam. Applications are,
  • Parking sensors(systems mounted on car bumpers that sense distance to nearby cars for parking)
  • Ground proximity warning system for aviation safety
  • Vibration measurements of rotating shafts in machinery
  • Top dead centre (TDC)/camshaft sensor in reciprocating engines.
  • Sheet break sensing in paper machine.
  • Anti-aircraft warfare
  • Roller coasters
  • Conveyor systems

  • Rotary encoders

Rotary encoders are used to measure rate of rotation, direction of rotation and shaft position. There are three types of Rotary encoders.
o   Magnetic
o   Optical
o   Resistive
  • Linear encoders

o   LVDT
LVDT applications are Crank shaft balancer, Pill making machine, Portable friction welder, etc.

Temperature and Humidity sensors


Light sensors

  • CDS (cadmium sulfoselenide photo conducive photocells)
  • Light dependent resistor (LDR)

Hall Effect sensors

Sense magnetic flux. Applications are,
ü  Bullet train
ü  DC motor controlling
ü  DC Current sensors

Novel sensors

  •   Kinect sensor

    Motion sensing input device which can identify gestures and voice commands. This sensor is used in Xbox360 game player.

Actuators

Actuators are hardware devices that convert a controller command signal into a change in a physical parameter
  • The change is usually mechanical (e.g., position or velocity)
  • An actuator is also a transducer because it changes one type of physical quantity into some alternative form
  • An actuator is usually activated by a low-level command signal, so an amplifier may be required to provide sufficient power to drive the actuator
  • Electrical actuators
    • Electric motors
      • DC servomotors
      • AC motors
      • Stepper motors
    • Solenoids
  • Hydraulic actuators
    • Use hydraulic fluid to amplify the controller command signal
  • Pneumatic actuators
    • Use compressed air as the driving force

                           Programmable logic controllers

A programmable logic controller (PLC), or programmable controller is an industrial digital computer which has been ruggedized and adapted for the control of manufacturing processes, such as assembly lines, or robotic devices, or any activity that requires high reliability control and ease of programming and process fault diagnosis.


                           Internal Architecture of a PLC


The basic architecture of a PLC consists of main components-the processor module, the power supply, and the I/O modules. The processor module consists of the central processing unit (CPU) and memory. In addition to a microprocessor, the CPU also contains at least an interface to a programming device and may contain interfaces to remote I/O and other communication networks. The power supply is usually a separate module, and the I/O modules are separate from the processor. The types of I/O modules include discrete (on/off), Analog (continuous variable), and special modules like motion control or high-speed counters. The field devices are connected to the I/O modules.

Ladder programming

Ladder logic is widely used to program PLCs, where sequential control of a process or manufacturing operation is required. Ladder logic is useful for simple but critical control systems or for reworking old hardwired relay circuits. As programmable logic controllers became more sophisticated it has also been used in very complex automation systems. Often the ladder logic program is used in conjunction with an HMI program operating on a computer workstation.

Industrial communication in Distributed control system (DCS).


In recent years, the use of smart devices and field buses makes distributed control system (DCS) to be prominent in large and complex industrial processes as compared to the former centralized control system. This distribution of control system architecture around the plant has led to produce more efficient ways to improve reliability of control, process quality and plant efficiency.
Nowadays, distributed control system has been found in many industrial fields such as chemical plants, oil and gas industries, food processing units, nuclear power plants, water management systems, automobile industries, etc.
In the supervisory level the operation is monitored and analysed. Huge amount of data transfer occurs in this level. Mostly used communication methods is Industrial Ethernet.
The local control is done by Control level and the field devices are connected to field level PLCs. For both control level and field level, Field bus, ASI, Device Net communication methods are used

There are some main networks for industrial communication.They are,
• Insdustrial Ethernet
• Sercos111
• CANopen

Industrial Ethernet

Industrial Ethernet is the term used to refer to industrial communication protocols using Ethernet standard physical layers such as: 
EtherNet/IP 
Modbus TCP 
TCP and UDP 
On an Ethernet Industrial network, it is possible to connect: 
Industrial products (industrial communication protocols) such as controllers, variable speed drives, robots, etc. 
  • The EtherNet/IP protocol 
EtherNet/IP is an industrial communication protocol based on CIP (Common Industrial Protocol), owned and managed by the ODVA, an independent standards organization (www.odva.org). 
EtherNet/IP is the result of implementing CIP protocol on standard Ethernet. EtherNet/IP operates on the same device and the same infrastructure as Modbus TCP, and both protocols can be activated simultaneously on the network at any time. 
EtherNet/IP is a robust protocol for use with sophisticated devices such as cameras, robots, etc. 

  • The Modbus TCP protocol 
Modbus has been the industry communication standard since 1979. During the internet revolution, Modbus was combined with Ethernet to form Modbus TCP, a completely open Ethernet protocol. 
The Modbus application layer is simple and universally familiar with its 9 million installed connections. 
Thousands of manufacturers have already implemented this protocol. Many have already developed a Modbus TCP connection and numerous products are currently available. 
The simplicity of Modbus TCP enables any fieldbus device, such as an I/O module, to communicate on Ethernet without the need for a powerful microprocessor or a lot of internal memory. 
The application protocol is identical on Modbus serial link and Modbus TCP; messages can be routed from one network to the other without converting the protocol. 
Since Modbus operates on the TCP/IP higher layer, users benefit from IP routing, thus enabling devices located anywhere in the world to communicate without worrying about the distance between them. Modbus and Modbus TCP are recognized as a fieldbus by the international standard IEC/EN 61158. They also comply with the “national Chinese standard” managed by ITEI. 
The Modbus TCP protocol uses a client/server architecture for data exchanges.

Sercos111

Fully Ethernet based communication solution enabling communication for Motion-centric machines with both drives and field devices. SERCOS III can also streamline the integration of safety automation, and is a true standard. It does not rely upon a specific manufacturer, and it’s one of the most powerful Ethernet-based communication solutions currently on the market.

• Standardized, Ethernet-based fieldbus-communication
With IEC 61491, Sercos (serial real-time communication system) established itself as the worldwide communication standard for automation. Sercos III uses industrial Ethernet for its transmission physics. The bidirectional full-duplex Ethernet communication provides full media redundancy.

• Universal automation bus
The use of standardized profiles for drive technology, I/O, and communication between controllers (C2C) is increasing the range of possible applications for sercos III: For the first time, sercos can be used as a fully integrated Ethernet-based solution for drive and field bus communications, including communications in safety automation. Sercos III also permits parallel transmission of standardized or proprietary IP protocols over a non-real-time channel.

CANopen

Performance and reliability
The CANopen bus is a vendor-independent, multi-master bus which ensures reliable deterministic access to real-time data in control system devices. The CSMA/CA protocol is based on broadcast exchanges, sent cyclically or on an event, which ensures optimum use of the pass band. A message handling channel can also be used to define slave parameters. The bus uses a double-shielded twisted pair, on which 127 devices maximum are connected by simple tap junctions. The variable data rate between 10 Kbps and 1 Mbps depends on the length of the bus (between 30 and 5000 m).
For field level Modbus,Profibus,HART,AS-Interface and Profibus DP interbus field bus protocols are supported.


Sunday, December 4, 2016

Modbus Protocol part 4-Practical implementation

Implement Modbus Practically
USB is now commonly used to connect various kinds of devices to your computer. Before USB, devices are connected using  RS232 . An RS232 port on computers of the past would look like below figure, a simple 9-pin port.

 RS232 was designed mainly to connect modems to computers so that the latter could dial into mainframes. But soon RS232 spread to a host of different devices.
 One of the major drawbacks was that RS232 is point to point standard. In other words, all you could do is connecting one device to only one other. You could not connect one device to multiple devices to create a network of devices. In addition to this, RS232 could be used only up to a distance of about 50 feet, so transmission distance was a problem. It also was not very resistant to sources of electrical noise.
 So the RS485 electrical standard was therefore created. RS485 allows the connection of multiple devices to create a network. Up to 32 devices can be connected onto one multidrop RS485 connection. RS485 also allows transmission for up to 4000 feet and is very resistant to electrical noise. Hence it was able to overcome the problems that plagued RS232.
Modbus is a protocol, RS485 is a electrical standard. Modbus defines messaging structure used to exchange data.RS485 only defines the electrical signal levels and wiring that allow data to be transferred.
Not only RS485, Modbus can stick into many different electrical standards such as RS232,RS422,Radio signals etc.
If we consider a PLC there are
·         CPU
·         Memory
·         Communication
If we take a memory segment it has two parts Memory address and memory value.

There are memory blocks with various sizes. This size depends on the application. Size of the memory block is measured by bits.
Ø  1 bit for Discrete input (on/off)
Ø  8 bit for Analog input (eg.232 for RTD)

Ø  Below figure shows PLC with analog input.


Modbus memory areas

But what is meant by coils, inputs, input registers and holding registers?
NOTE-Modbus memory areas can be used to store data which results from various applications.
The link between inputs/outputs with related memory block is called mapping. For each product Manufacturers define how the mappings are done

Modbus request commands

* I will explain about function codes later.

Modbus block read
Consider master device needs to read two memory blocks (10050 and 10057) in its slave device (ID 21)
The Read Input Status command only allows specifying a start memory block address and then the number of memory blocks to read from that start point. So in the case of the example, It would have to configure the Modbus master to send, as before, the Read Input Status command together with the  Modbus Unit Id of 21, but it would then specify a start memory block address of  10050 and a memory block length of 8.
So when this request is sent to the slave, the slave would return data for memory addresses 10050, 10051, 10052, 10053, 10054, 10055, 10056, 10057. The master would simply extract the data from 10050 and 10057 and ignore the remaining data sent back.

Physical connection

Every single device on the same RS485 network should have the exact same settings for their port parameters
·         Baud rate
·         Number of data bits
·         Number of stop bits
·         Parity

Friday, December 2, 2016

Modbus Protocol part 3

More into Modbus message structure

Address field

Address field contains two ASCII characters or 8 bits (RTU).Also we know that the valid slave addresses are in 0-247 range decimal.
·         In the response slave puts its own address in the address field to let the master know which slave is responding.

Function filed
The function field consists of two ASCII characters (ASCII) or 8 bits (RTU).In error free response the function code is similar to receive query. But if there is some error, the most significant bit of query function code is set to 1 in the response function field.
Ø  Example
Query function code=0000 0011
Error free response function code=0000 0011
If there is an error, response function code=1000 0011.
In erroneous situation slave puts unique code in to data field which describes the error occurred.

Data field
The data field is constructed using sets of two hexadecimal digits in the range of 00 to FF hexadecimal (pair of ASCII characters or one RTU character).In query, this data field contains discrete and register addresses, the quantity of items to be handled, the count of data bytes to follow in the data field and the data to be written in to registers.
If no error occurs response data field contains the requested data else it contains unique code which describes the error.

Error checking field
How Modbus does detect errors?
Standard Modbus serial networks use two kinds of error checking.

1.      Parity checking (even or odd) can be optionally applied to each character.
2.      Frame checking (LRC or CRC) is applied to the entire message.

Both the character check and message frame check are generated in the master device and applied to the message contents before transmission. The slave device checks each character and the entire message frame during receipt.

1.      Parity Checking
Users can configure controllers for Even or Odd Parity checking, or for No Parity checking. This will determine how the parity bit will be set in each character. If either Even or Odd Parity is specified, the quantity of 1 bits will be counted in the data portion of each character (seven data bits for ASCII mode, or eight for RTU).
The parity bit will then be set to a 0 or 1 to result in an Even or Odd total of 1 bit.

2.      Frame checking
IN ASCII mode there are two ASCII characters in the error checking field. The error check characters are the result of a Longitudinal Redundancy Check (LRC) calculation that is performed on the message contents, exclusive of the beginning ‘colon’ and terminating CRLF characters.

What is LRC?
The LRC field checks the contents of the message, exclusive of the beginning ‘colon’ and ending CRLF pair. It is applied regardless of any parity check method used for the individual characters of the message. The LRC field is one byte, containing an 8–bit binary value. The LRC value is calculated by the transmitting device, which appends the LRC to the message. The receiving device calculates an LRC during receipt of the message, and compares the calculated value to the actual value it received in the LRC field. If the two values are not equal, an error results.

In RTU mode error checking field has two bytes. The error check value is the result of a Cyclical Redundancy Check calculation performed on the message contents. The CRC field is appended to the message as the last field in the message. When this is done, the low–order byte of the field is appended first, followed by the high–order byte. The CRC high–order byte is the last byte to be sent in the message.

For more details refer Modbus official site.



Modbus Protocol part 2

In this post I will try to describe about master/slave configuration, Serial interface, Query-response cycle and transmission modes in the Modbus protocol.

What is master/slave technique?
There is only one device (master) which is requesting information and there can be many devices (Modbus slaves) that can supply requested information. In standard Modbus protocol there is a master and up to 247 slave device. Also master device can send information to slave devices. Each slave device has unique address from 1 to 247.

Examples for master and slaves
·         Master devices-Monitoring panels, servers
·         Slave devices-Mainly PLCs, VSDs


As I told earlier Modbus protocol defines structure of messages transmitting between master and slaves. The message send by master to any slave is called query and the message send by slave to master is called response.

A-What kind of action should be performed by the slave device
B-Any additional data needed to perform the function
C-To validate message contents
D- What kind of action should be performed by the slave device? If any error occurred the    function code of that error will be sent
E-Collected data
F- To validate message contents.

Transmission modes
We know that queries and responses are transmitting serially. But how does information pack in those messages and how to decode them???

There are two serial transmission modes
1.      ASCII mode
2.      RTU(Remote Terminal Unit) mode

ASCII mode
Before talking about this it is helpful to know about Modbus message framing. Above both transmitting modes Modbus message is framed. In this frame the beginning point and ending points are known. This frame has 8 bits.

Now let’s move into ASCII...We know that ASCII characters are represented by Hexadecimal Numbers. It is clear that 8 bits can represent 2 hexadecimal numbers. So There are two ASCII characters in one message. In this ASCIII transmission mode the time delay between there ASCII characters can be take time up to 1 second. That is main advantage of this method. If a greater interval occurs, the receiving device assumes an error has occurred.

Coding System: Hexadecimal, ASCII characters 0–9, A–F
One hexadecimal character contained in each
ASCII character of the message
Bits per Byte: 1 start bit
7 data bits, least significant bit sent first
1 bit for even/odd parity; no bit for no parity
1 stop bit if parity is used; 2 bits if no parity
Error Check Field: Longitudinal Redundancy Check (LRC)  *This will be discussed later.

In ASCII mode, messages start with a ‘colon’ ( : ) character (ASCII 3A hex), and
End with a ‘carriage return – line feed’ (CRLF) pair (ASCII 0D and 0A hex).




RTU Mode
Each 8 bit byte in a message contains two 4 bit hexadecimal characters.

Coding System: 8–bit binary, hexadecimal 0–9, A–F
Two hexadecimal characters contained in each
8–bit field of the message
Bits per Byte: 1 start bit
8 data bits, least significant bit sent first
1 bit for even/odd parity; no bit for no parity
1 stop bit if parity is used; 2 bits if no parity
Error Check Field: Cyclical Redundancy Check (CRC) *This will be discussed later

Let’s move into RTU framing
In RTU mode messages start with a silent interval of at least 3.5 character time. The entire message is transmitted in continuous stream. The figure shows the RTU frame. One frame should transmit without having time interval of less than or equal  1.5 character time between each fields(slave address, data Error check, Function code).If this condition is not satisfied received data will be discarded.

Important – It can be seen that in RTU mode there no dedicated bits to indicate start and end of a message. That is indicated by using specific time interval (3.5 character time).Therefore RTU mode has greater character density and hence has more data throughput.

The fields in a Modbus message will be discussed in next post.



Wednesday, November 30, 2016

Modbus Protocol part 1

Recently i used Schneider PLC to learn ladder programming and i saw that PLC has Modbus communication.I did some research about this communication protocol and thought you also may have interest about this industrially used communication protocol.

Modbus is a serial communication protocol developed by Modicon.😮😮
Well, What is serial communication and what is a Protocol ???

                                            Serial communication is process of sending/receiving data ,one bit at a time sequentially(or in an order).This definition simply gives the definition for parallel communication,which is two or more bits at a time simultaneously along multiple channels.
Parallel vs Serial communication (From wikipedia)
                                         Communication protocol is a system of rules that is applied to communication process/system to transmit data along any communication channel.
These rules are used to define ...  

  • Recovery methods. (due to Errors occur in the communication)
  • Data type used in the communication.
  • Address formats for data exchange.
  • Flow control of data.
  • Sequence control of data,Etc.

                                                     
The common language used by all Modicon devices(eg. PLC,VSD) is Modbus protocol.This protocol defines the message structure which is used to communicate between controllers,monitoring devices,Etc and therefore this is a messaging protocol.There can be seen so many protocols used in communication such as file transfer[FTP],Transmitting structured text(Hypertext)[HTTP],Etc.So now we know that Modbus is serial messaging protocol used in Modicon devices.
                                            Modbus is Application layer protocol positioned at level 7 of the OSI model.😮😮😮 Hell ! what is that ???
                                            The ISO(International Organization of Standardization)-OSI(Open System Interconnection) model is 7 layered  architecture defined for a communication system.
OSI model (from studytonight.com)
Now I will give very rough idea about the OSI model.

  • The physical layer converts the digital/analog bits into electrical signal or optical signals.It defines transmission medium(Copper cables,Bluetooth.Etc).
  • The Data link layer synchronizes the information which is to be transmitted over the physical layer.
  • The Network layer routes the signal through different channels from one node to other and It acts as a network controller. It manages the Subnet traffic.
  • The Transport layer decides if data transmission should be on parallel path or single path and the functions such as Multiplexing, Segmenting or Splitting on the data are done by this layer.
  •  The Session layer manages and synchronize the conversation between two different applications.
  • The Presentation layer takes care that the data is sent in such a way that the receiver will understand the information (data) and will be able to use the data.
  • The Application layer is responsible for interacting with various software applications and implement  communication components for all of them. Mail services, directory services, network resource etc are services provided by application layer.

Each layer has set of defined protocols used for different applications.

                                                       So,   Modbus protocol is application layer messaging protocol which provides Client/Server communications between Modicon devices.

In the next post i will go more detail into technical side of Modbus protocol.

If you have any doubt please leave a message.Thanks.