reading Pokeys pins

C Scripting questions and answers
User avatar
Mooselake
Old Timer
Posts: 522
Joined: Sun Dec 26, 2010 12:21 pm
Location: Mooselake Manor

Re: reading Pokeys pins

Post by Mooselake »

I've never auto leveled my 3D printers, two of them (Plywood Printrbot Plus and new Ender 3 Pro) don't have auto leveling, and my Thingybot Delta has a probe but it requires swapping out the hot end module for it.  Level all of them with screw or dial twiddling...

Only the Plus had issues, and that was after replacing the allthread with TR8-8, so little friction the carriage would drift down while setting and tilt, once I learned that a quick setup with a sheet of paper before powering it up eliminated the problem.  Otherwise it only needed leveling (we all know it's not really leveling...) on rare occasions.    I leveled it with a digital dial gauge to within 0.01mm on a double strength window glass bed.

The E3P is too soon to tell (only had it a few days), it got the stiffer spring mod.  It's included aluminum pcb sandwich MK3 bed isn't that great, and the highly touted magnetic (polymer on car sign magnet) print surface is mostly a bust, will be swapping that out for a pair of glass pallets soon.  Still usable but it has to cool off to remove prints or the flexy bed warps them

Kirk
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »


We should most likely move this to the 3d printer subject..
Can they be moved art?.

Gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

  Beats me, I try to play with the forum as little as possible. Its under server control so I cant do
real maintenance. Nothing too valuable so far in terms of information on the topic, you might just
reopen it under 3d printers....

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Ok for forum..

I was wondering if you had added any thing in the script's to be able to read the Probe Polarity, to see if it's set to true or false?

Gary
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

I dont think I did, I will check though to see if the variable for the base polarity is available in script.,
comparing that to probeinvert would indicate the actual state of the logic..

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Ok Thanks, i was looking to see how it's set in the planer/config true or false, i would like to be able to set the probhit led to the same state as my probes, on my touch plate i have it set to false and on the probe to true
and that make's the led  on when not hit  then off when hit, or  if true off when not triggered and on when hit.. i would like to keep them the same.. make sense?.

Gary
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

Have a question X=Engine.GetAxisPos(1);

if i run this
X=Engine.GetAxisPos(1);
print(X);
and have the X dro set to .199999
it will print .199999
then if i Zero the Axis now set to 0 and rerun
it prints -6.10352e-008

It only seems to happen after a Engine.GCode move..

am i doing something wrong or miss interpreting things

Gary
Last edited by gburk on Sun Dec 15, 2019 6:12 am, edited 1 time in total.
User avatar
Mooselake
Old Timer
Posts: 522
Joined: Sun Dec 26, 2010 12:21 pm
Location: Mooselake Manor

Re: reading Pokeys pins

Post by Mooselake »

Art can answer this way better than me, but it looks like floating point roundoff error. -0.000000061 looks pretty darn close to zero.

Kirk
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

Yup, Kirk has it right. Thats a number so small it is zero. But I'll note to add a line to kill it if its
less than .0000001 or something..


Art
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »

Gary:

As of next release..should be withing a couple days, you can get the
planner setting for probe level by asking for the global variable
"ProbeSetupLevel"

  You cannot set this, it is read only. It can be set only in the config.

Art
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Art

"ProbeSetupLevel" sounds good. Don't thing i need to set it at least for now.

I thought the number may have been a float, i tried a few conversions on it be same affect...

So question is if i am getting this value back after setting the axis to 0, Engine.SetAxisPos(0.null,null,null);
how much if any problem's will i have if i use the value for example to send the X axis to the returned value, of X =  Engine.GearAxisPos(1); Enging.Gcode("G01 X"+X); is say X axis is at .200 before the GCode move.

update
I tried this, last_pos = format("%.5f",(Engine.GetAxisPos( 1 ))); and i seem to always get the number 0 now after resetting setting the dro X axis to 0.. good way or bad?

Thanks
Gary
Last edited by gburk on Sun Dec 15, 2019 1:17 pm, edited 1 time in total.
User avatar
Mooselake
Old Timer
Posts: 522
Joined: Sun Dec 26, 2010 12:21 pm
Location: Mooselake Manor

Re: reading Pokeys pins

Post by Mooselake »

Floating point numbers are always a little tricky since in many cases they're very close approximations to the actual number.  It's the tradeoff to give you a much larger range than the number of bits involved would suggest.  Your method looks just fine to me, fwiw.

Tests for zero, or even equality with any number, can be a little weird.&nbsp; Unless there's some fudging in the scripting language I learned (back when computers were really rooms full of young woman with pencil and paper :) ) that rather than testing for float == 0.0&nbsp; (well, float .eq. 0.0)&nbsp; it's better to test for abs(float) <= very small number.&nbsp; In this case I'd suggest something like 1.0e-6 but vsn is really determined by the tolerance of what you're measuring.

Correct me if I'm wrong, it happens.&nbsp; HTH

Kirk
User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »


&nbsp; It is the nature of the scripter that it passes such numbers as floats. So when a number like
.00000061 shows up it will be printed as 6.1E-7 or such thing, but its still in essence a 0.0
in terms of the math. So you could use a Goto or any math on that number and typically
get the result your looking for.
&nbsp; This is no different than Mach3 or other controller, one of the most common support
questions I got on Mach3 was why the display would show .003421 or something after
a Goto(0,0,0). Of course this is simply less than 1 step of the motors, to move one
step more would be -0.0000xxx.&nbsp; Often when a DRO is showing 0.0 the base value its
displaying could actually be .000000001786 or so.

&nbsp; So dont worry about the number, unless your multiplying by millions, its simply
a rounding error more related to printing it than using it. As Kirk says, its common
to do a comparison to a small number to see if its actually zero. A statement
like
&nbsp; " if( fabs(x) < epsilon ) x = 0; "

is pretty common in code. epsilon changes from situation to situation, but is typically
pretty small. These small floats play a part though as they accumulate small errors
until they get large enough to be a full step of the motors. They play a part in end
accuracy of position over time.

&nbsp; My advice would be to ignore such small numbers, they mostly come from the fact
the motor can only move in quantum increments, so small differences will exist on every
move, but as they accumulate they self correct errors in motion over time.

Art


User avatar
ArtF
Global Moderator
Global Moderator
Posts: 4586
Joined: Sun Sep 05, 2010 6:14 am
Contact:

Re: reading Pokeys pins

Post by ArtF »



&nbsp; One other point you should consider. When you use Engine.SetAxisPos(0.null,null,null)
you are actually setting an offset. It doesn't set the index of the motor, that can only be
set by homing.

&nbsp; So as an example, lets say you homed the system and the index is now zero. The Machine
coordinate now shows zero and if you ask for current motor position it returns a zero. So
now you issue Engine.SetAxisPos(100.null,null,null) . If you now ask for the position of
the motors you get 100.000000, which is correct. But now you command a G0X100.01

&nbsp; The motor in question is set to 523 steps/ mm. The system will then move 523 * .01 steps
which is 5.23 steps. The motor can only move 5 steps. This leaves a difference of .23 steps
or .000439771 mms. As this process continues through a program you can imagine the
difference between actual position in steps and actual position in the program will always
swing between&nbsp; 1 and -1 step in increments that can be as small as the systems math
functions allow. So at any given time if you issue a Engine.SetAxisPos(0.null,null,null)
you may be setting the offset to a very small number or even an irrational number so
the offset become 1.666666666666666 . If you then ask for position, the formula
internally is ( motorIndex / numberOfStepsPermm ) - offset. Its not hard for the answer
to be .0000000000666666 or some such small value, it just means your almost right on the
step count, but not quite.

Art

&nbsp; &nbsp;
gburk
Old Timer
Posts: 324
Joined: Sun Nov 25, 2018 3:57 pm

Re: reading Pokeys pins

Post by gburk »

Ok

Thanks art and kirt

I am only using it for probing and have not found any real issues with it so i will let it be as is...

Thanks gary
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests