{
 "metadata": {
  "name": "",
  "signature": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter3 - Stepper motors & switched reluctance motors"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1 Page 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import division\n",
      "# Given data\n",
      "Lm=30 #in mH\n",
      "Iph=3 #in Ampere\n",
      "Rm=15 #in Ohm\n",
      "\n",
      "#Calculations\n",
      "tau_ed=Lm/Rm #in ms\n",
      "tdash=1/2*tau_ed #in ms\n",
      "print \"(i) Time taken by the phase current to decay to zero = %0.2f ms \"%tdash \n",
      "Energy=1/4*Lm*Iph**2 #in mW\n",
      "print \"(ii) Energy returned to supply = %0.2f mW \"%Energy "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Time taken by the phase current to decay to zero = 1.00 ms \n",
        "(ii) Energy returned to supply = 67.50 mW \n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2 Page 191"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "n=4 #no. of phase\n",
      "Ns=12 #stator teeth\n",
      "Nr=3 #rotor teeth\n",
      "\n",
      "#Calculations\n",
      "Beta=360/n/Nr #in degree\n",
      "print \"Step Angle = %0.2f degree \"%Beta "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Step Angle = 30.00 degree \n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3 Page 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "MainPoles=10 #no. of main poles\n",
      "teeth=7 #no. of teeth/pole\n",
      "Nr=60 #rotor teeth\n",
      "\n",
      "#Calculations\n",
      "Ns=MainPoles*teeth #stator teeth\n",
      "Beta=(Ns-Nr)*360/Ns/Nr #in degree\n",
      "print \"Step Angle = %0.3f degree\"%Beta "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Step Angle = 0.857 degree\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4 Page 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Beta=3 #in degree\n",
      "Revolution=25 #no. of revolutions\n",
      "f=3600 #stepping frequency in pps\n",
      "\n",
      "#Calculations\n",
      "Resolution=360/Beta #in step/res\n",
      "print \"(a) Resolution = %0.2f step/res \"%Resolution \n",
      "steps=Resolution*Revolution #no. of steps\n",
      "print \"(b) No. of steps required : \" ,steps\n",
      "speed=Beta*f/360 #in nps\n",
      "print \"(c) Shaft speed = %0.2f nps \"%speed "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(a) Resolution = 120.00 step/res \n",
        "(b) No. of steps required :  3000.0\n",
        "(c) Shaft speed = 30.00 nps \n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.5 Page 192"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Beta=1.8 #in degree\n",
      "Revolution=25 #no. of revolutions\n",
      "f=4000 #stepping frequency in pps\n",
      "theta=54 #required shaft rotation in degree\n",
      "\n",
      "#Calculations\n",
      "Resolution=360/Beta #in step/res\n",
      "print \"(i) Resolution = %0.2f step/res \"%Resolution \n",
      "speed=Beta*f/360 #in rps\n",
      "print \"(ii) Motor speed = %0.2f rps \"%speed \n",
      "pulses=theta/Beta #pulses\n",
      "print \"(iii) No. of pulses required to rotate the shaft through 54 degree : \" ,pulses"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "(i) Resolution = 200.00 step/res \n",
        "(ii) Motor speed = 20.00 rps \n",
        "(iii) No. of pulses required to rotate the shaft through 54 degree :  30.0\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.6 Page 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Ns=8 #stator teeth\n",
      "Nr=6 #rotor teeth\n",
      "\n",
      "#Calculations\n",
      "Beta=(Ns-Nr)/Ns/Nr*360 #in degree\n",
      "print \"Step angle = %0.2f degree \"%Beta \n",
      "Resolution=360/Beta #steps/revolution\n",
      "print \"Resolution = %0.2f steps/revolution \"%Resolution "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Step angle = 15.00 degree \n",
        "Resolution = 24.00 steps/revolution \n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.7 Page 193"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Beta=15 #in degree\n",
      "m=3 #no. of phase(1-Beta*Nr/360)\n",
      "\n",
      "#Calculations\n",
      "#Formula : Beta=360/m/Nr\n",
      "Nr=360/m/Beta #no. of rotor teeth\n",
      "print \"No. of rotor teeth : \" ,Nr\n",
      "#Formula : Beta=(Ns~Nr)/Ns/Nr*360 #in degree\n",
      "#When Ns>Nr\n",
      "Ns=Nr/(1-Beta*Nr/360) #no. of stator teeth\n",
      "print \"When Ns>Nr, No. of stator teeth : \" ,Ns\n",
      "#When Nr>Ns\n",
      "Ns=Nr/(1+Beta*Nr/360)\n",
      "print \"When Nr>Ns, No. of stator teeth : \" ,Ns"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "No. of rotor teeth :  8.0\n",
        "When Ns>Nr, No. of stator teeth :  12.0\n",
        "When Nr>Ns, No. of stator teeth :  6.0\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.8 Page 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "m=4 #phases\n",
      "Beta=1.5 #in degree\n",
      "\n",
      "#Calculations\n",
      "#Formula : Beta=360/m/Nr\n",
      "Nr=360/m/Beta #no. of rotor teeth\n",
      "print \"No. of rotor teeth :\" ,Nr\n",
      "Ns=Nr #no. of stator teeth\n",
      "print \"In multi stack motor, Stator teeth = rotor teeth = \" ,Ns"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "No. of rotor teeth : 60.0\n",
        "In multi stack motor, Stator teeth = rotor teeth =  60.0\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.9 Page 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Speed=2400 #in rpm\n",
      "Resolution=200 #steps/res\n",
      "\n",
      "#Calculations\n",
      "n=Speed/60 #in rps\n",
      "Beta=360/Resolution #in degree\n",
      "#Formula : n=Beta*f/360 \n",
      "f=n*360/Beta #in pps\n",
      "print \"Required pulse rate = %0.2f pps \"%f "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Required pulse rate = 8000.00 pps \n"
       ]
      }
     ],
     "prompt_number": 9
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.10 Page 194"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Resolution=500 #steps/res\n",
      "theta=72 #rotator turn angle in degree\n",
      "#Calculations\n",
      "Hmod_Res=Resolution*2 #half step mode resolution in steps/res\n",
      "print \"Half step mode resolution = %0.2f steps/res \"%Hmod_Res \n",
      "Beta=360/Hmod_Res #in degree\n",
      "steps=theta/Beta #in steps\n",
      "print \"No. of steps required : \" ,steps"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Half step mode resolution = 1000.00 steps/res \n",
        "No. of steps required :  200.0\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.11 Page 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Beta=1.8 #in dcegree\n",
      "revolution=10 #no. of revolution\n",
      "#Calculations\n",
      "resolution=360/Beta #in  steps/rev\n",
      "steps=resolution*revolution #no. of steps in 10 evolution\n",
      "print \"No. of steps =\",(steps),\"should be encoded.\" "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "No. of steps = 2000.0 should be encoded.\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.12 Page 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "J=10**-4 #in Kgm**2 \n",
      "w1=200 #in rad/sec\n",
      "w2=300 #in rad/sec\n",
      "delf=0.2 #in sec\n",
      "Tf=0.06 #in N-m\n",
      "\n",
      "#Calculations\n",
      "dwBYdf=(w2-w1)/delf #\n",
      "Tm=J*dwBYdf+Tf #in N-m\n",
      "print \"Motor Torque = %0.2f N-m \"%Tm "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Motor Torque = 0.11 N-m \n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.13 Page 195"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "# Given data\n",
      "J=3*10**-4 #in Kgm**2 \n",
      "f1=1000 #in Hz\n",
      "f2=2000 #in Hz\n",
      "delt=100 #in ms\n",
      "Tf=0.05 #in N-m\n",
      "Qs=1.8 #in degree\n",
      "\n",
      "#Calculations\n",
      "delt=100*10**-3 #in sec\n",
      "Qs=Qs*pi/180 #in radian\n",
      "w1=Qs*f1 #in rad/sec\n",
      "w2=Qs*f2 #in rad/sec\n",
      "dwBYdt=(w2-w1)/delt #\n",
      "Tm=J*dwBYdt+Tf #in N-m\n",
      "print \"Motor Torque = %0.4f N-m \"%Tm "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Motor Torque = 0.1442 N-m \n"
       ]
      }
     ],
     "prompt_number": 13
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.14 Page 196"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "J=4*10**-4 #in Kgm**2 \n",
      "Tm=0.3 #in N-m\n",
      "Qs=3 #in degree\n",
      "\n",
      "#Calculations\n",
      "Qs=Qs*pi/180 #in radian\n",
      "#Formula : Tm=J*Qs*dfBYdt #in N-m\n",
      "dfBYdt=Tm/J/Qs #in step/sec**2\n",
      "print \"Maximum acceleration = %0.3e steps/sec**2 \"%dfBYdt "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Maximum acceleration = 1.432e+04 steps/sec**2 \n"
       ]
      }
     ],
     "prompt_number": 14
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.1 Page 196"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi\n",
      "# Given data\n",
      "Ns=12 #poles\n",
      "q=3 #no. of phase\n",
      "Nr=8 #poles\n",
      "speed=6000 #speed in rpm\n",
      "\n",
      "#Calculations\n",
      "Beta=360/q/Nr #in degree\n",
      "print \"Step Angle = %0.2f degree  \"%Beta \n",
      "fc=Nr*speed*2*pi/2/pi/60 #in Hz\n",
      "print \"Commutation frequency at each phase = %0.f Hz \"%fc"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Step Angle = 15.00 degree  \n",
        "Commutation frequency at each phase = 800 Hz \n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.2 Page 196"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Ns=10 #poles\n",
      "q=5 #no. of phase\n",
      "Nr=4 #poles\n",
      "w=600 #speed in rpm\n",
      "\n",
      "#Calculations\n",
      "Beta=360/q/Nr #in degree\n",
      "print \"Step Angle = %0.2f degree \"%Beta \n",
      "fc=Nr*w/60 #in Hz\n",
      "print \"Commutation frequency at each phase = %0.2f Hz\" %fc\n",
      "#Note : Answer is wrong in the book."
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Step Angle = 18.00 degree \n",
        "Commutation frequency at each phase = 40.00 Hz\n"
       ]
      }
     ],
     "prompt_number": 16
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.3 Page 197"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Ns=6 #poles\n",
      "Nr=4 #poles\n",
      "Beta_s=30 #in degree\n",
      "Beta_r=32 #in degree\n",
      "La=10.7 #in mH\n",
      "LU=1.5 #in mH\n",
      "i=7 #in A\n",
      "q=3 #phase\n",
      "\n",
      "#Calculations\n",
      "thetaK=2*180/4-(Beta_r+Beta_s)/2 #in degree\n",
      "theta1=thetaK #in degree\n",
      "thetaY=2*180/2-(Beta_r-Beta_s)/2 #in degree\n",
      "theta2=thetaY #in degree\n",
      "dTheta=theta2-theta1 #in degree\n",
      "dL=La-LU #in mH\n",
      "T=i**2/2*dL/dTheta #in N-m\n",
      "lambda_a=La*i*10**-3 #in m\n",
      "lambda_u=LU*i*10**-3 #in m\n",
      "Wm=(lambda_a-lambda_u)/2*i #in joules\n",
      "#Formula : Power transfered = Energy 1 sec \n",
      "#Pm=2*pi*N*T/60=Wm*Nr*q*N/60\n",
      "T=Wm*Nr*q/2/pi #in N-m\n",
      "print \"Averagge torque = %0.2f N-m \"%T "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Averagge torque = 0.43 N-m \n"
       ]
      }
     ],
     "prompt_number": 17
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 3.4 Page 198"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Given data\n",
      "Nr=4 #poles\n",
      "La=10.7 #in mH\n",
      "Lu=1.5 #in mH\n",
      "i=7 #in A\n",
      "q=3 #phase\n",
      "\n",
      "#Calculations\n",
      "lambda_a=La*10**-3*i #in Wb/T\n",
      "lambda_u=lambda_a #in Wb/T\n",
      "i2=lambda_u/Lu/10**-3 #in Ampere\n",
      "Wm=(i2-i)*lambda_u/2 #in Jooules\n",
      "print \"Energy conversion per stroke = %0.3f Joules \"%Wm \n",
      "T=Wm*q*Nr/2/pi #in N-m\n",
      "print \"Average Tourque = %0.2f N-m \"%T "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Energy conversion per stroke = 1.608 Joules \n",
        "Average Tourque = 3.07 N-m \n"
       ]
      }
     ],
     "prompt_number": 18
    }
   ],
   "metadata": {}
  }
 ]
}