Data transfer LinuxCNC to / from custom board - Solved

More
05 Jul 2024 09:55 - 05 Jul 2024 13:49 #304447 by slowpoke
Hi,
Thanks to a lot of help from members here I now have my knee mill fully operational. Next task is to make some sort of mostly push-button user interface that I will mount to the belt cover. I prefer pushing buttons than mouse clicking for repetitive tasks. Conceptual sketch is below.

I will use an ARM uC that has a USB support and I could configure it as a HMI device (basically emulate keyboard presses), for example pressing the Green Power button will send a "F2" to LinuxCNC via a USB port. I think there are keystrokes for most if not all of the buttons shown below?

The display is also a touchscreen and I'm hoping to leverage that to emulate additional buttons/keystrokes based on how the machine is being used for example having buttons for common commands like G0, G1 etc.

It would also be good if I could display things like alarms on this display for example if a limit switch gets activated it could pop up an error on this display.  I imagine there is likely more than one way to accomplish that.  What would be the best way to get say a limit switch error message from LinuxCNC back to this board?

BTW I'm using the axis interface and a MESA 7i95t if that matters.

Thanks in advance
Edit, added a couple more images.
 
 
Attachments:
Last edit: 05 Jul 2024 13:49 by slowpoke.

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 10:09 #304449 by andypugh
Keystrokes are a pretty bad way to interface to LinuxCNC.

Can I suggest that you consider a Mesa 7i73 ? That can interface the control panel directly into the realtime layer of LinuxCNC.
store.mesanet.com/index.php?route=produc...oduct&product_id=116

It's probably not as much fun as your custom board, but it will work out of the box.

There is a strange HAL component that I wrote that might help if you choose to go your own way. It's strange because it does two completely different things in one component.
linuxcnc.org/docs/stable/html/man/man9/matrix_kb.9.html
The side that might help you is converting scancodes into HAL pins.
The following user(s) said Thank You: slowpoke

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 13:30 #304465 by slowpoke
Andy,

Thanks for the input, I have a few questions. Keep in mind I'm not a software guy, I can write embedded C type stuff but have no clue about the Linux kernel or anything related to that. I did with some help interface a few pins to the 7i95t by tweaking a HAL file.

I hope you don't mind but I will ask specific questions so I can fill in the knowledge blanks I have at the moment, here goes:

Regarding the 7i73:
1) I guess that you connect the 7i73 RS-422 interface to a serial port of the Linux PC, and then enable some sort of 7i73 driver in LinuxCNC that magically establishes the communication link between the two?
2) With the link established data transfer then happens quickly and automatically, if for example a pin changes status on the 7i73 a register in the kernel is updated?
3) How does one map the various 7i73 inputs to the desired action in the kernel?
4) I guess the values in the kernel registers can also be mapped to drive the outputs of the 7i73?
5) I'm guessing the mapping (3-4) is done in a HAL file?

Regarding the matrix_kb9 approach:
6) If I don't use a 7i93, it's not obvious how I would get the integers into the kernel hardware wise?

Thanks,
Jeff

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 13:56 - 05 Jul 2024 14:12 #304467 by cornholio
The 7i73 connects to the Smart serial port on your Mesa card. Talking about the "kernel" in this instance can be a bit confusing. Basically its easier if you think about "talking" to Linuxcnc as that is basically the source & destination.
I think the 7i93 would require a suitable daughter card with the SSerial interface on it, something like a 7I44 (although there are other options it just depends how far you want to delve into DIY forum.linuxcnc.org/show-your-stuff/48185-m-e-s-s-i-board is an example whilst shown for a 7i92 the Mesa Infrastructure is great).
I see in your first post you mention 7i95T
Having a read of the 7i73 Mesa manual will help in understanding how it all goes together.

hm2_7i92.0.7i73.1.3.input-10-not

Input number 3 not (input 3 inverted)
connected to the 3rd channel on sserial port 1 (each port can have up to 8 channels)
connected via a 7i92 card

The 7i73 will have a bunch of other inputs, outputs, encoder pins exported, plus a few others depending on how you config the board on startup.

Data transfers happen in the hm2 read & write functions of your card in the servo thread, which is setup in your hal file.

The docs give a better explanation.
linuxcnc.org/docs/2.9/html/man/man9/sserial.9.html#7I73

This is what I think wold need doing.
To connect directly to a serial port of your computer it would have to be hardware port (not USB), you would be limited to 115200 baud unless you have an exotic hi speed card (smart serial operates at 2.5M), someone would have to write a realtime driver for the port that handles the comms to the 7i73, not the easiest of jobs, would require reading and understanding the protocol used and implementing it as well.
Last edit: 05 Jul 2024 14:12 by cornholio.
The following user(s) said Thank You: slowpoke

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 14:26 #304470 by cornholio
Alpologies to Andy for jumping in.

3rd channel should read “channel number 3”
It’s actually “input number 10” not 3.

Sorry it’s late Down Under.
The following user(s) said Thank You: slowpoke

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 17:25 - 05 Jul 2024 17:29 #304480 by slowpoke
Everyone is welcome to join in, the more answers / ideas the better.

We're off to a good start.

One other thing I realize everyone uses their machine in a slightly different way so what's important to one might not be to another that being said if you think " he's obviously missing the ??? Button everyone needs that" let me know I'm at the blue sky phase so welcome to change.

Thanks again.
Last edit: 05 Jul 2024 17:29 by slowpoke.

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 19:52 #304488 by tommylight
Another wrench in the machine:
Mesa 7i73, RS422 use differential signaling, pretty sure there is no serial that can do that, but still could be done using some line drivers, that implies using intermediary boards, lots of wiring mess, ...
Normal serial ports do 115K as Cornholio mentined, ESP32 can do much more through USB to serial using it's built in whatever it uses.
Did anyone check if Mesa 7i73 can be made to communicate at lower speeds?
Aaaand arduino jumps in... :)
Do you have a 7i93 mentioned above?
Forgot what 7i93 does, so i'll go hide under a rock.
The following user(s) said Thank You: slowpoke

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 23:09 #304499 by cornholio
Yeah the 7i73 can do 115200, and few others, but they are nvram values so it’s something Mesa might have to set pre delivery.

Please Log in or Create an account to join the conversation.

More
05 Jul 2024 23:32 #304503 by PCW

1) I guess that you connect the 7i73 RS-422 interface to a serial port of the Linux PC, and then enable some sort of 7i73 driver in LinuxCNC that magically establishes the communication link between the two?

No, the 7I73 connects to one of the 7I95s two RS-422 interfaces.
The following user(s) said Thank You: slowpoke

Please Log in or Create an account to join the conversation.

More
07 Jul 2024 20:26 - 07 Jul 2024 20:33 #304603 by slowpoke

Keystrokes are a pretty bad way to interface to LinuxCNC.

Can I suggest that you consider a Mesa 7i73 ? That can interface the control panel directly into the realtime layer of LinuxCNC.
store.mesanet.com/index.php?route=produc...oduct&product_id=116

It's probably not as much fun as your custom board, but it will work out of the box.

There is a strange HAL component that I wrote that might help if you choose to go your own way. It's strange because it does two completely different things in one component.
linuxcnc.org/docs/stable/html/man/man9/matrix_kb.9.html
The side that might help you is converting scancodes into HAL pins.


 

Andy,
I'm exploring the various ways to get data to and from Linux to my board. I already have hard wires connections for EStop, and machine power.

Focusing for the moment on data from my board to Linux I made a table of the 50 or so button presses that I would need to send, and from playing with a Axis and a regular keyboard using showkey it seems there is a hot key or key sequence that covers all 50 buttons that I anticipate using. There are a few anomalies that requires sending two key strokes or in the case of the jog increment keeping track of how many I's or shift- I's were sent so that has the potential to get out of sync, but other than that it seems really straightforward to just have my little on board uC scan my buttons and send the key or key sequences based on the keycode in the table below.

I found the table "most Common Keyboard Shortcuts" in the Axis documentation.
Do you know if there are additional commands documented elsewhere?

When you say it's a pretty bad idea to do this perhaps there is something I have overlooked?.

The Mesa 7i73 is interesting, but probably not a good fit for this project for a couple of reasons:
1) Physically if mounted as a daughter board would make the overall board depth thicker than I want.
2) I want to use the little touchscreen as I have used it before and it allows easy GUI enhancement in the future for things I can't anticipate now.

Assuming this will work for data to Linux, I now need to put my thinking cap on to figure out how to best get the Linux status data I would like to use back to my board so I can optimize the GUI. Jog Increment value would be a good start, I need to make a list.
 
Attachments:
Last edit: 07 Jul 2024 20:33 by slowpoke.

Please Log in or Create an account to join the conversation.

Time to create page: 0.120 seconds
Powered by Kunena Forum