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

#21 Post by jph »

marcel_felde wrote: Sat May 22, 2021 8:58 am 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!
Hi Marcel,
YES - Micro stepping causes smaller movements !

Microstepping is a way of reducing the distance travelled per 'step' of the stepper motor. It increases resolution - meaning it reduces step size - and the only real drawback is that it decreases the maximum motor speed available. - which should be of no consequence in a ''needles' type display.
for example, micro step of 4, or 8 means that the 'needle' will move 1/4 or 1/8 degree per step. so you get a movement between steps of original / 4 or original / 8 - for example.
the A4988 driver has all this built in and useable by accel stepper. The A4988 has the hardware option of selecting 1/1 ... 1/2 .... 1/4.... 1/8 .... 1/16 ... step sizes my 3 jumper pins on the board. Enjoy.... tip - use the MINIMUM micro-step that does the job. If you need any info regarding max speed available with different steppers (providing you know the inductance) then I have a spreadsheet I created. ... but for now, if you use the 4988 or similar, then just play around.. it is good fun. ;)
Joe.
Joe. CISSP, MSc.

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

Re: Stepper 28BYJ loosing steps

#22 Post by marcel_felde »

Sounds amazing, I will definetalley try that!

The 28 BYJ has quite some advantages: Cheap. Cheap. Easy to get. Cheap. Measurements are avaiable for 3d constructions. Easy to mount. Offset axis for gauges that have offset needles or limited space. And they are cheap. ;)

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

Re: Stepper 28BYJ loosing steps

#23 Post by jph »

Hello Marcel and good morning.
I have been giving this some thought and here are a few conclusions.

PLEASE allow for the fact that my head is blurred due a night out last night and lack of coffee this morning . :lol: :mrgreen:

Firstly, there 'should' be no issue in step size for the BYJ stepper - at all !. (without using microstepping)
With the absolutely standard ULN board the stepper has the following spec.
The stepper itself has 32 steps per revolution (about 11 degrees per step which is poor) .. however, internally it is geared by approximately 64:1 meaning that the number of full steps per revolution is around 2040 steps. SO each full step is only moving the shaft about 0.175 degrees !!! , That is REALLY really small steps ! and should never need microstepping at all.

So, where are the potential issues you are finding with 'jumping' movements or lack of /smoothness ?
Well, imho, it can be any, all or a combination of the following. -
The update rate of the data from the sim that AM sends to the Arduino.
The speed of update of the movement of the Arduino stepper output.
And, of course, this is all tied into the 'frequency' of the stepper HW set in AM.

It does appear that you CAN alter the speed in RPM of the stepper at will within AM ! - (apologies as I was unsure of this and thought you could not)

With 2040 steps per revolution of a STANDARD BYJ stepper, then asking for an RPM of, say, 10 RPM is asking for the arduino to produce 10 X 2040 (20400) steps per minute - or around 400 steps per second ! so around 2mS per step. In that 2mS, the arduino has to process the 4 pin code cycle (per step) for the ULN driver board. That is a hell of lot to ask, even of a mega2560... That is along with whatever else is happening on the arduino.
And of course, how quickly can AM process the updated data from the SIM, and, send it to the arduino, and do all of the other things within the AM code.

Then also, even if the speed and update are ok, then an RPM value - with a slow change of data from the sim - may well cause the needle to jerk in movement as the update is slower than the rpm so each updated position - say - 6 degree every second ( which is equal to rpm of 1), when the RPM is set at 10 (60 degrees per second), will cause quick jumps between updates at 10 times the speed of the required update. Hence it can be working as programmed, but, will cause stuttering and jerky movement.
If the RPM was set to 1 (6 degrees per second) and then the movement was actually required at 60 degrees per second (10rpm) then the needle will be too slow to keep up with a greater rate of movement (delta)
And then conversely if the RPM was set to 10 RPM (60 degrees per second) and the movement required was at 1 degree per second then the needles movement between updates would be too fast - causing jerky stuttering movements.
There needs to be an allowance in the code for the delta(rate of change). Unfortunately, this can only happen AFTER the next update from the sim occurs. This would require the RPM to be constantly altered to cope with different delta.
It may well be possible in AM as the RPM does appear to be able to be changed on the fly.
It would also be an ideal case for PID control - which accelstepper provides. or, careful considerations and continued calculation of the rate of change between updates and setting the RPM to compensate and react accordingly following each update - or indeed, a slight overrun with accelstepper accel / decel etc...

This is a main reason, I think, that you are seeing stuttering or jerky movement I believe, however, loss of 'steps' may well be a comms issue between AM and the Arduino (hence to the stepper) - there is a way to test this I would think by writing specific lUA code in AM to send data to the arduino at varying speeds until (and if) the missing steps are seen)

I definitely recommend grabbing a PICO to rule out any issue with speed of the arduino and then you can, in reality, ignore that side. AM 4 includes support for PICO without MP. Yes, you cant use accel stepper, but, it is immensely faster than the mega etc.
https://siminnovations.com/wiki/index.p ... ry_Pi_Pico

You can DL an image for the PICO here -
https://siminnovations.com/wiki/index.p ... ry_Pi_Pico

using this, you remove any worries about arduino update speed (or should do :) ;) )

Hope that helps ? (and makes sense) ?

Joe
Last edited by jph on Mon May 24, 2021 7:06 am, edited 2 times in total.
Joe. CISSP, MSc.

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

Re: Stepper 28BYJ loosing steps

#24 Post by marcel_felde »

Thanks again and again, Joe! Wonderful!

--

The jerky, slow movement also appears while testing with accelstepper library. Without AM. I do not get the needle to move smoothly on low rpm.

Loosing steps only happen with AM on low rpm. Not on high rpm and not when driven directly with the accelstepper library or default stepper library.

I do calculation on the delta within a timer, not with the callback function of the dataref subscripe. The stepper position is also set within that timer.

--

I will have to wait with updating to AM4. Corona had quite some influence on my income as photographer and I do have a lot of licenses. Several AMs and much more APs. ;)

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

Re: Stepper 28BYJ loosing steps

#25 Post by jph »

Hi Marcel,
It is interesting that you seem to be getting issues with Accelstepper ???

Are you using the 'ConstantSpeed' example ? - That should not be causing an issue.
Using the ConstantSpeed example -

With setSpeed(200); // note setMaxSpeed must be > than setSpeed ----------------- I am sure you know all this but I am just thinking out loud,,,, :)

I would presume 1 revolution in around 10.2 seconds (without fine tuning)

On 'fullstep' mode the the BYJ, it should be receiving 200 steps per second constantly.

with setSpeed(100); it should be around 20.4 seconds per revolution

Do those not appear very smooth ?
Would be very interested in your results.
Joe.
Joe. CISSP, MSc.

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

Re: Stepper 28BYJ loosing steps

#26 Post by marcel_felde »

Yes, directly with Accelstepper. It is smooth as long as it turns fast enough. With slow speeds it gets jittering.

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

Re: Stepper 28BYJ loosing steps

#27 Post by jph »

marcel_felde wrote: Mon May 24, 2021 9:55 am Yes, directly with Accelstepper. It is smooth as long as it turns fast enough. With slow speeds it gets jittering.
Hmm, interesting..
I only have the bipolar converted byj here (I have many others but not in easy reach as they are in piles of boxes :) ) . however, I can probably easily convert it back to unipolar and use the ULN controller and give it a test here. I just need to re-solder the track cut for the red wire (5V) and rearrange the pins in the motor connector
Give me a day or two. We need to get to the bottom of this. There is no way to blame AM if problems are there directly.
Joe. ;)
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

#28 Post by jph »

Marcel,
try this code (ensuring your motor pins are set correctly) - using just the arduino stepper lib.

Also, a really good site -
https://lastminuteengineers.com/28byj48 ... -tutorial/

Code: Select all

//Includes the Arduino Stepper Library
#include <Stepper.h>

// Defines the number of steps per rotation
const int stepsPerRevolution = 2038;

// Creates an instance of stepper class
// Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence
Stepper myStepper = Stepper(stepsPerRevolution, 8, 10, 9, 11);

void setup() {
	// Nothing to do (Stepper Library sets pins as outputs)
}

void loop() {
	// Rotate CW slowly
	myStepper.setSpeed(100);
	myStepper.step(stepsPerRevolution);
	delay(1000);
	
	// Rotate CCW quickly
	myStepper.setSpeed(700);
	myStepper.step(-stepsPerRevolution);
	delay(1000);
}
Let me know ??
Joe
Joe. CISSP, MSc.

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

Re: Stepper 28BYJ loosing steps

#29 Post by marcel_felde »

Will try that, thanks Joe!

I never thought jittering could be caused by AM. It is about loosing steps, which is a problem, that only occurs with AM. ;)

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

Re: Stepper 28BYJ loosing steps

#30 Post by jph »

HI Marcel,
Just to clarify, I am trying to determine if you are getting smooth action at slow speeds with just arduino code (without AM)
I believe, from what you said, that it still appeared jerky (or jittering) at slow speeds with accelstepper ?
I would like to check that out first as it shouldn't be jerky (jittering) at slow speeds. Hopefully :? it 'should' be smooth at low speeds with the last code posted (standard arduino stepper.h)

We can then move on to checking the missing steps if thats ok with you?
Joe
Joe. CISSP, MSc.

Post Reply