Hi, so i started messing around with arduino about 3 weeks ago because im a machinist, and would like to have an mpg or (jog pendant) for my CNC. None of the generic mpg's online quite fit what i was looking for, so i started researching how to make my own and came across a way to use an arduino leonardo to make a button box and also an instructables describing what needs to happen in order for everything to work. Basically, what needs to happen is each button on the mpg needs to send a keystroke to the computer running the machine, and the computer needs to be programmed to read the keystroke and perform an action based off of whatever key is sent. The problem I'm having is id like to have 2 potentiometers controlling the spindle speed and table speed, but im not sure how i would send an analog value as a keystroke, or if there's possibly another way of performing the same function. I have a little bit of control on the other end, as i have to edit the screen script on the CNC software to obey they keyboard commands sent by the arduino, but that doesn't mean anything if there's no way to send digital signals from an analog read. Would i be better off just using an "up" and "down" button to control the value? Or could i use something like the "map" function or "if else" statements to kind of make a half-assed ADC? Any help would be greatly appreciated. Also don't know if its important or not, but the CNC software is Mach4.
-Thanks
It seems to me that the only option is UP & DOWN keystrokes
If your system has a mouse - you can try to map potentiometer signal to the mouse coordinates.
Welcome to the forum
Your query
sounds like the opposite of the title that you gave this topic, ie a keystroke from an analogue value
A keystroke is what its name implies, ie a single key value so it cannot be an analogue value (0-1023) any more than you could type a value from 0 to 1023 by pressing a single key on the keyboard.
However, depending on the ability of the receiving system to decode and act on what it receives you could send a series of keystrokes much as you would type 1023 on the keyboard and send 4 characters
There is no reason why you should not send single keystrokes representing up/down or increase/decrease as long as they can be interpreted and acted upon
Incidentally, your first post was difficult to read because it is a single slab of text so I may have got the wrong idea about your question. Consider splitting it into paragraphs with a blank line between them to make it easier to read
Forget the arduino for moment. How would you otherwise set the spindle speed? Is by entering data from the keyboard?
I would type the rpm manually and it would start once i run the program. I suppose i didnt completely clarify what the pot would be used for. Its not for "setting" the spindle speed as much as it will be overriding the current rpm. I'm looking for a quick way to adjust the rpm on the fly without having to run over to the computer to stop the program and re-entering a new value, or mess with a slider icon in the software. sorry, could've been a bit more descriptive.
It's funny you say that.. I've been told before that I need to split my posts up into paragraphs, but the dude that said it was also a bit of an ass about how he said it, so I just figured he was trying to talk trash to someone. I'll take you up on the advice though.
Anyways, I never thought about the mouse or even the mouse wheel. I'll definitely see if there's a way to program the software to use that as a valid input.
I'm doing all I can to avoid using the "up arrow" and "down arrow" since those are already mapped to the jog encoder. I guess if I need to, I can use them with a modifier key.
You can use any key to indicate up and down and have the receiver translate what it receives into an appropriate action
You can program some arduino boards (ProMicro, Black Pill, Leonardo I think) to act as a keyboard, so pretty much anything a keyboard could do, so would the arduino. If you wanted to take input from a potentiometer and use that to set a numeric speed into Mach, that can be done.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.