Message Boards Message Boards

How to compute number of sensor pulses per minute?

I am trying to build a magnetic tachometer using SystemModeler and Arduino. I am using the basic sensor example of ModelPlug with the potentiometer replaced by a Hall Effect sensor. So far, I have been able to generate interrupts (pluses) successfully.

How can I translate these pulses into angular speed of the motor?

I tried to work my way using the online book "Modelica By Example" but I can't figure out where to enter the code. I also tried to find the ModelicaByExample library online but in vain.

Is there any off the shelf component in the Modelica or ModelPlug or PlanarMechanics library that may be of help to compute real-time shaft rpm using the pulse?

PS. whenever the pulse is generated, another pin of the arduino gives a boolean output (i.e. whenever a pulse is generated, the output is 1, otherwise 0). I am hoping to use this pulse to compute real-time rpm of the motor. I am doing this just for the sake of clarity of the signal.ModelOutput

POSTED BY: Safi Ahmed

I'm not aware of something that does exactly that, but you can write your own component that does that.

Here is something that should get you started:

block PulseToRPM
  extends Modelica.Blocks.Icons.PartialBooleanBlock;
  Modelica.Blocks.Interfaces.BooleanInput u "Connector of Boolean input signal" annotation(Placement(transformation(extent = {{-140, -20}, {-100, 20}}, rotation = 0)));
  Modelica.Blocks.Interfaces.RealOutput rpm "Connector of Real output signal" annotation(Placement(transformation(extent = {{100, -10}, {120, 10}}, rotation = 0)));
protected
  discrete Modelica.SIunits.Time entryTime "Time instant when u became true";
initial equation
  pre(entryTime) = 0;
algorithm
  when u then
    rpm := 60 / (time - entryTime);
    entryTime := time;
  end when;
  annotation(Icon(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}, initialScale = 0.1, grid = {10, 10}), graphics = {Text(visible = true, extent = {{-80, -100}, {80, 100}}, textString = "RPM")}), Diagram(coordinateSystem(preserveAspectRatio = true, extent = {{-100, -100}, {100, 100}}, initialScale = 0.1, grid = {10, 10})));
end PulseToRPM;
POSTED BY: Malte Lenz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract