The M62-M65 Jeff mentioned earlier are designed to be queued in the motion 
queue, and will only be issued at the proper time. So if you hook one of 
them to your component which sends the rs232 command, it should be safe.

Regards,
Alex

----- Original Message ----- 
From: Kenneth Lerman
To: Enhanced Machine Controller (EMC)
Sent: Friday, November 30, 2007 10:23 PM
Subject: Re: [Emc-users] rs232 output


One problem is that the interpreter is asynchronous to the execution. I 
believe that someone (Alex Joni, perhaps) added something to allow you to 
make sure that the output had caught up with the interpreter. Off hand, I 
don't remember what that was.

Ken
----- Original Message ----- 
From: Roland Jollivet
To: Enhanced Machine Controller (EMC)
Sent: Friday, November 30, 2007 11:48 AM
Subject: Re: [Emc-users] rs232 output


Hi

I've had this idea for a while, as I posted on other cnc lists.
The proposal is to add, probably two lines of code, to echo every character, 
as the G-code file is processed, to the serial port, unconditionally.

Using 232, or 232>>485 multidrop, you could have as many devices as you 
want, sitting on the line, listening/waiting for their command.
You could even embed things like 'turn on the kettle' within a comment.
Basically all non time-critical things could be controlled with this method, 
freeing up valuable I/O.
You could then use a single parport line setup for all or any device to tug 
low, as an Ack, using a wait or pause command in G-code, rather than 
processing 232 in.

It also allows one to implement any complex command that might be outside 
the scope of EMC, without affecting the G-code program.

Of course, each function requires an embedded processor to implement it, but 
one pic could easily manage 15 solenoids/pumps/tools.

Roland




On 30/11/2007, Jeff Epler <[EMAIL PROTECTED]> wrote:
On Fri, Nov 30, 2007 at 01:27:11AM -0800, Klemen Dovrtel wrote:
> Is it possible to send a simple command to rs232
> within the G code using emc. I would like to control
> the pneumatic valves and some other simple stuff and i
> don't want to sped parallel port pins for simple
> things like this.

Every "serial" device is different, so to do this you will have to write
your own "HAL component".  If the control does not need to be real-time,
then it is fairly simple to do this.  One choice is to use Python and
pyserial.

You will have to install the pyserial package.  If your Ubuntu system is
on the internet, this can be done through the package manager by
selecting the package called 'python-serial'.  It is in the "universe"
repository, which is not enabled by default but you can find
instructions online for how to enable it.  If you're not online, then
download this file onto a usb drive then install it by double-clicking:
    
http://us.archive.ubuntu.com/ubuntu/pool/universe/p/pyserial/python-serial_2.2-1_all.deb

Here is an (untested!) example which should give you a general idea of
the complexity of such a driver.  This driver controls a hypothetical
serial-attached device which turns something on when the character "1"
is received, and turns it off when the character "0" is received:

#!/usr/bin/python
# -----------------------------------------------------------------------
# Import the necessary modules
import hal
import time
import pyserial

# Get the serial connection -- first port, 9600,8,N,1
import serial
ser = serial.Serial(0)

# Create the HAL component and its pin.  You will use a .hal file to
# connect whatever bit signal you want to the pin ' example.enable'.
h = hal.component("example")
h.newpin("enable", hal.HAL_BIT, hal.HAL_IN)
h.ready()

# The previous value of the 'enable' pin so that a byte is only sent on
# the serial port when it is necessary.  This setting, which is not a
# number, means that the first time the value will always be considered
# "changed".
last = None

# (without try/except, the component will print what looks like an error
# when emc is shut down, and the cleanup below won't happen)
try:
    while 1:
        # As long as the component is running, periodically check
        # whether the value has changed; if it has, send a command to
        # set the new value
        new = h["enable"]
        if new != old:
            if new: ser.write("1")
            else: ser.write("0")
        old = new
         time.sleep(.01)
except KeyboardInterrupt: pass

# Shut down the connected device at exit
ser.write("0")
# -----------------------------------------------------------------------

Put the above in a file named "example", make it executable (chmod +x
example), and put it in a directory on your $PATH.

In your HAL file, hook it up something like this:
    loadusr -W example
    net coolant iocontrol.0.coolant-mist => example.enable

Jeff

-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users






-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4



_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users




-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4



_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users




No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.503 / Virus Database: 269.16.10/1160 - Release Date: 11/29/2007 
8:32 PM 


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to