Go Down

Topic: New Libray for L298N (Read 7 times) previous topic - next topic

robtillaart

I also like short variable names as I don't like typing long names. However I learned that descriptive names (not necessary long) was the most important improvement to understand my own programs after 6 months much faster. Most newer IDE's like visual Studio have name completion so you don't have to type that much.

There are typical cases when you need a for loop than i and j are still favorite.

In Arduino you could write in shorthand notation like DW(PIN, LOW) and do a global search/replace . But in the end its just a choice, if it is a test program, who care, if it is to be maintained by me at least I care :)

Tip: why not using L for LOW and H for HIGH?  Everyone would understand those macros.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

sbright33

Often I use 0 or 1.  Just as short as L or H.
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

robtillaart

Very true as long as the defintions of LOW and HIGH are not changed  :)

from wiring.h
#define HIGH 0x1
#define LOW  0x0
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

robtillaart


Got another sleep over your code and you could write a library for your abbreviated notations, easy to reuse in all your sketches.

just make a folder abbrev under libraries and put this one in. Not tested and to be extended :)

Code: [Select]

//
//    FILE: abbrev.h
//  AUTHOR: Rob Tillaart
//    DATE: 2012-03-30
//
// PUPROSE: short notation of many Arduino specific commands
//
#ifndef ABBREV_H
#define ABBREV_H

#define L LOW
#define H HIGH

#define po(P) pinMode(P, OUTPUT)
#define pi(P) pinMode(P, INPUT)

#define dr(P) digitalRead(P)
#define dw(P,V) digitalWrite(P,V)

#define ar(P) analogRead(P)
#define aw(P,V) analogWrite(P,V)
#define aref(X) analogReference(X)

#define si(D,C,B)         shiftIn(D, C, B)
#define so(D,C,B,A) shiftOut(D, C, B, A)

#endif
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

sbright33

Hey you're making it easier for me to do what you told me not to!  You forgot to say Simon Says?
Maybe it's some kind of programmer sarcasm...

http://en.wikipedia.org/wiki/Stepper_motor
I've been thinking about my code too.  Tried Full step drive with 2 phases always on instead of the obsolete wave drive I'm using.  It didn't improve the performance one bit, in fact it got worse.  This is due to the limitations of my walwart power supply of only 2 amps.  In theory it should improve the torque and maximum speed, but the IC and motor would over heat much faster.  I considered adding this function to my older library but that would be even hotter than the big motor. 

I fixed an error at the top of my thread.  1.8 degrees.

Saw some motors on sale 24v 200ma?  What is the advantage of this higher coil resistance?
If you fall... I'll be there for you!
-Floor

Skype Brighteyes3333
(262) 696-9619

Go Up