Hello Guest it is April 19, 2024, 02:08:32 PM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Chaoticone

Pages: « 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 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 »
61
Mach4 General Discussion / Re: LATHE JOG BUTTONS
« on: August 26, 2019, 05:57:46 PM »
Code: [Select]
Typical lathe set up.Typical for a rear tool post/turret lathe.

Towards the operator or away from the operator is irrelevant. Why is this? Because you have front and rear turrets. Which way the tool is moving in relation to its start position and center of spindle is what matters. From larger diameter to smaller diameter is a move in the negative direction.

Be sure to read the Newfangled Lathe Turret Standard.pdf in your Mach4/Docs folder.

Mach is smart enough to look at tool offset, Tip dir and Direction of that tool offset when executing Gcode to determine which way a + or - move needs to move the tool. Jogging is a little different though. Jogging is a manual operation and Mach does not try to determine which way is a + or - move for any given tool. It just jogs in one of 2 directions at the operators discretion. The screen layout follows the right hand rule of other default machine types and some lathes, so it is the most common. That's not to say it couldn't be optimized for others though. Some will want the X jog buttons to be the exact opposite of what they are by default. Others with 2 turrets may just get rid of the + and - signs all together.

63
Mach4 General Discussion / Re: Pause Lua script mach4
« on: August 21, 2019, 04:29:46 PM »
OK, good.

Yup, running dwell in Gcode is as good a way as any. I would just use a single line or edit Katz function to take a time parameter if it was something i might use in different places.

The code below should also check the type of dwell and convert to a number or error out if it can't be converted.

Code: [Select]
function wait(dwell)
local inst = mc.mcGetInstance()
local defaultDwell = 250
if (dwell == nil) or (dwell < defaultDwell) then --No dwell passed or a shorter dwell than the motion device can process will cause errors
dwell = defaultDwell
end
local GCode = string.format("G4 p" .. tostring(dwell))
rc = mc.mcCntlGcodeExecuteWait (inst, GCode) ---wait for time of dwell
--Do something here if rc ~= 0 because you have an error
end

--Then use it like this

wait(100) --will wait for 250 milliseconds == .25 seconds because it is less than default defined in function

wait() --will wait for 250 milliseconds == .25 seconds because dwell is not defined so function will define as default

wait(500) --will wait for 500 milliseconds  == .5 seconds

Don't use it like this though..........

Code: [Select]
wait("10 seconds") --will cause problems if the dwell type check I mentioned above isn't added

64
Mach4 General Discussion / Re: Pause Lua script mach4
« on: August 21, 2019, 03:29:59 PM »
Sounds like you need a conformation input if you are wanting it to wait until a cylinder is in a certain position. Inputs are what makes machines smart. Are there other ways? Absolutely but none of them are the best way to do it. Using any time based event to wait for the success of a logic driven event is not a good idea. Switches, sensors and I/O are too cheap now. What happens if the air pressure is low and the event takes longer or never even happens? What if you get water in the air and that water ends up in the cylinder? Do yourself a favor and do it right. This is the exact reason mcSignalWait exist. It is the best of both. It waits for a logic change for the set amount of time. As soon as the logic changes it goes on (no wasted time). If the logic doesn't change in the specified amount of time you choose what to do next. This makes it efficient. It does not wait any longer than is necessary but (just like in your situation) it gives a time parameter for those instances where it doesn't do it as fast as optimal conditions would allow it. It also gives you options for when it doesn't do it at all. You have full control. Hard to beat that.

65
Mach4 General Discussion / Re: Pause Lua script mach4
« on: August 21, 2019, 01:06:11 PM »
If I have said it once I have said it a thousand times............. sleeps should be avoided. If you must use sleep anywhere you probably need to rethink your code/strategy. I'm not saying using a sleep is always wrong but I am saying it is the wrong answer 99% of the time.

Why not use mcSignalWait? Wait on that input to go false. Check your rc and do whatever you want after. Continue running, throw an error, etc.

Sleep will pause every script in the chunk it is called from. In macros, that is everything in the macros directory and any dependencies (required modules for instance). In a screen it is all the screen scripts and any dependencies required by any of it.

66
Mach4 General Discussion / Re: stop while Mfuncion run
« on: August 16, 2019, 12:42:52 PM »
C:\Mach4Hobby\Modules

67
Mach4 General Discussion / Re: stop while Mfuncion run
« on: August 16, 2019, 09:55:28 AM »
Get the return codes. Look at the mcErrorCheck.lua module. It is all the return codes and examples of how to use it are commented out at the top. The return code you got was not 40. It was -40. Instead of using the mcErrorCheck module you can also use the API call mcCntlGetErrorString as in the example below.

This is an example of what has worked well for me. I'm not going to a label. I run a function that does what I want and immediately after returning to the calling function I exit (return) that function. At that point there is nothing else in that script executed. But everything after that is wrapped in functions so something has to call them for them to run. If I had lines of code after that function that were not in a function, they would be executed.

if (rc ~= 0) then
   msg = mc.mcCntlGetErrorString(inst, rc) --Get the returned error string
   errorOut(msg)
   return --Exit the function
end

local function errorOut(msg)
   local inst = mc.mcGetInstance()
   mc.mcSpindleSetDirection(inst, mc.MC_SPINDLE_OFF)   
   mc.mcCntlMacroAlarm(inst, 3, msg)
end


68
Mach4 General Discussion / Re: Jog Speed DRO
« on: August 15, 2019, 01:05:01 PM »
Quote
mc.mcJogSetRate in the API is for single axis.
mc.mcJogSetRate(inst, axis, percentage)
How do I use it for all?

Simple, the same way you use a single pencil to write a lot of different things. You do it for each axis you want to set the rate for. Look at the API calls as colored pencils you are using to create a colored drawing. Some you use more than others. Some cover a lot of canvas, others are for fine details. They each do something specifically. There won't be a fine and wide for each but some do have both and others have one or the other.

One thing you might want to do though is at some point set all axes back to the same rate and it would be whatever the screen says it should be. I think the first example below is pretty much what the Jog Rate % code (function) does in the core.

Code: [Select]
local JogRate = 50

for v = 0,5 do --This will set 0-5 AKA X, Y, Z, A, B, C
mc.mcJogSetRate(inst, v, JogRate)
end

--Or

mc.mcJogSetRate(inst, 0, JogRate)
mc.mcJogSetRate(inst, 1, JogRate)
mc.mcJogSetRate(inst, 2, JogRate)

--Or if you don't want to set them by using a single variable set them independently......... even to different values if you want.

mc.mcJogSetRate(inst, 0, 50)
mc.mcJogSetRate(inst, 1, 25)
mc.mcJogSetRate(inst, 2, 100)



69
Mach4 General Discussion / Re: Jog Speed DRO
« on: August 15, 2019, 09:40:56 AM »
mc.mcJogSetRate is covered in the Mach4CoreAPI help file. That is what you will need to use. I'm pretty sure changing the value of a DRO (via script) displaying current jog rate will not change jog rates, only the DRO. Your interaction with the DRO is different than clicking in the DRO and entering a value. Therefore different events will or more accurately will not get triggered.

Two things to try.

It may work if you add script including mc.mcJogSetRate in the droJogSpeed "on update" script.

In the script you are changing the DRO value........ instead of changing DRO value set the jog rate using  mc.mcJogSetRate.

70
Quote
We do not want any” I D ten T “ errors here ( replace the word ten with 10 )

:D

Yeah, I have shot myself in the foot before. Sickening feeling.


Pages: « 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 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 »