• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
CDP Studio logo

CDP Studio

Software development tool for distributed control systems

  • Why CDP
    • Software developers
    • Automation engineers
    • Managers
  • Product
    • Design UI
    • Develop
    • Analyze and test
    • Deploy
    • Framework and toolbox
    • Compatibility
  • Services
  • Use cases
  • Pricing
  • Try CDP

CDP Studio Documentation

  • Examples and Tutorials
  • Simulating Spring–Mass System

Using QML in HMI GUI Simulating Rotational Inverted Pendulum

Simulating Spring–Mass System

Introduction

The purpose of this example is to demonstrate a basic CDP Simulator project in CDP Studio, the independent automation software for open PC based real-time distributed control systems.

The project shows how easy it is to create a custom mathematical model for simulation using a mass hanging from a spring as an example.

"Mass-spring Harmonic Oscillator"

Mass-spring Harmonic Oscillator (Svjo / © CC BY-SA 3.0)

Click here to go to the more detailed explanation of the example.

This example includes:

  • A library project containing one simulator component,
  • A system project containing a simulator application which uses the simulator component created in the library project.

Project Overview

Consider a mass hanging from a spring. The mathematical model is:

`dot x = v`

`dot v = - x k/m - v b/m`

The position `x` denotes the displacement from spring equilibrium and `v` is the speed of the mass hanging from the spring. Parameter `m` specifies the mass of the body, `k` is the spring constant and `b` the damping coefficient.

A differential equation like this can be evaluated using CDP Simulator.

void MassSpring::EvaluateDiffEquations(double t)
{
    x.ddt = v;
    v.ddt = -x * k/m - v * b/m;
}

How to Run the Example

To run the example from CDP Studio, open Welcome mode and find it under Examples. Next, in Configure mode right click on the library project and select Build, then right click on the system project and select Run & Connect. See the Running the Example Project tutorial for more information.

The Graph application will now visualize the damped oscillation of the mass. The oscillation is described by the state variable SpringSimulatorApp.MassSpring.x.

For further information see the CDP Simulator manual.

Using QML in HMI GUI Simulating Rotational Inverted Pendulum

The content of this document is confidential information not to be published without the consent of CDP Technologies AS.

CDP Technologies AS, www.cdpstudio.com

Get started with CDP Studio today

Let us help you take your great ideas and turn them into the products your customer will love.

Try CDP Studio for free
Why CDP Studio?

CDP Technologies AS
Hundsværgata 8,
P.O. Box 144
6001 Ålesund, Norway

Tel: +47 990 80 900
E-mail: info@cdptech.com

Company

About CDP

Contact us

Services

Partners

Blog

Developers

Get started

User manuals

Support

Document download

Release notes

Follow CDP

    © Copyright 2021 CDP Technologies. Privacy and cookie policy.

    Return to top