Hello Guest it is April 26, 2024, 02:05:31 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 »
1011
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 07, 2021, 01:11:00 PM »
Hi,
this is a classic case where I did not consult the register diagnostic and thus had the wrong path......and the path must be EXACTLY character
for character correct.

When you single step through the code and the once the local 'registerHandle=mc.mcRegGetHandle(mInst,"modbus0/wrtvfdspeed")'
statement executes hover the cursor over 'registerHandle' and the editor should display the value.....does the number displayed look like a genuine
memory address? If it does then the chances are that the statement has executed correctly if not then it has not found the correct handle ie the
path is STILL not correct.

Craig

1012
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 07, 2021, 01:01:22 PM »
Hi,
I can see one mistake:
the path is not modbus0/wrtvfdspeed it is:
modbus0/function2/wrtvfdspeed0

Change the path in the macro and single step through it.

Craig

1013
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 07, 2021, 12:56:01 PM »
Hi,
the macro is not really a means of changing the speed, it would have to run multiple times a secoond to do that, the macro is so you
can step through it one instruction at a time until you can understand what it does. Have you tried single stepping?

Craig

1014
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 11:51:08 PM »
Hi,
I have just got back from work, been shifting stuff all day and I'm buggered again! I'm beginning to think that going to Church on a Sunday
may not be such a bad idea after all.

Craig

1015
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 11:48:45 PM »
Hi,
I would guess at least a part of the code that you have installed is working, ie the VFD turns on and off and you can select FWD or REV,
so to bin it would be to 'throw the baby out with the bath water'.

What I would suggest is to put the proposed code in a macro so that you can run it in the editor.  Once you have established that it works
to your satisfaction and you understand it thoroughly then and only then install it in the PLC script.

The reason I suggest this is because a macro executes just once, if there is a problem with it you can stop it, and/or single step through the code
until you understand what's going on. If you put it directly in the PLC script it will run every few milliseconds, and if it does something strange you may have
to crash Mach to get it to stop, not ideal.

For no particular reason lets call the macro m666:

Code: [Select]
function m666()
     local mInst=mc.mcGetInstance()
     local registerHandle=mc.mcRegGetHandle(mInst,"modbus0/wrtvfdspeed")
     local commandedSpeed=mc.mcSpindleGetCommandRPM(mInst)
     local registerValue=(commandedSpeed/12000)*10000
     mc.mcRegSetValue(registerHandle,registerValue)
end
if(mc.mcInEditor()==1)then
     m666()
end

Try installing that in the macros folder of your current profile. You need to single step through it using the debug functions of the editor.
Using single step is the sure-fire best way to understand how your code works, and even more importantly when it does  not work!

Craig

1016
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 03:39:58 PM »
Hi,
OK. The PMC module has been around for about three years now, maybe more. Prior to its introduction the only way to have Mach
execute blocks of code repeatedly was to use the PLC, and I must confess its what I am still most familiar with.

The PMC module is a ladder logic module. Its designed to replicate Mach3 Brains and ladder logic is the predominant means of programming
industrial Programmable Logic Controllers. As it is a visual representation it is widely appreciated as the simplest means of programming.

The PMC module in Mach4 takes the visual representation, ie the rung of the ladder, and converts that into  chunks of Lua code, and its that
Lua code that simulates the logic implied by the ladder rung. The Lua code blocks are auto generated and are not easy to read or interpret,
really they are seldom ever viewed by human operators, we'd just open the PMC editor and look at the ladder diagram. It comes as no surprise
that you are having difficulty in reading and understanding the Lua code, it was never meant to be human readable.

You have posted  screen shots of the Modbus plugin set-up pages, which is useful, but still actually removed from what I asked for.
If you open the Regfile diagnostic you will see a tree diagram of ALL the registers in Machs core, and that is what I would prefer. Having said that
the shots you have posted, and the PM both confirm that the path to the speed register is:

modbus0/wrtvfdspeed

Now the speed command is a little different. In my own VFD if I choose to use Modbus comms I would supply a number related to frequency rather
than speed. For example my VFD goes to 400Hz, and the spindle does its full 24000 rpm at the frequency. The number I have to send is the frequency
IN TENTHS, thus if I send the number 4000 the spindle goes at full speed and if I send a number 2000 the spindle goes at half speed.
Machs core stores the speed as rpm. Thus if I interrogate Mach after issuing an s18000 for instance, Mach will respond with a number 18000.
To convert that into a number my VFD can use I would do the following:

RegisterValue=(MachSpeed  / 24000 )*4000

Just to double check:
RegisterValue=(18000/24000)*4000
=3000, which to my VFD means 300Hz which indeed causes the spindle to rotate at 18000rpm.

It would appear that your VFD it somewhat different in that you must issue a number related to percentage of full speed, IN ONE-HUNDREDTHS:
100%=10000 and
50%=5000

Do I have this correct? If so you will need a slightly different mathematic expression to convert the number that Mach reports to the number
that the VFD expects:

RegisterValue=(MachSpeed /12000) *10000                     given that 100% speed of your spindle is 12000rpm?

As a sanity check lets say you issue an s9000:
RegisterValue= (9000/12000) *10000
=7500

There are two ways to interrogate Machs core to get the current commanded speed. The way I am most familiar with is:
local speed=mc.mcGetPoundVar(inst, 2132)    So this statement gets the value of the pound variable #2132, which is where Mach stores its commanded
speed.

swifty posted this method:
local spindle_rpm = mc.mcSpindleGetCommandRPM(mInst)
This method, which I was previously unaware of, is much better and more elegant and I would suggest you adopt it also.
Thus we should have some draft code:

Code: [Select]
local registerHandle=mc.mcRegGetHandle(mInst,"modbus0/wrtvfdspeed")
local commandedSpeed=mc.mcSpindleGetCommandRPM(mInst)
local registerValue=(commandedSpeed/12000)*10000
mc.mcRegSetValue(registerHandle,registerValue)

Note here I am asumming that 'mInst' has already been evaluated in the PLC and stored as a local variable. If not you'll have to add a line:
local mInst=mc.mcGetInstance()

Please note that I have not tested this code, my machine is at work, and we are shifting premises and have been for the last two days, in fact
as soon as I finish this post I'm leaving to continue with that. At the moment I cannot even plug my machine in, let alone run it
and test some code.

May I suggest running it in the Lua editor before you put it into the PLC. Faulty code in the PLC can cause you grief. You want/need to de-bug any code
before you put it in there.

Craig

1017
Mach4 General Discussion / Re: Mach4 Set Motor Acc and Velocity via script
« on: November 06, 2021, 02:35:43 PM »
Hi,
kool. If I'm not mistaken its not strictly necessary to do a Flush/Reload cycle.

Lets say for example that the current velocity setting in the .ini file is 5000 units/min (mm units implied) and you executed a macro
m120 for example, which reduced the velocity setting to 2500 units/min. Mach would apply the new setting to that axis immediately
and remain that way for the remainder of the Mach session.....unless you execute m121 which restored the setting back to 5000 units/min.
In absence of the restoring macro the 2500 units/mm setting would apply but the data in the configuration page would still show 5000 unit/min.

If you shut Mach down the setting (2500 units/min) would be flushed to the .ini file, its standard procedure to do a flush at shutdown.
Thus at the next Mach session the .ini file is loaded and viola the setting (2500 units/min) that you made from the last session have now been
propagated to the motor configuration page.

I imagine that you want to change the motor parameters during a job, but then set them back to normal afterwards. If that's the case there is no need
to do the Flush/Reload cycle, that the motor configuration data is not current during that phase is of academic interest only, so why bother with
the Flush/Reload cycle?

Craig

1018
Mach4 General Discussion / Re: Mach4 Set Motor Acc and Velocity via script
« on: November 06, 2021, 10:05:52 AM »
Hi,
I haven't tried either of those APIs but they are similar to mc.mcAxisMapMotor() and similar ones which I have used.
They confused me to start because it did not appear that they were affecting the settings, and it was only then that I discovered
that only at certain times do the new settings get flushed to the .ini file and thence to the configuration values. The values you see
are the old ones, as stored in the .ini file, even though you have changed those values. Those values will change when the .ini file
is next loaded.

You can use mc.mcProfileFlush() and mc.mcProfileReload() if it concerns you that you cannot see the new values. Be careful with mcProfileReload(),
it can only be done in Idle State.

Craig

1019
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 06:54:15 AM »
Hi,
first please post a screen shot of the Regfile diagnostic, I need to see the register path.
Second, what number do you have to set in the register to cause a given speed?

Craig

1020
Mach4 General Discussion / Re: Modbus control huanyang GT vfd
« on: November 06, 2021, 06:51:56 AM »
Hi,

Quote
I noticed you have posted about this kind of thing a while ago - Do you use modbus spindle control yourself?  If so do you mind sharing the script?

I don't use MODBUS on my machine but a friend of mine has a CNC pressbrake which I helped him the interface Mach4 to the PLC of the machine.
It does not have a spindle .

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 »