Frequently Asked Question

Video: 7.6.2. Serial SCADA widget with HIL UART example
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 this demonstration on using Serial protocol  

00:00:05

in the Typhoon HIL toolchain.Let s start by opening the Serial  

00:00:10

Communication between HIL device and HIL SCADA example from the Examples Explorer. 

00:00:16

This example model demonstrates communication between a HIL RS232  

00:00:20

Serial interface and an instance of HIL SCADA on your computer, using the HIL SCADA  

00:00:25

Serial widget and a Serial to USB converter.If you would like to follow along to this example  

00:00:32

on your own HIL device, in addition to meeting the license requirements, you will also need a Serial  

00:00:37

to USB converter cable, so that you can connect the HIL device to your PC over a Serial link. 

00:00:43

Let s open it and go through the components and configurations. 

00:00:47

As you can see, there is a Three Phase Inverter connected to an Induction Machine,  

00:00:51

much like the model we worked on in Module 2 of HIL Fundamentals. In this case, we want to control  

00:00:57

this model from Serial communication, by setting the enable and torque parameters in HIL SCADA.  

00:01:03

This lets us control the inverter and load torque applied to the Induction Machine. 

00:01:07

Also, with this model, you can see that we want to monitor the motor speed and current,  

00:01:12

both of which are sent to the Serial Send component. 

00:01:16

So let s go take a look at the Serial communication structure.  

00:01:20

Starting with the Serial Setup component. By opening its properties, you can see how this  

00:01:25

is configured in this example. The baud rate is left at the default of 9600 bits per second. 

00:01:33

Now, let s look at the Serial Send component.As mentioned before, we want to send two  

00:01:38

variables, motor speed and current. These are directly connected to the Serial Send  

00:01:43

component with a bus join, because the Serial component accepts vectors as an input. 

00:01:48

By opening the component properties of the Serial Send component,  

00:01:52

we can see how it is configured. The message header in this case is left  

00:01:56

as the component default value and the sending period is programmed to 500 ms. 

00:02:02

The last component of the Serial communication structure in the Serial Receive component. In  

00:02:08

this case we want to control two variables in the model, enable, that turn the inverter on  

00:02:12

and off and the torque. These two are connected from the Serial Send component with a bus split,  

00:02:18

as they are inside a vector.Let s open the properties of the Serial  

00:02:22

Receive component. Here we can see the Header setting matches what we saw in the Send component,  

00:02:27

and the number of input variables is set to two, as we want to receive two variables.  

00:02:32

Finally, we should define the variable type, which in this case is real (or float) type. 

00:02:39

Let s compile the model and open the SCADA panel to see how Serial is configured in the SCADA. 

00:02:49

This SCADA panel is divided in three parts. The first part is the serial connection command,  

00:02:54

where you can connect and disconnect the serial port with the serial connection widget.  

00:02:58

If you open the properties of this widget, you can see that the Serial  

00:03:02

port settings should be defined as the same as in the model, like here. 

00:03:06

The message below the serial widget shows the serial connection status. 

00:03:12

The second part is the SCADA to HIL communication. In this panel you can set  

00:03:16

the parameters to control the model via serial commands, like Inverter Enable and Torque. 

00:03:23

The third part is the HIL to SCADA communication. In this panel the  

00:03:27

variables such as motor speed and current are read from the serial communication and output here. 

00:03:33

Now let s look at how the serial communication is programmed in the SCADA. 

00:03:37

To do this let s open the Panel Initialization dialog. 

00:03:41

This script contains two main functions. The first is serial_write , which is responsible  

00:03:46

for sending messages from the SCADA to the HIL device UART.  

00:03:50

The second function is serial_read , which reads from the HIL device via serial. 

00:03:56

Now, if you go back to the SCADA panel and click on the Continuous Write widget, inside  

00:04:01

the SCADA to HIL sub panel, you can see that it executes the serial_write function periodically,  

00:04:06

every 500 ms, and it sends the enable and torque variables to the HIL device. 

00:04:13

Similarly, if you go to the Continuous Read Widget at the HIL to SCADA sub panel you  

00:04:18

will see that the function serial_read is used periodically to read the serial  

00:04:22

data from the HIL device, every 500 ms.Now let s get ready to test this model. 

00:04:30

Before we start the model, we need to establish a Serial link over the computer. The first thing to  

00:04:35

do is to verify which COM port is connected to the HIL device. To do that, open the device manager of  

00:04:41

your Windows PC, go to the ports section, and check the number of the serial port where the  

00:04:46

HIL device is connected, as shown here.Go back to the SCADA panel and,  

00:04:52

in the Connection command panel, select the right COM number and click connect. Now run the model  

00:04:58

and, if you selected the right COM port, you should get the message Connection Successful. 

00:05:03

Now, let s enable the Inverter by selecting the Inverter Enable text box. 

00:05:08

You should be able to read the speed and current of the motor in the HIL to SCADA sub panel now,  

00:05:13

which means that serial communication is working fine. 

00:05:18

You can also change the Torque to a higher value, like 4 Nm, and check that the motor  

00:05:23

current increases and the RPM decreases, as is expected for open loop systems. 

00:05:30

With this we conclude our Serial communication example in Typhoon HIL toolchain. 

00:05:35

Thank you for your attention!

Please Wait!

Please wait... it will take a second!