evo-biomech / scAnt

open-source 3D scanning and processing pipeline
MIT License
173 stars 39 forks source link

Detecting stepper motors. #16

Closed Beamsspam closed 1 year ago

Beamsspam commented 1 year ago

I think I may be having an issue wherein I am unable able to manipulate the pitch [x-axis] and focus [z-axis] stepper motors through the scAnt GUI using the sliders. Even after setting both the x and z motors to home, the sliders remained greyed out and cannot be interacted with. Is there any known way that I could try to resolve this issue?

scAnt GUI

FabianPlum commented 1 year ago

Hi @Beamsspam,

Lovely to hear you are working on your own scAnt! Am I correct in assuming the Y axis does work and it's "only" the Z and X axes?

Did you manage to run the two steppers for X and Z through the Tic Control Centre application? If so, this will likely just be a matter of configuring the endstops correctly and adjusting the range of permissable motor positions.

Also: I would love to see your assembled scanner! Would you mind sharing some pictures of it with me, so we can add you to our growing world map of scAnt builds?

All the best Fabi

Beamsspam commented 1 year ago

Hello @FabianPlum Yes that is correct, it is only working for the y axes when running the scAnt code, but the Z and X axes can be run through the TIC Control Centre. What steps would I need to take to configure the endstops and adjust the range of permissible motor positions? My apologies, I am quite new to utilizing stepper motors for a something like this. I wouldn't mind sharing some pictures of the assembled scanner, although we still need to put a few finishing touches on it; and I'll need to check with the people I'm working on it with beforehand to confirm they'll be okay with it.

FabianPlum commented 1 year ago

Okay, great! In that case we should be able to fix this on the software side and your wiring of the steppers is likely not the culprit. The next thing to verify is that your endstops (limit switches) respond as expected.

With the TIC control centre application, could you confirm, that the stepper motors move until they reach the respective endstop but not try to move further? Only drive the steppers carefully into the direction of the endstops to not break anything in case the endstops have not been correctly configured.

Make sure to closely follow the steps lined out in the README file:

Stepper driver setup

  1. The Pololu stepper drivers can be controlled and set up via a console. Download the drivers specific to your system from pololu.com, which also provides additional information regarding installation and a list of supported commands. All drivers are open-source, and the respective code can be found on Pololu's Git.

  2. Unpack the downloaded .tar.xy file and install the driver:

sudo pololu-tic-*/install.sh
  1. Next, reboot your computer to update your user privileges automatically, otherwise you will have to use sudo to access your USB stepper drivers.

  2. If one or all of the stepper controllers were previously plugged into your computer re-plug them, so they are recognised correctly by your computer. Now, open the terminal and run:

ticcmd --list

This should output a list of all connected USB stepper drivers.

  1. To test which ID corresponds to which stepper, launch the Tic Control Center application and move the sliders. You can use this application to test each motor and set up turning speeds and assign pins for the connected endstops.

Double check your end-stop cables are connected to the correct pins on the pololu-tic board:

Then the setup should be:

for the Z-axis (camera slider)

stepper_set_up

The TX of the limit switch of the Z-axis (camera slider) needs to be set to "limit switch forward" and to "limit switch reverse" for the X-axis (gimbal).

From /scripts, open the Scanner_Controller.py script in an editor of choice and add the IDs of each the stepper to the corresponding axes:

self.stepperX_ID = "XXXXXXXX"
self.stepperY_ID = "YYYYYYYY"
self.stepperZ_ID = "ZZZZZZZZ"

Once you have verified that the endstops work as expected, we can continue setting up the stepper ranges afterwards!

Beamsspam commented 1 year ago

Okay, it appears to be possible to detect the limit switches in the TIC Control Center, though our current cable set-up is somewhat different, as these microswitches had been purchased for the project by a member of my team. Would this have the potential to cause issues further down the line? As I can organise replacements fairly easily. https://www.jaycar.com.au/spdt-250v-5a-standard-micro-switch-with-lever/p/SM1039 342355798_1230576877569403_4013408490521215683_n

After verifying the endstops are working as expected, and the IDs have been added to the corresponding axes, what will I need to do to set the stepper ranges?

FabianPlum commented 1 year ago

That's good news! Let's see if we can get this to work!

  1. Instead connecting the brown wire to the GND, connect it to the RXC otherwise you are essentially just shorting the board when the switch is pressed but no signal is received.

  2. Then in the TIC control centre set the RC to "Limit switch forward"

As I don't know whether the default state of the switch is "closed" or "open", in case the first attempt does not work, move the red pin from GND to 5V output (leaving the red connected to RC)

Let me know if you can get a signal then!

Beamsspam commented 1 year ago

Hello @FabianPlum, my apologies for the delay. I usually have the opportunity to work on our scAnt system later in the week. I don't seem to be able to get it to operate when set up like that. I have tried using an additional cable and setting it up like so. image And with the following settings. image

This appears to allow me to stop the motor in TIC control centre whenever I press the limit switch while moving towards it.

When running the scAnt code with this set-up, the camera will continue to reverse away from the camera when I click the home z-axis button in the GUI, and will continue to do even once it has reached the end of the CNC slider. Is this supposed to happen?

Edit: Never mind, I've been able to resolve the issue. It was a matter of the motor being inverted.