Pendant/dwc to hundredth
-
Hi
i use a duet3 sbc on a cnc mill, my question is how can i set up dwc on the x and y axies to hundredth of a mm and i will do the same on the same pendant like david`s ?
thanks for help -
+1 on this, especially the pendant. Would really like higher resolution on this since I use it primarily to set zeropoints, having it hardcoded to .1mm is a waste of precision. Also having up to 10mm steps on a jogwheel is totally overkill since you can rotate the wheel so much faster than you can press a button. I've tried desperately to modify the pendant code myself so I can get 100th of a millimeter but I just cannot make it work no matter what I try.
Original code:
output.print(distance/10); output.write('.'); output.print(distance % 10); output.write('\n');
attempt number 1:
output.print(((float) distance)/100);
attempt number 2:
char dist[4]; sprintf(dist, "%.2f", ((float) distance)/100) output.print(dist);
attempt number 3:
char dist[4]; sprintf(dist, "%.2f", ((float) distance)/100) for (char a : dist){ output.write(a); }
attempt number 4:
String dist=String(1.00); dist=String(((float) distance)/100); output.print(dist);
attempt number 5 (getting desperate here):
if (distance=1){ output.write('0'); output.write('.'); output.write('0'); output.write('1'); } if (distance=10){ output.write('0'); output.write('.'); output.write('1'); } if (distance=100){ output.write('1'); }
No luck. None of these work at all, they compile without issue but when connected the machine won't even respond to the jogwheel (pendant E-stop works though, so the code is running).
Admittedly i suck at programming, but thought I could at least manage to change the scale of a numerical command. Slightly depressing...
-
I did this recently. This might not be the best way to do it, but it's working. Here's my fork with the changes: https://github.com/unrepentantgeek/CNC-Pendant-Firmware
-
@unrepentantgeek Thanks, I'll try your solution.
I also just spotted an obvious mistake in my own 5th attempt. The If conditions should have == instead of =. I may try that as well just to get some satisfaction if it works.
-
@crap I totally feel that. This code was not my first attempt, I think I tried about 3 of the things that you did before I got this working. There was a lot of trial and error and watching the output via my logic analyzer.
-
@unrepentantgeek your modification:
output.print(distance / 100); output.write('.'); output.print(distance % 100 / 10); output.print(distance % 100 % 10); output.write('|'); output.print(distance); output.write('\n');
looks correct to me, except that I don't understand why you write a vertical-bar and then print the distance again. Did yo mean to use a semicolon instead of the vertical bar?
FWIW I wrote the original code to avoid using any floating point maths, to avoid dragging in the floating point library; but that probably wasn't necessary.
@crap did you still have "output.write('\n');" at the end of your replacement code?
-
@dc42 Now I feel really stupid. For sure I forgot to print \n on all my attempts. I think I either need to program more often or stay away from it completely...
Anyway, I'll share some of my latest findings:
-unrepentantgeek's code works for me (although I only copy-pasted the relevant lines, I didn't download the full code)-The original code has an obvious flaw: It sends G0 commands along with the F parameter in order to limit jog speed, but if the machine is in CNC mode then G0 commands are always at maximum feed and the F parameter is ignored. Pretty big flaw since jog wheels are mostly used for CNC builds (I think?). I changed this to G1.
-The machine lags terribly when I'm using the jog wheel now. Not sure if this happened with the original code since I barely used if before working on these changes. All commands are received and buffered, but the machine often comes to a near halt (moving so slow you can barely see the stepper rotate) for a few seconds before suddenly executing all moves that were buffered. Surely changing from G0 to G1 could not have this effect? I'll investigate more to see if mine or repentantgeeks changes caused this.
-
Alright, some results. This works:
output.print(((float) distance)/100); output.write('\n');
It was just the \n that was missing. I like this solution since it's very easy to read and modify the scale factor. And by using float you can have none-10 factors if you want. It does add about 1400 bytes to the program size, but that still only brings it up to 29% of total so it doesn't really matter.
Not sure though how many decimals are actually printed, since I don't have access to a ttl level serial monitor. I read something about two decimals being default in Arduino. For CNC use it is entirely possible some users would want 3 decimals.
About the machine lag, I did some more testing. if I change just one of the axis to use g0 while the other axis uses g1 I can't provoke it to start lagging. Which doesn't make sense, if I jog an axis that uses the g1 command it should still behave the same. Maybe it's just so sporadic that I can't figure it out, sometimes I can't make it lag and sometimes it's barely usable. Are G0 and G1 moves planned differently in any way? Maybe this theory is completely out of the question.
Either way it seems this is the end of my contribution, because after re-uploading the code so many times I eventually broke the micro-USB port off my arduino, traces and all. So no more updates on my pendant.