Machsupport Forum
Third party software and hardware support forums. => PoKeys => Topic started by: Tony Bullard 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
--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.
-
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?
-
Hi,
that is not VB, that is Lua....this has been written for Mach4.
Craig
-
Thank you Craig. I see now that SetFRO is the call to the function.
-
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
-
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)
-
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?
-
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?
-
"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.
-
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.
-
The 3 volt battery slot if for the RTC, real time clock. I suggest you read the Pokeys 57 user manual. https://www.poscope.com/wp-content/uploads/downloads/Pokeys/Manuals/PoKeys%20user%20manual%20(19.8.2017).pdf
If you have too much signal noise use a digital encoder for FRO as mentioned above.
-
On page 101 there is also a diagram for filtering the analog signal.
Apparently mine is not an isolated case.
The full control of the CNC (FEED+RAPID) is obtained only with a potentiometer, it is like opening/closing the tap on the sink.
-
I noticed that the Pokeys is very delicate and sensitive to disturbances from the electricity network.
so I tried to power with a battery, to have isolated power.
it works very well that way.
the system is very responsive and fast.
I made a short video.
https://m.youtube.com/watch?v=7d3OekCgyD0
now I have to find a way to effectively feed the Pokeys.
-
Something like this is what I use.
https://www.amazon.com/ALITOVE-100-240V-Converter-Security-Surveillance/dp/B07VQHYGRD/ref=sr_1_6?crid=3FUJSNNNO21AU&keywords=12%2BVolt%2BPower%2BSupply&qid=1672834471&s=electronics&sprefix=12%2Bvolt%2Bpower%2Bsupply%2Celectronics%2C86&sr=1-6&th=1
Cut the cord and connect it to the pokeys.
-
I tried as you advised.
Having servo drives, they tend to download spurious into the network, these are picked up by the Pokey.
The most stable system stays powered by a battery, but that was just a test.
I am convinced that if it had been a classic electronic stepper it would have created no problems.