Hello Guest it is April 26, 2024, 03:04:25 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 - joeaverage

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 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 »
4941
General Mach Discussion / Re: Control Panel
« on: March 21, 2018, 07:38:09 PM »
Hi,
if you use an external motion controller like  a UC300, an ESS or a 57CNC they have as many as 30 inputs
to which you can hook up buttons and switches.
The PoKeys 57CNC board also has the ability to accept analogue voltages that might result from a potentiometer say.

Craig

4942
Mach4 General Discussion / Re: How to set an active tool offset.
« on: March 21, 2018, 06:41:39 PM »
Hi,
this pretty much sums up what I know about it:

http://www.machsupport.com/forum/index.php/topic,36855.0.html

Could you use a signal and the testcount increment to determine when to run the script?

Craig

4943
Hi,
no its no good in the macros folder.

To put in the screen script strip off the bottom few lines:

if mc.mcInEditor==1 then
   autozero()
end

These lines were just to get the debugger to run properly. As I say strip them off and place the remaining
code in the screen load script...where is your choice I prefer to put functions like this just before the  signal
library.

Now as left-up script of your button put autozero(). Thus when you hit the button it will call the function autozero()
which happens to be in your screen load script and therefore available across Machs GUI.

Craig

4944
Hi,
even typing out the offending symbol screws with the posting.....

On the very first  line remove the word 'code' and the square brackets that enclose it. It ended up there because I did something screwy when posting the code.

Craig

4945
Hi,
there was something weird happening when I was posting the code and some extra symbols ended up in the post.


Remove '
Code: [Select]
' from the first line.

Craig

4946
Hi,
I see an error, when I was testing I upped the probe feed speed to 40, my installation has native units of mm so I had to increase the speed or
be there all night waiting for it to complete.

You'll need to edit it back to F4.

Craig


4947
Hi,
on my laptop without a probe attached, maybe you can test it
Code: [Select]
[code]function autozero()
local inst = mc.mcGetInstance()
local probeHand, rc = mc.mcSignalGetHandle(inst,mc.ISIG_PROBE)
local probeState=mc.mcSignalGetState(probeHand)
if probeState==1 then
    wx.wxMessageBox('Probe already active...cannot proceed')
    return
end
mc.mcCntlGcodeExecuteWait(inst, 'G01 G90 G31 Z-4 F40');
local zProbeStrikePos = mc.mcCntlGetPoundVar(inst, 5063);
mc.mcAxisSetPos(inst, 2, 0.060);
mc.mcCntlGcodeExecuteWait(inst, 'G00 G91 Z1');  --Rapid move to 1 inch above current pos
probeState=mc.mcSignalGetState(probeHand)
if probeState == 1 then
    wx.wxMessageBox("Probe is still activated! Check to make sure probe is not damaged or still contacting strike plate.");
else
    mc.mcCntlSetLastError(inst, "Z Axis now referenced.");
end
end
if mc.mcInEditor()==1 then
    autozero()
end

Couple of things I should point out. You see I have written this as a function and looks very much like a macro. I do this when I'm writing new code so I can put
it in a separate folder within my profile and I can run it with the debugger in the editor. Having it in a separate file means I don't pollute my macro folder with
buggy code. Once I've manually stepped through it and run a few tests then I will put in into its final location.

Here again I follow a somewhat iidiosyncratic policy of putting the function in the screen load script, usually near the top. Then I will put a function call on the button, not
the script itself. It means that when I go to find the script and edit it or have to delete it because its that buggy I can find it easily. If I were to attach the script
direct to the button the script will be buried in the screen script somewhere....I find it so much more convenient to put it at the top of the screen load script.
If it works out really well by all means put it direct on the button. This script is for my purposes only temporary to help you out so when we're done with it I'll delete
it knowing exactly where it will be.

Let us know if it works...

Craig[/code]

4948
Hi,
my apologies everyone, this is obviously posted it the wrong thread.

Craig

4949
Hi,
I'm on my laptop so don't have a probe hooked up, maybe you can test it out.

Code: [Select]
function autozero()
local inst = mc.mcGetInstance()
local probeHand, rc = mc.mcSignalGetHandle(inst,mc.ISIG_PROBE)
local probeState=mc.mcSignalGetState(probeHand)
if probeState==1 then
    wx.wxMessageBox('Probe already active...cannot proceed')
    return
end
mc.mcCntlGcodeExecuteWait(inst, 'G01 G90 G31 Z-4 F40');
local zProbeStrikePos = mc.mcCntlGetPoundVar(inst, 5063);
mc.mcAxisSetPos(inst, 2, 0.060);
mc.mcCntlGcodeExecuteWait(inst, 'G00 G91 Z1');  --Rapid move to 1 inch above current pos
probeState=mc.mcSignalGetState(probeHand)
if probeState == 1 then
    wx.wxMessageBox("Probe is still activated! Check to make sure probe is not damaged or still contacting strike plate.");
else
    mc.mcCntlSetLastError(inst, "Z Axis now referenced.");
end
end
if mc.mcInEditor()==1 then
    autozero()
end

Couple of things I should point out. You see I have written this as a function and looks very much like a macro. I do this when I'm writing new code so I can put
it in a separate folder within my profile and I can run it with the debugger in the editor. Having it in a separate file means I don't pollute my macro folder with
buggy code. Once I've manually stepped through it and run a few tests then I will put in into its final location.

Here again I follow a somewhat iidiosyncratic policy of putting the function in the screen load script, usually near the top. Then I will put a function call on the button, not
the script itself. It means that when I go to find the script and edit it or have to delete it because its that buggy I can find it easily. If I were to attach the script
direct to the button the script will be buried in the screen script somewhere....I find it so much more convenient to put it at the top of the screen load script.
If it works out really well by all means put it direct on the button. This script is for my purposes only temporary to help you out so when we're done with it I'll delete
it knowing exactly where it will be.

Let us know if it works...

Craig

4950
Hi,
you don't want to use the Touch Off module because the buttons aren't big enough? All the hard work has been done but for the lack of a mouse or track ball
you'd ditch it????

Anyway:
Code: [Select]
local mInst = 0;  --Sets current controller instance to 0, if running multiple controller instances, this will need to change
local rc = 0;  --Clear rc
local hSig = 0;  --Clear hSig

You don't need to reset these, they are created anew each time it runs and they are garbage collected once they go out of scope. Redundant. Lua uses a stack for local
variables not a fixed memory location.

Code: [Select]
--SETUP OF VARIABLES
local probe = mc.ISIG_PROBE;  --Set input here, mc.<INPUT_NAME>; input needs to be mapped in Mach4
local strikePlateThickness = 0.060;  --What is the thickness of the strikeplate, or how much do you want to offset 0?

Why bother, you're just getting cute, there is nothing wrong with mc.ISIG_PROBE  There might be a case for a strike plate thickness variable. I'm not going to bother,
I want to get this code down short and sweet, if you want to come back later and pretty it up OK but in the first instance get it to go!

Code: [Select]
function checkProbe ()

hSig, rc = mc.mcSignalGetHandle(inst, probe);  --Load hReg with probe state
state = mc.mcSignalGetState(hSig);  --Get Signal State
if (state == 1) then  --if hReg true ('if probe is activated then')
return true
else
return false
end
end  --checkProbe()

Do you really need a separate function to do this...it means a new local stack and context switch overhead and you use it only twice in the whole script.
I can write it in one line so why bother complicating this thing?

Code: [Select]
return false
This is I suspect will result in a syntax error, 'false' may have meaning in C or C++ but in Lua  0 means false any other number like 1 means true.

Code: [Select]
local CurrFeedRate = mc.mcCntlGetPoundVar(inst, 2134);  --Gets current Feed Rate, #var 2134
local CurrFeedMode = mc.mcCntlGetPoundVar(inst, 4001);  --Gets current G0/G1 state, #var 4001
local CurrPositionMode = mc.mcCntlGetPoundVar(inst, 4003);  --Gets current G90/G91 state, #var 4003
local zProbeStrikePos = 0;  --clear variable

Whats the point of these, you are collecting and storing this info but nowhere later in the script is it being used. Meanwhile you risk syntax/logic errors and for no
gain. Redundant.

Code: [Select]
local zProbeStrikePos = 0;  --clear variable
As per above, this variable is created anew in a stack, no need to clear it.

Code: [Select]
local zAxisCurrentPos = mc.mcAxisGetPos(inst, 2);  --Get Current Z position, sometimes the probe will continue past strike point.
local zAxisDifference = (zProbeStrikePos – ZaxisCurrentPos);  --Gets overshoot, returns positive
local zAxisNewOffset = strikePlateThickness – zAxisDifference;  --Subracts overshoot from known thickness of strikeplat

I use a solid probe when making circuit boards. If there was any significant overrun at the probe event I would know and yet there is not. Do you have any
evidence that allowing for overrun is actually required? I'm not going to bother because I know from personal experience that its not required. Save the extra
coding and the syntax/logic errors that could creep in and upset what should be simple code.

I have some code written and am testing it out. I can't test it on my machine so it may be a bit ragged. Will post when complete.

Craig

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 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 »