Hello Guest it is April 27, 2024, 07:30:24 AM

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 »
7211
Mach4 General Discussion / Re: Lua success with external buttons to Mach4
« on: January 22, 2017, 05:24:18 PM »
Hi Craig,
0-3.3V is the analogue input voltage range of pin 42. It will be converted to a 12 bit number in the range 0-4096.
You can convert that back into a number representing a voltage and read a table indexed by that number if you wish,
but why?

Just read the 12 bit number. Your OV ratio is simple:

ratio=0.5+(value/4096) where value is the contents of the register ie 0-4096.

Craig

7212
Mach4 General Discussion / Re: Mach 4 Machtric 2.2kw VFD Modbus
« on: January 22, 2017, 04:30:08 PM »
Hi Zuxztah,
maybe try 'Read Input Register', looks to me like you have the right address.

Craig

7213
Mach4 General Discussion / Re: Mach 4 Machtric 2.2kw VFD Modbus
« on: January 22, 2017, 02:25:32 PM »
Hi Zuxztah,
just re-reading your last post and I think you are correct, ie the Slave address is the VFD device number. I wish I could
experiment but I don't have a 485 link. Further my machine is out in the garage and I've pretty much be told, doctors orders' to
stay the hell out of there!

Craig

7214
Mach4 General Discussion / Re: Mach 4 Machtric 2.2kw VFD Modbus
« on: January 22, 2017, 02:14:28 PM »
hi Zuxztah,
8150 was just my guess, read thru your manual to find the actual register number.

For instance my Delta VFD:

Quote
210CH Motor speed (rpm)
- would need to convert 210C to decimal...

Craig

7215
Mach4 General Discussion / Re: Mach 4 Machtric 2.2kw VFD Modbus
« on: January 22, 2017, 01:29:25 PM »
Hi Zuxztah,
kool!

Code: [Select]
I guess the Reg file thing you told me to do "RegMyTrial" was for explaining purposes? For me to find the registry editor?
Yes.

Couple of things I see that could do with refinement or experimentation:
Both your Modbus functions have slave address 0 and Modbus address 8192 or 8193. Try the other way around.
The VFD is the slave device and the address of the registers internal to the VFD are 8192 and 8193. Try it and tell
me if it works, I can't test it without a 485 link.
Second item: the two registers are continuous so you could have just one function

Modbus function: Multiple write
Slave address: 8192
Modbus address:0
Nmbr reg:2

ie each time the Modbus function runs it sends both the control word AND the frequency word. It means that the CRC check which must
happen within the Modbus plugin only has to run once.

Another idea that you may wish to experiment with is reading the actual spindle speed from the VFD, in this instance you are not
writing data to the VFD but reading from it. Don't have your VFD manual on screen at the moment but there is a register that has
the current speed, I'm going to guess 8150:

Modbus function: Read single holding reg
Slave address: 8150
Modbus address:0

So you would end up with another register in the Regfile called something like ActSpeed which could be read and then displayed on the screen.

The next item on the agenda is being able to manipulate your control words from a button on screen or an M code. I suggest you have
a look thru some of DTGs videos to get some ideas how to use the 'Edit Screen' function.

Craig

7216
Mach4 General Discussion / Re: Lua success with external buttons to Mach4
« on: January 22, 2017, 12:08:07 AM »
Hi Craig,
look in the API.chm ('Help Docs' button File Ops tab with M4 enabled), I have it almost permanently on the taskbar so I can refer to it;

LUA Syntax:
hReg, rc = mc.mcRegGetHandle(
      number mInst,
      string path)
So the correct way to get the register handle is:

inst=mc.mcGetInst()
hreg=mc.mcRegGetHandle(inst, "<your register, whatever you called it>")


Its got nothing to do with the screenset. Go to Diagnostics/Regfile and expand the different entries until you find where the PoKeys plugin
or maybe the Modbus plugin has put the register. For instance I have a macro that uses an instance register called ALcode. Its handle:

hreg=mc.mcRgGetHandle(inst,"iRegs0/ALcode")

ie the path is iRegs0/ALcode.

If you cant find the register then you haven't created it yet. Solve that first.

Craig

7217
Mach4 General Discussion / Re: Lua success with external buttons to Mach4
« on: January 21, 2017, 10:28:46 PM »
Hi Craig,
believe it or not we've had a genuine NE gale and about 3in of rain over the last 24 hours, not complaining about the rain!

Quote
“MachDuino”.  I have tried all three options with no success.  My screen set is wx4

The name is the name of the screenset you are using. wx4 is a default screenset that ships with Mach4. It is recommended that
you copy it and rename it to something individual say 'Craigwx4Set' or similar. Any changes to the set say buttons, macros and
so on will be saved to that set. If you update Mach4 with a later build wx4 will be overwritten and any changes you made to it
will be lost whereas your individually named screenset will be retained. The underlying code that selects and loads the screen is LUA
and LUA is case sensitive, your screenset is case matched but otherwise follows the rules for LUA variables, ie doesn't start with a
number or a LUA keyword.

Code: [Select]
You mention 0 to 4096, DTG’s table goes from 0 to 1023, could that have anything to do with it,
This depends on the PoKeys board. If memory serves it uses a 12 bit ADC, ie 0 to 4096. If it uses a 10 bit ADC, like DTGs Arduino,
the range would be 0 to 1024.

Code: [Select]
The other thing is the name of the register, which goes into those lines inserted into the PLC script
Most of the buttons and switches you have used on your control board have two distinct states. Mach4 runs the signal script each and
every time a signal changes state. You don't have to poll them every once and a while. An analogue signal is converted to a digital number
and communicated via Modbus by TCP/IP and the Modbus function runs every 25ms or so. The Modbus plugin creates and defines a register
in the Regfile and the register is updated with the digital representation of your analogue value everytime the Modbus function runs ie every 25ms.
You can read the register any time you like but I imagine you wish to see it live so you would put the code necessary to read and display it in the
PLC script as it runs every 40ms or so.

Craig

7218
Mach4 General Discussion / Re: Lua success with external buttons to Mach4
« on: January 21, 2017, 05:42:40 PM »
Hi Craig,
I see DTG has already replied with a solution that uses a lookup table.

I think this might also work: the PoKeys yields an 12 bit number and ranges from 0 to 4096.

ratio=0.5+(pokeyvalue/4096)
percent=ratio*100

Craig.

7219
Mach4 General Discussion / Re: Mach 4 Machtric 2.2kw VFD Modbus
« on: January 21, 2017, 05:27:12 PM »
Hi Zuxztah,
have a look at Diagnostics/Regfile. You will see a number of registers. Most of them are defined and/or created by various plugins
but you can define your own as well.

Try this: Configure/Plugins/Regfile- you should see a page with two tabs 'Instance Registers' and 'Global Registers'. Try creating an instance
register (page icon with green cross) and a new register will be formed which you can name, provide a default value and make persistent.
Make one called RegMyTrial with a default of 100 and make it persistent. Click Apply and exit.

Now inspect that new register by Diagnostic/Regfile and expand iRegs0 and you should see the register you created RegMyTrial and its value.
You can edit its value by double clicking. This register could now be accessed or written to by any script in Mach4. For instance you might
store a value of the X co-ordinate when running one of your macros say m100 but later you could recall that number in another macro say m101.
Of course this is just an example, read chapter 4 of the Mach4 Scripting Manual that is in the 'Help Docs' button of the File Ops tab when Mach4
is enabled. It explains the usage of registers. Note also that you could store either a number or a string. I make use of the string store to
record a path and filename in one of my macros which can later be used to open that file in another macro.

For your spindle control problem you are going to allow the MODBUS plugin to define two new registers. They will be seen at Diagnostics/Regfile
and expand modbus0. You could manually edit them there or you could programmatically edit them when you hit a button or execute a script.
You would also be able to see the registers by Diagnostics/Modbus and expanding but note that the only registers displayed there are those which
have been created or owned by the Modbus Plugin, it is not the right place to edit them however.

Once you've got your 485 comm link working and the two new registers defined in the Regfile then you can go on to work out how to manipulate
them.

Craig

7220
Mach4 General Discussion / Re: Mach 4 Machtric 2.2kw VFD Modbus
« on: January 21, 2017, 03:46:43 PM »
Hi Zuxztah,
if I understand correctly you only require two registers to control your spindle:

slave reg 8192- contains the bit pattern to turn on or off the spindle and its direction
slave reg 8193- contains a numeric value for the frequency

I believe also that your MODBUS connection window (your first pic) should have 'use zero base addressing' checked.
I propose that the Mach4 registers are modbus0/spinCntrl  and modbus0/freq.
Your frequency setting function (your second pic) should have the slave address 8193 and the Modbus register should be modbus0/freq.

Your spindle control function (your third pic) is inconsistent. The function selected is 'write multiple registers', you only require 1 register word.
The slave address (the VFD is the slave device) should be 8192 and the Modbus register should be modbus0/spinCntrl.

In order to control your spindle you need to load the required bit pattern into modbus0/spinCntrl, ie one word transmitted but different values
for the required spindle function.

Does that make any sense?

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 »