Re: [Emc-users] Python question

2020-12-16 Thread John Dammeyer
> From: Chris Albertson [mailto:albertson.ch...@gmail.com]
> 
> For me this was a good example.  I wanted to write a userspace
> pendent interface.  Assuming you have created a pin object as "h", the
> pin's input is read as h.in and you can set h.out to set the output.   The
> link below is a sample program that copies a pin's input to its output.  So
> it shows both reading and writing.
> http://linuxcnc.org/docs/html/hal/halmodule.html#_driving_bidirectional_hal_io_pins
> 

The key thing is the python hal component.  
Do you know where the source code is for that?
John

> On Wed, Dec 16, 2020 at 3:41 PM  wrote:
> 
> > With the great help on list and off I'm having some progress.
> >
> > When debugging it is very convenient to be able to run a program in a
> > terminal window. Doing so immediately shows syntax errors. The program can
> > talk to an Arduino listening on a USB simulated serial port and can create
> > pins that can be displayed or set in halcmd. A ctrl-C closes things. The
> > only remaining problem is that I have not found a way to read values from
> > existing HAL pins in order to get axis positions and other useful
> > information. Halcmd and other programs can display the value of any pin. Is
> > reading pins created by another program not supported in python or am I
> > just missing a vital incantation?
> >
> >
> >
> > ___
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
> >
> 
> 
> --
> 
> Chris Albertson
> Redondo Beach, California
> 
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Python question

2020-12-16 Thread Chris Albertson
For me this was a good example.  I wanted to write a userspace
pendent interface.  Assuming you have created a pin object as "h", the
pin's input is read as h.in and you can set h.out to set the output.   The
link below is a sample program that copies a pin's input to its output.  So
it shows both reading and writing.
http://linuxcnc.org/docs/html/hal/halmodule.html#_driving_bidirectional_hal_io_pins

On Wed, Dec 16, 2020 at 3:41 PM  wrote:

> With the great help on list and off I'm having some progress.
>
> When debugging it is very convenient to be able to run a program in a
> terminal window. Doing so immediately shows syntax errors. The program can
> talk to an Arduino listening on a USB simulated serial port and can create
> pins that can be displayed or set in halcmd. A ctrl-C closes things. The
> only remaining problem is that I have not found a way to read values from
> existing HAL pins in order to get axis positions and other useful
> information. Halcmd and other programs can display the value of any pin. Is
> reading pins created by another program not supported in python or am I
> just missing a vital incantation?
>
>
>
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>


-- 

Chris Albertson
Redondo Beach, California

___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] 7i96 multi wire input

2020-12-16 Thread Gene Heskett
On Wednesday 16 December 2020 17:42:58 Sven Wesley wrote:

> Den tors 10 dec. 2020 kl 15:31 skrev Gene Heskett 
:
> > But, I'll also state that my way is not the only way, There are
> > (N-1)! ways to do it where N is the number of inputs you need to
> > smunch into one wire to stop LCNC, and ! is the factorial symbol.
> > And could be expanded to handle more fault sources easy enough as
> > long as they all worked alike. With "work alike" defined as turning
> > on an isolated switch when it faults.
> >
> > Take care Sven.
> >
> > Cheers, Gene Heskett
>
> Turns out it's all fine to run them all together. Got this drawing
> from the designer of the driver.
>
>
> [image: error-line.jpg]

That is all fine if you don't care which driver did it, or simply don't 
have enough i/o and you can go inspect the drivers to see which one got 
the tummy ache. I did mine individually because I had the i/o to throw 
away, and still do, probaly 40 unused i/o's yet. And while the drivers 
are accessible, its not all that convenient.  Safety wise, this is 100% 
functional.

Cheers, Gene Heskett
-- 
"There are four boxes to be used in defense of liberty:
 soap, ballot, jury, and ammo. Please use in that order."
-Ed Howdershelt (Author)
If we desire respect for the law, we must first make the law respectable.
 - Louis D. Brandeis
Genes Web page 


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Python question

2020-12-16 Thread John Dammeyer
Quick question.  On the MDI screen in Axis does the HALUI connection set the 
Active G-Codes: field with a reply?

So if an M7 is sent M7 shows up.  If an M8 is sent the M8 shows up.  And if 
both coolants are switched off with the M9 we see the M7 M8 vanish and replaced 
with M9.  
The 
http://linuxcnc.org/docs/html/gcode/m-code.html#mcode:m7-m8-m9
Says that these are linked directly to the iocontrol.0.coolant-mist or flood 
pins.

I'm asking because again on the User control screen we can switch the spindle 
on and change the speed but the Sx and Mx values don't show up in the Active 
G-Codes.

So it's like the user screen has a back door into LinuxCNC different from the 
G/M codes.  And that's why we have that override issue where spindle is turning 
from the user screen but no M3/4 in effect so when an S1000 is issued on the 
MDI the spindle stops.  Which is correct but I question then the user screen 
and how it's done.

In a way I understand.  After all there isn't a G code for jogging an axis.  

But the Coolant check boxes work differently again suggesting the Active 
G-Codes: list is upated whenever an MDI command is sent.  Give this a try to 
see what I mean.
In the AXIS screen check both Flood and Mist.  Then go to the MDI screen.  Note 
the Active G-Codes still says M9.
Now on the command screen enter an M7 to turn on MIST.   Go back to the MDI 
screen.  Notice the M9 is gone but there's both an M7 and an M8.  So it appears 
to be correctly reporting two outputs.  The M7 on an already on M7 doesn't 
change anything.

So then we're back to this spindle issue.  If the spindle is turning clockwise 
at 500 RPM from the command window and an S1000 is issued from the MDI then 
shouldn't the reported status back from the lower level state that there is an 
M3 in process and S is now 1000.

That would be more consistent.

Thanks
John




___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Python question

2020-12-16 Thread ken.strauss
With the great help on list and off I'm having some progress.

When debugging it is very convenient to be able to run a program in a terminal 
window. Doing so immediately shows syntax errors. The program can talk to an 
Arduino listening on a USB simulated serial port and can create pins that can 
be displayed or set in halcmd. A ctrl-C closes things. The only remaining 
problem is that I have not found a way to read values from existing HAL pins in 
order to get axis positions and other useful information. Halcmd and other 
programs can display the value of any pin. Is reading pins created by another 
program not supported in python or am I just missing a vital incantation?



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] 7i96 multi wire input

2020-12-16 Thread Sven Wesley
Den tors 10 dec. 2020 kl 15:31 skrev Gene Heskett :

> But, I'll also state that my way is not the only way, There are (N-1)!
> ways to do it where N is the number of inputs you need to smunch into
> one wire to stop LCNC, and ! is the factorial symbol. And could be
> expanded to handle more fault sources easy enough as long as they all
> worked alike. With "work alike" defined as turning on an isolated switch
> when it faults.
>
> Take care Sven.
>
> Cheers, Gene Heskett
>

Turns out it's all fine to run them all together. Got this drawing from the
designer of the driver.


[image: error-line.jpg]
___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Python question

2020-12-16 Thread John Dammeyer
Thanks Andy,
I'll check into that.  I've attached two screen shots of an app I put together 
in just over a half hour.  Mostly trying to remember how to do certain things. 

Press the buttons on the user screen and the Active GCodes are updated.  A 
total of 98 lines of code including blank lines between each function.  Trivial 
really.   Written on WIN-10 PC.  Compiled on PC. Running on PC.  But, project 
can be copied onto Pi4 with LinuxCNC or a desktop with LinuxCNC and compiled 
there for that target.  Write once, compile anywhere.

There is a function 'UdateOptionsList' that updates the Active GCodes.  This 
would be the place where the LinuxCNC system is updated with the M3 and S500 
(and any other M,G commands in the list) after a user clicked the + button.  Or 
entered something from the MDI line.

Your code link shows
static RCS_CMD_CHANNEL *emcCommandBuffer = 0;
as a method of sending information to LinuxCNC.

Defined in /cmd_msg.hh
But as yet I've not figured out how it gets from there into LinuxCNC.  
Something to do with the NML.
More work required.

John


> -Original Message-
> From: andy pugh [mailto:bodge...@gmail.com]
> Sent: December-16-20 2:58 AM
> To: Enhanced Machine Controller (EMC)
> Subject: Re: [Emc-users] Python question
> 
> On Wed, 16 Dec 2020 at 06:29, John Dammeyer  wrote:
> 
> > https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/usr_intf/emcrsh.cc
> > It uses sockets in that file which implies this is how communications is 
> > done.
> 
> Not normally. emcrsh is an "add on" interface for communicating with
> remote LinuxCNC systems.
> 
> halui is probably a better example of how to control LinuxCNC from C / C++
> https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/usr_intf/halui.cc
> 
> --
> atp
> "A motorcycle is a bicycle with a pandemonium attachment and is
> designed for the especial use of mechanical geniuses, daredevils and
> lunatics."
> � George Fitch, Atlanta Constitution Newspaper, 1912
> 
> 
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Sample code

2020-12-16 Thread ken.strauss
Apologies for my late response but I've had to attend to other matters. 

 

In your sample Python code where is "data" defined?

 

-Original Message-
From: Ernesto Lo Valvo  
Sent: December 11, 2020 11:06 AM
To: emc-users@lists.sourceforge.net
Subject: Re: [Emc-users] Sample code

 

I have made something similar to what you ask between a Raspberry and an
Arduino board with a 16x2 LCD display.

The Python program that runs on the Raspberry is this:

 

--

import linuxcnc

import serial, time

 

ser = serial.Serial('/dev/ttyUSB0')  # open serial port data =
linuxcnc.stat()

 

try:

 while True:

  data.poll()

  x=data.actual_position[0]-data.g5x_offset[0]

  y=data.actual_position[1]-data.g5x_offset[1]

  z=data.actual_position[2]-data.g5x_offset[2]

  a=data.actual_position[3]-data.g5x_offset[3]

   r0=("X{x:5.2f} Y{y:5.2f}".format(x=x,y=y))

   r1=("Z{z:5.2f} A{a:5.2f}".format(z=z,a=a))

 

   ser.write(r0.encode('utf-8')+'%')

   ser.write(r1.encode('utf-8')+'%')

   time.sleep(.05)

 

except KeyboardInterrupt:

 ser.close()

--

 


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Python question

2020-12-16 Thread andy pugh
On Wed, 16 Dec 2020 at 06:29, John Dammeyer  wrote:

> https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/usr_intf/emcrsh.cc
> It uses sockets in that file which implies this is how communications is done.

Not normally. emcrsh is an "add on" interface for communicating with
remote LinuxCNC systems.

halui is probably a better example of how to control LinuxCNC from C / C++
https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/usr_intf/halui.cc

-- 
atp
"A motorcycle is a bicycle with a pandemonium attachment and is
designed for the especial use of mechanical geniuses, daredevils and
lunatics."
— George Fitch, Atlanta Constitution Newspaper, 1912


___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Python question

2020-12-16 Thread Frank Tkalcevic
The sockets part is for the "rsh" remote shell interface - the UI is a
command line interface.  The big comment at the beginning of the file shows
the text command list - eg for spindle commands - spindle (none) | forward |
reverse | increase | decrease | constant | off

As for searching, I normally just used the linux command line tools on my
cloned copy of the linuxcnc repository - find, grep, etc.
On the github webpage, there is a "Search or jump to..."  field in the top
left corner that allows you to search.  sendSpindleIncrease appears a couple
of times - the one you want is in shcom.cc

-Original Message-
From: John Dammeyer [mailto:jo...@autoartisans.com] 
Sent: Wednesday, 16 December 2020 5:27 PM
To: 'Enhanced Machine Controller (EMC)'
Subject: Re: [Emc-users] Python question

Ah.
https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/usr_intf/emcrsh.cc
It uses sockets in that file which implies this is how communications is
done.  

But as usual, the code is quite vague.  For example there's this function.
static cmdResponseType setSpindle(char *s, connectionRecType *context) {

And inside the function 
switch (checkSpindleStr(s)) {
 case -1: return rtStandardError;
 case 0: sendSpindleForward(spindle); break;

and a few more cases.
So where is sendSpindleForward(spindle) ?

Is there a way to search for "sendSpindleForward" to find out if it's a
MACRO or a function that formats the message to go to the socket?

Thanks
John



> -Original Message-
> From: Frank Tkalcevic [mailto:fr...@franksworkshop.com.au]
> Sent: December-15-20 9:48 PM
> To: 'Enhanced Machine Controller (EMC)'
> Subject: Re: [Emc-users] Python question
> 
> If you look at the axis source code, to increment the spindle you call...
> 
> c.spindle(linuxcnc.SPINDLE_INCREASE)
> 
> where
> 
> c = linuxcnc.command()
> 
> 
> linuxcnc.command() comes from halui.cc (I think), which sends a message...
> 
> static int sendSpindleIncrease(int spindle)
> {
> EMC_SPINDLE_INCREASE emc_spindle_increase_msg;
> emc_spindle_increase_msg.spindle = spindle;
> return emcCommandSend(emc_spindle_increase_msg);
> }
> 
> So, to invoke an action, you are actually sending a message to linuxcnc,
not just settings  a pin.  Status information, like spindle speed,
> for example, come from the status message, which is also exposed via halui
for python.
> 
> There are examples, like linuxcnc/src/emc/usr_intf/emcrsh.cc, which do
this in C++.
> 
> 
> 
> -Original Message-
> From: John Dammeyer [mailto:jo...@autoartisans.com]
> Sent: Wednesday, 16 December 2020 3:59 PM
> To: 'Enhanced Machine Controller (EMC)'
> Subject: Re: [Emc-users] Python question
> 
> Let's say you wanted to access the hal pins and essentially run the
machine using a different programming language like C instead of
> python.
> 
> How's the linkage done from say the Axis GUI to the rest of the system?
Like Spindle ON button and then Spindle +
> 
> John
> 
> 
> > -Original Message-
> > From: andy pugh [mailto:bodge...@gmail.com]
> > Sent: December-15-20 5:15 PM
> > To: Enhanced Machine Controller (EMC)
> > Subject: Re: [Emc-users] Python question
> >
> > On Wed, 16 Dec 2020 at 01:10,  wrote:
> > >
> > > Are the necessary environment variables document somewhere?
> >
> > I think you just need to "import linuxcnc" to get access to linuxcnc
> > command and state.
> >
> > But you would probably still need to create and net hal pins to get
> > values from hal.
> >
> >
> > --
> > atp
> > "A motorcycle is a bicycle with a pandemonium attachment and is
> > designed for the especial use of mechanical geniuses, daredevils and
> > lunatics."
> > ? George Fitch, Atlanta Constitution Newspaper, 1912
> >
> >
> > ___
> > Emc-users mailing list
> > Emc-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/emc-users
> 
> 
> 
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
> 
> 
> 
> ___
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users