Nano MobaTools Library - Speed Steps Needd Advice

Hi Franz Peter and all

I have a sketch working, just, with stepper motor. The only reference to speed is a
myStepper.setSpeedSteps( 2000 );
I do not know how this number is set. How to calculate what speed should be entered (x10)
The manual for is : void myStepper.setSpeed(int rpm10 ); comment is set up 'rotation speed' is this the rotation at last point of gear drive? In my case I need the last driven gear to turn at 20rpm (show as 200?)approx. The gear ratio at this point is 42:1 including the 28byj-48 gearbox .
The calculation and if any other code is required unit16-t..... ?
Just need to clarify in my 80 years old brain.

Thankyou
Charles

Hi Charles,
you must strictly distinguish between setSpeed() and setSpeedSteps().

setSpeedSteps() defines the step frequency. To have a better resolution without using float, it is set in steps/10sec. So your
myStepper.setSpeedSteps( 2000 );
will advise the lib to create 200 steps/sec. Now the mechanic of your setup defines how many revolutions/min this will be. The lib doesn't know anything about this.

myStepper.setSpeed(int rpm10 );
defines the speed in rev/min*10. The factor 10 again is only to get a higher resolution.
Internally this value is converted to steps/sec. To do this, the library needs to know how many steps are needed for one revolution. This value is set, when creating the stepper object, e.g.:
MoToStepper myStepper( 2048, FULLSTEP );
What means there are 2048 steps for one full revolution. So you must know, how many steps are needed to create one full revolution. This includes the steps/rev of the stepper motor itself, and the gear ratio.
If this value is not correct, you will not get the correct speed with setSpeed().

Regards, Franz-Peter

Hi Franz-Peter

Thanks for the info. I will try and work out. I will post the sketch later today, with comments in the sketch.

Charles

Have attached .ino for my project with a lot of notes plus a photo of the project. Do not look to closely at the engineering!! lol

TransferFP1.ino (4.1 KB)

Have a great week everyone.

Charles

Hi Franz-Peter and everyone.

Is someone able to assist with the mess that I have made of my sketch. Especially what I need to do to sort the speed and speed steps etc. and the gear calculation.

Thankyou
Charles

If the gear ratio between motor and output shaft is 1:42, I get a step per second rate of 16.25 steps per second or:
myStepper.setSpeedSteps(162); // or 163

20 RPM / 42 = 0.476 * 2048 = 975.2 / 60 * 10 = 162.54.

Hi JCA34F

Thanks I will go thru that step by step. Looks good, and what I was looking for. With the list of gears and the result that is 1:42 correct ?
Thankyou
Charles

I would prefer if you copy the sketch into your post ( with code tags ) as explained here.

I doubt that, because the ratio of the 28byj-48 gearbox is already ~1:64 ( differs a little between different manufactureres and is mostly not exactly 1:64 ) The motor itself needs 32 steps/rev in full step or 64steps/rev in half step mode.
In FULLSTEP the 28byj-48 needs ~2048 steps per revoluton at its output shaft.
So what's really the reduction of your belt drive? Surely not 1:42.

I don't think this is possible with the 28byj-48. This motor is not able to reach more than 30rpm at the output shaft of the motor - if at all. Even if your drive belt gear is less than 1:42 you will not get 20rpm.

How many teeth on the large cog belt sprocket? On the small cog belt sprocket? On the right angle gear? On the drill shaft gear?

Hi Franz-Peter and everyone
The code below. The ratio needs to be check out I am sure it is incorrect. That will help. Other things like does speedDir need to be included etc. The loop etc works ok. the settings need a change or two! Once we know correct gear ratio and how to show it for speed steps etc I can experiment with output speed. Should I e using bipolar or monopolar?
Thanks for your patience.
Charles

#include <MobaTools.h>

const int stepRev = 2048;                      // ??
//const int stepRev = 4096; //Or                // steps per revolution  28byj48 no box= 32  (x64 ratio)  with box =2048 FULLSTEP  (HALFSTEP=4096)

//const int stepRev = 770 //Or                // steps per revolution  28byj-48 with additional gears.  After 28byj-48  motor gearbox, #1 belt drive = 40t, 
//                                                 #2 belt drive = 20t, #3 crown = 20t, #4 idler = 18t, #5 = 15t.  Total is:  2 x 1 x 1 x 1.1 1.2 = 2.64.?
//                                                 Therefore orig bearbox is  64th reduction divided??    2.64 overdrive  =   ?? 
//                                                 28byj-48 motor only = 32 rpm x 24 = 768   as used.FULLSTEP   (HALFSTEP=)1536

const byte stepperPins[] = {2,3,4,5};     

// create stepper object
//MoToStepper myStepper( stepRev, HALFSTEP );or

MoToStepper myStepper( stepRev, FULLSTEP );


// create button objects

const byte buttonPins[] = { A0, A1, A2, A3, A4 };                   // adjust button pins to your needs = 5

//const long stepperPositions[] = {0, 4096, 8192, 12288, 16384}; //Or     // must be same number of elements as buttonPins = 5
//const long stepperPositions[] = {0, 1000, 2000, 3000, 4000}; // Or
//const long stepperPositions[] = {0, 700, 1400, 2100, 2800};  //Or 
//const long stepperPositions[] = {0, 250, 500, 750, 1000 };   //Or 
//const long stepperPositions[] = {0, 3000, 6000, 9000, 10000 };//Or

const long stepperPositions[] = {0, 1500, 3000, 4500, 6000};


const byte buttonCnt = sizeof(buttonPins);                          

MoToButtons myButtons( buttonPins, buttonCnt, 20, 500 );

void setup() 
{
  Serial.begin(115200);
//  Serial.println(file name is:   ("TransferFP1, Arduino 1 8 18, last amended 17 March 2024");

  Serial.println("Starting...");

  myStepper.attach( stepperPins[0],stepperPins[1],stepperPins[2],stepperPins[3] );

  myStepper.setSpeedSteps( 2000 );    //Need advice on what this number sshould be.



  myStepper.setRampLen( 50 );         //  steps to achieve set speed  
}  

void loop() 
{
  static int lastPos = 0;                                // must be static to not get initialized to 0 with every loop
  myButtons.processButtons();                            // Check buttonstates
  for ( byte pos = 0; pos < buttonCnt; pos++ ) 
  {
    if ( myButtons.pressed(pos) ) 
    {
      Serial.print("Move from "); Serial.print(lastPos); Serial.print(" to "); Serial.println(pos); myStepper.write( stepperPositions[pos] );
      lastPos = pos;
      myStepper.writeSteps( stepperPositions[pos] );
    }
  }
}


You lost me! I only see 4 gears / pulleys in the picture. Where is the idler?
How many teeth on the crown gear? How many on the gear the crown gear is driving?

Hi JCA34F
Thanks for your comments. I apologize for not making it clearer.
The missing idler is unseen in the photo due to the gear above hiding it. It is under the vertical white gear and attached to the shaft underneath. The crown is 20t. The shaft underneath goes across the length and has a 15t gear on each end to drive along a rack. The drill gear is 20t.
Charles

Hi Franz-Peter and everyone.

Update
Have finally got the gear ratio worked out, The overall ratio for the whole gear train is now 31:1 . This makes the stepRev 992.
setSpeed should then be ?? How is this determined, and setSpeedSteps is calculated from this.
As the sketch is for unipolar. It seems that bipolar is best for torque. If I modify the motor by removing the correct motor wire are there any changes to make to the code ?
Your patience is appreciated once these above items sorted it should be good.
Thanks
Charles

I cannot follow you. How do you get 992 steps per rev from that gear ratio?

Hi FranzPeter

The 28byj-48 with 64:1 gearbox is 32 x64 = 2048. Now allowing for the addition to gearbox, the new ratio of total gearbox is now 31:1 calculation is now 32 x 31 = 992. This becomes the stepRev in the first part of sketch. ```
const int stepRev = 992;

Have I done this correctly?
Thankyou
Charles

Hi all
If I change above sketch to operate as bipolar (currently 5 wire unipolar) what code do I need to change? Thankyou
Charles

The first gear in your train is 40:20, so a 2 to 1 step UP, the crown gear shaft will be1024 steps per rev. Now, which shaft do you want to turn 20 RPM? What is that shaft's ratio to the crown gear? If the final shaft is turning 20 RPM, what is the RPM of the crown gear shaft?

Hi guys,

If it is difficult to do calculations with fractions where the teeth-numbers are put in

I want to suggest a different method to determine the over all gear-ratio:

There is already mark on one tooth of the "output-shaft"
image

write a simple testcode that does nothing more that create step-pulses at a rather low frequency as long as a button is pressed down.
button pressed down: => create steps
button released : => stop

at start do a functioncall to setZero()

each time the button is released print the actual step-position to the serial monitor

press button until mark has done approximately one revolution
note the number of steps

just as an example number let's say the number of steps is: 12345

second stage:
use the number of steps in a second testcode that does 10 revolutions
which equals to 12345 * 10 = 123450 steps

let the thing run the 123450 steps and check if the mark is really at the most up position like in the picture
if it has turned too far reduce the number a few steps
if it has turned not far enough increase the number a few steps

test again.

If it seems pretty good
let the thing do 100 revolutions and repeat the same procedure.

On the other side:
what is so hard about writing the number of teeth for each and every toothwheel, toothbelt-wheel and whatever else parts that are included in this geartrain??

The overall gear is simply the result of multiplying fractions build from each wheel-pair which can be done by each pocket-calculator, smartphone, Microsoft Excel, libre-office calc, and each and every calculator software which is a standard on windows MACs, Linux, Chrome OS, and even online available

I have a very different question:

what is the final purpose of rotation the drill at whatever rpm?

details versus overview:
We are talking about details. Please give an overview over your whole project.
in mimimum 70% of all cases knowing the whole thing offers completely different and much better working solutions.

This is like

here is an analogon that shall show what can happen if just ask for details:

Newbee: "I want to do better cutting please help me sharpening. "
Expert: Sure I can help you. What kind of cutting-tool are you using?
(expert asks back for details the newcomer left out slowing down getting a solution)

Newbee: a scissor.
Expert: OK take this sharpening tool
Newbee: Yea works great Next question How can I make it cut faster I need to finish faster.
expert: Motorised scissors.
newbee Yea works great though still not fast enough.

expert: Ok can you give an overview about what you are cutting.
newbee: the green of a football-arena.
expert: Oha! take a big mowing tractor with a seven boom spindel-mower and GPS-steering

In the beginning the newbee always just told details.
The expert was assuming the newbee knows that his basic approach is well suited.
which turns out to be very bad suited
that's the reason why it is always a good idea to give an overview and to explain what shall happen in the end.