New GUI for embedded systems

More
12 Sep 2018 14:36 #117403 by UnfinishedBusiness
Hello,

I'm working on a GUI written in C that outputs directly to the frame buffer and requires no dynamically linked GUI libraries. (Works without X). I own a company that manufactures CNC plasma cutters and we would like to develop what we are calling our Gen2 control that is completely embedded (A single circuit board that includes Linux SOC, stepper drivers, power supply, aux inputs, aux outputs, analog inputs, etc). I've read some posts around here with some folks mentioning that these embedded systems are "toys" and I agree to the extent that most readily-available embedded systems like Rasberry Pi or BeagleBone are not an industrial duty system at all and not meant to operate in industrial conditions. I want to note here that our "Mainboard" has been developed in-house and is *very industrial*. Having a single board is very attractive to us for several reasons but mostly because it will allow us to support our hardware under a direct replacement warranty and not have to troubleshoot between control wiring, drivers, interface board, and external computer hardware issues...

We would like to release this GUI as open source and it will be compatible with virtually any architecture that Linux has been ported too, Raspberry Pi and BeagleBone are included in that. It will include a "CAD & CAM" module that will integrate into our cloud-based CAD/CAM system (Will also work offline, just without cloud access to drawings and job files) so drawing parts, creating toolpaths, and posting Gcode can all be done without leaving the GUI, or open Gcode files posted from other CAM systems...

Right now I have a working DRO, indicators for some inputs, and jogging working. I have these working by using "system" commands to interface to halcmd. This is not a great solution but I seem to be having a hard time finding documentation to interface to the rtapi via C. I know the python bindings are written in C so this should be fairly straightforward.

Is there anyone here with in-depth knowledge of the rtapi that would be interested in helping a little bit with this?

Thanks,
Travis
Attachments:

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

More
12 Sep 2018 15:15 #117408 by andypugh
Looking at the (no longer included, but very simple) emclcd GUI, that seems to do jogging by #including shcom.hh

github.com/LinuxCNC/linuxcnc/blob/2.6/src/emc/usr_intf/shcom.hh

For example, here it jogs axes by using sendJogCont:
github.com/LinuxCNC/linuxcnc/blob/2.6/sr...intf/emclcd.cc#L1134

The basic interaction mode in LinuxCNC is NML messaging, and shcom seems to be an easy way to do this (if C++ headers are valid in a C file)

Looking at the documents, though, it seems to say that one should use motion.h
www.linuxcnc.org/docs/2.7/html/code/code-notes.html#_commands

And looking at the file, it does seem to contain all the commands that a GUI would need:
github.com/LinuxCNC/linuxcnc/blob/2.6/src/emc/motion/motion.h
The following user(s) said Thank You: bkt

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

More
12 Sep 2018 17:33 - 12 Sep 2018 17:33 #117414 by UnfinishedBusiness
andypugh - Thanks for the quick reply!

I looked through everything you pointed me too but I'm still not sure how to attack this.

shcom.hh is not available at /usr/include/linuxcnc

motion.h is and my code compiles with it included but I'm not sure where to go from there because motion.c doesn't seem to include any functions to init NML and send messages.

I'm linking with -lnml which seems to work but I haven't found any documentation on how to use libnml.

Right now my approach with halcmd and popen works. Is there a way I can turn off estop and enable machine power from halcmd?

Also is there a way to pump g-code into linuxcnc via halcmd or another terminal program? Maybe I can stick with this approach
Last edit: 12 Sep 2018 17:33 by UnfinishedBusiness.

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

More
12 Sep 2018 17:53 #117416 by Grotius
Hi Travis,

Join the forum. I hope you can bring knowledge and bring linuxcnc to higher market level.

Wich company do you own? Microstep, Swiftcut or maybe Purelogic? B)

Also is there a way to pump g-code into linuxcnc via halcmd or another terminal program?
G-code is done by the g code interpreter only. It's a block of linuxcnc.

Is there a way I can turn off estop and enable machine power from halcmd?
E stop and power on in linuxcnc simulation mode can be done with keyboard shorcut's like F2 & F3 or via touch screen or
screen select with mouse click. If you have custom gui, you have to do keybindings.

My advise is, look at the gnipsel gui. For me it's almost impossible to write linuxcnc in C in one lifetime.

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

More
12 Sep 2018 17:59 #117417 by andypugh
I think that you might need to subscribe to the developers mailing list to get answers to the sort of question that you are asking.

Look at the "Community" link at the top of the page.

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

More
12 Sep 2018 18:10 #117418 by Grotius
Andy,

I think that is a good idea.

If Travis is capable of writing linuxcnc only in C, i'm sure i help him with development of this version.
If i look at the code we have today, i am satisfied. I have what i wanted, i only miss a cam system.
But Travis has a online cam system... Maybe something like dassault systems?

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

More
12 Sep 2018 19:26 #117422 by UnfinishedBusiness
andypugh - I may subscribe to the mailing list later on but I think I figured out a good solution.

grotius - I'm going to send you a PM, I don't want to use this forum to advertise my company.

I found a solution to my questions. I'm going to use the python library to execute python code from inside the C code of my GUI. It seems funny to go C GUI->python->C python bindings->LinuxCNC when I could just go C GUI->LinuxCNC but right now the python interface is pretty well documented so I'm going to go this route for now. It seems to be working well, I'll make the Github repository public once I have a GUI up and running.

Thanks!

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

More
12 Sep 2018 19:30 #117423 by andypugh
It would probably make more sense to make a thin shim layer between your C and the C++ API.

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

More
12 Sep 2018 19:42 #117425 by UnfinishedBusiness
I agree but the documentation is really hard to get through and come up with something that works. If you can come up with an example of c++ code that uses includes from /usr/include that initiates an NML interface and speaks of how to actually send commands across I'd love to see it but I've already spent 10 hours today digging and I'm empty handed. The python method is a little bulky and is now the only externally linked library my gui needs in order to compile, so I would love to ditch this method.

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

More
12 Sep 2018 22:21 - 12 Sep 2018 22:52 #117434 by Grotius
Hi,

Here a example how to :
emc-users.narkive.com/44bLaS4j/controlli...nally-with-c-program
Anyway, here's a complete program that uses the C++ interface to log the
position at about 10Hz:

#include "emc.hh"
#include "emc_nml.hh"
#include <unistd.h>
#include <iostream>
#include <cstdlib>

int main(int argc, char **argv) {
if(argc < 2) { std::cerr << "Usage: " << argv[0] << " NMLFILE\n"; abort(); }
const char *nmlfile = argv[1];
RCS_STAT_CHANNEL *stat = new RCS_STAT_CHANNEL(emcFormat, "emcStatus", "xemc", nmlfile);
while(1) {
usleep(100*1000);
if(!stat->valid()) continue;
if(stat->peek() != EMC_STAT_TYPE) continue;
EMC_STAT *emcStatus = static_cast<EMC_STAT*>(stat->get_address());
std::cout << emcStatus->motion.traj.position.tran.x << " "
<< emcStatus->motion.traj.position.tran.y << " "
<< emcStatus->motion.traj.position.tran.z << "\n";
}
return 0;
}

Provided by the Bird, 5 years ago.

What i found important in this conversation :

If you want to dig into it, look at the sources for xemc, halui &
halcmd. They will uncover most of the calls and show how they are used


Halui will be the most usefull to start with i think.

The source code of Halui.cc :
github.com/michelwijnja/external_offsets...mc/usr_intf/halui.cc

If you change this file in your application, you can test your connection's quite easy.

Halui pins : linuxcnc.org/docs/html/man/man1/halui.1.html you can use them with the halcommand line for quick test's.

In you ini file :
[HAL]
HALUI = halui

For example i think when you copy and rename the halui source code to "test" and compile linuxcnc again.
Your ini can look like :

[HAL]
HALUI = test

Then your pin names are test.program.run and so on.

If this works, you can delete some linuxcnc part's step by step to make a c or c++ coded user interface.
Last edit: 12 Sep 2018 22:52 by Grotius.

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

Time to create page: 0.281 seconds
Powered by Kunena Forum