Hello Guest it is April 24, 2024, 08:44:34 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 - 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 »
81
Mach4 General Discussion / Re: Button script
« on: August 07, 2019, 06:15:10 PM »
If it can all be done in Gcode do it all as one string of gcode and do not use wait. It will be executed in order.

If you have to use api calls you might want to consider using a coroutine. See the ref all home button, function in screen load script and PLC of wx6.set.

I would get rid of those sleeps too. Rule of thumb is if you have to use sleep you need to rethink your code.

Maybe you can do it all in a macro (say 127). Then when you want it to run from a button the buttons clicked script looks something like this.

local inst = mc.mcGetInstance()
mc.mcCntlMdiExecute(inst, "M127")

82
If your steps per are not right the further you go the worse it gets out. Check you backlash and calibrate your motor tuning. These 3 links will help. They are very short and very relevant.

https://www.machsupport.com/forum/index.php?topic=12513.0

https://www.machsupport.com/forum/index.php?topic=12512.0

https://www.machsupport.com/forum/index.php?topic=16315.0

83
Mach4 General Discussion / Re: Creating M-Code to activate Outputs
« on: August 07, 2019, 01:38:40 AM »
Think you could do them all with a single macro and just set the output number using a p var. Something like M201P1, M201P2, etc. Will have to look. I know I did it before.

84
Why not get and set the VFD over Modbus?

85
Something like this should work. Make sure you set the right output in the script. I would have a function in the screen load script that is ran each cycle through the PLC script.

Code: [Select]
--PLC script
TogWayOil()

--Screen load script
function TogWayOil()
local hSig, rc = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT1)
local sigState, rc = mc.mcSignalGetState(hSig)
local vX, rc = mc.mcAxisGetVel(inst, mc.X_AXIS)
local vY, rc = mc.mcAxisGetVel(inst, mc.Y_AXIS)
local xyVel = math.sqrt((vX * vX) + (vY * vY))

if (sigState == 0) and (xyVel > 0) then --turn the output on
rc = mc.mcSignalSetState(hSig, 1)
elseif  (sigState ~= 0) and (xyVel == 0) then --turn the output off
rc = mc.mcSignalSetState(hSig, 0)
end
end

86
OK, yeah let's talk about that other thread in that other thread. I will clean this one up.

87
Quote
Do I even need those inst = mc.mcGetInstance() in there since at the begging of the screen load script it says this already.

Nope. As long as the inst variable is within the scope of the script you are working with and is already properly defined there is no reason to redefine it or create a local copy of it.

But, if there is ever a chance the script may be called for different instances of Mach4 you should write the script with provisions to define the inst from whatever is calling it.

88
Do I need to modify the start screen code and the sig library and create M code scripts to just make a button that already exists and has predefined M Code action work?

For example I just want to make the Mist button work and give it an output to turn on. Where do I do this? Is there a tutorial for this exact thing where you just want to make an existing button and Mcode work?

 I can make a new button that does this and I could make a new M code script that does this, but I would think they intend for you to use the built in action for this? mc.OSIG_MISTON? I will keep reading and reading and reading to figure it out, but hopefully someone can just give a quick link with a good simple to understand way of how it should be done for best performance.

Thanks. I looked for a couple hours so far and have not figured it out yet. Too tired from a long day I guess. I am reading through a bunch of information, but there is just so much to look at and no straight to the point of the best way and the exact code and where to put it etc. The only variable from what pretty much everyone is doing for this simple task is which output they are using. In my mnd this simple thing should not require a programmer to get working...

Not sure what the problem is. The mist toggle button toggles the state of the mist output (as it should) in the default screens. Even has an LED beside it to indicate its status. Executing a M07 and M09 turns the mist on and off as well. Not sure how much simpler it could be. There is even a dedicated output labeled "Mist On" (the only way you can control any output is to know what output your controlling). You aren't trying to control your mist with a general purpose output are you?

89
Mach4 General Discussion / Re: Coroutine or executewait
« on: August 02, 2019, 06:03:17 PM »
It all depends on what your doing. If it can be done with mc.mcCntlGcodeExecuteWait() then no reason not to use it. Technically I guess it would be the safest. But using a coroutine is perfectly fine too as long as it is implemented correctly.

90
Mach4 General Discussion / Re: mach 4 plasma
« on: August 02, 2019, 12:44:39 PM »
Have a look in your C:\Mach4Hobby\Docs folder, Plasma_Configuration.pdf. That is covered on page 2 and 3.

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 »