GearHeads Corner
August 04, 2020, 08:30:00 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 ... 37 38 [39]
  Print  
Author Topic: reading Pokeys pins  (Read 45762 times)
0 Members and 1 Guest are viewing this topic.
Mooselake
Hero Member
*****
Posts: 634



View Profile
« Reply #570 on: December 16, 2019, 12:20:58 AM »

Floating point numbers are always a little tricky since in many cases they're very close approxima tions 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.  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 Smiley ) that rather than testing for float == 0.0  (well, float .eq. 0.0)  it's better to test for abs(float) <= very small number.  In this case I'd suggest something like 1.0e-6 but vsn is really determine d by the tolerance of what you're measuring .

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

Kirk
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5645



View Profile
« Reply #571 on: December 16, 2019, 07:08:27 AM »


  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.
   This is no different than Mach3 or other controlle r, 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.  Often when a DRO is showing 0.0 the base value its
displayin g could actually be .00000000 1786 or so.

  So dont worry about the number, unless your multiplyi ng by millions, its simply
a rounding error more related to printing it than using it. As Kirk says, its common
to do a compariso n to a small number to see if its actually zero. A statement
like
  " 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 accumulat e 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.

  My advice would be to ignore such small numbers, they mostly come from the fact
the motor can only move in quantum increment s, so small differenc es will exist on every
move, but as they accumulat e they self correct errors in motion over time.

Art


 
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5645



View Profile
« Reply #572 on: December 16, 2019, 07:28:05 AM »



  One other point you should consider. When you use Engine.Se tAxisPos(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.

   So as an example, lets say you homed the system and the index is now zero. The Machine
coordinat e now shows zero and if you ask for current motor position it returns a zero. So
now you issue Engine.Se tAxisPos(100.null,null,null) . If you now ask for the position of
the motors you get 100.00000 0, which is correct. But now you command a G0X100.01

  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 differenc e of .23 steps
or .00043977 1 mms. As this process continues through a program you can imagine the
differenc e between actual position in steps and actual position in the program will always
swing between  1 and -1 step in increment s that can be as small as the systems math
functions allow. So at any given time if you issue a Engine.Se tAxisPos(0.null,null,null)
you may be setting the offset to a very small number or even an irrationa l number so
the offset become 1.6666666 66666666 . If you then ask for position, the formula
internall y is ( motorInde x / numberOfS tepsPermm ) - offset. Its not hard for the answer
to be .00000000 00666666 or some such small value, it just means your almost right on the
step count, but not quite.

Art

   
Logged
gburk
Sr. Member
****
Posts: 319


View Profile
« Reply #573 on: December 16, 2019, 09:57:05 AM »

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
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5645



View Profile
« Reply #574 on: December 20, 2019, 10:59:02 AM »

Gary:

 Version with "ProbeSetu pLevel" as variable is now online. Untested but added in the codebase.

Art


Logged
gburk
Sr. Member
****
Posts: 319


View Profile
« Reply #575 on: December 20, 2019, 02:20:27 PM »

Art

Not sure how you set it up, but i tried the GlobalGet ..

And the only value i get returned is 0, i assume you are looking for a true or false depending on how the probe is set Right ?..
it was the same value returned 0, for false or true after i changed the probe in config settings. .

Gary 
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5645



View Profile
« Reply #576 on: December 20, 2019, 05:41:25 PM »

Gary:

 Its only set at startup, so even if you switch that setting, youd have to restart to see the change.
Theory being one doesnt change that setting in general use so its not realtime checking it. It should
show 1 for true, 0 for false.

 I will double check though and fix it up this weekend if it isnt doing it properly. .

Thx
Aty
Logged
gburk
Sr. Member
****
Posts: 319


View Profile
« Reply #577 on: December 21, 2019, 01:56:23 PM »

Art

Thank,s i did change from true to false in config and then restarted auggie when i was testing it but always seamed to returning a 0..

Gary
Logged
ArtF
Administrator
Hero Member
*****
Posts: 5645



View Profile
« Reply #578 on: December 22, 2019, 08:32:13 AM »

Gary:

 Fixed and tested. On startup the current setting is recorded to that variable.
I had a typo in there so it wasn't changing.

Thx for the test.
Art
 
Logged
gburk
Sr. Member
****
Posts: 319


View Profile
« Reply #579 on: December 23, 2019, 07:09:31 PM »

Art

Yes that fixed it.

Thanks gary
Logged
gburk
Sr. Member
****
Posts: 319


View Profile
« Reply #580 on: December 28, 2019, 04:31:28 PM »

Art


if you can remove the print statement s you added for testing that would be great, it's making it hard to follow the print outs on the screen now the script will finish running but the prints will keep scowling for a while after wards and i'm having a hard time keeping tract of whats going on at the time..

Thanks gary
« Last Edit: December 28, 2019, 10:12:48 PM by gburk » Logged
Pages: 1 ... 37 38 [39]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!