Pages: 1 [2] 3   Go Down
Author Topic: New Libray for L298N  (Read 6306 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't understand what you did in the code.  But I can see some misunderstandings.  All the degrpm functions have deg then rpm as parameters.  So you put 10RPM where deg goes in loop.  I didn't mean for you to call mydelay in loop.  You can use it for that instead, but I meant it to be called where I put it in the function.  Here's how I would do it.  I have verified this does not drift on my motors.

degrpm1A(1,9000,1000);
Serial.println("At 0,9,18,270");

I'd be happy to send you my easing library, but it's not so "easy" as this one is.  I'm concerned you might need some help with it.

Yes! I will make it into a class.  It's under development.

I'm not really microstepping.  In this code I am half stepping.  The vibration depends on the speed you choose.  For big motors my PWM library helps with this.  But the circuit is more complex.  What motor are you using?  What speed is vibrating?  I know some tricks.

For x,y line drawing all you'd have to do is glue a laser on a 28BYJ motor shaft (x).  Then glue that to another perpendicular (y).  Each step is movement in the x or y direction.  I haven't gotten to this yet.  Maybe it is not fast enough to be persistent.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you try the 2 lines I suggested above?
For every hour:

degrpm(1,3000,1000);

If you are using 28byj motor then you are using the wrong code of mine.  Use stepper2.pde instead.  Did you see the other thread on this forum? 

I don't know what to do about vibration when you are moving at the speed of a clock second hand.  You can use the analog pins as digital in or out. 

Sorry I'm not following the intentions of your code.  That's not how I meant it to be used.  That's great if it works for you!
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, I used the wrong code  smiley-red back to the drawing board!
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The apparent torque depends on the RPM you choose.  You can use up to 10x the rated continuous voltage for a stepper.  But you cannot leave this voltage on to hold it into position for long.  Be careful!  Steppers can run hot safely, but there is a limit.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can buy a powerful and cheap breakout board with this chip on it.
Only 6 downloads so far?  It's very easy to use, don't be afraid to try it!
I guess there's no interest in the longer PWM version...
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Santa Fe
Offline Offline
Full Member
***
Karma: 1
Posts: 201
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks sbright33 I can use this in a sun tracker project I am working on
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Let me know if you like it.  Any improvements I can make?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I guess there's no interest in the longer PWM version...

I really appreciate your work, and I would be very much interested in trying your PWM version, could you please share it? (possibly with a description of the 8-pins wiring)
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will describe the 8 pins to match the code here:

Uno D2,3,4,5 go to the L298 motor IC like before
9,10,11,13 go thru 1k RES to 2,3,4,5
There are 4x 1uf CAPs between GND and 2,3,4,5
It's a really simple circuit, times 4.
I realize 13 is not PWM, that's a bug, I should use 6 instead, but I have not fixed the original code yet.
This circuit allows the PWM pins to create a smooth voltage with the appropriate time constant.
To use PWM in the code you have to change pinMode of 2-5 to INPUT.
When you change it back to OUTPUT, the maximum speed is not reduced.
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I will describe the 8 pins to match the code here:

Uno D2,3,4,5 go to the L298 motor IC like before
9,10,11,13 go thru 1k RES to 2,3,4,5
There are 4x 1uf CAPs between GND and 2,3,4,5
It's a really simple circuit, times 4.
I realize 13 is not PWM, that's a bug, I should use 6 instead, but I have not fixed the original code yet.
This circuit allows the PWM pins to create a smooth voltage with the appropriate time constant.
To use PWM in the code you have to change pinMode of 2-5 to INPUT.
When you change it back to OUTPUT, the maximum speed is not reduced.


I will try that, thanks, have you received my PM?
Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Has anyone used this library lately?  Any suggestions for improvements?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1866
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Steve, thanks for your work on this; I am moving next 2-3 weeks but plan to use it on a couple of projects shortly thereafter..

Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Offline Offline
Full Member
***
Karma: 0
Posts: 153
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi sbright33
Your post has inspired me to have a look at my xyz-stepper-setup .. in particular with respect to vibes & resonance, and the effect-output from the steppers. So, I looked at microstepping and 'chopper'-circuit. It  sounds very tantalizing, but I already burned a driver and a set of resistors, so I'll have to proceed with some more care. Putting the coil-resistors made a huge difference in effect-outtake and vibrations .. (and 'they' are the ones that's burned out, not the driver ;o) )

I've noticed that you imploy capacitors somewhere in the process .. did I miss some info on where? [edit: ah! you'r using the ic and not a driver where the capacitor likely is imployed]

I've moved time-delays from millis() to micros(). My minimum delay would be 2 millis before the stepper would stop working properly .. it would start resonating noisily, and just that. How far down do you go ( 500 micros ? .. not to insult you, but the presentation of your code leaves something to be desired ;o) ). Some time ago I dropped a pwm-implementation becourse it didn't work (I was trying a quick flip of ENABLE .. no good idea [edit: or?]). How fast (and how) do you flip a pwm-setup?

I've written a 'pen'-class that deals with two steppers (x & z) .. and I'm surprised to find that they quickly loses syncronity. I've delt with it by reducing a few micros on the fastest stepper-delay and it's bringing the problem to a minimum on the few tests I done. Is it a problem you recognize and can comment on?

Anyhow, it's been inspiring

note: I've achtually delt with the 'burning off' the drivers in code .. by preventing one stepper to have too long delays while 'holding'. I'm not sure weather your code needs it, but get an impression from my code: (burnIn sets the max-delay, pause() just sets all LOW). The code is put in a loop where micros() are executed. The code has the syncronicity-variable mentioned above too.

         if( (cStepper::oldTime + cStepper::burnIn) <  micros() ){
            // if delay more than burnIn then holding is abandonned
            cStepper::Pause() ;
         }// end if oldTime + burnIn

         if(  ( (cStepper::oldTime + cStepper::mDelay) < micros()) ){
            // mDelay microseconds has passed
            if( cStepper::stepCounter < abs(cStepper::destination ) ){
            // if stepper has not reached destination:
               if(cStepper::mVelocity == cStepper::mMaxVelocity){
                  ad = 5 ; // subtract 5 micros to fastest stepper-delay becourse it lags behind
               } ;
                                        cStepper::oldTime = micros() - ad ;
               if( HalfOrFull ){ cStepper::Step() ;}
               else{ cStepper::StepHalf() ;}
               
               res7 = true ;
            }
            if(cStepper::stepCounter == abs( cStepper::destination) ){
               cStepper::Stop() ;
               res7 = false ;
            }
            if(cStepper::stepCounter > abs( cStepper::destination) ){
               Serial.println("cStepper::setTime() exeded" );
               delay(100) ;
               cStepper::deEnable() ;
               cStepper::Stop() ;
               res7 = false ;
            }
         }// end if (oldTime + mDelay) < micros
« Last Edit: June 10, 2012, 06:08:27 am by Carsten53T » Logged

Offline Offline
Edison Member
*
Karma: 8
Posts: 1341
If you're not living on the Edge, you're taking up too much space!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Has anyone tried it lately?  Any suggestions for improvement?
Logged

If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 32
Posts: 1866
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Steve,

I still haven't had time to try this out well; I am in the middle of DC motor stuff on the L298N.

Can you tell me what timer you use, and do you reprogram it's frequency?  I'm trying to get my head around multiple libraries using times etc...

Regards, Terry
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Pages: 1 [2] 3   Go Up
Jump to: