Waltz Stepper Drivers: Functional Yet Noisy

After assembling one of the Waltz boards and only screwing up the the tiny driver once the board works!
There were only a few quirks in getting the board to run. A grounding issue between my laptop and the Arduino and the scope which made things flip out whenever the scope connected. Which means something isn't as well grounded as it should be, since half the outlets where I live don't have a ground that might have been the issue... connecting all grounds explicitly in the circuit fixed the grounding issue. From that point out operating the motor was pretty smooth. The board was hooked up to an arduino with modified 'blink' code to step the motor continuously in a given direction. Here's a video of the waltz board driving a stepper:

It worked well up to several kHz of step frequency if the step frequency got too fast the motor would just sit there and make a very annoying whining sound. The controllers were tested up to around 10A with no heat sinking or additional cooling. Using the 'will this burn my finger?' test methodology the main power fets remained cool enough up to around 6A that you could continuously keep you finger on them. At 10A they had a temperature of  'owfuckshitthathurts' after around 5s of keeping your finger on a fet, but it wasn't that 'burn on contact' kind of hot. In conclusion I should get some thermocouples/ temp sensors also the boards seem quite capable of being pumped over 10A. Once they are upgraded to D2pak FETs rather than the jankily soldered on Dpak FETs this might improved heat sinking and current capacity.

On the next rev of the stepper driver the caps are going to be swapped out so the motors can run at higher voltage. Hopefully this will push the motor PWM frequency out of the audible range. The way the A4898 does current control is a fixed off time system, this makes the output PWM of the system variable with various operating conditions such as  the voltage supply inductance of the motor and the decay rate settings on the controller. The noise and vibration also seems to vary greatly with the step frequency of the motor and the microstep settings. Motor operation seems much smoother and less noisy at increased speeds, this might be partially due to rotor inertia/velocity matching up with the commutation of the motor. There will have to be some characterization to find optimal operating points.
The motors being used are 27.4kgf*cm (381oz*in), 3.5Arms/phase, NEMA 23 hybrid steppers: data sheet. When stepping the motors vibrate enough on any hard surface to be really obnoxious, that's why the motor is sitting on a cushion in the video. 

Next steps for the millathe project will include measuring up the millathe itself sizing it for a new set of ballscrews and mounting hardware. The next set of boards needs to be designed as well as the motherboard to hold all of the smaller stepper boards.


Stepper Boards have Arrived: Waltz v0.2

Woooooo the boards arrived like several weeks ago they arrived, but what ever they're getting posted about now so ...woooo stepper boards. They're all pretty n'purple n'stuff.
So far I've only assembled one and there seem to be no fatal errors on the board that will prevent it from functioning. Couple minor package errors and what not but whatever.

here's a pic of the board:
I went with purple because why the hell not?
I've been slightly distracted from the project by work. However there will be more posts soon since there needs to be board testing.

In the mean time pretty boards are pretty, but pretty useless boards are pretty useless until they are tested otherwise.


Millathe Stepper Driver v0.2: waltz

In order to power the millathe's axes I decided to create a stepper driver with a higher current capacity than most hobby stepper controllers out there. Driving a mill seems to be above the capabilities of standard hobby stepper motors. Below is a picture of the board. I named this version 'waltz'.

Waltz v0.2


The waltz boards are currently being manufactured overseas in China at Myro PCB. Unfortunately as it turns out the first week of October is 'National Day' in China and the the factory closed down for the week a few days after the order was put in. On the flipside this gave me time to finalize/order components before the boards arrived. 

waltz v0.2

The waltz board is designed to fit in a 20 position 0.1" spacing card edge connector, this makes the board 53x62.5mm. Each board has two full bridges made to power a single bipolar stepper motor. The control of the motor is handled by an Allegro A4989. The FETs to be used in the half bridge are FDD8778 in a TO-263 package, each has 14mOhm of on resistance. These were chosen because of their relatively low gate capacitance/charge to reduce switching losses, however the majority of losses in this system will be ohmic. The Allegro A4989 was chosen because it  seemed like a good all in one solution for various  features such as current control, fast current decay and, up to 16th microstepping all while still supporting external FETs. The only two control inputs to the chip required are step and direction.

This brings us to how this system is going to be controlled. The plan is that several waltz boards will be plugged into a single motherboard carrying an arduino nano. Card edge connectors seemed like a modular way to stack multiple stepper drivers on a single board while having large amounts of connector contact area for the power paths and conveniently allowing for data to come in the same connector. The Arduino nano will partly be the brains of the operation. A computer will stream the control information (step and direction) for all of the waltz boards to the Arduino which will act as a buffer/ demultiplexer and timer making sure all of the outputs are  switched synchonously and with proper timing. This type of setup will take heavy calculation off of the arduino however the tool paths/ step patterns will have to be preprocessed on a computer before being sent to the arduino.

Concerns /Issues/Thoughts/Modifications:
-The current ripple for this system could be quite large depending what motor is chosen. That being said each capacitor is rated to pretty high ripple >4A ripple. However I would like to raise the input voltage to the motors, which would make this more of a concern.
-I would  like to increase the voltage of the system allowing for faster stepping and more awesomeness, this requires new bus caps as they are the limiting factor for the motor voltage, currently they are only rated to 16V.
-Screw these capacitors.
-I Screwed up the zener gate clamp pinout on using a 3-pin package...derp. In the mean time the diodes will have be added in a weird orientation. can be fixed on next rev.

That is all on the waltz board for now more updates when they come in and the mother board is ready to go.


Millathe: Initial State Pictures

The Millathe with tool post and homemade tool post holder, the spindel speed is adjusted through the pair of little leve :

For some reason the door does not like to shut, it pushes against the lid of the gear box despite not looking bent, seems to close fine without the gear box lid though.

All the gears on this side are for the autofeed. Notice the small cracked plastic gear on the upper right. There is also a gear hidng be hind the 76 tooth gear which appears to be detached from its  shaft. On the left is the main drive belt, it goes down to the motor which is single phase 500W asynchronous:

The gear box/ shifter. While there is no back gear on this device it can go pretty slow (speeds are printed on the front of the lather below here it says Maximat7). Theres a little bit of rust on the steel gears and some wear from shifting visible on the phenolic gears but over all it doesn't seem to be in bad shape:

One day perhaps the traction system in the millathe will be redone or incorporated into the control system, but that is a project for the future.


The Millathe: A CNC story

So a long while back I managed to acquire an Emco maximat 7 machining center. It has been my goal to make it a CNC machine, however it has been sadly sitting in my living room waiting for me to finish busscooter, but now that that is done (besides a few safety features which need to be added). I've turned my sites to making this CNC dream a reality and things are finally starting to happen.

So hear's the deal: this machining center, or the millathe as it is has been nicknamed, is like 75% lathe 25% mill and 100% heavy, seriously the millathe isn't that big but weighs well over 100lbs.  Unfortunately I don't have pictures right now and am other wise not at home so those will get posted later. It also happens to be Austrian and metric which is wonderful because if you know me I tend to shun 'standard' units (really? Who calls 'units standard' when only a small fraction of the planet uses them?). The lathe portion of the millathe seems fully operable except for the lead screw; which is linked through a mess of gearing to what appears to be a cracked plastic press fit gear, so  cant be turned automatically by the spindle motor. The lead screw does have a knob so you can turn it by hand, but this project is about avoiding that. Unfortunately most of the gears in the lathe system seem to be of phenolic materials but they're functional for now, perhaps some time in the future I will rebuild the power part of the spindle drive but that's another project and another thing to add to the list of fixes.

Currently the plan is to make lathe portion CNC before turning to what ever may be wrong with the mill section of the machine. The list of key action items for modifying the millathe in no particular order  looks like this:

  •  Replace lead screws (I might not replace them but they look a bit wonky).
  • Add Backlash compensation, because no one loves backlash in automated systems.
  • Acquire steppers for driving the Z and R axis screws giving control of the lathe port.
  • Create method of supplying power to said steppers in order to control the system.
  • Create control system for the steppers.
At the moment I've started looking at the control side of things.  The plan is to stream through USB to an arduino nano which can act as a buffer and send the signal out separately to each stepper driver synchronously. I plan on using the Allegro A4989 stepper motor driver to control all of these shenanigans. It will require that each motor needs 2 outputs from the arduino, one for step and, one for direction.
 The outputs from the A4989 generally go straight to the gates of transistors but, it's tempting to instead direct them to some gate drives to allow them to drive larger fets for larger stepper motors. I haven't really done any calculations to justify this but it seems like it would be nice thing to have a one size fits all solution to driving steppers even if it is over kill. A pair of LM5109A gate drivers per stepper driver seem perfect for this task since they have inputs that can be driven separately allowing for whatever sort of control method the stepper controller feels like. 

However last night I began to experiment with methods of sending arduino data over usb and had moderate success in getting LED's to count synchronously according to their appropriate digital out ports rather than by using the normal digitalWrite commands. This was kind of  interesting since apparently pyserial only sends data as strings and chars. Which to me this seems weird and inefficient but I'm not that experienced with data streaming techniques. Hopefully it will be able to send data at a pace appreciable enough to make it work other wise. I'll talk more about messing around with this in the next post.

I don't have any pictures of the millathe to post at the moment but I always feel bad not posting a picture so here have a repost of the  tool post holder I made for the millathe a while back. It is currently mounted on the millathe and works just dandily. yaaay reposts.


Math n Stuff (Specifically Geometric Algebra)

So one thing, I've been doing lately instead of building things is studying geometric algebra.

Now you might as why on earth would someone devote them self to some obscure type of math when vector calculus, differential equations and linear algebra satisfy most engineers. Geometric Algebra while not that widely known as far as I can tell (at least I know no mechanical engineers that know of it, but that really isn't saying much), has some pretty snazzy properties. I will babble about it for for a variety of reasons:
1. Its pretty cool (for debatable definitions of cool). 
2. It has applications to a robotics engineering problem I have encountered and would like to solve. 
3. Geometric algebra is like a general enough form of math that it encompasses several other forms of math used in various areas of engineering in a single construct and could be useful in a wide variety of engineering applications.
4. Writing down the important bits will help me remember it.

Honestly as a mechanical engineer it's been a bit of a 'mindfuck' learning mathematics from papers on maths. After reading several papers, maths from a mathematician's perspective seems very different from how I've thought about math up to this point and how I think more applications oriented think about math. As a meche I was looking at maths in what I think was a practical yet backwards thought process that dictated math functions the way it does because that's the way the world works; but I think mathematicians would say math functions the way it does because of the way that people decided to define it is as a logical construct, regardless of how reality works. Which I would say is much more accurate and leaves the door open to interesting ways types of constructs. Math only functions how it does because of how we define it, it just so happens the world was nice enough to allow its self to match up with some of out logical patterns that we like to call 'math'.

Either way, back to geometric algebra.
Some of its useful characteristics: 
Geometric Algebra naturally models geometric things we tend to care about in a concise fashion,  it can be extended to n dimensions, and structures that represent imaginary numbers are naturally formed by the algebra without actually having imaginary numbers. Remember those weird things where \(i^2 = -1 \)? That is an 'imaginary' number. In geometric algebra (what I consider one of the most useful properties) you can represent more than just \(i\), the algebra can be used for quaternion representations where the imaginary numbers are extended to \(ijk\) or extended even further to represent arbitrary set of 'imaginary' constants which would all have the property \(n^2 = -1\) while remaining orthogonal to each other in an whatever dimensional space.
If you're an engineer you might realize the utility of that last bit, it allows you to perform rotations of abitrary dimension using rotors which are kind of like generalized versors.

While I don't know of any applications where you would want to use >6 dimensions but I think it's kind of nice that geometric algebra gives you the option.

For a bit of history on Geometric Algebra

Otherwise I'm going to talk about some of the technical details of geometric algebra. This are defined in terms of the geometric product, which is the fundamental  operation of geometric algebra, it is denoted by a lack of symbol ,similar to what we do with multiplication. It has the properties of multiplicative associativity, and distributivity over addition. In the following example \(a,b\) and \(c\) are multivectors but you can think of them as normal vectors right now. The geometric algebra rules that:

1.Associative: \(a(bc) = (ab)c\)
2.Distributive: \(a(b+c) = ab + ac \)

Note the geometric product is non commutative, I think that this property is best thought of as a feature because it ends up giving the outer product of the geometric some important characteristics. The inner and outer products of the geometric algebra are defined in terms of the geometric product as:

outer product: \((ab-ba)/2 = a \wedge b\)

inner product: \((ab+ba)/2 = a \cdot b\)

geometric product in terms of the inner and outer product: $$ab = a \cdot b + a \wedge b$$

And the outer and inner products are analogous to the cross products and dot products of normal vector math how ever they have some subtle differences that I wont go into right now.

 More on the outer product:
The outer product is the antisymmetric part of the geometric product. Also from now on the outer product will be noted as \(\wedge\) in equations. This property of antisymmetry has some useful effects, and results in something almost the same as a cross product. The cross product of two parallel vectors is 0. similarly the outer product of two vectors that are scalar multiples(a.k.a. parallel) will also result in 0. 

$$a \wedge b = - b \wedge a$$
if  $$ b = a $$
$$ a \wedge a = - a \wedge a $$
$$ \therefore a \wedge a = 0 $$ 

If vectors are orthogonal then the following is true: \(ab = a \wedge b \). The result of vector \(vector2 \wedge vector1\) is not a vector, it is of greater dimension or 'grade', a vector is of grade 1, a plane is of grade 2 and a volume element would be of grade 3. When two things are wedged together their grades add as long as they are not linear multiples of each other.
$$ a , vector, line$$
$$ a \wedge b, grade 2 plane$$
$$ a \wedge b \wedge c, grade 3 volume$$
$$ a \wedge b \wedge a = - a \wedge a \wedge b = - 0 \wedge b, grade 0$$

This is to show some of the basic properties of geometric properties of geometric algebra but I don't have time to write a text book so I'm just going to show a few more things about the outer product right now.  Consider two vectors \(a\) and \(b\) with orthonormal bases (fancy terms for \( \hat x\) and \( \hat y \) ) \( e_{1}, e_{2} \) and scalars \( a_{1} , a_{2}, b_{1}, b_{2} \).

Consider the following: 

$$ a \wedge b = (a_{1} e_{1} + a_{2} e_{2}) \wedge (b_{1} e_{1} + b_{2} e_{2}) $$
Remember in geometrric algebra stuff distributes over addition so:
$$ a_{1} b_{1}  e_{1} \wedge e_{1} + a_{1} b_{2}  e_{1} \wedge e_{2} + a_{2} b_{1}  e_{2} \wedge e_{1} + a_{2} b_{2}  e_{2} \wedge e_{2} = a_{1} b_{2}  e_{1} \wedge e_{2} + a_{2} b{1}  e_{2} \wedge e_{1} $$

and the outer product anti-commutes so:
$$ = ( a_{1} b_{2} - a_{2} b_{1})  e_{1} e_{2}$$ 

If you are familiar with the vector math this may be apparent but the outer product of two vectors results in a planar element with a magnitude of the parallelogram spanned by the vectors \(a\) and \(b\). This is the same as a cross product except that the cross product would produce a third vector perpendicular to the other two rather than a plane spanning the two vectors. This pattern continues with higher dimensions, the outer product of 3 vectors would produce a signed volume element with the magnitude of the spanned parallel piped. In fact this would hold to n-dimensional hyper volumes!

I mentioned before that one of my favorite properties of geometric algebra was how it treated imaginary numbers. Lets take a look at how 'imaginary numbers' occur as a result of the geometric algebra. Consider orthonormal vectors of magnitude 1, \(a\) and \(b\). The inner product is 0 for orthogonal vectors so in this case \(ab = a \wedge b\).

$$ (ab)^{2} = abab = -aabb = - (aa)(bb) = -1 $$

That's right. \( (ab)^{2} = -1\). The imaginary numbers naturally appear out of the geometric algebra. Part of the nifty thing is is that it does not require anything to define this besides the geometric product, and isn't actually dependent on a number of dimensions to exist besides having more than two. In this way you can construct multiple 'imaginary' planes and perform rotations higher dimensional systems in the same manner as a lower dimensional system. Some of you guys might note the possibility of the Euler equation to be applied here which does happen. Infact is allows us to construct the powerful rotor which allows arbitrary rotation across a vector. But that is for another time. 

End of geomtric algebra for now next time I will talk about the inner product and general screw motion.


Busscooter maiden voyage: successful

So buss scooter was pretty much finished it is missing two not 'required' but generally highly recommended things being among them are non-foot brakes(since we aren't going to count foot brakes despite them being quite effective) and head lights. But for the time being busscooter after its successful maiden voyage of driven home will chill in my living room; functional (being defined as having the capability to transport myself from point A to B) but without those 'safety bells and whistles'. But for now it can be considered done the extra stuff will go on in due time since I don't plan on using it as a main means of transport.

Over all it was a satisfyingly uneventful maiden voyage home, namely because no one died and the battery didn't run out. The ride home took like 20mins for around 4.2miles giving an average speed of 12.6mph including many stops which probably made actual traveling speed ~15mph or 6.7m/s.

Current form of the busscooter
You might notice a few modifications, namely nicer sprockets (also larger gear ratio), different motor and a splatter/chain chain guard (made from a random piece of plastic bent using a hot wire).

I might talk a bit more about the additions to busscooter later, but that's all for now on busscooter,  there'll be more posts when the head lights and brakes get added. I think my next vehicle will be a bit more practical and have more than two wheels because from observation making an interesting and ride-able scooter-like vehicle seems to take more effort than a four wheeled vehicle, but maybe I just don't find scooter-like things as interesting as gokarts.


Electric Vehicle Part II: Frame Built

So the frame of the vehicle when last discussed was a highly non-structural frame with a seat some wheels and a motor. This is it now:

A much more structural thingy with a base board and supports and hot damn it even has a chain to transfer power. This thing is almost usable. All of the making the fork and headset and such happened of the course of a few months of off and on work. The making it structural bit happened in about two weeks of more dedicated work. This thing has existed too long in a semi constructed shape, hopefully it will be done soon; or at least rideable its hard to say when a project is done because then the mods and shiny bits start getting added.

 How ever on that note time to talk about structure a lot of the 80/20 carts made at MITERS have been planar creations supported by the sheer shear strength of the aluminum beams they sat on.  Since this bike/EV/thing is like 1.5m long and made out of 20mm 80/20 bars that wasn't going to fly. What the vehicle really needed was a larger moment of inertia to prevent flexing in the middle. This was achieved through the angular braces that form a bridge like structure under the seat. The ends of this bridge structure sit on horizontal bars that are fixed in between 1/4" plates this provides a solid base near the ends of the scooter. Unfortunately this meant the 80/20 had to connect at strange angles, this required bent brackets to accommodate the angles needed by the supports.

Rear brackets
Here is a picture of a bent and yet to be bent pair ofrear brackets. The aluminum is 1/8" thick and for size reference the holes are 20mm apart and fit M5 screws. That also gives a reference for the wrench in the next picture as a poor-man's brake. It is fucking huge. It is around 2' long and provides an excellent lever arm.
Each bracket was bent in small increments deforming one section at a time along the bend line. Despite the inaccurate method the brackets fit in place pretty well. Some brackets which needed larger angles were heated with a torch before bending this made it significantly easier to bend some of the brackets without ruining the intergrity of the metal(...well maybe its temper was ruined but w/e).

Whats was actually more obnoxious than the bending was cutting some of the 80/20 sections. Distinctly the braces on the rear of the vehicle. In order to provide natural support for the braces (both in the front and in the back) they were cut with a niche in the bottom so they could rest on top of the the brackets and supports on the frame base. Due to the odd 3-D angles getting the interface was a pain without using a mill but since I wanted to get this done quickly and precision was not a requirement the joints were band sawed then filed a bit.

Etched cut to make

Left: Cut Just made by bandsaw, chunk barely held in Right: mirror support without chunk of aluminum in place.

Yes that cut looks weird but that is actually how its supposed to be. When viewed from the proper angle it is just a 90 degree cut out like this:
Support bar from a less confusing angle
The angle in the end of each support fits over the edge bar or bracket it connects to, this way when some one is sitting on the scooter and these bars are loaded in compression and they transfer the forces more directly to the structural objects they sit on rather than the brackets that keep them in place. It also means I don't have to worry about them becoming displaced as easily   Either way not very exciting yadd yadda, after attaching the additional supports and what not the electric vehicle was quite solid. After the supports a large sheet of 1/2" plastic(it might be HDPE) that I found was fixed to the base. These steps are kind of boring and I'll skip posting more about the structure of this thing. It's a frame in the shape of a bike/scooter. The next discussion will be about the drive train/energy storage of the scooter.

Also holy crap I'm tired of referring the 'the electric vehicle' as a scooter , EV, minibike. From now on it shall be known as busscooter because it is long like bus and according to some people will have the turning radius of a bus....which is not entirely inaccurate given its length.


Electric Vehicle coming along Part I

So in the mean time of not posting I've been making an electric vehicle for small motor.

It kind of like a minibike..ish. Its been called a skate board crossed with a scooter among various other things, but nothing seems to describe it right. Either way its coming along and its about time for the post of the project. To start off here's the (partially incomplete because I'm lazy) cad model of the project:

Despite being incomplete the vehicle is pretty much the same shape as the cad model. However there were several changes to the structure of the vehicle that were just done on the fly. Namely all the additional supports besides the vertical posts holding the seat up. But I'll get to that in the next post.

The bike was meant to be ridden in the 'superman' position. This vehicle really borrows a lot from other vehicles that have been produced by other people at miters, hence the 80-20 frame. However unlike most of the other 80/20 vehicles that seem to get made the mini bike will be non planar. Partially because the 80-20 extrusions are too thin with out more support (20mm metric is being used rather than 1").
In retrospect it was a bad decision to use 20mm framing for this, not because it is skinny but because the 20mm 80/20 on mcmaster carr uses M5 nuts/screws and its difficult to find M5 tabbed weld nuts of the proper dimensions (at least in quantities less than several thousand) which forces you to buy the expensive proprietary ones actually meant for the framing. If it had been made with 25 or 30 mm extrusion the frame would have been quite heavier not to mention more expensive but the price difference might have been compensated for if I was to using generic nuts.

Time to go over the construction of the vehicle:

One of the first things to do for the vehicle was to figure out the steering for the project. The wheels picked out were unfortunately too wide for a standard bike fork. So a fork was made out of a bike The tubes were roughly cut then milled to the proper angle and size. Then roughly fit together and welded

Partially machined tubes

Machined tubes fit being fit together and the welded fork.

 After welding the main portion of the fork together some steel plugs were turned and cut to fit into the ends of the fork. These were welded into the fork and will hold the shaft/wheel assembly.

Steel plugs inserted into fork
The plugs were then welded in place then flats were milled onto the sides and a 1/2" bit was drilled through for the shaft which is also 1/2". 

Fork awkwardly clamped down ready to get its flats
Note: the welds were ground down because they looked ugly. The welds seem solid though, after attempting to break them several times unsuccessfully, they're expected to be strong enough to hold a mildly obese person.

plugs with holes going though fork
A chunk of steel was turned down to act as the fork crown and support the bottom bearing of the headset and the bearings were press fit into the head tube.

Ghetto step welded on now the Y of the fork is a complete mass of ground down  weldedness
Next step was to make a method of attaching the head tube to the rest of the frame. 
I kinda winged it and welded  some 1/8" steel U-channel to make an attachmenty thingma dig, it takes x2 M8 bolts in the bottom to hold it on the front brace of the rest of the frame. Here is the head set/fork mounted on the frame base:
It was a giant floppy mass at this point but I get into the rest of the structural details later.

Those little orange wheels were obtained from harbor freight for a disturbingly cheap price of like $8.50 a piece. They came with a matching pair of disturbingly crappy bearings; after watching someone else using the same wheel destroy their bearings, I decided it would be best to preemptively swap them out for a better set.

 The old bearings were removed and a spacer was placed in the center of the wheel that would hold a bearing on either side. The new bearings were then press fit in up to their retaining rings, but the spacer was over sized slightly to make sure that it would contact both inner bearing races.

Turning down one of the spacers.

Spacer next to bearing
Bearing on spacer
Spacer and bearing in hub of wheel
The in-hub spacers remove axial loading on the inner bearing races.This allows the wheels to be tightened in place without stressing the bearings in a bad way (these were normal roller bearings not meant for high axial loading) as well as transfer axial forces to both bearings at the same time. Here is a ghetto mspaint illustration of the hub/bearing assembly:

The hub spacer forms a bridge between the two hub bearings effectively making a solid column, making sure that both of the inner bearing races are supported at the same time.

The next step was to actually get handles bars on the bike by making the bike stem. In the course of this the main thing learned was that the bike stem was not called the 'handle bar holder'.
Started with a large chunk of aluminum

Drilled some holes for a flexture clamp to hold the handle bars and reamed a larger hole to take the top of the bike fork

Repeated process on the other side of the block but drilled holes for  the clamp of the fork and drilled a larger hole to hold the handle bars. Then the front was rounded while being held very awkwardly (read: improperly) in an indexing head note: I would highly recommend against doing this for various reasons. The stem was sanded a bit afterward so it didn't look like it'd been chewed on by an angry aluminum hungry dog.
The rounding was kind of a pain in the ass so on the other side the corners were milled off at 45 degree angles .
Also note the larger holes were slit on one side using a band saw, the slits are roughly 1mm wide but it seems to be plenty of room to get effective clamping force.

The complete stem installed, a homemade cap was installed to connect to the star nut in the top of the fork
Bike with temporary handle bars installed... it also grew a seat and a motor in this picture but we can talk about that later.

Yay it's finally a rolling frame. But it has no support structure and I would not bet it on holding any one with that skinny 20mm 80/20 frame. This part actually posed some annoying requirements since 80/20 framing really doesn't do angles well unless you make your own brackets for it. It probably would have taken less time to learn to weld aluminum and put the frame together at this point each joint has too many nuts and screws it both seems annoying inelegant and pain in the ass to make. That being said this post
 feels really long so talking about how this flat floppy frame was made structural will be talked about in part II  of this post.


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 = '+'
            phase_sign = '-'
        if slot_edeg >= 180:
            phase_sign = '-'
            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


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:

#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.