Hello Guest it is March 28, 2024, 07:29:51 AM

Author Topic: Huge feedrate error  (Read 2566 times)

0 Members and 1 Guest are viewing this topic.

Huge feedrate error
« on: June 12, 2016, 05:56:16 PM »
Consider the following M code.  It should read the feedrate from a DRO, which is does (300), set the feedrate to 300, move to X5Y5 then back to zero.

Code: [Select]
function m200()
    local inst = mc.mcGetInstance()
    local Feedrate = mc.mcProfileGetDouble(inst, 'PersistentDROs', 'droPLFeedRate', 1)
    mc.mcCntlSetLastError(inst, 'Set Feedrate')
    code2 = 'F ' .. Feedrate .. '\n'
    code2 = code2 .. 'G01 X5 Y5\n'
    code2 = code2 .. 'G01 X0 Y0\n'
    mc.mcCntlGcodeExecuteWait(inst, code2)
end

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

It does not set the feedrate to 300IPM.  It sets it to 3IPM.  The Feedrate variable is correct.  Same thing happens if I replace Feedrate with a '300'.  So thinking that I just need to multiply the Feerate variable by 100, I try this...

Code: [Select]
function m200()
    local inst = mc.mcGetInstance()
    local Feedrate = mc.mcProfileGetDouble(inst, 'PersistentDROs', 'droPLFeedRate', 1)
    mc.mcCntlSetLastError(inst, 'Set Feedrate')
    code2 = 'F ' .. Feedrate * 100 .. '\n'
    code2 = code2 .. 'G01 X5 Y5\n'
    code2 = code2 .. 'G01 X0 Y0\n'
    mc.mcCntlGcodeExecuteWait(inst, code2)
end

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

This sets the system Feedrate to 9IPM.  Do I have a setting wrong?  Seems like the only code that will run inside mc.mcCntlGcodeExecuteWait is simple.  This one is similar.  The G31 executes but the feedrate is a fraction what it is told to be.

Code: [Select]
function m200()
    local inst = mc.mcGetInstance()
    local Feedrate = mc.mcProfileGetDouble(inst, 'PersistentDROs', 'droPLFeedRate', 1)
    mc.mcCntlSetLastError(inst, 'Set Feedrate')
    code2 =  'G31 Z-2 F100\n'
    code2 = code2 .. 'G92 Z0\n'

    mc.mcCntlGcodeExecuteWait(inst, code2)
end

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

The Feedrate is running at 1IPM.  Also can't get any of this to actually run by calling the M code.  It runs in the editor, but not when the M code is called.
Re: Huge feedrate error
« Reply #1 on: June 12, 2016, 06:01:45 PM »
I should also mention that if I load a gcode file that has say...F100 in it, The feedrate sets properly.  This only seems to be happening using mc.mcCntlGcodeExecuteWait.  Also interesting is that no matter what I set the Feedrate variable to, it will not go higher than 9IPM.  I can say 'F3000' or 'F900000'.  Either way, the system feedrate gets set to 9IPM.
« Last Edit: June 12, 2016, 06:04:24 PM by rrc1962 »
Re: Huge feedrate error
« Reply #2 on: June 12, 2016, 07:47:23 PM »
So....I got this M code working.  Not sure what I did, but now it works one time.  If runs as it should, but to get it to run again, I have to shut down M4.   Most of the time, I have to use task manager to shut it down. 

Isn't there a way to trap runtime errors here?  It runs fine in the editor, so debugging there is of little use.

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Huge feedrate error
« Reply #3 on: June 12, 2016, 08:26:18 PM »
there is a post on the affect of each Gcode run type I will find it and post it. it's from one of the mach guys

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Huge feedrate error
« Reply #4 on: June 13, 2016, 04:11:51 AM »
Have you ever considered using the registry plugin (also can be persistent) and assign a register to your dro, this can then be retrieved from within the macro.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Huge feedrate error
« Reply #5 on: June 13, 2016, 09:07:21 AM »
Have you ever considered using the registry plugin (also can be persistent) and assign a register to your dro, this can then be retrieved from within the macro.

DazTheGas

Good idea.  I had not thought of that.  Could the feedrate also be set that way?  IE:  Assign the Feedrate DRO to a register and rather than posting 'F100' to mc.mcCntlGcodeExecuteWait(), just set the registry value assigned to the DRO.  Retrieving the feedrate value wasn't the problem.  Setting it was the issue.

I did get it working.  I knew the macro was running because is was setting last error.  I was just failing somewhere within.  I put message boxes after every line of code and ran it until the message boxes quit showing.  Turns out it was a case of a bad line of code.  The code looked fine and ran fine in the editor, just wouldn't run in real time.  I retyped what looked like an identical line and commented the first, and it ran fine.  This is the second time this has happened.