Stepper 28BYJ loosing steps

Support for Arduino in combination with Air Manager and Air Player

Moderators: russ, Ralph

Message
Author
User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Stepper 28BYJ loosing steps

#11 Post by jph »

If using the 28BYJ try upping the voltage. ! - in almost all cases it works.
Also, make sure you check the steps per 360 degrees are ok as they are often NOT 4096.. - they can be 4086.
I fully agree that calibration is definitely the best..... but........ you can check the steps with a very fine needle and marker.

Definitely DO try upping the control voltage. ie - if you have the 5v version try running at 9v, I have even run the 5v version at 12v and it was fine. - YMMV... :!: :shock:
You can also change the unipolar operation of the stepper to bipolar and use a proper driver (double the torque)

Re VI6606 - DEFINTELY NO !!!!!!
They do NOT support the NON X2x type stepper !
The 6606 ONLY supports the X2x type units (which are actually more like a cross between a stepper and a moving coil meter. ) virtually no torque - but, perfect for instruments n 99% of cases. The 6606 is SPECIFIC for the X27 type.
Conversely, do NOT use the 4988 or similar stepper driver for the X2X series !!!!! :o :o :o :o :o - the X2x instrument stepper need to use the proper driver like the 6606.
The 4988 or similar is certainly fine for the 28BYJ or NEMA ----- IF the BYJ is modded for Bipolar operation (simple).. or used with and standard bipolar stepper such as the nema 17 or even 23. No worries !
To mod the 28BYJ for bipolar with use with something like a 4988. remove the blue cover, cut the track from the red wire on the pcb, then remove the red lead. Sorted. ! ;) let me know if you need more info.
I would simply just up the voltage to the BYJ.......... worst case is it fries ... no worries, it is only a dollar or so :lol: run the 5V units at 9 or 12V...
All good fun...
Joe
Last edited by jph on Fri May 07, 2021 11:50 am, edited 3 times in total.
Joe. CISSP, MSc.

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Stepper 28BYJ loosing steps

#12 Post by jph »

Have a look at -
https://siminnovations.com/forums/viewt ... =10#p35331
There is some more info for you..
Joe.
Joe. CISSP, MSc.

marcel_felde
Posts: 159
Joined: Wed May 09, 2018 12:19 am

Re: Stepper 28BYJ loosing steps

#13 Post by marcel_felde »

Hello Joe,

Thank you so much!

In fact I did try 12V some weeks ago which resulted in a very hot stepper motor. But I could try 7V or 9V. In fact I have already 5V, 12V, 24V and 230V. I try to keep voltage variety to a minimum because in the airframe with to many wires it is of advantage to have things sorted... ;)

In fact, the steps do not play a role. Because I have a calibration at zero and than have so many steps that the needle moves all the way. With the N1 indicator it is about 3 rotations. On the altimeter 10 rotations. I assume that it is only a problem if the speed is set wrong or a problem with the communication between ULN2003, the stepper driver software and Air Manager. In fact, the 28-BYJ only move smoothly with Air Manager if either the speed of the motor is set to be low - than the needle moves not fast enough on greater data changes - or the speed of the motor is set to high and the needle is moving high speed. Outside this situations it is always jerky.

I tried to adjust the script for the altimeter to set up speed according to the change rate of the data. This works but is more complicated. And I did not test for data loss in this scenario. Would be a point to think about for the N1 gauge too. But it would be better to solve the problem of loosing steps in Air Manager or the driver... ;)

Yes, many needles are possible with the X25/X27. I just did trim down the limiter inside such a stepper to get this VSI to work from -6000 to 6000 instead of -4000 to 4000. :) But in real instruments and also rebuilts like RMI, N1, ALT, STBY ATTI there are gears used. And this is usually a nogo for X27 low torque...
photo_2021-05-07_16-06-41.jpg
I will have to read about those drivers. Thanks for the links!

Marcel

marcel_felde
Posts: 159
Joined: Wed May 09, 2018 12:19 am

Re: Stepper 28BYJ loosing steps

#14 Post by marcel_felde »

Joe, have read your information! The driver for NEMA steppers sounds great. I think I will then replace the 28byj on some areas. This loosing steps issue does not leave me very lucky - instruments in the sim have to be reliable. ;)

What is the advantage of the modification of the 28byj?

And as far as I remember, the X27 were much smoother while using Simvim than compared with ArdsimX. May this depend on the software driver? And if yes, how can we get this in AM? :)

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Stepper 28BYJ loosing steps

#15 Post by jph »

Hello Marcel and good morning.
LONG answer follows.. sorry about that but it is not too easy to explain and may be helpful for others as well ...

I have several points for discussion here, that hopefully answer some questions - and maybe / probably / raise other questions.
There is some in depth stuff, and some - hopefully - summary stuff - so skip over anything as needed - or when you get bored.............. :(

Firstly, let me try to address the differences between bipolar and unipolar stepper motors.
The unipolar stepper motor uses centre tapped coils as it 'was' easier to use polarity change on the coils in a 'simple' manner without directly reversing current flow direction externally - by effectively maintaining the centre tap at a single level and then switching levels at either 'end' on the coil magnetic polarity is reversed. This is either 5 wires - in the case of the BYJ as the two driver coils have a common centre tap, or, 6 wires if the centre tap is not common.

Then, along came affordable H-Bridge driver circuits which allowed the full coil to quickly change current flow and magnetic polarity without the need for a centre tap producing a bi-polar coil.
Practically ALL stepper motors now are Bipolar - apart from some specialist units beyond the scope of this thread.
The 28BYJ is a UnIpolar stepper driven by a very simple ULN2003 Darlington transistor driver where the centre coil taps are held at the input voltage applied to the external Voltage input for the secondary drive circuit of the ULN2003 - basically the driver is low drive level in to high level out where the Darlington pair on the output is a very efficient and very high gain current amplifier hence, can be driven from a simple uP port yet switch relatively high external current levels. ALL the work is done on the uP (Microprocessor) - in this case, your Arduino or whatever the uP is.
This is cheap and nasty, it works, but is pretty crappy. It also involves a LOT of processing power in relative terms. It can simply use basic logic levels due to the centre tapped coils whilst demanding a hell of a lot from the uP.

Ok, so on to a BIPOLAR stepper. The setup (internally!) of a bipolar stepper is 'basically' similar in coil layout as the unipolar - in that there are two main driver coils - but instead of 5 or 6 wires, it only needs 4. ALL the current / polarity switching is done by an external H-Bridge switching setup so you only need to supply current to the 'ends' of the drive coils and the reverse direction is controlled by the H-bridge driver output stage. The inefficient centre tap on the drive coils is not needed now. We can now apply more current to each coil with the centre tap bypassed. What this means is that with a H-Bridge circuit the polarity reversal of the driver coil of the stepper motor is supplied form the H-Bridge. A H-Bridge is fairly simple, It is four FETs (originally 4 BJTs ! - yuk!) . they can be simply switched to reverse the supplied direction of polarity. You don't need to know HOW it works, as it is all self contained in the 4988 etc.

This time, you need to have an EXTERNAL 'driver' that does all the work for you alleviating the work of the uP AND providing the necessary H-Bridge - usually in N and P channel FET form - to do the work.
Enter the A4988 or similar as a great starter FULLY CAPABLE driver board. This is so simple to use as you only need to supply two inputs to it - 'Direction' - a simple logic level high or low, AND a 'step pulse' train where each logic level specific edge drives the motor one step. So basically, you set direction, then apply a pulse train at the speed you require to control speed of stepper, and, the amount of steps you need.

A BYJ 'modded' from unipolar to bipolar - AND then driven by a REAL stepper driver usually has an increase in torque by an incredible 250% !!! - with the same driver voltage. The load on the uP is also far less.
Now, with a 'modded' BYJ to Bipolar, and, a suitable driver board such as the 4988, then the drive function in AM for the driver board is exactly the same as the VID66-06 function in AM. (simply because the VID6606 uses industry standard driver protocol). But note, as I have said previously - a vid66-06 IC cannot be used for anything apart from the X2x Series, and the standard bipolar steppers cannot be used for the x2x steppers !. It is simply that the drive PROTOCOL is the same, hence the AM VID66-06 function will work for ANY industry standard stepper driver.

(I will post some links and images later in this LONG post.) . Brother Keith my friend, @Keith Baxter has probably missed me posting long laboured posts haha. :P (hope you are well Keith sir ?)

--------------------------------------------

Part 2 of long boring post ....................

The AA4988 will drive the NEMA 17 steppers fine and also the 23 in most cases. Limits of what can be done depends on the impedance of the coils - which then dictates torque and speed capabilities and also max voltage and current which can all be calculated from the coil impedence If needed - in most cases it is simply a matter of connecting the stepper with an appropriate voltage and adjusting the current limiter pot on the A4988. I created a spread sheet for the math for this if you want it. ? - basically buy the smallest nema 17 and stick it on the 4988 and adjust the current limiter pot to keep the current below a suitable level for your motor and also within the limits of the driver - and for 99.9% of cases it will be fine. BUT, also, a modded BYJ to bipolar with a 4988 will also be fine - and - usually the smaller nema 23 will also be excellent - these tend to be used in the cnc 3d printers with those drivers, but it must be noted the actual torque needed for a 3d printer is fairly low but still much higher than you would probably EVER ever need, even with a nema 17. ! . If using a BYJ, set the current pot on the 4988 to minimum and then adjust upward until you are happy with the performance. You can run higher than listed V levels if needed providing you limit the current.
For a full CNC - as in a CNC router, then that is a different ball game, but, not actually a big issue as far far higher power drivers can be bought for a few dollars that could move a stack of bricks with the appropriate stepper motor.... :o (and STILL use the 'vid66-06' function in AM !!!!)

I didn't realise at first that you are using real instruments and supplying drive to the geared internals etc. Very nice ! More on this later.. including 'missing steps'

-------------------------------------------

Now.. Missing steps in AM...
I would be interested in Corjan offering some input here if possible ? ( @Corjan )
BUT, I think it may be a case of AM simply not keeping up with the drive of the BYJ ULN unit - depending on SPEED of rotation, and also, the number of other functions used, and of course, the complexity and length of code used in AM. ? But, Corjan is the guy to offer input on that. - to save time Corjan, you only really need to look at this section of this missive regarding 'missing steps'

What I would be tempted to do is remove AM from the equation and set up a complete Arduino routine to see how it goes ?.
personally, I would suspect that AM can, in certain cases, be overloaded. BUT this is purely thinking out loud. If it works fine in Arduino on its own, then the problem would appear to be in the relationship and timing of Arduino to AM depending on load (at either end!). - a 'scope' would certainly help to diagnose the issue. I have my trusty hankek 100Mhz digital here, but not handy... Perhaps you could check at your end Corjan ? - just a thought.

-----------------------------------------

Marcel, If you are happy with Arduino coding, or willing to experiment then seriously look at using message port and also a fantastic library called 'accel stepper'. it has some really nice examples built in to give you a flavour.

EDIT - Note for clarification - I reread this and I didnt make this part clear ----- @marcel_felde - Marcel, to experiment with Accelstepper library the arduino you CAN use the standard ULN / BYJ stepper board with no modifications, it is supported in its original form along with the industry standard units which means you can also use the library for any other driver, including a modded BYJ with a suitable driver board. So to try the library then you don't need to change anything in hardware at this stage.. !


I have used accel stepper and it is superb. I am NOT a message port aficionado though ! - although I intend to use it for most of my hardware projects that involve steppers, display etc, I am certainly not proficient in it's use at this stage, although it appears straightforward and would answer all your issues I believe.
With accel stepper you can control the rise speed, decay speed intermediate speed and anything else speed related.
If you wanted an NG gauge for a PT6 for example - then you could set it to slowly climb to 13% then if burn occurs you can rapidly increase the speed of rise - the acceleration, and also deceleration near the end of the value, and even overshoot. You can make the gauge look and act more or less like the real thing.
in AM the speed is - afaik - fixed once set. this is REALLY bad for gauges that change velocity of movement - as most do ! - exactly as you describe. AM can only do so much with it's pre-programmed Arduino images. The only way around that apart from message port etc, would be to have specific images for the Arduino that focused on specific functions. As Corjan mention within the last week, the use of 'hardware' within the AM community is fairly low so that side of development would appear to be a lower priority with AM4 etc that the gauge functionality and general issues. Which is fully understandable. Even then, having control over stepper acceleration and deceleration would be probably not be on the cards.
BUT, we do have message port. ! - which I think is far far better than anything offered by other hardware linkup programs.

----------------------------------------

Ok, now for some images / links regarding unipolar and bipolar steppers - and also modification of the BYJ for bipolar operation. (with around 250% more torque)

One on my bench - hope it has enough detail as to how to do it ?.
IMG_20210508_083222042.jpg
A link to a good site describing uniploar / bipolar -
https://techexplorations.com/blog/ardui ... er-motors/

A link to modding the BYJ along with colour codes of wires and phases.

https://ardufocus.com/howto/28byj-48-bipolar-hw-mod/

A link to the A4988 board - available on AliExpress for less than a dollar. ! (same board !!!)

https://www.tme.eu/Document/25459777e67 ... U-2128.pdf

Phew... that was longer than I expected... I cant even be arsed checking for typos haha. ;)
Joe. CISSP, MSc.

marcel_felde
Posts: 159
Joined: Wed May 09, 2018 12:19 am

Re: Stepper 28BYJ loosing steps

#16 Post by marcel_felde »

Hello Joe,

Thank you so, so much for your detailled answer!

It took a while until I was able to check that voltage issue: In fact, with 7,5V it is still loosing steps as before. So I assume this has to do with the communication between AM and the driver.

I will test to change the stepper speed depending on the value change rate, if it still will loose so many steps. Maybe this is a workaround until the problem is fixed...

I will also try out other solutions you suggested me, but I need more time for that. ;)

Thanks again,

Marcel

marcel_felde
Posts: 159
Joined: Wed May 09, 2018 12:19 am

Re: Stepper 28BYJ loosing steps

#17 Post by marcel_felde »

"in AM the speed is - afaik - fixed once set"

You can set speed. But I don't know if this fixes the problem... as mentioned, I will have to try it out.

marcel_felde
Posts: 159
Joined: Wed May 09, 2018 12:19 am

Re: Stepper 28BYJ loosing steps

#18 Post by marcel_felde »

@jph

Hello Joe,

I did install the Accelstep library this morning. And also test with the default stepper library. Both work fine and don't loose steps. While with AM you can see the needle misplacement after even one turn, the needle is still accurate with those libraries after several minutes of movement. So this could very likely be a communication problem between AM and the driver. @Ralph

I want to test this theory with the message port, but as you may know from the other thread, that does not work at all at the moment.

--

Another exploration: If you want to have smooth and slow needles with a 28BYJ, you need a gear! The stepper itself cannot provide them. ;)

User avatar
jph
Posts: 2846
Joined: Fri Apr 10, 2020 12:50 pm
Location: Somewhere over the rainbow..

Re: Stepper 28BYJ loosing steps

#19 Post by jph »

marcel_felde wrote: Sat May 22, 2021 8:28 am

Another exploration: If you want to have smooth and slow needles with a 28BYJ, you need a gear! The stepper itself cannot provide them. ;)
Hi Marcel, I never found and smoothness issues with the BYJ with accel step lib. It was silky smooth as far as I remember. But it is quite a while since I used it. I will see if I can dig out my code.
If you converted it to bipolar and used a 4988 for example, then you can also use microstepping which would negate and gearing issues you may have. -
ps: - I cannot remember off hand if halfstep worked with the BYJ and standard ULN driver in unipolar mode......
The main code and arduino stuff is on another machine. But I will take a look when I get chance.

But, would you agree that Accelstepper is an absolutely superb library, and I think is absolutely the best thing to use for almost any realistic gauge in a flight sim ?. ;)
Joe
Joe. CISSP, MSc.

marcel_felde
Posts: 159
Joined: Wed May 09, 2018 12:19 am

Re: Stepper 28BYJ loosing steps

#20 Post by marcel_felde »

I thought that those microstutters on slow movements are hardware issues through the step size.

Will microstepping cause the motor to do smaller movements?

When a compass disc or needle is directly mounted on the 28BYJ, you may have wonderful smooth movements if it is fast enough. If the needle or disc is moving very slow, for example in slow turns, you can see the steps in the movement.

--

In fact, there was even a big step concerning smoothness between ArdsimX and Simvim. But I don't know which libraries he was using. I never was able to operate Simvim in our sim itself - too much needles. ;)
But if you are right with Accelstepper, and the Message Port will hopefully work some day, I will convert all my instruments from ArdsimX to AM with Message Port for sure!

Post Reply