Need one microsecond resolution for telescope control

Application: Telescope tracking.

Goal: Move stepper motor 1 microstep every 750 microSeconds.

Need: Code to do this

If I understand the documentation correctly, the micros() function only works with multiples of 4, which does not work with my timing requirement (which I have also proven with my prototype board)

There is a fair amount discussion at AVR level about enabling higher resolutions for reading input but I am having difficulty finding one for output AND,

Also, I cannot speak at AVR levels and much of the discussion is quite beyond me.

Anyone have any code that can accomplish my goal?

Right now I am using simple digitalWrite commands to step the motor, and not using any stepper control libraries (different issue on another post).

Driver: DFRobot TB6600, TB6600 Arduino Stepper Motor Driver - DFRobot
Motor: https://www.omc-stepperonline.com/download/17HS15-1684S-HG100.pdf
4 wire bipolar
Power Supply: 12V
Arduino Uno R3

The number 750 gives 187.5 when divided by 4. That suggests that using micros() for timing should give an error of about 2µsecs. That's only 0.27%. And if you accumulate the count of micros() the error will not accumulate. In other words if the first movement is 2µsecs in error the next move will probably be exactly on time.

The reason micros() works at 4µsec intervals is because anything shorter would absorb too many CPU cycles.

If the small error using micros() is unacceptable you can probably use one of the Hardware Timers to give you a 750µsec interrupt interval - provided, of course, that it does not occur in the middle of a micros() interrupt :slight_smile:

...R

Thanks for the reply Robin2.

Reference: "you can probably use one of the Hardware Timers"

Need code, no idea how to do this. Apologies. On a very steep learing curve!

Thanks again..

Try and get it working with the simple approach first. I am certain that the 2us error will not be significant to your application.

You may get 62.5 nanoseconds resolution out of arduino, start to learn how:
https://www.gammon.com.au/timers

Hello,

Just to note, the STM32F103C8T6 has a clock of 72MHz, which can make things faster to run, than in an ordinary arduino of 16MHz. And it can still be programmed with the Arduino IDE :wink:

maxmach:
Application: Telescope tracking.

Goal: Move stepper motor 1 microstep every 750 microSeconds.

Need: Code to do this

If I understand the documentation correctly, the micros() function only works with multiples of 4, which does not work with my timing requirement (which I have also proven with my prototype board)

No, 4us resolution is perfectly adequate. The steps are 750 us apart, 4 us is way down in the noise and
irrelevant. 100us resolution would probably work in fact, certainly for small microsteps.