Hello Guest it is May 14, 2021, 03:26:39 AM

Author Topic: Dynamic Endstops / Limit Switches / Subroutines  (Read 992 times)

0 Members and 1 Guest are viewing this topic.

Dynamic Endstops / Limit Switches / Subroutines
« on: July 28, 2017, 05:07:04 PM »
So I'd like to probe for ideas and sanity checks here on my project.

Pre-TLDR/LastParagraphFirst: So the question is if faced with a dynamic limit switch distance problem, how would you implement it? Is there a clean way to implement it in the G-code where the limit switch can simply trigger a *pause*, and proceed to the next line to resume in the reverse direction after an elapsed time? Is this possible in the G-code where a limit switch can cause a break-to-next-line or through a system of subroutines? Would I need to roll a Lua script? Opinions are appreciated!

So I've got a robot with an X and Y axis in a gin that needs to push that probe shown on the end of the X axis into each cotton bale when it arrives at the weigh table. The robot is built from OpenBuilds parts, and last year we used this PlanetCNC controller that proved to be an unreliable PITA and didn't have a few G code commands implemented that I wanted. In the PlanetCNC software, limit switches could only cause E-Stops or could not resume to a next line-- so if I paused with the limit switch it'd just keep driving forward when resumed. I was able to band-aid it to work by using an Arduino to interrupt pulses to the drivers when it sensed the limit switch at the bale was pressed, and send keystrokes via AutoHotKey to the software to resume.

The problem I'll face when implementing it again with (planning on using but not yet purchased) Mach4 and a PMDX-416 SmartBOB is the same as last year, albeit I'm hoping the more robust software/hardware will allow me to more elegantly implement it.

I realize G Code does not allow if/for/while conditionals by default, or jumps on conditionals, or any of that... The thing is, I have a limit switch that is dynamically placed because the cotton bales arrive on the weigh table with about a 1ft margin of distance. I need to have the robot drive out, hit the limit switch (thus also pushing the probe into the bale), come back out, and repeat 4 times. See the video: https://www.youtube.com/watch?v=XbuhTXTsVVk
This year it will go faster due to a belt drive conversion, and it will hopefully be more reliable and not need janky band-aids due to Mach4/SmartBOB..hopefully.


Offline mark4

  •  167 167
    • View Profile
Re: Dynamic Endstops / Limit Switches / Subroutines
« Reply #1 on: August 06, 2017, 12:04:24 AM »
hi i believe you could write a mcode to do what you want in so much as i understand it from your description. why do you want to make the switch the limit you could have the switch as just the switch when activated do this. that is the approach i would take. also there are other scripts that can do routines in mach but i am not that programmer. good luck
Re: Dynamic Endstops / Limit Switches / Subroutines
« Reply #2 on: August 06, 2017, 10:29:44 AM »
I think you are doing this the hard way. As I understand what you are trying to do you don't need coordinated motion, just X then Y and positions. This isn't CNC, this is basic machine control. You probably want this to work every day reliably for years and years.  You are trying to kludge up a controller with a PC as a critical part.

Use one of the AutomationDirect DoMore BRX plcs with free programming software. Free tech support too.  They have high speed I/O for up to 250 Khz step rates. Lots of I/O available, industrial reliability, talk serial, ethernet, modbus etc.
Re: Dynamic Endstops / Limit Switches / Subroutines
« Reply #3 on: September 12, 2017, 01:13:50 PM »
Holy crap I would have used that last year had I known it was so cheap!!! Unfortunately at this point I've got to do it with what I have.
I wanted to use what I was familiar with, and something I could pass on to the next guy since I'm leaving this place. I personally would have coded it in C with a microcontroller, but the guy I'm handing the project to would be lost.

I've been doing it with Mach4 and so far so good with dynamic limits. I'm having some errors infrequently on my PMDX SmartBOB with it killing the process when there's too many steps left past the x limit switch when it hits the bale, but I'll work that out. I wish I could make those firmware changes myself but apparently I'd need the Mach4 SDK which I don't think I can get :(
I ended up using G31 probing for the 'bale detecting limit switch'. If I can get the SmartBOB to play nice and reliably with that I should be good.