Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

How to map a motor angle between 0-360 degrees

How to map a motor angle between 0-360 degrees

I have a motor model which is running continously and I want to create a variable based on the rotational angle (theta_r) which stays between 0-360 degrees.
In Matlab i solved it like this:

Code:



    theta = theta_r - old_theta_r;
   
    if theta >= 360
        old_theta_r = theta_r
    else
        old_theta_r = old_theta_r;
    end;

The result is:
https://imgshare.io/images/2019/07/25/sequence.md.png

But modelica seems to execute the code differently.

Any tips on how I can create this in Modelica?

Edited by: didrif14 - Jul-25-19 07:48:16

Re: How to map a motor angle between 0-360 degrees

SOLVED!

Re: How to map a motor angle between 0-360 degrees

Could you say how you've solved it for the other users?

Re: How to map a motor angle between 0-360 degrees

It was just a matter of wrong if statement, I solved it like this:


Code:



  theta = theta_m.y - old_theta_m;

  old_theta_m = if theta >= 360 then
                               theta_m.y
                          else
                               old_theta_m;

There are 0 guests and 0 other users also viewing this topic
You are here: