-1

i will be designing a robot with multiple stepper motor. is it advisable to use millis instead of delay here or not? right now im testing if Millis() would work but still having a hard time programming this.

migrated from electronics.stackexchange.com Jul 7 at 14:53

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • 2
    Depends on what you need to do. delay is a blocking call, while if you use millis you can do other things between checks for time. This may not be important if you are using a multi-core arduino or it may mean the difference between responsiveness and sluggishness. – Ron Beyer Jul 3 at 3:35
  • This is a poor way to control stepper that requires acceleration, velocity limits and deacceleration to target position. Get a CNC shield and FET driver bridge and do it right with GRBL Panel,software to Uno uC interface on USB – Sunnyskyguy EE75 Jul 3 at 6:09
  • I use 10us step pulses using Arduino + CNC Shield + GRBL PANEL s/w over Windows via USB and get excellent servo speeds, home button (auto-cal) Jog buttons with tuned g,v, max constants and optimum step rates. Bit banging is so archaic. – Sunnyskyguy EE75 Jul 3 at 18:58
0

Arduino function delay() which pauses the program for an amount of milliseconds specified as parameter.

millis(), on the other hand, is a function that returns the amount of milliseconds that have passed since program start.

Just like delay() has a microsecond-version called delayMicroseconds(), millis() has micros(). If you need better resolution, micros() may be the way to go.

However, be aware that micros() will overflow after approximately 70 minutes, compared to millis()‘s 50 days. This means that the functions’ return values will start all over from zero.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.