Hello! Thanks for your reply.
you want to control two stepper motors with the two axes of a joystick and you want to control a 3rd stepper motor with one (or is it two?) buttons.
Yes it is correct. I want to control two steppers with the two axes of a joystick and at the same time control a third motor(1) with two buttons.
The purpose of this device is to freely move a small platform in XZY directions. The movements are not pre-definined but depend only on two inputs: joystick and end-stop switches. The platform will carry a DSLR camera, so that is all the weight I need. I don't need CNC-like levels of "strength" (sorry if not the appropriate term) because the steppers only have to counteract camera weight, gravity and friction. BUT I do need to be able to set VERY fine movements because if I use big magnifications I will have very narrow depth of field, thus I need to move in the sub-mm ranges to have great sharp focus.
Imagine a horizontal plane formed by X and Y axes; this plane can move upwards or downwards (it along the Z axis). I want to control the position of the camera along the Y axis (left-right) by moving the joystick towards left or right; in the same way I want to control the position over X axis (front-backwards, which will ultimately control focus on the object located at a fixed position from the front of the camera) when I move the joystick towards or away from me (let's imagine I'm situated behind the camera and pointing towards the object, thus moving the joystick in the X axis will change the distance between camera and object). The joystick shield has four buttons (2), thus I would control the position over Z axis (up-down) by pressing let's say button 1 and button 2. Maybe buttons 3 and 4 could be for moving up and down using twice the speed, but I can take care of that later.
Do you want the distance the joystick is moved to control the speed of the motor or its position?
Thanks for getting into the details! Let's do this:
NO, I do not want the speed to be proportional to the extent of the joystick being moved (if that is what you meant). I want that every time the joystick is moved in one axis, the corresponding stepper moves one unit of distance. I assume one can do that with Arduino: the arduino takes the analog signal from the joystick, and when it detects that the joystic has moved in one axis (no matter how much is moved, just if its negative or positive with respect to the "rest position") then sends the signal to the CNC shield to move the motor one unit of distance in the positive or negative direction with respect to the current direction of the camera. Repeat until joystick is back in rest position. Simple: you move the joystick away from you, the camera moves toward the object until you leave the joystick alone. You move the joystick towards you and the camera moves backward (away from the object), until you leave the joystick. When you leave the joystick, the camera just stops (ie it doesn't get back to a given position). The unit of distance is set as a constant at the beginning of the code, so if I need to change it I can just modify the code, compile, upload and use it. There could be some use, now I think about it while I write, if I define two different units of distance, one for X, one for Y and one for Z, just in case I need to move faster in the Z direction for example or if I need even more precise movements for focusing but not for traveling sideways.
For the Z axis, it's similar but with the buttons: you press let's say button 1 and the camera moves upwards until you stop pressing. Press button 2 and camera goes down until you leave the button. Maybe buttons 3 and 4 can act in the same way but twice the speed (ie move 2x unit of distance).
Note that no GRBL and no computer is involved during the operation. I need it to be autonomous device (ie the computer will be connected only to upload new code).
That is how I envision the device. I just never did it like this before. I assume that I need to download the joystick library and learn how to do it, but I have never sent signals to a motor thourgh CNC shields and I have never used drivers or steppers (I used a single knob joystick once a few years ago to move a cursor in the screen just for fun... but I want to get more serious now!)
Thanks so much for reading and commenting!
-
actually it'll be two motors because it's the Z axis (upwards-downwards) and I need some more strength, but I will simply clone the 4th motor from the 3rd motor in the CNC shield.
-
https://www.itead.cc/wiki/File:Joystick_Shield_kit_.jpg