Hello Guest it is March 29, 2024, 02:29:16 AM

Author Topic: Mach4 Pokeys 57E with FRO  (Read 3951 times)

0 Members and 1 Guest are viewing this topic.

Mach4 Pokeys 57E with FRO
« on: February 26, 2019, 12:57:39 PM »
I got the following code from a very well written example in the Pokeys Pluglins manual here:

https://www.poscope.com/wp-content/uploads/downloads/Pokeys/LibrariesAndPlugins/Mach4%20plugin%20user%20manual%20(5.2.2017).pdf

The code is from here:
blog.poscope.com/wp-content/uploads/2016/04/PoKeys_analog_FRO.zip

Code: [Select]
--Function to read value from analog register
function ReadRegister(device, analogPin)
    local inst = mc.mcGetInstance()
    local hreg = mc.mcRegGetHandle(inst, string.format("%s/Analog input %s", device, analogPin))
    return mc.mcRegGetValueString(hreg)
end

--Function to set FRO value
function SetFRO(analog)
    local percent = analog/1*250 --calculate percentage from 0% to 250%
    local inst = mc.mcGetInstance()
    mc.mcCntlSetFRO(inst, percent)
end

--Main
local device = "CNC controller" --Change this to the name of your PoKeys device
local analogPin = "41" --Analog input pin number

analogVal = ReadRegister(device, analogPin) --Save analog register value in variable
SetFRO(analogVal) -- Set FRO value in %

The instructions say to put this code almost at the end of the PLC script.
If all is set up properly in Mach4 does this code look like it might work? I’m new to coding but the variables don’t seem to match and the math is incorrect among other things.
Any help would be appreciated.
Re: Mach4 Pokeys 57E with FRO
« Reply #1 on: February 26, 2019, 01:28:03 PM »
I see now the that the analog value is 0 to 1, not the 12 bit  value of 0 to 4096 so the math is correct.

But what about the last two lines are they VB script for Mach3?
Re: Mach4 Pokeys 57E with FRO
« Reply #2 on: February 26, 2019, 04:31:34 PM »
Hi,
that is not VB, that is Lua....this has been written for Mach4.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Mach4 Pokeys 57E with FRO
« Reply #3 on: February 26, 2019, 04:45:14 PM »
Thank you Craig. I see now that SetFRO is the call to the function.
Re: Mach4 Pokeys 57E with FRO
« Reply #4 on: May 22, 2020, 04:50:37 PM »
this ist old with the manual pasting of code. in the newest version i suggest to use a encoder as FRO. watch here: https://youtu.be/iPAwvuvKkXk turn the subtitles on
Re: Mach4 Pokeys 57E with FRO
« Reply #5 on: January 01, 2023, 05:35:32 AM »
Hello,
I bought Pokeys57E to pair with ESS.
I'm trying to configure potentiometer for the FEED (FRO%)
in the PLC scrip I don't understand what I have to write in this string, and the syntax
SetFRO(analogVal)
« Last Edit: January 01, 2023, 05:38:46 AM by daniba73 »
Re: Mach4 Pokeys 57E with FRO
« Reply #6 on: January 01, 2023, 09:00:38 AM »
This is not what you asked for but there is an easier way to do it now. Set your Pokeys analog input pin, pot pin,  as shown on page 33 of Pokeys Mach4plugin_manual.pdf That's on Pokeys Device configuration / Pokeys pin mapping. Next enable Feedrate override and set its pin # and % of override on / Special functions. That's it. It works! See attachments. I think?
Re: Mach4 Pokeys 57E with FRO
« Reply #7 on: January 01, 2023, 04:10:16 PM »
Thanks, I did as you said and it works!
But now I have to solve a problem.
I explain what happens.
To do some tests on the fly I took these 5 volts from a PC USB socket (cut a common USB cable and use the red and black wires).
The board is normally powered with LED lighting.
I configure doors etc etc ... as usual .. nothing exceptional ..
I connect a potentiometer following the instructions...etc etc
so everything works...
let's get to the good....
as soon as i turn on the cnc servos, the potentiometer values start to oscillate...and the Mach4 slide wobbles..
I turn off the servo... everything returns stable...
other...
is it possible to add a digital shot? it is difficult to hit 100% with the potentiometer, it would be enough that from 98% to 102% the slide remains fixed on 100% is it possible?
« Last Edit: January 01, 2023, 04:13:44 PM by daniba73 »
Re: Mach4 Pokeys 57E with FRO
« Reply #8 on: January 02, 2023, 07:52:33 AM »
"To do some tests on the fly I took these 5 volts from a PC USB socket (cut a common USB cable and use the red and black wires).
The board is normally powered with LED lighting." So you're powering the board with 5 volts?

"I connect a potentiometer following the instructions...etc etc"  Is it connected to the boards 3.3v and board GND as stated in the Pokeys 57 user manual? Or is it connected to 5 volts from a PC USB socket? The analog input is not 5 volt tolerant and the 57E is not grounded to the PC.

"the potentiometer values start to oscillate" Read the Pokeys 57 user manual for low-pass filtering for analog inputs signal noise. There is an easy "slider" adjustment for it.
« Last Edit: January 02, 2023, 07:59:22 AM by Tony Bullard »
Re: Mach4 Pokeys 57E with FRO
« Reply #9 on: January 03, 2023, 03:02:00 AM »
I did further tests.
Powered with normal 5 volt switch.
changed ethernet cable.
potentiometer changed.
used short cable.
no result.
as soon as I power up the servo drive, the slide shakes.
to get sufficient stability I have to set the sensitivity slider all the way to the right.
consequently its control becomes slow and insensitive.
this defeats the purpose for which I bought this accessory.
request.
There is a 3-volt battery slot on the board.
what is it for?
I left blank.
Note.
potentiometer is connected correctly to pin 3.3volt.
« Last Edit: January 03, 2023, 03:06:52 AM by daniba73 »