mathjax

Showing posts with label Pattern Generator. Show all posts
Showing posts with label Pattern Generator. Show all posts

2013-02-24

winding pattern generator:

finally wrote the winding pattern generator for an arbitrary number of phases, source:
winding pattern generator
It was written in python 3.x so you'll need to run it. It out put the phase as a number and the direction of the winding as the sign. If any of you end up using it, it would be awesome to hear suggestions, or added features or what you might like to see next.

But yeah so this is that motor winder thing I was talking about, it was accidentally lost while playikng the game of musical partions while reinstalling things on the laptop.
But I rewrote it! and here is.
It gives you a winding pattern for a n-phase, m-pole and k*2 pole motor. If you're too lazy to open up the code to look at it, here's the most important part of it:


def pattern_gin(slot_edeg, phase_slice):
 
    phase = m.floor((slot_edeg % 180)/ phase_slice)#actually calculates the phase for the slot

    if (phase % 2 == 0):#dictates the direction of each winding
        if slot_edeg >= 180:
            phase_sign = '+'
        else:
            phase_sign = '-'
    else:
        if slot_edeg >= 180:
            phase_sign = '-'
        else:
            phase_sign = '+'
    return phase_sign, phase

This is the function that defines the phase and direction of a winding on one stator tooth.
As the input it takes the electrical degree position and the electrical degrees of each phase and matches them up...its really not that exciting.

I've been learning haskell and I'm considering making some sort of simulator

2013-01-19

Long time no see

So hello again. Thought it was past time to make another post.
Current projects that have been happening/ happened are:
-A motor winding pattern generator for an arbitrary  number of phases.
It was written in python and was made in a fairly awkward form, but I ended up deleting some of it in frustration while rewriting it.

Idea behind a pattern generator for a motor:
A permanent magnet motor consists of magnets and solenoids in some circular configuration. In order to produce torque the solenoids must be turned on when they are in the proper position. This is where the winding pattern generator comes in it creates the winding 'pattern' so that when voltage is applied to any particular phase of the motor each pole on that phase produces a force in the same direction  this goes back to one of my last posts when I made a motor. This bring about babble of electrical angles which I talked about for a moment in this post. 2pi rads of electrical angle per pair of magnet poles (or you can think about it in degrees if you like), this gives a whole crap load of radians per motor but since our magnets are tessellate (positive pole up, then negative, then positive.....repeat) we really only care about how things line up within a single 2pi rads interval. So when talking about electrical angles it is useful to think of them as electrical angle mod(2pi), I kind of like to think of it as walking off the right edge of a TV screen and coming back on the left side.


This makes things easier to count and think about positionaly and bring up the question:
When do we actually want to turn on a phase?
And depending on what the goal iswant to do that answer can actually not be that straight forward. However in most cases you probably only care about getting maximum torque out of your motor. In order to produce the maximum amount of torque you want to turn your motor on when it is directly between the pole of two magnets.

This corresponds to an angle of either 0 or pi depending how you want to look at it. So how do you get all of your poles in one phase to produce torque in the same direction? By applying voltage to all of the poles in a certain interval at the same time. Ideally all of the poles in the phase would be at the same electrical angle when turned on. This ensures that they all push in the same direction.  By defining a certain window of electrical degrees where sum((nth pole torque) for 0 to n poles)>0 at all times in that interval. i.e. the motor will always be pushing in the same direction.

This pattern can be calculated without too much work below is some fake code I wrote to calculate the winding pattern for an arbitrary phase motor of n even poles, and an arbitrary number of slots.
Please forgive the bastardization of code, it was really an organizational exercise to make sure the motor winder is written properly next time it gets written...hopefully this is not too nonsensical looking.

Psuedo code for motor winder:
#pretend the person already entered the number of poles, number of phases and number of slots(stator poles) and they make physical sense:
pole_num
phase_num
slot_num

#find the amount of electrical degrees to alot to each phase interval
#and the electrical degrees per slot
phase_slice = 180 / phase_num
slot_slice = pole_num * 180 /slot_num

#map the values out over all the slots and phases so you have each phase interval
#and the electrical and of each slot
slot_angles = map(lambda(n): (n * slot_slice) % 360): range(slot_num))
#phase intervals mapping not needed but good to look at sometimes to make sure everything makes sense
#phase_intervals = map(lambda(n): ( n * phase_slice) % 180):  range(phase_num))

#this is the heart of the program it decides the phase number and the direction in which to wind each phase slot

defun pattern_picker (slot_angle[n], phase_slice)(
    #makes and integer of each slot corresponding to the phase interval it lies on
    phase = floor(slot_angle[n] % 180 /phase_slice)
 
    #decides the direction of each slot winding on the stator
    (if even?(slot_angles[n])
   then (if (slot_angle[n] > 180)
       then (case = "-") else(case = "+")))
    (if odd?(slot_angles[n])
    then (if (slot_angles[n] > 180)
       then (case = "+") else(case = "-")))

#outputs the direction and phase for a given stator slot
return( string(case)+string(phase))

#gets the direction/phase for each slot
winding_pattern = map(pattern_picker(slot_angles[n], phase_slice): slot_angles, repeat(phase_slice))

print("Behold! Your winding pattern sir: \n")
for slot in range(len(slots)):
(if (slot != len(slots)) then (print(winding_pattern[slot] + ", ")
    else (print(winding_pattern[slot] + "... the end"))


I'll babble more about this later and potentially post some code which will actually calculate a winding pattern.

Edit: I tweaked the code upon realizing I made a few mistakes in the pattern picker funtion with regards to the variables being passed in as well as the definition of the phase number.