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 > Fanuc


Fanuc Discuss Fanuc controllers here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 10-13-2011, 12:20 AM
 
Join Date: Oct 2011
Location: USA
Posts: 7
nazdackster is on a distinguished road
Input not active in sub!

I added an input (flow switch) to an 18i control. I added a rung in the ladder like:
Code:
----| |----------------------------------(   )-------
   X0021.1                              G54.4 #1004
I'm using it to detect flow after I turn coolant on. It works fine in the main program O0248, but when I call a different sub M98P0301, where I also want to turn on and then look for the coolant flow, it does not work (so it activates my alarm). I can see it working in the ladder, the flow is on, and I wait long enough before I look, but [#1004 NE 1] is true, so it alarms.

I thought system variables (inputs) should be visible across all macros / subs.

For now, I simply disabled the feature I wanted in O0301 (a warm-up, slow grind in the morning if the delay since last grind is more than 100 minutes)

Seems very odd that it works fine in the main, but not the sub... Any ideas? THANKS !!!
Reply With Quote

  #2   Ban this user!
Old 10-13-2011, 02:19 AM
 
Join Date: May 2004
Location: United States
Age: 48
Posts: 2,217
txcncman is on a distinguished road

I think variables have to passed off to subs with a G65 custom call.
__________________
http://www.kirkcon.com/
Reply With Quote

  #3   Ban this user!
Old 10-13-2011, 02:22 AM
 
Join Date: Feb 2006
Location: india
Posts: 1,187
sinha_nsit is on a distinguished road

Originally Posted by nazdackster View Post
I thought system variables (inputs) should be visible across all macros / subs.
I also believed this till I saw your post. Yes, this is pretty odd.

However, I still believe that these must be available in subs, even if not in macros, since a sub uses the same set of variables; it is like extension of the calling program.

It is possible to pass on the status of system variables inside a macro/sub through local/common variables.

Incidently, though may not be relevant for this case, one has to be careful while using EQ or NE because of round off errors.
For example, 1 NE 1.0000001
Reply With Quote

  #4   Ban this user!
Old 10-13-2011, 03:53 PM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

System variables can be read thru a macro or sub call program. It is quite odd that it is not working for you. They are what they are and nothing should change them coming into the macro or sub.

Here is something to try to see if it maybe has not changed yet or it is being set to a different value for whatever reason as Sinha said.

#1=#1004
M0
[#1004 NE 1]

When the machine stops at M0 look to see what #1 is set to make sure it is changing it when it should. Now if something goofy is going on like the floating point math then you could try using IF[ROUND[#1004]NE1] although I doubt this is the problem.

Stevo
Reply With Quote

  #5   Ban this user!
Old 10-13-2011, 08:02 PM
 
Join Date: Oct 2011
Location: USA
Posts: 7
nazdackster is on a distinguished road

Thanks for the help... I found this message on page 894 of manual B-63523EN-1/03 (found Here)

When a system variable listed in the table below is used in a macro
program, and the macro program needs to be executed after the block
immediately preceding the macro program is executed, an M code
(parameter No. 3411 to No. 3432) for suppressing buffering or G53 must
be inserted immediately before the macro


I haven't tested this, but based on looking up those parameters and other areas it sounds like I could put an M01 just before executing the IF, and I think this would prevent it from looking ahead too far... It almost sounds like it might be looking at the flow switch before I turn the valve on. I don't have anything in there that would inhibit look-ahead. Does this effect sound possible to you folks? I am definitely calling it as a sub, not a macro.

I'll let you know if it works, but would be interested to hear if look ahead can cause this timing issue.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 10-13-2011, 08:23 PM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

Oh yes most defiently it will cause this problem. The only reason I did not suggest it is because I took what you said in your first post "and I wait long enough before I look" to be you had a dwell or that the IF statement was many lines after you turned on the coolant.

I have had this problem many times because the macros I write execute faster then the system variable can register the proper setting. There are a few things that you can do. You can put a dwell before the IF statement G4X(). You could also put a handful of EOB before the IF statement. Also if your machine supports turning off the look ahead via G-code you can turn if off before the coolant on and then turn it back on after the IF statement.

If you try my suggestion in my first post you will know if the look ahead is grabbing the wrong value for #1004 before the IF statement.

Stevo
Reply With Quote

  #7   Ban this user!
Old 10-13-2011, 09:16 PM
 
Join Date: Oct 2011
Location: USA
Posts: 7
nazdackster is on a distinguished road

Thanks Stevo...

I guess that explains why it works in the regular program but not the one that gets called after a long delay.

In a normal grind, I turn on the coolant, then call this O0301 sub (which usually does not grind, only adjusts offsets after delays), then I call another that checks wheel diameter and adjusts dress amount based on the amount left (it doesn't need much when big, but needs more dress later), then I call another that does my gauge compensation, which is about another 40 lines of code, then I look for the flow switch...

In the O0301 sub, if it was more than 100 minutes since the last grind, I just turned the coolant on, waited G04P250, checked the switch, then called the grind macro. Fault. So I waited G04x2.0, and that wasn't enough either. So I think it had already looked way past the flow switch check, it wasn't about the amount of time, the controller had already blown past that line of code and moved on. The solenoid wasn't even turned on yet.

This sounds like it could be a big problem...

What I read was that the M01 (optional stop) will make sure nothing is executed past that line until it should be, in case a stop is called for.

Look-ahead sounds kind of risky, but I guess I just don't understand it well enough.

Do you think M01 after a timer and ahead of the float switch check will work?


Thanks again.
Reply With Quote

  #8   Ban this user!
Old 10-14-2011, 12:05 AM
MysticMonkey's Avatar  
Join Date: Mar 2009
Location: Australia
Posts: 366
MysticMonkey is on a distinguished road

Using Parameters 3411 -> 3420 you can use any m-code to suppress the NC from processing all arithmetic expressions and conditional branches. yes M01 would be a good choice
alternatively parameters 3421 -> 3432 to set a range of m-codes
__________________
***********************************************************
*~~Darwinian Man, though well-behaved, At best is only a monkey shaved!~~*
***********************************************************
*__________If you feel inclined to pay for the support you receive__________*
*_______Please give to charity http://www.oxfam.org/en/getinvolved_______*
***********************************************************
Reply With Quote

  #9   Ban this user!
Old 10-14-2011, 02:11 AM
 
Join Date: Feb 2006
Location: india
Posts: 1,187
sinha_nsit is on a distinguished road

Another example of look ahead problem:
Let us say the requirement is to keep an output ON for 10 seconds, and then execute further.
#1100 = 1;
G04 X10;
#1100 = 0;
It would not work!
#1100 would remain ON only for a fraction of a second, even though there would be a dwell of 10 seconds before executing the next NC-statement.
Reply With Quote

  #10   Ban this user!
Old 10-14-2011, 06:25 AM
 
Join Date: Oct 2011
Location: USA
Posts: 7
nazdackster is on a distinguished road

Originally Posted by sinha_nsit View Post
#1100 = 1;
G04 X10;
#1100 = 0;
It would not work!
So if I understand this correctly, a good countermeasure would be:

#1100 = 1;
M01 (optional stop to disable look-ahead);
G04 X10;
#1100 = 0;

I'll try that technique today. Thanks again everyone!
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 10-15-2011, 05:29 AM
 
Join Date: Feb 2006
Location: india
Posts: 1,187
sinha_nsit is on a distinguished road

M01 should come after G04.
A couple of EOBs after G04 would also work.
Just a single EOB in a block is considered an NC-statement (blank NC-statement).
For NC-statements, generally look-ahead is just one or two blocks on common Fanucs. But a large number of consecutive macro-statements may get executed.
Reply With Quote

  #12   Ban this user!
Old 10-15-2011, 10:45 AM
fordav11's Avatar  
Join Date: Aug 2011
Location: Fordaville
Posts: 939
fordav11 is on a distinguished road

the look-ahead buffer is 3 blocks as stated in Fanuc manuals, from 6M/6T to later 16/18/21 controls
Reply With Quote

Reply

Tags
inputs g54.0




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
VB or Active X maybe? executible dannystooblue Want To Buy...Need help! 0 06-11-2008 07:36 AM
Active high vs. Active low aaronkeit Gecko Drives 0 08-22-2007 02:57 AM
What does active Hi and Lo do? phantomcow2 TurboCNC 5 11-17-2005 12:21 AM
active Lo or active Hi? phantomcow2 Hobbycnc (Products) 4 09-28-2005 05:18 AM
Active High/Active Low Sanghera General Electronics Discussion 21 11-06-2004 08:47 PM




All times are GMT -5. The time now is 07:26 PM.





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