![]() | |
| Home Page | Mark Forums Read | Today's Posts | My Replies | Classifieds | Reviews | Photo Gallery | Web Links | Share Files | Advertise With Us | Ad List |
| |||||||
| Fanuc Discuss Fanuc controllers here! |
| This forum is sponsored by: |
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
| |||
| |||
Guys need your help on this. Getting very frustrated!!! I have a Fanuc 15MF on a Monarch VMC When I am setting a variable in my macro #1 for example is my pick. I set it #1=.1 in my main program. It sets fine when I look at my local variables #1=.1000 but when I draw out the number to see what it actuall is it is set to .09999999. This is killing me in my macro statments IF[#1GE.1] it does not comply and it runs back through the loop. I have even tried setting #1=.10000000 in my main program. To fix the problem for now in the start of my sub I set #1=ROUND[#1*10000]/10000 it will set it then to .1000 I can not find any parameters in the book on rounding the numbers. |
|
#2
| |||
| |||
| Just a quick example of what is going on. O0001(MAIN PROGRAM) #17=.3 #26=.4 M98P2 O0002(SUB PROGRAM) N1 G0G90X0 #17=#17+.1 IF[#17GE#26]GOTO2 GOTO1 N2M99 Once it starts the sub the 2nd line after N1 sets #17=.4 so when it reads if #17 is greater than or = to #26 "which it now is" it should go to N2 and end. This is the only machine that I have this problem with. |
|
#3
| |||
| |||
| It's a floating point error you can get on some machines. 0.1 is a number that can't be converted to binary (as I understand), so the 'actual' number the machine uses is 0.099999 recurring. It's a weird quirk everyone comes across eventually. Usually it's not a problem as this minute error is less than the accuracy of the machine, but it can get you when you start using parametric programming. So you're solution is the right one. Weird innit? |
|
#4
| |||
| |||
| Thank for the response. It is pretty weird cosidering that I do a lot of parametric/macro programming on many different machines and controls but never have run into this problem. Someone had explained it pretty good in another forum if you want to check it out. http://www.cnczone.com/vb...d.php?t=160881 But yes for the resolution of the problem I had to use the rounding function. The program I have posted is just an example but in the real program I had to rewrite the IF statement to get it to work. IF[ROUND[#17*10000]/10000GE[ROUND[#26*10000]/10000]]GOTO2 Thanks again. |
|
#5
| |||
| |||
| In any computer program we never directly test two real numbers for equality. An indirect method is to check if the ABSolute value of the difference of the two real numbers is smaller than a chosen small number, say 0.000001. Integers, of course, can be directly tested for equality. A drawback of the control is that it does not ask the user to declare a particular variable as a real number or an integer. It accepts real number (with zeroes after decimal) also where integers are expected (e.g., a counter). Another example is this: #1=1.0 G#1 X_ Y_ Z_ F_ is a valid G01 statement, whereas G1.0 will give error (though I have not tried this). Usual computer languages such as Pascal or Fortran do not allow the use of real numbers in place of integers. Such a flexibility in CNC control sometimes causes confusion. One tends to treat real numbers as integers. One must understand that a real number will always have some floating point error, whereas an integer will always be same and accurate. |
| Sponsored Links |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need Help!- cn1 pin assignment | jpatricio_76 | Fanuc | 12 | 03-24-2008 08:37 AM |
| EMC2 variable pitch / variable diameter threading. | samco | General Metalwork Discussion | 0 | 03-09-2008 01:40 PM |
| corner rounding | sundy58 | FeatureCAM CAD/CAM | 1 | 11-22-2006 08:54 PM |
| Doing year 10 Assignment.. | DMartello | Australia, New Zealand Club house | 8 | 05-03-2006 05:41 PM |
| Rounding of an edge | outlaw paintbal | Benchtop Machines | 4 | 03-10-2006 10:12 AM |