Frequently Asked Question

Video: 7.6.1. Serial introduction
Last Updated 2 years ago


Press "Ctrl + F" to find the keyword of your interest.

If you wish to have a direct link access to the video timestamps, please follow these instructions.

Found this video helpful? Why not take the whole HIL Specialist course? A Certificate is waiting for you for free at HIL Academy.

Would you or your organization benefit from having these videos narrated in your native language? Contact us and let us know if you wish to contribute.

TRANSCRIPT

00:00:02

Hello everyone and welcome to our Serial communicationprotocol Introduction in Typhoon HIL device.

00:00:08

The Serial protocol components are availableunder the communication protocol tab of the

00:00:12

Schematic Editor Library Explorer and it correspondsto three main components: Serial Setup, Serial

00:00:19

Send, and Serial Receive.

00:00:21

Serial communications are enabled by a UniversalAsynchronous Receiver and Transmitter controller,

00:00:26

or UART, which is the key component of theserial communications subsystem of a computer.

00:00:32

The UART takes bytes of data and transmitsthe individual bits in a sequential fashion.

00:00:37

At the destination, a second UART re-assemblesthe bits into complete bytes.

00:00:42

Each UART contains a shift register, whichis the fundamental method of conversion between

00:00:46

serial and parallel forms.

00:00:49

Serial transmission of digital informationthrough a single wire or other medium is less

00:00:53

costly than parallel transmission throughmultiple wires, which is a key advantage of

00:00:58

the serial transmission protocol.

00:01:01

Communication can be simplex, that is in onedirection only, with no provision for the

00:01:05

receiving device to send information backto the transmitting device, full duplex, when

00:01:10

both devices send and receive at the sametime, or half duplex, when devices take turns

00:01:15

transmitting and receiving.

00:01:17

The speed of the UART is defined by its baudrate.

00:01:20

This is the number of bits that can be transmittedin one second.

00:01:24

In Typhoon HIL Schematic Editor, Serial componentscould be found in the Serial folder under

00:01:28

the Communication tab.

00:01:31

The Serial library consists of three components:Serial Setup, Serial Send, and Serial Receive

00:01:37

as shown here.

00:01:38

The Setup component is the main componentof Serial library.

00:01:42

This component is used for basic UART settings,like baud rate, data bits, parity, and stop

00:01:48

bits.

00:01:49

Most HIL devices have an exclusive connectorfor Serial RS232 communication which is used

00:01:54

for sending and receiving Serial signals.

00:01:57

Only in HIL402 specifically, there is an optionto select which digital input at the HIL device

00:02:02

will act as the UART receive pin, since HIL402slack a dedicated RS232 connector.

00:02:09

The selected settings will apply for SerialSend and Serial Receive components.

00:02:13

For example, if you choose a baud rate of9600, the Serial Send component will send

00:02:19

data at a 9600 baud rate, and the Serial Receivecomponent will read data at a 9600 baud rate,

00:02:26

too.

00:02:27

To reach these settings, double click on theSerial Setup component in Schematic Editor.

00:02:32

A dialog window should appear like the oneshown here.

00:02:35

The Serial Send component is used to sendmessages from the HIL device to any attached

00:02:40

device via the UART controller.

00:02:42

It is possible to set the Byte order, Headermessage, and Sending period.

00:02:47

The input of this component is a vector, andthis vector is defined by the component which

00:02:51

is connected to the Serial Send component.

00:02:54

The message can be represented in two ways,which are represented in this slide.

00:02:59

In the first, the message contains a headerpart and a data part, while in the second,

00:03:03

the message has only a data part.

00:03:06

In either configuration, the message doesnot have an end indicator.

00:03:10

It is important to be careful with parsingdata on your machine.

00:03:13

The data type is defined by the componentthat is connected to the Serial Send component.

00:03:18

The allowed data types are float, unsignedinteger, and integer.

00:03:22

In order to define the message header, wehave three options as shown here.

00:03:26

The first is to leave the Header textbox empty.

00:03:29

That means that the Data will be sent withouta header frame as raw bytes, corresponding

00:03:33

to a message that only sends data values.

00:03:36

The second option is to define an Array ofhexadecimal numbers.

00:03:40

In this case, you need to write the 0x preamblebefore your hexadecimal numbers array, as

00:03:45

shown here.

00:03:46

The third option is to define an Array ofcharacters, where any ASCII character can

00:03:50

be entered.

00:03:51

The Serial Receive component is used for readingmessages which are sent to the HIL Device

00:03:56

from any attached device to the RS232 port.

00:03:59

This component receives input bytes and convertthem into data values.

00:04:04

Input data values are represented by variablesof a type defined in the Input variable data

00:04:08

type property.

00:04:10

Once the variables are received, they canbe used within the simulation.

00:04:14

The Messages can be any of the types we describedin the previous slides.

00:04:18

As you can see, this component has two ports:the Data port and the Status port.

00:04:23

The Data port is the port which outputs thereceived data to the component that Serial

00:04:27

Receive is connected to.

00:04:30

The Status port, on the other hand, outputsthe number of Framing and Parity errors that

00:04:34

occurred while receiving.

00:04:36

If parity is not enabled, such as when parityin the Serial Setup component is defined as

00:04:41

None, the Status port output will always bezero.

00:04:45

Let s show an example of how simple serialcommunication looks.

00:04:49

In this example, we will perform a loopbackcommunication with the HIL device UART controller.

00:04:55

A loopback test can verify the operation ofserial communication by sending and receiving

00:05:00

data from the same serial port.

00:05:02

It can show problems in the serial port, thecable, or the software generating the messages

00:05:07

without having to connect to third-party hardware.

00:05:10

To do this simply connect the receive RXDand transmit TXD terminal together with a

00:05:15

jumper wire, like shown here.

00:05:17

The connections are indicated in grey.

00:05:20

In the model we have connected a Constantcomponent to the Serial Send component.

00:05:24

The variable types are described in the Constantcomponent s properties, as shown here in the

00:05:28

dialog box.

00:05:30

The Value text box defines a vector of constants.

00:05:33

There are four constants, so the number ofvariables which will be sent through the UART

00:05:37

is four.

00:05:39

The Signal type is real, which means thatevery variable will be formatted as real,

00:05:43

which is the same as float type.

00:05:45

The execution rate of the Serial Send componentdepends on the execution rate defined in the

00:05:50

constant component.

00:05:52

Next, we will use the Serial Receive component.

00:05:56

In this case, the number of input variablesis four.

00:05:59

For this reason, the Bus Split component hasfour outputs, and it is used to split the

00:06:04

received variables.

00:06:06

To analyse the received variables, we connectfour probes on the Bus Split outputs.

00:06:11

When we compile this schematic and run itin HIL SCADA, Probe 1 will represent the first

00:06:16

variable, Probe 2 will represent the second,Probe 3 the third, and Probe 4 the fourth.

00:06:22

Lastly, Probe 5 will output the count of receivingerrors.

00:06:26

We ve now finished our introduction to Serialcommunication in the Typhoon HIL Toolchain.

00:06:31

In the next lesson, we will look at a morepractical example of using Serial.

Please Wait!

Please wait... it will take a second!