Matrix Keyboard controlling LinuxCNC
- AlexMagToast
- 
				 Topic Author Topic Author
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 93
- Thank you received: 69
			
	
						23 Jul 2023 12:46				#276068
		by AlexMagToast
	
	
		
			
	
	
			 		
													
	
				Matrix Keyboard controlling LinuxCNC was created by AlexMagToast			
			
				Hey Guys,
i already wrote about the userspace Component to use an Arduino for IO Expansion.
One guy on my Discord asked if it could be used for Matrix based Keyboards aswell. Often times professional HMI devices use Matrixkeyboards for the Keys and Buttons. For example TMC 420 or Siemens Sinumerik 840C.
So i added Matrixkeyboard support. It can create pins in hal to control LinuxCNC IO's aswell as emulate Keystrokes in Linux, therefore it is possible to use some Keys for LinuxCNC Stuff (for example run Spindle etc) or Input Keystrokes (to input gcode commands for example). All with one Matrix Keyboard and one Arduino.
Funny enough the guy that originally asked me now won't respond anymore, so i would be interested if somebody else might find this useful and is willing to test it with me.
I think the configuration is quite easy, but might be a bit overwhelming first. Just hit me up and we'll get it to work together.
Here is the link to the software if you want to take a look at it.
github.com/AlexmagToast/LinuxCNC_ArduinoConnector
Cheers,
Alex
					i already wrote about the userspace Component to use an Arduino for IO Expansion.
One guy on my Discord asked if it could be used for Matrix based Keyboards aswell. Often times professional HMI devices use Matrixkeyboards for the Keys and Buttons. For example TMC 420 or Siemens Sinumerik 840C.
So i added Matrixkeyboard support. It can create pins in hal to control LinuxCNC IO's aswell as emulate Keystrokes in Linux, therefore it is possible to use some Keys for LinuxCNC Stuff (for example run Spindle etc) or Input Keystrokes (to input gcode commands for example). All with one Matrix Keyboard and one Arduino.
Funny enough the guy that originally asked me now won't respond anymore, so i would be interested if somebody else might find this useful and is willing to test it with me.
I think the configuration is quite easy, but might be a bit overwhelming first. Just hit me up and we'll get it to work together.
Here is the link to the software if you want to take a look at it.
github.com/AlexmagToast/LinuxCNC_ArduinoConnector
Cheers,
Alex
		The following user(s) said Thank You: tommylight, besriworld, panming 	
			Please Log in or Create an account to join the conversation.
- cakeslob
- Offline
- Platinum Member
- 
				  
		Less
		More
		
			
	
		- Posts: 922
- Thank you received: 275
			
	
						25 Jul 2023 00:44				#276189
		by cakeslob
	
	
		
			
	
			
			 		
													
	
				Replied by cakeslob on topic Matrix Keyboard controlling LinuxCNC			
			
				are you using this with a sinumerik 840 specifically? or is this just an example of the keypad matrix? 
I just checked, it looks like I have a sinumerik 840 so I am wondering.
					I just checked, it looks like I have a sinumerik 840 so I am wondering.
Please Log in or Create an account to join the conversation.
- AlexMagToast
- 
				 Topic Author Topic Author
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 93
- Thank you received: 69
			
	
						27 Jul 2023 09:37				#276358
		by AlexMagToast
	
	
		
			
	
			
			 		
													
	
				Replied by AlexMagToast on topic Matrix Keyboard controlling LinuxCNC			
			
				it will work with all Matrix based Keyboards.
If your willing to try we can create an configuration for your keyboard and test it.
Would you be able to hook it up to an arduino?
					If your willing to try we can create an configuration for your keyboard and test it.
Would you be able to hook it up to an arduino?
Please Log in or Create an account to join the conversation.
- panming
- Offline
- Senior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 48
- Thank you received: 11
			
	
						02 Sep 2023 05:23				#279644
		by panming
	
	
		
			
	
	
			
			 		
													
	
				Replied by panming on topic Matrix Keyboard controlling LinuxCNC			
			
				hello,I'm trying to drive this matrix keyboard, which has LED lights in parallel, similar to matrix keyboards and matrix LEDs in one, and scan lines are common.
I tried to write the Arduino code following the example you gave, but I didn't know anything about programming, worked hard for a long time, and almost gave up.
Below is its schematic
					I tried to write the Arduino code following the example you gave, but I didn't know anything about programming, worked hard for a long time, and almost gave up.
Below is its schematic
Please Log in or Create an account to join the conversation.
- AlexMagToast
- 
				 Topic Author Topic Author
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 93
- Thank you received: 69
			
	
						12 Sep 2023 09:07				#280529
		by AlexMagToast
	
	
		
			
	
			
			 		
													
	
				Replied by AlexMagToast on topic Matrix Keyboard controlling LinuxCNC			
			
				Hi, Sorry for the late reply.
If i understand correctly, besides the matrix keyboard, there are also multiplexed LEDs in the Keyboard.
The LEDs Light up, when OUT0 is HIGH and OUT8 is Low, right? Are resistors already in place for the LEDs?
What kind of hardware do you have? I'd be interested to learn more about it.
I'll try to help you and see how i can implement the LEDs for you.
How do you want the keys to behave?
					If i understand correctly, besides the matrix keyboard, there are also multiplexed LEDs in the Keyboard.
The LEDs Light up, when OUT0 is HIGH and OUT8 is Low, right? Are resistors already in place for the LEDs?
What kind of hardware do you have? I'd be interested to learn more about it.
I'll try to help you and see how i can implement the LEDs for you.
How do you want the keys to behave?
Please Log in or Create an account to join the conversation.
- panming
- Offline
- Senior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 48
- Thank you received: 11
			
	
						13 Sep 2023 01:15				#280587
		by panming
	
	
		
			
	
	
			
			 		
													
	
				Replied by panming on topic Matrix Keyboard controlling LinuxCNC			
			
				I log in to the forum on time every day to wait for your reply, fortunately I waited. Hahaha.
Yes.When OUT0 is high and OUT8 is low,the LED named O64 will be on. When OUT8 is low and the button named I64 is pressed,Arduino will get the signal.BTW,With my knowledge of electronics, LEDs have two functions here, the first indicates some kind of signal from the linuxcnc, and the second is to prevent the fourth case from being misidentified when three keys are pressed at the same time.
I'm using arduino mega 2560.
This panel is from SYNTEC, a CNC controller manufacturer from Taiwan.
Add in the photos of it at work, and maybe you will know the specific use.
					Yes.When OUT0 is high and OUT8 is low,the LED named O64 will be on. When OUT8 is low and the button named I64 is pressed,Arduino will get the signal.BTW,With my knowledge of electronics, LEDs have two functions here, the first indicates some kind of signal from the linuxcnc, and the second is to prevent the fourth case from being misidentified when three keys are pressed at the same time.
I'm using arduino mega 2560.
This panel is from SYNTEC, a CNC controller manufacturer from Taiwan.
Add in the photos of it at work, and maybe you will know the specific use.
Please Log in or Create an account to join the conversation.
- panming
- Offline
- Senior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 48
- Thank you received: 11
			
	
						13 Sep 2023 01:33				#280588
		by panming
	
	
		
			
	
	
			 		
													
	
				Replied by panming on topic Matrix Keyboard controlling LinuxCNC			
			
				the resistors already exist, it's just that the schematic omits them
I want linuxcnc to have input and output pins corresponding to the number of buttons, so that I can control each LED and button independently. For example, when the spindle is turned on in the virtual panel or MDI or some other way, the LED under the spindle button will light up.
Heartfelt thanks.
					I want linuxcnc to have input and output pins corresponding to the number of buttons, so that I can control each LED and button independently. For example, when the spindle is turned on in the virtual panel or MDI or some other way, the LED under the spindle button will light up.
Heartfelt thanks.
		The following user(s) said Thank You: AlexMagToast 	
			Please Log in or Create an account to join the conversation.
- AlexMagToast
- 
				 Topic Author Topic Author
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 93
- Thank you received: 69
			
	
						13 Sep 2023 10:40				#280617
		by AlexMagToast
	
	
		
			
	
			
			 		
													
	
				Replied by AlexMagToast on topic Matrix Keyboard controlling LinuxCNC			
			
				ah i see. The Matrix keyboard should already work.
Currently you can choose between modes for each key,
1. Input Pin in LinuxCNC
2. emulated Keypress. -> for example Numbers, Letters, Enter, Shift, delete and so on like an "normal" Keyboard"
3. typing of text. For example you can go to MDI and select the command field. Then press a button, which would enter a string, for example "M6 G43 T". You could then enter a number with number keys in mode 2. and Enter with another Key.
I started implementing another mode for multiplexed LEDs. I can't really test it. Would you be open to test it for me?
					Currently you can choose between modes for each key,
1. Input Pin in LinuxCNC
2. emulated Keypress. -> for example Numbers, Letters, Enter, Shift, delete and so on like an "normal" Keyboard"
3. typing of text. For example you can go to MDI and select the command field. Then press a button, which would enter a string, for example "M6 G43 T". You could then enter a number with number keys in mode 2. and Enter with another Key.
I started implementing another mode for multiplexed LEDs. I can't really test it. Would you be open to test it for me?
Please Log in or Create an account to join the conversation.
- panming
- Offline
- Senior Member
- 
				  
		Less
		More
		
			
	
		- Posts: 48
- Thank you received: 11
			
	
						13 Sep 2023 11:59				#280621
		by panming
	
	
		
			
	
			
			 		
													
	
				Replied by panming on topic Matrix Keyboard controlling LinuxCNC			
			
				I haven't tested whether the matrix keyboard part can work, but I guess it should work normally with a high probability. Because I recommended it to several of my friends, and they all said it was very good.
I can provide everything I can. You can tell me if you need anything.
					I can provide everything I can. You can tell me if you need anything.
Please Log in or Create an account to join the conversation.
- AlexMagToast
- 
				 Topic Author Topic Author
- Offline
- Premium Member
- 
				  
		Less
		More
		
			
	
		- Posts: 93
- Thank you received: 69
			
	
						13 Sep 2023 16:35				#280647
		by AlexMagToast
	
	
		
			
	
	
			 		
													
	
				Replied by AlexMagToast on topic Matrix Keyboard controlling LinuxCNC			
			
				Hi,
check out this Code: github.com/AlexmagToast/LinuxCNC_Arduino...or/tree/keyboard_dev
I've added a function to drive multiplexed LEDs. I think it might work.
Around line 286 there are two settings:
const int LedVccPins[] = {0,1,2,3,4,5,6,7};
const int LedGndPins[] = {8,9,10,11,12,13,14};
The numbers correspond to the OUT pins on your drawing. please change them to how you connect the keyboard to the arduino.
I've implemented the python part also, but never tested it. Might work, but propably not
I guess it makes sence to test the arduino first.
To test could you please wire the arduino up with the keyboard,
connect it to ArduinoIDE and open Serial Monitor.
Send E0:0
After that by sending M0:1 the first LED should turn on.
Each LED is identified by a number, from 0- (rows*columns in your case 55).
You can adress it with the number behind M. The number behind : defines the State. So M5:1 turns on LED the 6. Led in the matrix.
M5:0 should turn it off.
If this works you can try if by chance the python part works too.
i am curious about your Results.
-Alex
					check out this Code: github.com/AlexmagToast/LinuxCNC_Arduino...or/tree/keyboard_dev
I've added a function to drive multiplexed LEDs. I think it might work.
Around line 286 there are two settings:
const int LedVccPins[] = {0,1,2,3,4,5,6,7};
const int LedGndPins[] = {8,9,10,11,12,13,14};
The numbers correspond to the OUT pins on your drawing. please change them to how you connect the keyboard to the arduino.
I've implemented the python part also, but never tested it. Might work, but propably not

I guess it makes sence to test the arduino first.
To test could you please wire the arduino up with the keyboard,
connect it to ArduinoIDE and open Serial Monitor.
Send E0:0
After that by sending M0:1 the first LED should turn on.
Each LED is identified by a number, from 0- (rows*columns in your case 55).
You can adress it with the number behind M. The number behind : defines the State. So M5:1 turns on LED the 6. Led in the matrix.
M5:0 should turn it off.
If this works you can try if by chance the python part works too.
i am curious about your Results.
-Alex
		The following user(s) said Thank You: besriworld 	
			Please Log in or Create an account to join the conversation.
		Time to create page: 0.087 seconds	
 
													 
	