High Precision Stepper Motor Control

Hello, this is my first post to the forum. I am part of an undergraduate research group. The purpose of this group is to convert a coreXY 3D printer into a 2D tracking device. It will be tracking a zebra fish in a tank and will eventually be used to scan the fish's brain in real time as it responds to environmental stimuli. As you could imagine, this requires a great deal of precision. I am attempting to use the AccelStepper library to facilitate this. As a disclaimer, my only exposure to coding is through a university matlab class. I feel ok with matlab but am not familiar with Arduino at all. Any help or insight would be greatly appreciated.

stepper_v2.ino (704 Bytes)

not sure what your asking

presumably you have a sensor that can determine if the location you want to be at is forward/back and left/right. you'll need to step two motors until the forward and side errors are within some error tolerance

your problem may be more about understanding the characteristics of the AccelStepper that the arduino. i think since you're more interested in maintaining relative position, not sure you'll need to worry about speed or acceleration

Hi, thanks for the response.
I do not have an external sensor to determine the location of the motor.

I was planning on making location based on number of turns resetting every loop to always make the current position zero and the target position refreshed.

Target position would be determined from an external code through image processing (not my job) and should be simplified as x amount of steps away from motor position (0).

You said that the speed and acceleration would not be a concern? Would this hold true if the fish were to dart quickly out of frame? That would be when the imaging would have to take place.

You are correct in that I am unfamiliar with this library. Do you think it is suited for my uses? If it is are there any specific tutorials you could recommend. I tried using the usual Stepper motor library but the delay between loops was 30 ms and that was too large. Looking for a max delay of about 4 ms
Thanks again.

presumably you have a sensor that can determine if the location you want to be at is forward/back and left/right.

i'm not even suggesting that you know the location of the motor or the fish, simply its relative location from the motor.

presumably your camera can determine this.

a stepper motor has a minimum speed between steps, you have to give it a chance to move. so i'm asking why would you step any slower than possible

if the fish were forward and to the right of the camera, you would step the one motor forward and the other motor to the right as quickly as possible until the error is each direction is < than some tolerance.

i would expect the motor is moving constantly even if the fish is relatively still. you may be omre concerned with vibration. and that's why i mention a tolerance.

Ok, I think I understand the situation a little bit more now. I think I will have to really get familiar with the library before I continue asking more questions. Wouldn't want to waste anybody's time.
Thanks again