# LabVIEW MathScript RT Module

cancel
Showing results for
Did you mean:

Highlighted

## how to implement sliding mode control in mathscript

Hi everyone,

I have been trying to implement sliding mode control in LABVIEW , and i think the best option is to use Mtahscript. But i don't have any idea how to do it...

As in MATLAB i had created a model containing two blocks of plant and controller and wrote their equations accordingly, BUT i don't have any idea how to implement it in LABVIEW. Anyone who have used LABVIEW/MAthscript for sliding mode cotroller designing, plz help me finding solution.

Kind regards

Message 1 of 10
(5,509 Views)
Highlighted

## Re: how to implement sliding mode control in mathscript

The preferred way to simulate a system in LabVIEW is to use the Control and Simulation Loop (part of the Control Design and Simulation Module) where the 'solver' integrates the system over time. A good example is the shipping example:

C:\Program Files (x86)\National Instruments\LabVIEW 2014\examples\Control and Simulation\Case Studies\Automotive\ABS Control\Control of Vehicle Motion - ABS.vi

Here is picture of the diagram, so you have an idea.

Now, if you do not have the simulation loop, then you can just use LabVIEW For Loop and try to create the integration funcions that would make this system to work... This is a bit more work but also doable...

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 2 of 10
(5,497 Views)
Highlighted

## Re: how to implement sliding mode control in mathscript

I do have the control and simulation Loop. But the point that i want to ask is, how to implement Sliding mode control in it, as there are blocks for controller design like PID etc , but i haev to design controller using Sliding mode control technique. I have implemented Sliding mode control in MATLAB/Simulink using S function, but i don't know how to implement it LABVIEW.

Message 3 of 10
(5,487 Views)
Highlighted

## Re: how to implement sliding mode control in mathscript

Well... as you can see in my picture above, you do not necessarily need a S-function. If your S-function is m-based, then you can use the Mathscript node to define the nonlinear equations and, then, use the 'integrator' from Simulation Palette to integrate the signal (if you have derivative).

However, if your S-function is C based, then you can try to use another function in Simulation called External Model Interface. You will need to create a DLL and code your features into it. But probably you have all this code already and I think it can be somewhat easy to do... Here is the documentation:

http://zone.ni.com/reference/en-XX/help/371894D-01/lvsimconcepts/sim_using_emi/

If you still have difficulty to do this after you look into my information, it would help if you could create a simple schematic or some paper that describes what you are trying to do.

Hope this helps,

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 4 of 10
(5,481 Views)
Highlighted

## Re: how to implement sliding mode control in mathscript

Can you give me file example ABS Brake, please?

@Barp wrote:

The preferred way to simulate a system in LabVIEW is to use the Control and Simulation Loop (part of the Control Design and Simulation Module) where the 'solver' integrates the system over time. A good example is the shipping example:

C:\Program Files (x86)\National Instruments\LabVIEW 2014\examples\Control and Simulation\Case Studies\Automotive\ABS Control\Control of Vehicle Motion - ABS.vi

Here is picture of the diagram, so you have an idea.

Now, if you do not have the simulation loop, then you can just use LabVIEW For Loop and try to create the integration funcions that would make this system to work... This is a bit more work but also doable...

Message 5 of 10
(897 Views)
Highlighted

## Re: how to implement sliding mode control in mathscript

This example is shipping with the LabVIEW Control Design and Simulation Module and you can find the example and its subVIs in the folder:

C:\Program Files (x86)\National Instruments\LabVIEW <version>\examples\Control and Simulation\Case Studies\Automotive\ABS Control\

Does that work for you?

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 6 of 10
(882 Views)
Highlighted

## Re: how to implement sliding mode control in mathscript

I can't open this example in my version. Can you give me your example(abs.vi)? Thank you!!!

Message 7 of 10
(876 Views)
Highlighted

## Re: how to implement sliding mode control in mathscript

If you can't open it, it is because you also need to install the LabVIEW MathScript Module. You can get that in here:

Also, keep in mind that you have to match the LabVIEW versions of the Modules too. For example, if you have LabVIEW 2018, you have to install LabVIEW Control Design and Simulation Module 2018 and LabVIEW MathScript RT Module 2018 for x86:

Barp - Control, Simulation, RTT and HIL - National Instruments
Message 8 of 10
(864 Views)
Highlighted

## Re: how to implement sliding mode control in mathscript

Hi sir..

I AM A NEW WORKER WITH LABVIEW. BUT I WANT TO DESIGN A SLIDING MODE CONTROLER IN LABVIEW. CAN YOU GIVE ME SOME EXAMPLE OF THESE CONTROLLER IN LABVIEW TO HELP ME?

Message 9 of 10
(106 Views)

## Re: how to implement sliding mode control in mathscript

@omid73 wrote:

I AM A NEW WORKER WITH LABVIEW.

You are asking for a LabVIEW solution, thus you should post in the LabVIEW forum instead. A moderator can move it for you.