Posts

Showing posts with the label controls

Simulating a motor in ngspice

Image
 Motors and actuators are an integral component of any robotics project.  In this post I will describe how a simple pmdc motor can be simulated using xspice and ngspice.  Modelling of a PMDC motor A simple model of a pmdc motor is given below :  Model f a PMDC motor  The electrical characteristics (current voltage and back emf) can be modeled by the following equation :-   where Ra is the armature resistance, La is the inductance of the coil, Vs the applied voltage and Vb is the back emf of the motor.  The mechanical characteristics of the motor are :-    Jm is the moment of inertia, Bm is the friction constant , Tm is the torque applied by the motor and TL is the external load torque.    In the above two equations we can substitute :    Vb = k w(t) Tm = k i(t) where w(t) is the angular velocity and i is the armature current of the motor. In order to model these in xspice code model these equations were discretized a...

Why do we need feedback in a control system?? (And basic functioning of an integrator)

Image
 I still remember my introductory course on control systems. It was "not very well explained" to say the least. It was something which I learned as I needed to use these concepts in various advanced courses and projects. Just trying to share some of that. So why do we need a feedback in a control system ?? A plain simple answer might be to sense how much deviation the system has from the desired response. Which is 100% correct. But how does this error help the "controller" actually control the output ?? I will take the example of a simple integrating controller (modeled by 1/s) to try and explain the function of feedback.   Let us say I give my system some input reference (ref) and the system now gives me some output (out).  Now ideally the output should be equal to the reference however due to  a multitude of reasons(system non-ideality, noise, or load applied to the system) in most real world scenarios the input will not match the output. That is why need a fe...

An open source signal processing toolbox for ngspice (an open source circuit simulator)

Image
Inspired partly by curiosity to learn about signal processing and controls and partly by Matlab simulink , which can simulate circuits as well.   ( https://in.mathworks.com/help/physmod/sps/powersys/ug/building-and-simulating-a-simple-circuit.html ) (where we can  directly include components like lpf and integrator as blocks). I thought it would be nice to have such blocks in open source for ngspice. ( http://ngspice.sourceforge.net/ )   Installation this tool box is built as a ngspice code model and can be compiled along with ngspice as described in the manual ( http://ngspice.sourceforge.net/docs/ngspice-34-manual.pdf ).   This tool is being developed in a separate fork of the main ngspice branch which can be cloned from here :     https://sourceforge.net/u/harshcht/ngspice/ci/master/tree/ Then build ngspice using the steps described in section 32.1.2 of the user manual.   Examples the main example file (feedback_example.cir) is an example ...