GRBL and Polar Tables

I have really tried to search through the existing posts on the forums to solve this as I have seen some existing discussions from @jeffeb3 regarding Sandify output for polar machines. I created a SCARA machine a year ago and it is working great thanks alot to Jeff’s help! As a new challenge, I am trying to build a compact polar machine using a mechanism such as “Sandtrails” - a polar sand table . I am using an Arduino uno + CNC shield running GRBL.

The X axis controls the linear rail atop the rotating central axis
The Y Axis spins the central pivot point,

Currently:
g1x50 command extends the linear axis to its full radius,
g1y360 command spins a full rotation of the central pivot

20 tooth pulleys
200 tooth central pulley

Here is the output of my $$ in grbl:

Grbl 1.1h [‘$’ for help]
[MSG:‘$H’|‘$X’ to unlock]
$0=10
$1=25
$2=0
$3=2
$4=0
$5=1
$6=0
$10=6
$11=0.010
$12=0.002
$13=0
$20=0
$21=0
$22=1
$23=1
$24=2000.000
$25=2000.000
$26=250
$27=1.000
$30=1000
$31=0
$32=0
$100=100.000
$101=22.222
$102=250.000
$110=10000.000
$111=10000.000
$112=500.000
$120=20.000
$121=50.000
$122=10.000
$130=1000.000
$131=1000.000
$132=200.000
ok

I am trying to figure out how I could get sandify output compatible with this setup?

I’d appreciate any tips or help. Thanks in advance!

JK

2 Likes

You have to use a post processor.

Do you have any scripting experience? Python? Perl?

The thr format is simple, it has an angle (radians) and a radius (normalized):

0,1 ← zero angle, full extension
6.28, 0.5 ← One full rotation, half extension

628, 0.0 ← 100 rotations, no extension

Your machine is only one easy step from these pilar coordinates. The theta needs to be multiplied by 180/pi. The radius needs to be multiplied by 50.0.

You need a little script that reads in the number from a thr file (generated in sandify). For each coordinate, spit out the G1 X(blah) Y(blah).

I wrote one program like this before. It is around here somewhere. I posted a repl.it. But your scaling might be a little different.

If you can’t figure it out, I will try to get a minute on a keyboard and make the script.

Since this is the third such request, I might add it to sandify. But probably not for a long time.

1 Like

Thanks as always Jeff! I did see that script somewhere. I think I got confused because I thought that individual wasn’t sending via GRBL, but I could be wrong. I’ll go look through it and see what I can sort out with my admittedly limited scripting skills. I really appreciate your help. I am sure I will be back with some broken code at some point :slight_smile:
JK

1 Like

OK Jeff, I found your python code on repl.it and adjusted it to the best of my ability:

import math

# Config
#MOTOR_1_UNITS_PER_ROTATION = 6
#MOTOR_2_UNITS_PER_ROTATION = 6
INPUT_NAME = 'sandify.thr'
OUTPUT_NAME = 'transformed.gcode'

# Open the files.
with open(INPUT_NAME, 'r') as infile:
  with open(OUTPUT_NAME, 'w') as outfile:

    for line in infile:

      # First, separate by content and comments
      parts = line.strip().split('#')

      if len(parts[0].strip()) == 0:
        # This line doesn't have anything that isn't a comment
        outfile.write(line.replace('#',';'))
        continue

      else:
        (theta, rho) = parts[0].split()

        # Here, we're actually doing the math.
        #m1 = float(theta) + math.acos(float(rho))
        #m2 = float(theta) - math.acos(float(rho))

        x = float(rho) * 100
        y = float(theta) * 180 / (math.pi)
		
		
        outfile.write("G1 X{:0.03f} Y{:0.03f}\n".format(x, y))          

    # We just moved each motor a bunch. A whole lot.
    # When we start the next file, we don't want it to unroll
    # So we will make the current coordinate something that is small, but the same.
    xmod = x % MOTOR_1_UNITS_PER_ROTATION
    ymod = y % MOTOR_2_UNITS_PER_ROTATION

    outfile.write("G92 X{:0.03f} Y{:0.03f} ; Reset the coordinates\n".format(xmod, ymod))

================

It is now exporting the gcode in a nice converted form. There is only one issue I am trying to wrap my head around. Here is a picture of my current setup:

My X-axis is the full diameter, when it is homed (x=0) it is at the perimeter and when it is fully extended (x=100) it is again at the perimeter. the problem is that a rho value of 0 corresponds with the middle of the table in sandify as far as I can tell, but that converts to an x of 0, which is back at the perimeter. Am I making sense? Trying to wrap my brain around it, but it is late. I’ll hit it again tomorrow. Appreciate any guidance you have!

JK

1 Like

Change that to:

x = 50.0 + float(rho) * 50.0

It may not matter, but get in the habit of adding the .0 on any numbers you want to have precise math on. In some case, leaving that off creates integers, and integer math drops anything after the decimal place. So also change the 180 to 180.0.

But the real story here is to just always start at 50 and scale the rho by 50. Hopefully 50 is close enough to the center. If not, you can adjust the two 50 values to get them right.

1 Like