I am trying to learn OpenModelica for electronics. I a trying to model a simple ArduinoUno DC Motor Circuit. The build and simulation runs are successful, however there is no current in the circuit.
model test_DCMotor
Arduino.Components.ArduinoUno arduinoUno(sketch = "DCMotor.ino") annotation(
Placement(visible = true, transformation(origin = {-34, 42.5}, extent = {{-34, -42.5}, {34, 42.5}}, rotation = 0)));
Modelica.Electrical.Machines.BasicMachines.DCMachines.DC_PermanentMagnet dcpm (
VaNominal=24,
IaNominal=0.87,
wNominal(displayUnit="rpm") = 1130.9733552923,
Ra=3.69,
La=0.231e-3,
Jr=5.55e-7)
annotation(
Placement(visible = true, transformation(origin = {69, 77}, extent = {{11, -11}, {-11, 11}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Resistor resistor(R = 270) annotation(
Placement(visible = true, transformation(origin = {34, -4}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Ideal.IdealDiode diode annotation(
Placement(visible = true, transformation(origin = {67, 49}, extent = {{9, -9}, {-9, 9}}, rotation = 0)));
Modelica.Electrical.Analog.Examples.Utilities.Transistor transistor annotation(
Placement(visible = true, transformation(origin = {64, -4}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Sources.ConstantVoltage constantVoltage(V = 5) annotation(
Placement(visible = true, transformation(origin = {34, 72}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Electrical.Analog.Basic.Ground ground annotation(
Placement(visible = true, transformation(origin = {-38, -32}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(arduinoUno.D3, resistor.p) annotation(
Line(points = {{0, 28}, {19, 28}, {19, -4}, {24, -4}}, color = {0, 0, 255}));
connect(resistor.n, transistor.b) annotation(
Line(points = {{44, -4}, {54, -4}}, color = {0, 0, 255}));
connect(constantVoltage.n, arduinoUno.GND) annotation(
Line(points = {{44, 72}, {48, 72}, {48, 92}, {-86, 92}, {-86, 0}, {-34, 0}}, color = {0, 0, 255}));
connect(constantVoltage.p, arduinoUno.Vin) annotation(
Line(points = {{24, 72}, {16, 72}, {16, 86}, {-34, 86}}, color = {0, 0, 255}));
connect(arduinoUno.GND, transistor.e) annotation(
Line(points = {{-34, 0}, {8, 0}, {8, -22}, {74, -22}, {74, -10}}, color = {0, 0, 255}));
connect(arduinoUno.GND, ground.p) annotation(
Line(points = {{-34, 0}, {-38, 0}, {-38, -22}}, color = {0, 0, 255}));
connect(transistor.c, diode.p) annotation(
Line(points = {{74, 2}, {76, 2}, {76, 50}}, color = {0, 0, 255}));
connect(constantVoltage.p, diode.p) annotation(
Line(points = {{24, 72}, {16, 72}, {16, 49}, {76, 49}}, color = {0, 0, 255}));
connect(constantVoltage.p, dcpm.pin_ap) annotation(
Line(points = {{24, 72}, {24, 56}, {52, 56}, {52, 88}, {62, 88}}, color = {0, 0, 255}));
connect(dcpm.pin_an, diode.p) annotation(
Line(points = {{76, 88}, {94, 88}, {94, 50}, {76, 50}}, color = {0, 0, 255}));
annotation(
uses(Arduino(version = "0.3.0"), Modelica(version = "4.0.0")));
end test_DCMotor;
Arduino Ino Code
int motorPin = 3;
// Pin 3 has PWM, connected it to the DC motor
void setup() {
pinMode(motorPin, OUTPUT);
// Set motor pin to output mode
}
void loop() {
analogWrite(motorPin, 150);
// Motor at 150/255 of full speed
delay(100);
analogWrite(motorPin, 250);
// Motor at 250/255 of full speed
delay(100);
}
I am getting 0 current in all the components. What is wrong in this experiment setup?