CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > G-Code Programing


G-Code Programing Discuss G-code programing and problems here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 08-15-2009, 08:31 PM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?
Am I stupid or is my mill stupid?

Stupid question- machines do as they're told... or do they?
I can't figure this out and its probably something simple.
I have just upgraded my centroid M-50 control's PC so I could run version 8.21 of the control software which allows full advanced macro that I didn't have before. I'm very familiar with macro on Haas, but am still figuring out the little syntax quirks on the centroid.
Here's the problem in the program (only relevent lines shown):

#110=-.138 ; Target depth
#103=.015 ; rough step-down
;
#110=ABS[#110] ; set #110 to positive value
#111=[(#110/#103)-(#110MOD#103)] ; # of rough steps

At this point, #111 should be a whole number representing the number of loops to step down for a subroutine. BUT, the control returns a "divide by 0" error on the line setting #111. How is .015 a 0?!!? I don't get it.
I've tried using a different variable #, getting rid of the mod statement, getting rid of the division statement etc. This thing really just wont divide by .015!
And BTW- the parameter for floating point error is set to ignore past 6 decimal places and the floating point error never seems to be less than 8 places. (Default is no floating point correction)

PLEASE HELP before I punch this thing!
Also, if anybody knows if there's a way to view the value of variables or get to some kind of table that shows them, that would be very helpful as I cannot find anything about that in the software manual.
Reply With Quote

  #2   Ban this user!
Old 08-15-2009, 09:02 PM
beege's Avatar  
Join Date: Feb 2008
Location: USA
Posts: 518
beege is on a distinguished road

Not absolutely sure what the MOD does, but if it removes the integer, then:

111=[(#110/#103)-(MOD(#110/#103)1)]

Would this work? or something like it?

What about INT(#110/#103)?
Reply With Quote

  #3  
Old 08-15-2009, 09:39 PM
HuFlungDung's Avatar
Moderator
 
Join Date: Mar 2003
Location: Canada
Posts: 4,825
HuFlungDung is on a distinguished road

MOD determines the remainder, right?

(#110-MOD(#110/#103))/#103 should give an integer. I'm just guessing, I don't have anything handy to run the expression through to see what the computer thinks of it. After all it always looks right until you try it and it won't run!

I'm not sure of the syntax for MOD, maybe this would be better:

(#110-(#110MOD#103))/#103
__________________
First you get good, then you get fast. Then grouchiness sets in.

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

Last edited by HuFlungDung; 08-15-2009 at 10:01 PM.
Reply With Quote

  #4   Ban this user!
Old 08-16-2009, 04:42 AM
 
Join Date: Nov 2006
Location: UK
Posts: 121
ChattaMan is on a distinguished road
Square brackets

I don't know about your Centroid control but with Fanuc everything in
parenethesis () is ignored. All maths functions have to be in square brackets []
Reply With Quote

  #5   Ban this user!
Old 08-16-2009, 01:45 PM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?

The Centroid manual describes MOD as being used just like the / division sign but it returns only the remainder without the integer.
This is the only function the manual shows that could be used to deal with remainders. I don't see anything like ROUND or INT although I really wish these were available.
On the Centroid control, [] brackets are used to specify a whole main function (like Haas) and () parentheses are used within brackets to deliminate priority of calculation- just like standard mathematics.

Again, the problem is not with the MOD statement. If I get rid of it and just try to divide #110/#103, it still returns a divide by 0.
Since my first post I even tried making #103=15 and then multiplying the result by 1000. IT STILL GIVES THE ERROR! I just don't get it!
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 08-16-2009, 01:51 PM
 
Join Date: Apr 2008
Location: USA
Posts: 502
SBC Cycle is on a distinguished road

You might be better off with an IF - THEN catch here. I assume you want to stop short of your target depth.

The way you are doing it is certainly more elegant but simplicity may be the key here.
Reply With Quote

  #7   Ban this user!
Old 08-16-2009, 02:33 PM
 
Join Date: Apr 2008
Location: USA
Posts: 502
SBC Cycle is on a distinguished road

I just reread your last post. "The Centroid manual describes MOD as being used just like the / division sign but it returns only the remainder without the integer".

A modulo operation should always return an integer.

Example 9 mod 4 should return 1 not 0.111111111 (1/9)

I can't be certain how the control would handle using the MOD function with real numbers.
Reply With Quote

  #8  
Old 08-16-2009, 06:57 PM
HuFlungDung's Avatar
Moderator
 
Join Date: Mar 2003
Location: Canada
Posts: 4,825
HuFlungDung is on a distinguished road

#111=[(#110/#103)-(#110MOD#103)] ; # of rough steps
Maybe the control just doesn't like your naked # symbol in the comment and the "divide by zero" error is simply something "undefined" which is the same thing as divide by zero.

It wouldn't be the first time that a controller did not ignore what was in the comments
__________________
First you get good, then you get fast. Then grouchiness sets in.

(Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)
Reply With Quote

  #9   Ban this user!
Old 08-17-2009, 01:03 AM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?

Originally Posted by SBC Cycle View Post
I just reread your last post. "The Centroid manual describes MOD as being used just like the / division sign but it returns only the remainder without the integer".

A modulo operation should always return an integer.

Example 9 mod 4 should return 1 not 0.111111111 (1/9)

I can't be certain how the control would handle using the MOD function with real numbers.

Wikipedia disagrees: http://en.wikipedia.org/wiki/Modulo_operation

I like your idea with the IF-THEN, but I need to calculate the number of loops and possible remainder before it starts the subroutine so that it can start at a calculated depth (in this case between 0 and .015 should start at Z-.003). Example: Z-.138= -.003 - (9x.015). That way it will always hit the target depth on the last pass. This is part of a macro routine that will always be recieving different values and I want IT to be able to do this for me because I know it CAN. If I have to bust out the calculator every time, then whats the point?

REMEMBER: I said that it just thinks #103=0 --- I can get rid of the MOD statement leaving #111=#110/#103 only and it still gives me the error.
THAT IS THE PROBLEM ALL MODULO's ASIDE
But really, I appreciate everybody's input.
Reply With Quote

  #10   Ban this user!
Old 08-17-2009, 01:06 AM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?

Originally Posted by HuFlungDung View Post
Maybe the control just doesn't like your naked # symbol in the comment and the "divide by zero" error is simply something "undefined" which is the same thing as divide by zero.

It wouldn't be the first time that a controller did not ignore what was in the comments

Good call, I'll try getting rid of the comment tomorrow and see if it works.
"Keep it simple, stupid" is always good advise.
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 08-17-2009, 11:10 AM
 
Join Date: Feb 2009
Location: USA
Posts: 64
James L is on a distinguished road
MOD

I set up this part on my HAAS machine :
#110 = -.138;
#103 = 0.015;
#110 = ABS[#110];
#111=[[#110]/[#103]];
........
and it ran without error.
I had issues only when using the MOD statement.
I copied and pasted your original posting and got the same error as you did before trying it like this.

I typed this line into MDI and got the divide by zero answer too
#110 = .138;
#103 = .015;
#111 = [#110 MOD #103];

This did not give an error with:
#110 =138 and
#103 =1.5

The issue here is having a number too small for MOD to work with. The If Then statement may be your best bet, to contain an option to make the number larger in multiples of 10 pre-MOD and then dividing by multiples of 10 accordingly afterward. The idea here is to keep the Remainder large enough for your control to recognize it or it will return an error.
Reply With Quote

  #12   Ban this user!
Old 08-17-2009, 12:30 PM
 
Join Date: Jan 2008
Location: USA
Posts: 30
Ceramic Man is on a distinguished road
Buy me a Beer?


Ok, I figured out the problem and it was as simple and stupid as I originally thought!

The problem was not with the math line.
None of the variables had been set, so #103 WAS 0 along with all the others. This is not to say that I didn't set them.
The Centroid control does not provide any way to view what the variables are set to or I would have known the problem the first time around.
Today I ran the program and got the error. Then I tried rapiding to X#103 and it moved to 0. When I set the variable in MDI and tried again from MDI, it moved to X.015. Hmmmmm...
Looked at the manual again and found that variables 100-199 are reset to zero whenever a new program (or subprogram) is loaded.
So, its as stupid as I thought- I was using variables that cannot be passed to a called subroutine.

To help clear up the MOD issue: Some controls (and compilers when programming BASIC) will only accept Integers in a MOD statement, and some will accept real numbers (according to Wikipedia). My centroid control accepts only INTEGERS so I must do this (roughly):
#110=#110*10000 ---> these lines make any values entered non-decimal values
#103=#103*10000 --^
#112=[(#110MOD#103)/10000] -----> performs the MOD with INTEGERS and then divides result back to ten-thousandths.
Now #112 is set to the correct start position so that the subroutine can step down by #103 the calculated number of times and end up at #110 on the last pass. I tried it and it works.

Thanks for all the help!!

Last edited by Ceramic Man; 08-17-2009 at 01:15 PM.
Reply With Quote

Reply




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
probably a stupid question mad.sculpture Linear and Rotary Motion 4 10-09-2007 04:55 PM
Stupid problem - jogging incremental Mach 3 mill Green0 Mach Mill 2 06-23-2007 02:50 PM
Stupid Question CNCRob CNCzone Club House 2 09-04-2005 01:42 PM
Before I do anything stupid... runnoahrun Hobbycnc (Products) 2 04-15-2005 05:24 PM
New here, 1st stupid question! FXRocket General Metal Working Machines 4 11-03-2004 09:04 PM




All times are GMT -5. The time now is 12:21 AM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361