Welcome to Our Community

Some features disabled for guests. Register Today.

First time building a XY gantry, want to use Raspberry pi?

Discussion in 'General Talk' started by paulwece, Mar 20, 2019.

  1. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Hi, my application requires a XY gantry to iterate thru products in a tray, turn it on, and evaluate the noise level. The ACRO kit seems to fit my need. I plan to buy just the mechanical setup and some NEMA 17 motors. In order to get a custom size, I might need to cut the V-slot to a certain size.

    Having said that, I want to use a Raspberry Pi to control the 3 steppers using drivers like Pololu A4988. A mic will be attached to record the sound, which the Raspberry Pi will store and calculate FFT on.

    Please correct me if anything I've mentioned are not feasible. I'm new to this, and also to Raspberry Pi.

    I plan to order the ACRO kit (mechanical only), the motors, and perhaps the limit switch:
    Micro Limit Switch
    Please tell me if this limit switch is good enough.
    I haven't given much thought to power supply yet. Openbuilds sell 24V power supplies and I'm not sure if that's overkill for my need.

    Any advice would be appreciated, as far as materials to buy that'll make my life easier, and design tips.

    Thanks
     
  2. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    I'd use grbl running on a separate Arduino, then use the Pi to send g-code over serial, maintaining lots of free time to do experimental work and onboard data.

    I'd also use "real" stepper drivers, to keep things simple and reduce room for error, but that's up to you. (I like these guys: https://smile.amazon.com/gp/product/B07B9ZQF5D)

    Those limits should be fine, especially if you don't need them for really precise absolute machine positioning (usually not a good idea on switches under $100)

    NEMA 17s love 24V, they're super quick. Just keep the current levels reasonable (no higher than 1.2A, most likely).
     
  3. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Thanks.

    That driver you recommended looks awesome. Do you need one for each stepper or can one driver drive multiple ones? Can you also recommend a power supply? I also need to think how to power the Raspberry Pi/Arduino. I only want to plug in one cable, so if I get a 24V power supply I want to power the chips too.
     
  4. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Also, how many limit switches do I need? In the video, it seems they used 3 NEMA17s for the ACRO build (only x, y movement, no z). So do I need 2 limit switch for each stepper (one for each end of travel) and therefore a total of 6?

    Thanks
     
  5. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    Technically one has the power capacity to do both y axis motors, but I wouldn't do that; you can run into current-sharing issues due to minor deviations from the motors' nominal specifications. Typically that shows up as one having a slightly lower resistance or impedance, "stealing" more of the current from the driver (which can't simultaneously adjust to both motors), and the other motor stuttering and the gantry racking over. Best, to minimize troubleshooting possibilities, to just have one motor per driver.

    I use a MeanWell NES-350-24 for 24V. It's an older, more expensive (~$50), model, but appears to be more reliable. There's a cheaper one for around $33 too, that doesn't get reviewed quite as well. That's the model in the OpenBuilds PSU, which is nice if you don't want to deal with mains wiring, but otherwise quite expensive for what you get. Depends on your level of comfortability.

    The Arduino can be powered from the Pi over USB quite happily, and you probably wouldn't even need the full 2.5A supply to do so. But you will need to think about powering the Pi in general. A 24-9V buck converter could do it (tons of overhead on a 350W supply), but since the Pi is technically still a computer, you'd want a nice one with good filtration and regulation. Probably easier to just get a decent second 9V PSU. I like the little MeanWell units, I have 12V and 5V ones, no idea if they make a 9V one but it's worth a look.

    Limits are per axis, the motors are irrelevant there. One per if you just need homing "the machine is about here, give or take", two per if you want hard travel limits to keep from crashing the machine. Grbl is good with soft limits though (won't even motion-plan a line of G-code if it takes the machine out of bounds).

    Homing's fairly approximate, just gives the machine a rough idea of where it is to within the repeatability tolerance of the limit switches. You'd want to then zero G54 work coordinates based on the actual work being done and the equipment being worked on (like a pallet or vice in a traditional mill, maybe a corner of your tray here).
     
  6. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    Thanks, to simplify the design, can I just use the Pi only without the Arduino? Only one axis will be moved at one time, since the items are in a grid. Turning on products, recording sound, and calculating FFT will only happen when the gantry is stationary. So the code will be something like:

    move x
    move y
    power a servo that presses a button on the product
    record 3 seconds of sound
    calculated FFT
    store FFT
    move x
    move y...

    Real time control is not required. I think the Pi has enough processing power to do all those sequentially?
     
  7. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    If it's that simple, I'm sure you can. It would be pretty similar to my SliderCam build, here: DSLR Video Slider

    From that, imagine this single-axis control is made in Python instead of C, and you'd get the gist:

    Code:
    int motionControl() {
      totalMotorSteps = currentDistanceInt * 5; //calculate total steps (0.2mm = 20-tooth gear on 2mm pitch belt; 40mm per rev, 200 steps per rev, ergo 1/5th mm per step)
      pulseDelay = (1000L * (currentDurationInt - (currentStepsInt * shutterDuration))) / totalMotorSteps; //how long to pause in ms between STP pulses to the motor driver
      intervalDistance = totalMotorSteps / currentStepsInt;
    
      //once per overall run
      if (travelDir == 0) digitalWrite(dir, LOW);
      else if (travelDir == 1) digitalWrite(dir, HIGH);
      //Serial.begin(9600);
      //Serial.println(pulseDelay);
    
      //step loop
      do {
        digitalWrite(stp, HIGH); //fire motor driver step
        delay(pulseDelay);
        digitalWrite(stp, LOW); //reset driver
        //btnVal = readLcdButtons(); //check there's no stoppage - this takes too long and significantly slows motor; use reset for stop!
        currentStep++;
    
        //at end of each step
        if (currentStep % intervalDistance == 0) {    //if current number of motor steps is divisible by the number of motor steps in a camera step, fire the camera
          digitalWrite(trig, HIGH); //trigger camera shutter
          delay(80);
          digitalWrite(trig, LOW);    //reset trigger pin
          delay((shutterDuration * 1000)-80); //delay needs changing to timer so stop button can be polled
        }
    
      }
      while (currentStep < totalMotorSteps);
    
    } //end motion control
    From RobTC/SliderCam (Obviously ignore the //commented out bits that are for bugchecking or features that didn't work quite right).

    So it's not complex, just a bit of programming and adjusting as you go. Especially if it's on a grid, since then you can model the actual layout as a matrix, and just move around it in software, similar to the way I did the GUI elements (most of the program, realistically) in SliderCam.

    It's faster and easier to build it as a 2-axis CNC build with Arduino/grbl, because it's really easier to calculate G-Code and send it over serial than implement a motion controller. But if you have the time to play with it and want more of a challenge to learn the hardware/software, then yeah, rolling your own is super fun.
     
  8. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    You mentioned it's better to have one driver for each stepper motor, so I will get two drivers then. I also like that industrial grade driver you recommended on Amazon. But what about this:
    STR Stepper Drives | Applied Motion

    The above is more expensive but it seems to be from a major brand. I'm building this to be used in a company setting so cost is not as important as other factors like quality, safety, etc...

    I think I will get the power supply from Openbuilds store because I don't want to deal with mains wiring (safety). Is one power supply enough to power both stepper motors?
    thanks
     
  9. cmitcham

    cmitcham New
    Builder

    Joined:
    Apr 5, 2018
    Messages:
    13
    Likes Received:
    6
    i use a raspberry pi with a protoneer cnc shield to run my workbee. it's pretty cool i think...
     
  10. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    Oh, yeah, then definitely make the most of the budget you have, no need to worry about driver prices. And I like those! They seem very nice. And you can get the cheapest one for this use case as well, which according to the table is $99, not $75, but whatever.

    The 24V supply is like, 15A. You probably won't see more than a 2A power draw from all three motors simultaneously under load!
     
  11. paulwece

    paulwece New
    Builder

    Joined:
    Mar 14, 2019
    Messages:
    16
    Likes Received:
    0
    The raspberry pi comes with a wall plug so I will use that to power the Pi.

    Another item that requires power is the actuation unit to turn on the buttons at each xy location. I'm thinking about using a hobby servo or a small stepper like 28byj48. I guess the 28byj48 can take 12V so I can just power it off the main power supply unit that supplies the Nema 17s right?

    Since there is quite a bit of xy movement, what kind of wire to do recommend? The kit I bought didn't contain wiring. I guess the wires needs to handle repeated flex. How about the wiring kit that OpenBuilds provide?

    Thanks
     
  12. Rob Taylor

    Rob Taylor Journeyman
    Builder

    Joined:
    Dec 15, 2013
    Messages:
    476
    Likes Received:
    196
    Can't power it off a 24V supply, though. I mean, maybe you could, I dunno, but it seems like overkill since it's another motion operation to implement in code. Could a 24V solenoid plunger work? They're a little power-hungry, but you have ample to spare and they're easy to set up physically and in code.

    Weird that the ACRO wiring kits don't come with drag chain but the other machines do, I'm not sure where you're supposed to put the flex conduit during operation without it dragging around your parts. Other than that, which you could probably discuss with them at their main part store email or find on their Youtube, it seems like a solid option. For my laser, I bought all the wiring and connectors and drag chain and everything forever separately, and it's not worth it if you're not anticipating a bunch of future motion control builds. Just grab the $100 kit.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice