Hello Guest it is March 28, 2024, 07:06:56 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 »
3581
Mach4 General Discussion / Re: lua error
« on: October 07, 2018, 02:45:16 AM »
Hi madi,
I think you have got that board going as well as anyone has.

They don't have a good reputation:
http://www.machsupport.com/forum/index.php/topic,36023.0.html

Craig

3582
General Mach Discussion / Re: Motor Driver issue
« on: October 07, 2018, 01:55:46 AM »
Hi,
sorry should explain how to use it.

One end, doesn't really matter which, goes into the output you want to test. The other end you hold on a 5V terminal. If the output
is low one LED will light up. If the output is high then neither will light up. If that's the case hold the floating end on a 0V terminal.
If the output is high a LED (opposite color) will light up.

Craig

3583
General Mach Discussion / Re: Motor Driver issue
« on: October 07, 2018, 01:48:03 AM »
Hi,
the ouputs of the board are TTL....that is to say active outputs.

If the output is high it will be somewhere between about 4.5V and 5V and be able to produce about 20mA of current. If you try to draw more current than
that you'll probably fry it.

If the output is low it will be between about 0.5V and 0V and able to sink about 20mA of current. If you cause it to sink more than that you'll blow the
IC.

There is a very useful little circuit that you can make which will indicate when the output is high and when it is low. Provided you use it on circuits
of 5V or 3.3V it works OK. You'll blow it at higher voltages One LED is on when the output is high and the other is on when it is low.

Craig

3584
hi,
lets review what we have got, what we need to do yet and some ultimate goal.

We have a macro (m180) that can lock the turret. It still needs to be tested on your hardware.
We have a macro (m185) that advances the turret one position and then locks it place and advances a counter to indicate the new position. Again this needs
to be tested on your hardware.

What remains to be done is have a procedure made up of these two operations that can advance until the Index switch is detected. Mach can then reset its
tool position counter and be assured for the rest of the session it will stay in sync with the tool.

Another useful procedure would be to have a function that advanced two positions, or three positions or more. Thus if the current tool is no.2 and
tool no. 4 is required use the 'advance by two' function.

Why might you ask that I am adding all these functions? Am I not complicating matters.....and the answer is yes...to a certain extent.

My ultimate strategy is to have a table of functions called Turret[].

It will have a function called Lock.
It will also have a function called Advance.
It will have a function called Index.
It will have a function Advance2.
It will have a function Advance3.

and so on.... You can see where this is going. My hope is that Index your machine at startup you will call Turret.Index     That's it! You need do no more.
To go from your current position to two positions further you call Turret.Advance2   That's it! You need do no more.

Code like that is best as a module....but we will come to that later.

First trick is to make some code that works...there is still a little to go yet.  The next thing is to refine the code so that its efficient and robust. THEN if all
is well stick it all in a multifunction table.

Provided we can get code to work you could bail before doing all the table/module stuff, I won't drag you down that rathole unless you want to! ;D

Craig

3585
Hi,
now we need a function to advance the turret by one. We need another register....open the Regfile plugin and add another register
iRegs0/TurretPosition. It will record the current position of the turret, from 0 through 5.

Lets assume for the moment that we know, or rather Mach knows that the turret is locked into a position. This code might work:

Code: [Select]
function m185()
--Advance the Turret
local inst=mc.mcGetInstance()
local hsig1=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT3)
local hsig2=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT4)
local hsig3=mc.mcSignalGetHandle(inst,mc.ISIG_INPUT4)
local hreg1=mc.mcRegGetHandle(inst,'iRegs0/TurretLock')
local hreg2=mc.mcRegGetHandle(inst,'iRegs0/TurretAdvance')
local hreg3=mc.mcRegGetHandle(inst,'iRegs0/TurretPosition')
if (mc.mcSignalGetState(hsig1)==0) then
mc.mcSignalSetState(hsig1,1)
mc.mcRegSetValue(hreg1,1)
end
mc.mcSignalSetState(hsig2,1)
mc.mcRegSetValue(hreg2,1)
local rc=mc.mcSignalWait(inst,mc.ISIG_INPUT4,1,10)
if (rc==mc.MERROR_TIMED_OUT) then
wx.wxMessageBox('Turret failed to Advance')
return
end
mc.mcSignalSetState(hsig2,0)
mc.mcRegSetValue(hreg2,0)
--************************************************
local inst=mc.mcGetInstance()
local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT3)
local hreg=mc.mcRegGetHandle(inst,'iRegs0/TurretLock')
if (mc.mcRegGetValue(hreg)==0) then
mc.mcRegSetValue(hreg,1)
mc.mcSignalGetState(hsig,1)
end
local rc=mc.mcSignalWait(inst,mc.ISIG_INPUT4,1,11)
if (rc==mc.MERROR_NOERROR) then
elseif (rc==mc.MERROR_TIMED_OUT) then
wx.wxMessageBox('Turret failed to lock')
return
end
mc.mcCntlSetLastError(inst,'Turret Locked')
mc.mcRegSetValue(hreg,0)
mc.mcSignalSetState(hsig,0)
--*************************************************
local hreg4=mc.mcRegGetHandle(inst,'iRegs0/TurretPosition')
local currentTool=mc.mcRegGetValue(hreg4)
local currentTool=currentTool + 1
if (currentTool==6) then currentTool=0 end
mc.mcRegSetValue(hreg4,currentTool)
end
if (mc.mcInEditor()==1) then
m185()
end

The first part just sets up the signals required and turns the TurretLock and TurretAdvance outputs on. Once the ToolPosition
switch makes the TurretAdvance output turns off. The code between the two lines of asterisk is just our m180, or turret lock function.
The last bit of code increases the count of the Turret Position register.

We are getting close now.

Note all this code is pretty ragged and not well tested yet. I'm also beginning to wonder if I've used registers when I haven't needed to. In particular
the four ToolIndex,  ToolPosition, TurretLock, and TurretAdvance are looking redundant. They wont do any harm so I'll leave them be but we may at
a later time decide that they are not required.

The second issue is that this last macro includes the code of another one, can I use a subroutine or is pasting the code in complete better?
In this case I suspect its better to paste the code in directly. It admittedly means that there is some repeated code, but memory is cheap. It may make
the code a little easier to read with subroutines but I think it will run best as repeated code.

In this instance I will go with the repeated code strategy and later try reducing it by subroutines and compare the two.

Craig

3586
Hi,
I've just realized that I have not allowed anyway to turn the TurretLock signal off.

If you are OK with the idea that if the turret is in position as indicated with the TurretPosition switch then the
TurretLock signal could be turned off immediately. That would require only two more lines of code, one to set the
register to zero and the other to your the output off.

Code: [Select]
function m180()
-- Lock the turret.
local inst=mc.mcGetInstance()
local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT3)
local hreg=mc.mcRegGetHandle(inst,'iRegs0/TurretLock')
if (mc.mcRegGetValue(hreg)==0) then
mc.mcRegSetValue(hreg,1)
mc.mcSignalGetState(hsig,1)
end
local rc=mc.mcSignalWait(inst,mc.ISIG_INPUT4,1,11)
if (rc==mc.MERROR_NOERROR) then
elseif (rc==mc.MERROR_TIMED_OUT) then
wx.wxMessageBox('Turret failed to lock')
return
end
mc.mcCntlSetLastError(inst,'Turret Locked')
mc.mcRegSetValue(hreg,0)
mc.mcSignalSetState(hsig,0)

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

Craig

3587
Hi,
sick of me yet!!!

Let me know if you stumble on any of the stuff so far.

Assuming all is good then we can start writing code to do things. The first thing we need is a macro to lock the turret.
I've called it m180....for no particular reason. Its generally considered that macros under 100 are Machs own....go there but
you may be trashing one of Machs macros. Anything above 100 is OK. Note there are some macros there  that you don't want
to trash either. From memory m161 and m162 are related to laser operation. You may not care that they get overwritten but
I would avoid doing so.

Another quirk of Mach4 is that when it reads a macro name it converts all upper case to lower case and strips out leading zeros and spaces.
Thus:
m180,
M 180,
m  0180,
M018   0
all point to the same thing, namely m180. Windows is not case sensitive and so M180 works, try that in Linux and you'll bomb.
It doesn't happen often but it does happen that if you use a non standard name because it 'looks nice' you can introduce an error.
I therefore name everything as Mach reads it, ie lower case, no leading zeros and no spaces. What you choose to do is up to you
but I promise on one of those rare occasions when it throws an error is going to leave you really pissed off.

Here is the m180 macro:
Code: [Select]
function m180()
-- Lock the turret.
local inst=mc.mcGetInstance()
local hsig=mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT3)
local hreg=mc.mcRegGetHandle(inst,'iRegs0/TurretLock')
if (mc.mcRegGetValue(hreg)==0) then
mc.mcRegSetValue(hreg,1)
mc.mcSignalGetState(hsig,1)
end
local rc=mc.mcSignalWait(inst,mc.ISIG_INPUT4,1,11)
if (rc==mc.MERROR_NOERROR) then
elseif (rc==mc.MERROR_TIMED_OUT) then
wx.wxMessageBox('Turret failed to lock')
return
end
mc.mcCntlSetLastError(inst,'Turret Locked')

end
if (mc.mcInEditor()==1) then
m180()
end
Note I have done some things which you may question and may not work.

The first thing I've done is asked is the register iRegs0/TurretLock on or not. If its not on then turn it on.
Turn on the output Output#3, here I am assuming output#3 is hooked to the turret lock input of your turret.

Thats the easy bit. The next bit might take a little more thinking about. I have written a mc.mcSignalWait(inst,mc.ISIG_INPUT4,1,11)
instruction. You might like to read in the  API.chm document of the documents folder in Mach4. You will as you code Lua be reading
and re-reading...and re-reading....and re-reading the API document....and curse when you realize that its out of date, NFS have added new
stuff which hasn't even got in there yet!

Basically the instruction is saying 'Wait until ISIG_INPUT4 goes high (that's your ToolPosition signal), and time out after 11 seconds.
What I have done is assume that while you say it takes ten seconds for the turret to lock it might take less than that too. Thus when
the TurretLock signal is sent then Mach waits until the ToolPosition signal comes good. If that hasn't happened after 11 seconds you have a problem
and it will put a wxMessage on screen which you will have to clear. I'm not sure yet what you want to do in a fault situation.
If the turret locks within the timeout period then the you get a status message and the function completes normally.

Note that many of the API's have a return code, shortened to rc. The rc will give an indication as to whether the function has finished executing normally
or not. In this case I'm using it to detect a timeout which is an indication of turret lock failure.

Do you think that will work?

Craig

3588
Hi,
OK finally we can test what we have done so far.

start up Mach and open the Regfile Diagnostics page and pin it to the top. Make sure that on the jog tab the keyboard inputs are enabled.

Then on each occasion you hit F1 the input#3 LED should come on and the register iRegs0/ToolIndex should reflect your keypress.
Likewise if you fit F2 then input#4 LED should come on and iRegs0/ToolPosition should reflect the keypress.

Craig

3589
Hi,
I like to test as I go. I could go and hook up a couple of switches to my ESS, but that's out in the garage. What I'm going to do instead is use a couple
of keyboard inputs to mimic the switches, means that I can do it all on my laptop.

It is not quite as straight forward as it sounds, you have to use a workaround to get it to work. Its such a valuable technique that it is
worth making the effort to learn, you will use it dozens of times over the coming months/years. I'm copying work that Daz-the-Gaz has already
done. Watch his video:
http://www.machsupport.com/forum/index.php/topic,31585.msg219180.html#msg219180

Open Configure/Plugins/Keyboard and add two new keyboard inputs, I used F1 and F2 and called them ToolIndex and ToolPosition respectively.
Now you need some code to go in the PLC. To start with make a temporary file in your temp folder....something like tempplccode.

Code: [Select]
--************************************************************************
--************************************************************************
--TEMPORARY TESTING CODE ONLY

local hsig1=mc.mcSignalGetHandle(inst,mc.ISIG_INPUT62)
local hsig2=mc.mcSignalGetHandle(inst,mc.ISIG_INPUT3)
if mc.mcSignalGetState(hsig1)==1 then
mc.mcSignalSetState(hsig2,1)
else
mc.mcSignalSetState(hsig2,0)
end
local hsig3=mc.mcSignalGetHandle(inst,mc.ISIG_INPUT63)
local hsig4=mc.mcSignalGetHandle(inst,mc.ISIG_INPUT4)
if mc.mcSignalGetState(hsig3)==1 then
mc.mcSignalGetState(hsig4,1)
else
mc.mcSignalSetState(hsig4,0)
end

--END OF TEMP CODE
--*****************************************************************************
--*****************************************************************************

Now open the PLC script and paste the code in just before the end.

You will have to close Mach and restart before these changes take effect.

Craig

3590
Hi,
note that when you exit and save the screen editior you will have saved a modification to the existing screenset.set.

If you are new to Mach4 then I would guess you already have a separate and individualized profile.ini file. What you may not
realize is that you should have a separate and individualized screenset.set as well.

The reasoning goes like this....if you are using wx4.set (as I do) and then you start making all sorts of additions and tweaks then when you next
update Mach to the newest and greatest build then you will also get a fresh copy of the newest and greatest wx4.set as well overwriting all your work,
and depending on circumstances you may not be able to get it back....double and triple bugger! >:D Ask me how I know.....I will have to answer PM as
the swearing filters would not permit me to post a frank reply!!!!

I recommend you go to the Mah4Hobby folder and find the screenset folder and make a copy of your favorite screen set with an individualized name.

Now when you run Mach go to View/Load Screen and you will be presented with a list of available screens which should include yours, select it and click Open
and that is now the screenset in use and will be recorded in your profile as such. Note mine is called ESSMillwx4.set. It will not be overwritten when you update.

It may be that I am insulting your intelligence by painstakingly laying out these things but I found they were exactly what tripped me up when I was learning.
If you feel slighted I apologise. I hasten to add that there may well be others following this thread and it might have relevance to them even if you find them
trivial.

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 »