Build a Hybrid Control System with NI LabVIEW Statechart and Control Design and Simulation Tools

Contents

Introduction to Hybrid Control Systems

Hybrid control systems integrate discrete logic combined with physical system dynamics. In “Hybrid Systems Control,” Panos Antsaklis and Xenofon Koutsoukos gave a simple example of a hybrid control system – a manufacturing plant with multiple machines connected via an automated material handling system.1 Parts are processed on separate machines, but the processing begins only when digital sensors indicate the delivery of the parts to the machines. So the complete system is described by the combination of the event-driven dynamics of the parts moving between machines and the time-driven dynamics of the processes within the machines.

Antsaklis and Koutsoukos discussed the use of hybrid control systems in manufacturing, communication networks, autopilot design, engine control, traffic control, and chemical process control.1 They also discuss how hybrid control is employed in a wide variety of embedded control systems that interact with the physical world. In “Tutorial on Logic-Based Control: Switched Control Systems,” J.P. Hespanha and Daniel Liberzon examined hybrid control system applications and focused on reconfigurable systems, fault correction systems, and certain classes of parameter-adaptive systems.2

You can represent discrete logic in National Instruments LabVIEW software using a graphical approach to event-based programming called the LabVIEW Statechart Module. You can fully describe the physical system dynamics using the LabVIEW Control Design and Simulation Module. With the combination of these two modules, you can develop a complete hybrid control system simulation or real-time implementation in one environment.

Back to top

LabVIEW Statechart Module

 

David Harel proposed statecharts as a more advanced method for describing reactive systems and state machines than state transition diagrams or “state diagrams.”3 State diagrams are directed graphs containing nodes for states and arrows for transitions between states. The transition arrows are labeled with triggering events and guarding conditions.

A major drawback of state diagrams is that they do not incorporate hierarchy or modularity. Thus, they can become quite large and unmanageable for complex systems.

Harel proposed statecharts as a means to simplify the visual description of complex discrete event systems.3 He described the example of an avionics system with the following states:

  1. In all airborne states, when yellow handle is pulled, seat will be ejected
  2. Gearbox change of state is independent of braking system
  3. When selection button is pressed, enter selected mode
  4. Display-mode consists of time-display, date-display, and stopwatch-display

Example No. 1 shows the need to cluster states into a superstate. Example No. 2 describes independence or orthogonality. Example No. 3 highlights the need for general transitions rather than a single event-labeled arrow. Example No. 4 describes the refinement of states. With the statechart approach developed by Harel, you can represent modularity, clustering, orthogonality of states (or concurrency), and refinement. You also can “zoom” within a statechart to explore different levels of abstraction.

The statechart concept for discrete event systems was incorporated into the Unified Modeling Language (UML) specification developed by the Object Management Group (OMG) consortium.4 The OMG consortium is an international, open membership, not-for-profit computer industry consortium. The LabVIEW Statechart Module is compatible with the UML specification for statecharts.5

The LabVIEW Statechart Module can run on desktop PCs running Microsoft Windows or it can run on desktops converted into dedicated real-time targets using the LabVIEW Real-Time Module. In addition, the LabVIEW Statechart Module can run on a wide variety of embedded targets including PXI controllers, NI CompactRIO or Compact FieldPoint programmable automation controllers, or NI Compact Vision System.

The LabVIEW Statechart Module also can run on LabVIEW FPGA targets such as PXI/PCI FPGA devices, on the FPGA within a CompactRIO reconfigurable chassis, or on Compact Vision System. You also may use this module with third-party hardware through the LabVIEW Microprocessor SDK, LabVIEW Touch Panel Module, or LabVIEW PDA Module.

 

Back to top

LabVIEW Control Design and Simulation Module

 

The LabVIEW Control Design and Simulation Module includes tools for linear systems analysis and control system and estimator design, as well as numerical simulation capability for both controlled and uncontrolled systems.

You can use numerical simulation to design and analyze physical components, systems, and processes. With the simulation loop structure of the LabVIEW Control Design and Simulation Module, you can represent continuous-time or discrete-time systems in standard block diagram form. You also can note both feedback and feedforward signal paths with arrows on the wires within the block diagram. And you can use hierarchy in the block diagram to represent the dynamics of different subsystems. You can place any LabVIEW VI within the simulation loop, and place the simulation loop within a larger LabVIEW program. This capability makes it easy to create batch simulations or integrate simulation as part of a larger design and analysis task.

Dynamic system simulation capabilities include single input, single output (SISO) systems and multiple input, multiple output (MIMO) systems. Linear system blocks are included for both continuous-time and discrete-time systems. You can use differential equations, transfer functions in the s-domain, or zero-pole-gain models to describe continuous-time systems, and use difference equations, transfer functions in the z-domain, or zero-pole-gain models to describe discrete-time systems.

Nonlinear system blocks include backlash, dead zone, friction, quantizer, saturation, rate limiter, relay, and switches. You can add custom nonlinear systems through 1D, 2D, or 3D table lookup blocks or through the addition of textual equations in the block diagram. For textual equations, you can use either a Formula Node or a MathScript Node (within a subVI). Standard block diagram signal arithmetic is included along with signal generation, plotting, trimming, and linearization capability, as well as various methods for optimal design.

You can easily use the same simulation VI that has been developed for offline simulation for a real-time simulation or control system by combining the LabVIEW Control Design and Simulation Module with the LabVIEW Real-Time Module. Thus, you can use a desktop PC as a dedicated target or use embedded targets such as PXI, CompactRIO, Compact FieldPoint, or Compact Vision System.

 

Back to top

Case Study – Cruise Control System Simulation

 

 

You can find a shipping example, called Cruise Control User Interface VI, that combines the LabVIEW Statechart Module with the LabVIEW Control Design and Simulation Module here:

C:\Program Files\National Instruments\LabVIEW 8.5\examples\simulation\Cruise Control\Simple Cruise Control

 

The front panel for the Cruise Control User Interface VI is shown in Figure 1. In this example, you test-drive a hybrid control system simulation that combines discrete logic for the user interface with a continuous-time simulation of the vehicle dynamics, road profile, and PID cruise control system.

When you run the VI, you can drive the vehicle manually and then put in a desired speed on the accelerator slider. As the vehicle goes over the simulated road, observe the speed of the vehicle (red needle on the speed gauge) slowing down when it goes up an incline and then speeding up when it goes downhill. You can observe the vehicle slow down to a stop if you set the accelerator to zero (in other words, take your foot off the pedal). You can also see the vehicle stop at a specified point on the road profile if you apply the brake.

To activate the cruise control, click the on button in the cruise control section of the front panel. This sets the cruise control state to idle. Then you can click on the set button to provide the setpoint speed for the cruise control system. At this point, the green needle on the speed gauge moves up to match the setpoint speed. Note that the accelerator slider begins moving on its own to indicate the control action of the cruise control system. There is less speed variation than in the manual control system (you) as the vehicle goes uphill and downhill.

If you want to disable the cruise control system and switch to manual control, you can press the on button again to turn the cruise control off. You can press the resume button in the cruise control section of the front panel to bring the cruise control immediately back to the last setpoint for speed and to the on state.

 

 

Figure 1. Front Panel for the Cruise Control User Interface VI

Figure 2 displays the top-level block diagram for the Cruise Control User Interface VI. It shows a simulation loop with both the hierarchy for different physical subsystems (cruise control, road, and vehicle) as well as the Run Statechart VI for the Cruise Control Logic.

 

 

Figure 2. Top-Level Block Diagram for the Cruise Control User Interface VI

You can view the Cruise Control Logic statechart diagram by right-clicking on the Run Statechart VI and selecting the “Open Statechart” option. Figure 3 shows the statechart diagram for this example. It includes an Initial state as well as four other states: Off, Idle, On, and Set.

 

 

Figure 3. Cruise Control Logic Statechart Diagram Featuring Initial, Off, Idle, On, and Set States

Figure 4 shows an example of a subsystem in the continuous-time simulation – the PID control system. The block diagram of the control system is easily visible along with a saturation block to restrict the control signal.

 

 

 

Figure 4. Subsystem in the Continuous-Time Simulation – The PID Control System

Back to top

Conclusion

LabVIEW makes it easy to combine discrete event systems and physical system models together into one simulation or real-time program. The LabVIEW user interface helps to create dynamic and interactive programs that you can use as part of a complete system design process. The LabVIEW Statechart Module has unique prototyping and deployment capabilities in that it can run on Windows, LabVIEW Real-Time targets, or LabVIEW FPGA targets. The LabVIEW Control Design and Simulation Module can run on Windows or LabVIEW Real-Time targets, but it can also easily communicate with LabVIEW FPGA targets.

You can find additional examples and tutorials for statecharts and system simulation and control at ni.com/embeddedcontrol or ni.com/realtime.

 

 

Back to top

References

 

1 Antsaklis, P., and Koutsoukos, X. “Hybrid Systems Control,” http://www.nd.edu/~pantsakl/elecpubs/256.pdf

2 Hespanha, J.P., and Liberzon, D., Abstract for “Tutorial on Logic-Based Control: Switched Control Systems,” http://med.ee.nd.edu/MED10/pdf/abstract.pdf

3 Harel, D., “Statecharts: A Visual Formalism for Complex Systems,” Science of Computer Programming 8 (1987), pp. 231-274, http://www.wisdom.weizmann.ac.il/~dharel/SCANNED.PAPERS/Statecharts.pdf

4 “Unified Modeling Language™ - UML® Resource Page,” http://www.uml.org/

5 Douglass, B., “UML Statecharts,” http://www.embedded.com/1999/9901/9901feat1.htm

                    

Back to top