Go Down

Topic: New 28BYJ-48 library (Read 18594 times) previous topic - next topic

Thanks so much for this code!
I'm just starting with arduino and have one project where I need control over steppers.

I guess I'll spend the weekend re-working the code to support multiple motors :) Oh why can't Arduinos use Python? :)

(Word of caution to everyone, after struggling for far too long to get my stepper going, I found out that my controller was busted! 3 of the IN terminals were not soldered at all and were causing havoc to my stepper motion!)

Again, many thanks for sharing this!

sbright33

I have some code that works for 3 steppers that is non-blocking.  I didn't include it here because it is much harder to understand.  Let me know if you want some help?
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Thanks,
I managed to adapt your code for my needs, as I only need each stepper to work at different times.
My code is still messy ATM, while I try to learn more about Arduino programming, but for this next stage I'll have to make it non-blocking, any tips there?

(I really like the awesome torque your code extracts from these little motors. I'm impressed!)

sbright33

I already wrote 4 related functions that are non-blocking can you find them?
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Just to say - have started using the non blocking variants with two motors as the basis for a stepper motor robot platform.  Seems fine and very useful.  thanks.

sbright33

Not sure I included the code in the post to run 2 motors at once.  How did you modify it Chris?
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

neonmind

sbright33, thanks for sharing!
the most impressive is torque !

i don't think i'm doing everything right, but it works !)

could you please tell settings for absolute maximum torque  ? now i'm using something like this in setup()
Code: [Select]
degrpmslowCool4_nowait(0,180*100,1500);
and
Code: [Select]
ccwss(current_settings.mtr_steps,1500);
in loop() for 8.4v power

bryanb334

Pretty amazing work you have done on this!
A couple of questions:

Does the current detection work if you are using 12v for the motor, and if so, how is it wired? The analogue pin only takes 5v doesn't it?  What is the principle of operation of this feature?

Also, on the motor driver, there is a jumper beside the 5-12v input pins.  Any idea what it is for?

Thanks!
Bryan

nmz787


Not sure I included the code in the post to run 2 motors at once.  How did you modify it Chris?


Is stepper2.ino here:
https://gist.github.com/sbright33
the latest code? or is it the file included on page 1 of this thread?

It would be really nice if you edit the first post to include a link to the latest version.

My other question is, does this code support microstepping, I believe this means instead of giving 100% of the pulse length, you only give a portion of the complete duty cycle via a modulated pulse (PWM). The PWM freq has to be a good bit higher than the pulse duration though, I think. This might require an LC filter matched to the PWM freq, to smooth out the current, but might work without. I'd like to try!

sbright33

Thanks Bryan!  Yes, the overcurrent detection works with 12v.  Just connect a motor coil to A0 thru a 5k resistor.  For some unknown reason I did not need a resistor voltage divider.  For voltages over 12v this may be needed.  My explanation is simple.  It detects a change in torque using the simple code I've included.  The jumper needs to be present for normal operation. 

The Github link above is the most current tested version.

PWM does not play well with this motor because of the gears.  Already a half step is 1/11th of a degree.  If you attempted 8 microsteps that'd be 1/88th of a degree.  Surely the gear train slop is much greater.  As soon as you stop than start again, this small movement would not translate to the external shaft.  I'm curious about your application.  Why do you need more resolution than 0.1 degrees?

I have written code for a bigger stepper without gears using a form of PWM that smooths the steps when it is turning slowly.  Each step was about 1 degree.  Unfortunately it cannot stop between steps.  The code is on Github.
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

binooetomo

Hi

Thanks Bryan!  Yes, the overcurrent detection works with 12v.  Just connect a motor coil to A0 thru a 5k resistor.  For some unknown reason I did not need a resistor voltage divider.  For voltages over 12v this may be needed.  My explanation is simple.  It detects a change in torque using the simple code I've included.  The jumper needs to be present for normal operation. 


Do you mean that A0 is in paralel with Motor VCC and the supply ?




The Github link above is the most current tested version.


Question :
1. How much is the Min/Max value of motorSpeed (line 325) ?
2. in calloften() : what is your concern for calling off() each 2 ccw() ?   (line 179)

Sincerely
-bino-

pauldreed

I still can't get this working!!
I have tried the standard Stepper.h library and it runs fine on my Arduino Uno, but I'm struggling with this.
I've changed the pin allocations to 8, 9, 10, 11, (as per my hardware) and tried un-commenting various lines within the loop() section, but there is no sign of life, or led's on the ULN2003 module.
I'm not too confident about what I should be un-commenting - could someone pls give an example, or a line number to un-comment.

Paul

GreyE30

Hi there,
Great bit of work here, I have several of the different "functions" from your loop() running quite well but have some questions regarding running 2 motors at the same time.

I am also having some trouble seeing where you call out "degrpmEZ" in either the setup() or loop() but that could just be my understanding of the code when I compile parts of your code into a separate program.

Also, have you ever done something for proportional directional control like from a sensor or joystick? I am trying to achieve this using some of your functions and other tips on here but do not seem to be able to mirror the input acceleration, even at slower speeds.

Many thanks     

sbright33

@bino-  Pin A0 on Arduino should be connected to a motor coil.  Any of the 4.   Thru a 5k resistor for safety.

1) You should rarely adjust motorSpeed manually in the code.  Instead use a different RPM value in the function calls.  The minimum depends on the load and voltage.

2) off( ) turns off the coils. 

@paul- Try uncommenting a line in setup()? You can test any of the functions with DegRPM in them.

@grey- It is difficult to do 2 at once.  I had made a list of all the functions and variables you must duplicate and rename somewhere in this post.

I do not use degrpmEZ.  But you can!  It's similar to other functions.  It disables some features as you can see.

PDC?  Like when center is stop.  A small move rotates slowly.  Larger increases the speed?  This may be a case where you change motorSpeed to vary the delay between each single step.  Or you can go 10 degrees then read the speed from the joystick for the next 10 degrees?

Once you test my functions and understand them an idea will come to you.
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

ProfePaco

Hi:

Thanks a lot for your contribution. It is a great work.

I am just checking your code. It runs!


However, I am going to suggest you something. I have some doubts and I think many people is going to have some problems to understand your code.

For example, the fucntion calloften(), that it is code in loop()
//at least every d ms
//will catch up if behind

I have no idea of the meaning and no more explanation is shown in the code. In the first post you only shows a little explanation of some functions, with no examples of real use. For example, calloften(), and the majority of the functions have a very short explanation that difficult a lot using your great code.

It is really a pity that such a good code was so difficult to use. Please, could you elaborate more the explanations? We really need something like this:

degrpm1(boolean bcw, long deg100, int rpm100)
This function runs the motor. If bcw ==  1 then.... if bcw == 0 then---
deg100 is the degrees to rotate. To rotate 90, enter 9000.
rpm100 is the speed is rpm. To run at 10 rpm, enter 1000. Please take into account that the maximum speed depends on voltage. For example, with 5V you should expect a maximum speed of XXX. At 9V, XXX, at 12V XXX



A specific question.  is there any function to run the motor for ever?

Thanks again for your work.

Francisco

Go Up