How can I build kinematicPTP block from trapezoidal speed profile? - modelica

How can I build a kinematicPTP block from this speed profile?
It's a trapezoidal profile with acceleration, constant velocity and deceleration phase. In particular :
Acceleration Time : 10 s
Start speed ( at time = 0 s ) : 0 rad/s
Speed at 10 s : 47.1 rad/s --> Acceleration : 4.71 rad/s^2
Constant speed time : 5 s ( at 47.1 rad/s )
Deceleration Time : 3 s
End Speed : 0 rad/s --> Deceleration : 15.7 rad/s^2
I'm trying to use Modelica.Blocks.Sources.Trapezoid but I can't build deceleration phase.
Thank you very much for your help.

I can think of two possibilities using either Modelica.Blocks.Sources.Trapezoid or Modelica.Blocks.Sources.CombiTimeTable.
model M1
Modelica.Blocks.Sources.Trapezoid trapezoid(
amplitude=47.1,
rising=10,
width=5,
falling=3,
period=18,
nperiod=1)
annotation(Placement(transformation(extent={{-80,60},{-60,80}})));
Modelica.Blocks.Sources.CombiTimeTable combiTimeTable(
table=[0,0;10,47.1;15,47.1;18,0],
extrapolation=Modelica.Blocks.Types.Extrapolation.HoldLastPoint)
annotation(Placement(transformation(extent={{-80,20},{-60,40}})));
annotation(experiment(StopTime=20), uses(Modelica(version="3.2.2")));
end M1;

Related

Which method to use to calculate average velocity and what are the assumptions of the each method?

i learned to calculate average velocity between two intervals. For the below table i calculated average velocity by calulating velocitties at 10 and 15 by information given and average of both them will be the average velocity at 12.5sec. But most calculate average velocity by first method. Both answers will be completely different.
I want to understand the assumptions and when to use which method.
Time (s)
Distance (m)
Velocity (m/s)
0
0
0
5
55
11
10
120
12
15
200
13.33
20
270
13.5
FIRST METHOD
average velocity = (202m - 122m)/(15s - 10s)
average velocity = 80m/5s
average velocity = 16m/shere
SECOND METHOD
velocity = (122 m)/(10 s) = 12.2m/s
velocity = (202 m)/(15 s) = 13.4667 m/s
average velocity = (13.4667 m/s + 12.2 m/s)/2
average velocity = 12.8333 m/s

TwinCAT Motion record travel distance

I need some help writing a function block which I can use to record the travel distance of an axis. This should record every time the axis moves sort of like an odometer, this value will be used for preventative maintenance on the axis. ie greasing the ball screw and linear bearings.
The function has to ignore chatter on the axis when it is not moving and accomodate the homing function which overwrites the position several times.
You can achieve this by integrating absolute value of axis set velocity.
VAR
lrCycleTime_s : LREAL;
lrVelocity_mmPerCycle : LREAL;
lrDistance_mm : LREAL;
END_VAR
======================================
lrCycleTime_s := UDINT_TO_LREAL(_TaskInfo[GETCURTASKINDEXEX()].CycleTime) / 10000000; //Get cycle time in seconds
lrVelocity_mmPerCycle := Axis.NcToPlc.SetVelo * lrCycleTime_s ; // Convert velocity per second > per cycle
lrDistance_mm := lrDistance_mm + ABS(lrVelocity_mmPerCycle);
Remember to execute this in a task with cycle time equal to your motion cycle time (default is 2ms)

Calculate acceleration from data points

I have a servo motor, and this servo motor I would like to make it follow a "motion pattern" as closely as possible, and use the same value for acceleration and deceleration.
The attach picture illustrates the "motion pattern" (Y = velocity, X = Time)
motion pattern:
accelerates 0m/s to 0.100m/s.
constant velocity 0.100m/s for 4 sec.
decelerates to negative ?m/s.
accelerates to 0m/s, and motor position = 0.
How can i calculate the acceleration and deceleration?
What i have tried so far is:
Time = (total time - constant velocity time) 10 - 4 = 6sec.
Distances = (total distances - constant velocity distances ) 1 - 0.4 = 0.6meter.
acceleration = (2 * distances / (time^2) 2 * 0.6 / sqr(6) = 0.0333m/s.
But with this acceleration it over shoots in the negative direction by 500mm.
Take a look at the PLC Open motion function blocks, for example the MC_MoveRelative and the MC_MoveContinuesRelative block:
(Beckhoff documentation)
As Sergey already stated you can use those blocks to create a motion profile by entering all the parameters you need and integrating the blocks in a step chain.

Calibrating an accelerometer

I have a device which contains an accelerometer. I'm looking for calibrating my 3D accelerometer.
I'm proceeding as follows:
The first time, I put my device in a flat position (rest) and I obtained these values :
x = -0.02
y = -0.02
z = -1.02
I applied Pythagoras's theorem to calculate total acceleration : A = sqrt(x*x + y*y + z*z)
Normally, when I subtract -1 (9.8 m/s2) from A, it should give 0 m/s but in my case it gives me : 0.01, so can I consider that my accelerometer is calibrated with a litle error = 0.01 or should I subtract 0.01 from all my outputs data for each axes.
Thanks in advance
#Nadosh:
Yes, data acceleration is 3 bytes. x,y,z in order did you mean line this

iPhone - AVAudioPlayer - convert decibel level into percent

I like to update an existing iPhone application which is using AudioQueue for playing audio files. The levels (peakPowerForChannel, averagePowerForChannel) were linear form 0.0f to 1.0f.
Now I like to use the simpler class AVAudioPlayer which works fine, the only issue is that the levels which are now in decibel, not linear from -120.0f to 0.0f.
Has anyone a formula to convert it back to the linear values between 0.0f and 1.0f?
Thanks
Tom
Several Apple examples use the following formula to convert the decibels into a linear range (from 0.0 to 1.0):
double percentage = pow (10, (0.05 * power));
where power is the value you get from one of the various level meter methods or functions, such as AVAudioPlayer's averagePowerForChannel:
Math behind the Linear and Logarithmic value conversion:
1. Linear to Decibel (logarithmic):
decibelValue = 20.0f * log10(linearValue)
Note: log is base 10
Suppose the linear value in the form of percentage range from [ 0 (min vol) to 100 (max vol)] then the decibelValue for half of the volume (50%) is
decibelValue = 20.0f * log10(50.0f/100.0f) = -6 dB
Full volume:
decibelValue = 20.0f * log10(100.0f/100.0f) = 0 dB
Complete mute:
decibelValue = 20.0f * log10(0/100.0f) = -infinity
2. Decibel(logarithmic) to Linear:
LinearValue = pow(10.0f, decibelValue/20.0f)
Apple uses a lookup table in their SpeakHere sample that converts from dB to a linear value displayed on a level meter.
I moulded their calculation in a small routine; see here.