Hello all, I have recently purchased the linear actuator kit and backbox from Open builds. I have everything setup and running, but now i need some help writing some very simple macros. For starters, i wanted to give a quick summary for the purposes of this project. I am needing to run one of our casted parts underneath a plasma nozzle, which will increase the surface energy and allow for better adhesion between its surface and our sealant. The parts have to move underneath the beam of plasma at a relatively high speed/small distance, that can be controlled. I need a way for the linear actuator to move at a certain speed and linear distance, pause, and then return back home. For the purposes of limited exposure under the beam of plasma, i need it to move at very close 120mm/s, which i believe is the maximum this motor can do. And i need it to move at the speed for a total of 20mm. As you can probably guess, and i useless when it comes to writing this type of code. Im just a measley mechanical engineer. Can anyone help me out?
A gcode macro to do that should be straightforward (no need for js). (You can add gcode to a macro button in Control) Assuming that you've got the actuator set up as the X axis, you can make the movement you describe with the code below (copy / paste to the 'GCODE' tab of a new macro in Control) Code: G21 ;make sure we are in metric G91 ;set relative mode G1 X20 F120 ;move X axis 20mm at 120mm/s M30 ;end of program - probably not needed, but good form. This will move the X axis 20mm from where ever it is currently to 20mm away at 120mm/s. Note that there will be a period of acceleration / deceleration included in the 20mm travel. If you need the 20mm move to be at completely uniform velocity, then you would need to allow extra distance at either end (we can calculate this if required).
Thanks guys, this information has been helpful! To answer your question on the exact actuator we have...: Nema 23 stepper motor with 8mm lead screw. Maxmimum speed is 8000mm/min. I have calculated that the maximum RPM would be 12000RPM. How do i get the motor to move at said speed? Do i need to go in the custom properties and change the maximum speed as well? And semi related, is there a way for the program to time how long it takes to move the distance specified in the macro? Basically, i just want to verify the speed with a load on the conveyor is actually moving at the prescribed speed. Thanks
Yes, would need to tune Acceleration and Max Rate: Grbl v1.1 Configuration and Grbl v1.1 Configuration
What Misterg and Peter said. But also, to pause and move back... Code: G21 ;make sure we are in metric G91 ;set relative mode G1 X20 F7200 ;move X axis 20mm at 120mm/s G4 P2 ;pause for 2 seconds G1 -X20 F7200 ;return to start M30 ;end of program - probably not needed, but good form.
Something a bit wrong there - 8000mm/min with an 8mm pitch screw would be 1000 RPM (7200 mm/min would be 900 RPM).
I don't think that timing will help, because the gcode sender (Control) only issues the movement request which is added to a queue within the GRBL hardware. All the motion is controlled by GRBL according to its configuration parameters, which include acceleration and deceleration ramps which are 'invisible' to the gcode sender. I think the only thing that you can do is calculate what would be required and rely on GRBL to deliver it. [ETA - you would check that you don't lose any steps through repeated cycles.] As an example: If the actuator could accelerate at (say) 240mm/s^2, it would need 0.5 second to get to 120mm/s, during which time it would travel 30 mm. It would need the same again to slow back to zero. If you wanted 20mm travel at constant speed, then the total travel that the gcode would need to request would be 80mm (30+20+30), and would take ~1.17 seconds to execute.