zondag 27 oktober 2013

Change unipolar 28BYJ-48 to bipolar stepper motor

Now here's something I was not expecting. Previously, I tried to drive this stepper motor with the driver board that came with the motor. My main goal was of course keeping the accuracy of the tiny motor safe and then testing at which speed I could get the maximum torque it could produce. Depending on the driving method, I came up with 300gcm when it was driven using half stepping and 380gcm when I switched to full stepping. Those were actually good results considering that the datasheet predicted these numbers more or less.

Now this kind of motor is not really up-to-date with modern technology. Unipolar stepper motors are not that common anymore. Bipolar steppers are twice as efficient with the same amount of copper on the internal windings. Even in full stepping mode, a unipolar stepper still has 2 out of four wires not active all the time. So basically, if there was a way to run current through all windings in the motor at all times, the thing would be stronger and faster.

That's what happens in a bipolar stepper motor. It has only two windings instead of four in a unipolar stepper. Both windings can be activated all the time, but their polarity is switched in four steps. This means that this kind of motor only has four wires instead of 5 (or 6 or 8). The tricky part is changing the polarity. That cannot be achieved by the simple driver board that came with this motor. It only activates one or two out of four outputs, but current always flows in one direction.

What if we could change the wiring of this motor, thus converting it to a bipolar model? All you would need to do is cut the red wire in the scheme above and then ignore the center connection marked 2+3+6+7. The result would be something like the left drawing.

I found out that this is very easy with this motor. All you need is a sharp knife and a tiny screwdriver. Use the latter to remove the blue plastic cap that hides a small PCB. On this PCB, you can see eleven solder points. All it does is fixate the wiring of this stepper (which can be either unipolar or bipolar by design) into a unipolar type by connecting the center of the two windings. If we cut this connection and ignore it in our scheme, what's left is a real bipolar stepper motor.






This is what the PCB looks like in detail. The red connection in the scheme above is actually the copper connection in this picture that I cut with a cutter knife. That's all you need to do! Well, for your own peace of mind, you could also try to re-attach the blue plastic cover. And now, ignore the red wire of the motor. We don't need it anymore.




But now we have a motor without a driver board. What you need is a H-bridge type which luckily exists in small packages if you're not going to drive heavy machinery. I used a L293D 16 pins DIP chip which I found online for $5.5 for ten chips.

I drew up this scheme that I used to drive the motor with an Arduino (actually I used an Atmega8 on a breadboard doing exactly the same thing, only a bit slower). I'm using 9V on the motor in this test since windings are twice as long as in the original version. I guess you could go much higher than that, this thing never heated up in my test.



My simple code example to drive it can be found here.

Finally, most importantly, my torque test resulted in :

800gcm !!

which is at least twice as much as full stepping unipolar (380gcm) and almost 3x more powerful than my half stepping unipolar test (300gcm)

Basically, if I cut one wire in the motor, it gains almost 3 times its original strength.

I like it! A lot! :)



zaterdag 26 oktober 2013

Eén jaar

Moest het nu juist één jaar vroeger zijn, dan was het vandaag vrijdag. Bye bye Aalst schreef ik hier en daarmee was de laatste werkdag bij de Vlaamse Milieumaatschappij een feit. Dat het mijn laatste werkdag tout court zou worden, kon ik toen niet voorspellen.

Toch waren er toen al problemen met de gezondheid. Het is vreemd dat je zoiets vergeet, maar net vorige week nog werd ik er op attent gemaakt dat hoewel in mijn herinnering alles pico bello was in die periode, de waarheid toch een beetje anders was. Het tijdelijke contract was toen reeds twee maal verlengd, wat me natuurlijk blij maakte. Ik deed dat namelijk erg graag, dat programmeren in het verre Aalst. Alleen, die afstand hè.

Maar een extra verlenging kwam er niet, en ik was toen blij. Blij omdat het niet meer zou lukken vanwege de rugklachten, tóén al. Een tijd later zou ik naar de dokter gaan om mijn usual stuff te vragen om de pijn weer actief te onderdrukken. Diclofenac is de ontstekingsremmer die ik in de periode tussen de twee operaties wel vaker nam. Niet altijd was het gevoel van wonderbaarlijke genezing aanwezig dat was blijven hangen meteen na de eerste operatie. Ik was recht gesprongen uit mijn ziekenhuisbed en kreeg meteen naar mijn voeten van de chirurg die dat toevallig had opgemerkt toen ie net op dat moment mijn kamer binnenkwam.

Maar soms was dat dus toch nodig, zo'n medicijnenkuur en in november 2012 startte er dus weer één. Die zou niks meer helpen en vanaf januari zou ik zelfs werkonbekwaam verklaard worden. Daarna zou weer niks meer helpen en in mei zou er een operatie volgen. De revalidatie zou minder snel gaan en zelfs op een moment helemaal stoppen. Dat moment ligt ook al weer enkele maanden in het verleden en echt beterschap is er niet. Er is geen hernia meer, maar de pijn en de mankepoot zijn weer helemaal daar.

Hoe het verder gaat, weet niemand. Misschien weet de chirurg dat volgende week als ie de uitslagen van de laatste botscan beoordeelt. Ik reken niet op duidelijke antwoorden, want die bleven in 't verleden na een botscan ook altijd uit, maar je weet nooit.

Hoe het carrièregewijs verder gaat weet ik dus evenmin. Wat wel vast staat is dat de toekomst anders wordt.

Als het lukt toch, maar daar ga ik altijd vanuit :)

vrijdag 25 oktober 2013

Stepper motor 28BYJ-48

This is the English version of this earlier blogpost.
Also check this blogpost on how to change the motor into a bipolar model with a lot more torque.

This must be the cheapest stepper motor I know. I guess the reason why it's so popular among hobbyists is simple: its price. I don't know many real steppers cheaper than 20€ and if you find one, you still need to take into account that it usually runs at high currents, so driving the thing with a microcontroller takes some high power circuitry which again is way too expensive for my purposes. I just want to have some fun with small projects where torque and speed are not really main issues. Accuracy is, though!

That's why I bought a whole bunch of these on AliExpress.com. If you buy larger quantities (which usually is the only option on that site), these babies only cost $2.5 each.

That's even including this small driver board equipped with a ULN2003 chip. That little thing makes driving the motor with an Arduino real easy and really really really cheap.


I found this datasheet which is actually describing the 12V version of the motor, but I don't see any difference between the two versions, other than its voltage. I prefer my 5V version though because it gives me the opportunity to use the thing in battery operated projects. There's no need for seperate power sources for the motor and the project that it belongs to. I also found this wiki page online with a lot of info on the motor.

Using the driverboard on an Arduino is real easy. All you need is four outputs that connect to four of the seven circuits in the ULN2003 chip on the small board. Actually three inputs of the chip remain unused, you could even drive some extra high power things like a power LED or a relay with the board. The inputs are there (inputs 5,6,7) but accessing the outputs might be a bit more tricky.

Now basically, all you should do is switching on the four outputs you defined in your Arduino program one by one. That's what makes the motor turn in on direction. Reversing the order would change its direction. If you repeat these steps about 500 times, then the motor should do almost one revolution. The word almost is a bit strange when used in this context, I'll try to clear that up a bit further. All this seems pretty straight forward and of course: it is. Too bad that it doesn't work that way. Ik had to search a bit further, because driving a thing like this (a unipolar stepper motor) can be done in a few different manners, as I found out later.

My gut feeling was not wrong. It just doesn't work on this motor. This table shows four different ways of driving a unipolar stepper, and the first one is called wave drive. That's what my initial thougts were, but again: it doesn't work with this motor. I tried it, but most of the time it didn't even start. When it did, there was no torque whatsoever and it made the little thing completely useless.

Half stepping is what it should be according to the manufacturer. That's number three in this table. It's a bit more complicated, but not that big a deal. All you need to do is use 8 steps instead of 4. If you would name the wires A,B,C and D, then the scheme would be the following: first activate wire A, then A and B together, then only B, then B and C together... and so on. So half the time, there's one wire active and the rest of the time there's two wires active. It should give the motor the smoothest movement and that's probably the reason why this is what the datasheet recommends. Well, actually it just says to do it like this. There's no alterative in the sheet. According to this table, there's a better way if you worry about torque, because half stepping only provides about 70% of the maximum torque available.

If you really want the full potential, try the second option called Full stepping. Get back to four steps, but this time always put a voltage on two of the four wires. The scheme would be AB, BC, CD an DA. This gives the motor its full torque.

There's a fourth way to drive a stepper motor, that's using Microstepping. That takes expensive circuitry, so I won't bother about that for this page.

But my first concern was definitely its accuracy and torque. Though moving heavy objects is not really my goal, the worst nightmare when driving stepper motors must be that the thing skips steps due to a heavy load. You probably wouldn't notice this phenomenon at first, but when you want to move an object at an angle of exactly 46,7° in one direction, then this is a major concern. The application that I have in mind for this motor requires this kind of accuracy, and if a part that only costs $2.5 could accomplish that, it would make me one happy camper.

That's why I did the following tests. I made this little Youtube clip which only shows half stepping. I tried measuring the real torque of the motor, because the initial tests using this wave drive method went completely wrong. With half stepping being the prefered method according to the datasheet, this would be my next approach. I want to know what torque to expect in real life, and equally important: at which speed it can do this. This is the result:



First of all, I measured one piece of important information. Its current is about 120mAmps in half stepping. Theoretically, that would take it to 160mAmps in full stepping, but I never measured this.

But again, the major concern was torque and speed. A torque of 300 gcm (0,03 Nm / 4.25 oz inch - nice conversion website here) can be measured by applying 300g weight on a lever of exactly one cm distance away from the center of the rotor. This is not very convenient in real life, so I tried a lever of 10cm with a weight of 30g attached at the end.

300 gcm was no problem, but when I tried 350, the motor hesitated. It was missing steps, as you can see when it returned and pushed away the whole construction. These tests were done at a a speed of 333pps (pulses per second in some datasheets) or 3ms delay between pulses. At this speed, one revolution takes 12.6 seconds.

I tried to speed things up to 500pps (2ms delay between steps), but then the motor also failed the test. The maximum speed without any load was 800 pps (1.2 ms delay or 5.0 seconds for one revolution). At higher pulses, the motor just stopped.

I also tried full stepping when no camera was running, and I found that 380 gcm was its maximum torque at 333 pps (3ms delay). Those numbers produce the absolute max torque this motor can produce (when connected as unipolar with the driver board that's included, check this blogpost to see how I converted this motor into a bipolar model, which increased its torque even more dramatically!!). Why full stepping is not the preferred method is not clear to me, it just says so in the datasheet. I found no downside to this method, the motor does not seem to make more noise or run less fluently than in half stepping.

The number of steps in one revolution is a bit of a mystery to me. I found different numbers online, but all tests I did resulted in 508 or 509 steps for one revolution. 508 doesn't really make a complete turn, and 509 overshoots the 360° a bit.

The truth no doubt lies somewhere between the two. What bothered me was the fact that it's not an integer value. Probably this is due to the fact that these motors are geared internally. Also, there seem to be a few versions of the motor on the market and not all models seem to have the same gearset inside. I found this topic that talks about this strange phenomenon.

Another really major problem is the fact that I measured a lack of almost 6° when the motor changes direction. This problem is huge when I need to be as accurate as I mentionned earlier. There's an easy solution though, and I plan to make a manual correction with the software that drives the motor. My plan is to always move the motor in one direction for accurate positioning. If I do need to move back, I'll overshoot 10° and move back. This keeps the gears always positioned in one exact direction.

I wrote some very simple Arduino code, which you can find here. Four functions define the two methods half stepping and full stepping. You can choose to test one function by uncommenting it in the major loop(). The half stepping functions are called forwards() and backwards(), full stepping is accomplished by uncommenting forwardsFull() or backwardsFull(). It may be a good idea to set all outputs back to LOW afterwards (function motorOff()).

donderdag 24 oktober 2013

Het grote 'foert' moment

De maat was vol. Het moest nu maar eens gedaan zijn, had ze gezegd. Dat ie maar eens terugkomt als ie wat langer nuchter is, want zo kan het echt niet meer.

Eentje maar, één karakterfout was de aanleiding. Later noemde ik het in een moment van herkenning 'het grote foert-moment'. Als ik arrogant mag zijn, noem je dat goede raad geven. Anders hou ik het liever bij ervaringen delen die ik heel goed ken.

Maar dat is o zo groot, die herkenning. Het potje kookt over en het enige wat ik kon doen is weglopend iets roepen over een pot die je op kunt. Misschien denk ik dat alleen en zijn die woorden er niet echt. Maar steevast wou dat vroeger zeggen dat de concentratie alcohol die avond hoger lag dan andere avonden. Het tempo waarin het steeg, ook. Wie denken de anderen wel dat ze zijn? Er zijn limieten aan wat ik aanvaard, en dit pik ik dus niet. Foert!

Toch is er iets vreemds. Ik zeg dat ik dat nu niet meer zo heb, en dat blijkt niet waar te zijn. Ik heb mijn mond vol over hoe ik veranderd ben en hoe ik mijn karakterfouten heb aangepakt zoals dat trouwens staat ergens in een stap van ons programma. Het is een stap tussen vier en tien, maar ik weet niet dewelke. Maar ik ken die range omdat ik altijd beweer dat ik enkel één tot drie en elf en twaalf gedaan heb. Dat blijkt dus ook al niet te kloppen, want deze stap zit ergens in mijn todo reeks.

Maar dat is de kritiek. Hij is gegrond, want net vorige week liep ik weg van een discussie. En dat moet ik beamen, want ik herinner me het goed. Toch was het helemaal anders, want mijn promille veranderde niet die avond. Het potje kookte trouwens over omdat het al behoorlijk vol was, en dat herinner ik me ook. Ik heb zelfs het fundament van de kritiek ingezien en aanvaard. Het is niet omdat kritiek me boos maakt dat ie niet gegrond is. En binnen 24u heb ik de basis van de kritiek dan ook aangepakt. Het probleem is nu trouwens van de baan, terwijl ik vroeger koppiger nee bleef zeggen in mijn eigen wereld waar hoogstens één persoon gelijk had.

Eén van die stappen staat daar nog. Ergens tussen vier en tien. Maar lees ze eens heel goed. Luister eens heel goed naar wat de anderen zeggen. Het boekje met de stappen is geen bijbel. Mensen zitten een half leven lang aan dezelfde tafel zonder ze allemaal te doen. Het zijn suggesties, levensvragen die een antwoord krijgen en die je mag lezen als je dat wil. Weet alleen dat ze er staan en doe er iets mee als je er klaar voor bent. Of doe er niks mee en geef er een draai aan. Draai net zo ver tot de factor alcohol weg is uit het 'foert' moment.

Voor mij is dat nu voldoende. Ooit leer ik ze misschien nog af, maar haastig ben ik niet. Want mijn 'foert' moment is nu droog, en dat vind ik al een levensgroot verschil.

woensdag 23 oktober 2013

Zeg nooit roze tegen fuchsia


Geef nu gewoon toe dat ie er mooi uitziet. Ik weet dat wel hoor, het is de kleur die een vijftienjarig meisje zou kiezen. Maar op deze website (tallygear.com) kan je veel opberghoesjes vinden voor je Dexcom glucosesensor.

Ik had er al langer last mee, en omdat ie niet beschermd was, is er zelfs al een kras in het scherm gekomen tijdens onze Ardennen geocache. Da's jammer, maar gelukkig zit ze op een plaats waar ik nooit moet kijken op de grafiek. Boven 350 ben ik nog nooit geraakt en ik hoop dat zo te houden. En met mijn Dexcom (en mijn stabiel lijf, suikergewijs dan toch) heb ik de juiste tool om het niet zo ver te laten komen natuurlijk.

Nu dus goed beschermd: je kan het met die clip aan de lits van je broek hangen, de achterflap kan je door een broeksriem halen of je kan hem rond je nek hangen met het bijgeleverde zwarte lint. Een aanrader !

dinsdag 22 oktober 2013

Botscan

Een vreemd gevoel was dat toch en het duurde een hele poos. In 't Engels zeggen ze gut feeling, hier zou je kunnen zeggen dat je 't voelt aan je water. Maar er was dus iets mis.

Ik lig dus onder de scan vandaag omdat het rugprobleem maar niet opgelost geraakt. De chirurg stuurde me na de vorige afspraak verder naar de kelder van Sint Augustinus omdat de MRI scanner op de gelijkvloerse verdieping geen defecten zag. Op de afspraak zag ik het zelf, het voordeel was dat er nu een voor en na foto was. Voor en na de operatie zag je nu duidelijk op de MRI dat er wel degelijk toen een hernia in de weg zat en nu is die dus weg. Maar voor de rest is de scan niet problematisch.

Het verslag van de radioloog sprak wel over defecten die we al langer kenden en ze zijn er nu nog. Maar die zijn niet van die aard dat je er last van kan hebben, zo lees ik de woorden. Ik hoor wel een dramatische opbouw tegen de scan van drie jaar geleden, nog voor mijn eerste operatie. Toen waren er ook al meldingen van problemen boven de tussenwervelschijf die nu behandeld was. Maar niet van die aard om er last van te hebben. Nu dus ook niet, maar ik vind de uitleg minder geruststellend dan die van toen.

Maar dat was niet wat ik nu voelde aan mijn water. De botscan begint en de camera beweegt traag vanaf mijn hoofd naar beneden. Er wordt een volledig beeld genomen denk ik dan, misschien zal men later meer in detail gaan in de onderrug. Toch duurt die opname 20 minuten en ik vind dat dus vreemd.

Na die tijd wordt me uitgelegd dat de dokter de foto zal bekijken en dan beslissen of er meer detail nodig is. Ik wacht dus af, maar meteen verschijnt de arts in kwestie naast me aan de bewegende tafel. "U bent hier toch voor klachten in de lage rug?" vraagt ie me. Ik kan dat natuurlijk alleen beamen, maar de vraag baart me zorgen. Je zou toch denken dat de persoon achter de knoppen dat detail wel weet?

Niets is minder waar als ik plots van achter de glazen wand de volgende woorden hoor: "Aaaah, dat is lumbaal of wa?". Ik ben geen dokter maar dat woord ken ik natuurlijk ondertussen. De vijf onderste wervels noemen dokters lumbale wervels. Daarboven zitten een hoop thoracale en in je nek heten ze cervicaal. De scan is dus verkeerd en ik word gevraagd om me wat anders te positioneren op de bewegende tafel. Het kussen moet weg en er komt een rolkussen onder de nek. En dan komt er een nieuwe scan om meer detail te zien, dat is toch het verhaal dat in mijn gezicht verteld wordt. Dat zal ook misschien wel zo zijn, maar ik weet intussen dat de eerste foto's dus op de verkeerde lichaamsdelen nadruk hebben gelegd.

Na de scan vraag ik de dame die alle uitleg gaf over hoe ik me best positioneer op de tafel waar het misverstand nu zat. Veel antwoord krijg ik niet, en ik richt me op de heer die van achter zijn scherm is gekomen. Ik vraag hem op de man af of er nu het woord cervicaal op zijn blad stond en dat bevestigt hij. Ik zeg nog dat dat niet erg is, want ik weet ondertussen dat er een fout zit in mijn dossier. Ik vraag hem nu om die fout recht te zetten, maar hij heeft die bevoegdheid niet. Ik krijg alleen de goede raad om uit te kijken welke delen ze later nog fotograferen.

Hoe ik dat dan al wist? Ik kwam bij de controledokter van de mutualiteit een tijdje geleden en zijn eerste vraag toen ik binnenkwam was: "Hoe gaat het nu met uw nek?". Mijn antwoord was vervelend, want ik was dus daar om te bevestigen dat ik te veel pijn had om te kunnen werken. En mijn antwoord was dus dat er niks mis was met mijn nek. Gelukkig was het misverstand snel uit de wereld en geloofde hij meteen dat mijn probleem echt wel lager zat. Maar toen zag ik dus mijn dossier op zijn computerscherm en dat zegt letterlijk: cervicale hernia. Eentje in je nek dus. Ook hij kon dat dossier natuurlijk niet aanpassen, maar het is wel vervelend.

Ik zal dus inderdaad best op mijn qui vive blijven bij de volgende onderzoeken !

maandag 21 oktober 2013

Lightbox 360: The making of



Uiteraard is daar aardig wat werk in gekropen, maar het is dan ook een project waar ik een hele tijd geleden al mee startte.

En het fijne was zeker dat het helemaal niet enkel over elektronica gaat, maar ook zowat alles wat een nerd kan doen om zich wat bezig te houden. Dat ging van het zoeken naar een oplossing om het gat van de display een beetje netjes uit te frezen (in deze blog) tot het testen van het fototoestel met als extra funfactor een ultrasone sensor die een foto neemt als je op één meter afstand een voorwerp voor je toestel brengt (in deze blog). Ik deed ook wat testjes van componenten, vooral dan de goedkope Chinese stappenmotor (in deze blog) die nu vaak wordt gelezen via Google Translate. Ik had dus de pagina beter in het Engels gemaakt, zoals ik het origineel had gepland ;-)

Verder was het natuurlijk vooral solderen, programmeren en zelfs één keer spelen met een laser. Waarom dat nodig was, kan je onder andere zien in dit 'making of' filmpje.