On Saturday 11 September 2021 00:52:26 John Dammeyer wrote:

> So a bit more news.  Good news!
>
> The attached screen shot from the RM CAN monitor shows 3 messages. 
> The first message with ID 0x298 is a PDO message which is the status
> from the device.  Second byte lower 4 bits represents what it says the
> outputs are set to.  The top 4 bits are what it was commanded to do
> with those outputs.
>
> The next message is the NMT heartbeat from node 0x718 which is my
> device.  The 0x05 says its alive and NMT_OPERATIONAL which means it's
> allowed to send PDO messages with device information.
>
> Finally we have the PDO message 0x318 which is 'from' the Pi4 LinuxCNC
> interfaced to the Lawicel CANUSB as /dev/ttyUSB0 using the Python
> pySerial library.
>
> Notice the 0x04 data byte.  That's the bit which is connected to the
> Mist ON/OFF button and that bit switches on a relay in my little
> device.
>
> Also attached is the python file.  I put the HAL stuff in the
> custom.hal file.
>
> I click on the checkbox on the Axis interface and the mist relay
> clicks on.  Click again to remove the checkmark and the mist relay
> goes off.  And the PDO message on the monitor goes from 00 to 04 to
> 00.
>
> This example is the sending from AXIS via pySerial onto the CAN bus. 
> Next step will be to present a switch press that is read by my device
> and shows up in the first byte of the 0x298 PDO.  And I guess I'll add
> a heartbeat from LinuxCNC..
>
> Lots more to do but at this point I can control relays via CAN bus.
>
> John Dammeyer

I don't know much about the CAN bus, but this does sound like a howto to 
do a relay.

But I went a different path as I am using a peristaltic pump that has a 
std brushed motor to drive the pump. A positive displacement pump quite 
similar to whats used at the hospital for IV drips.

But the pump ran way too fast and could drain an 8oz coke bottle of 
koolmist mix in a couple minutes, flooding the work area which had no 
drainage or waste recovery provisions on my 6040 mill.  So I setup a 
timer in hal to generate a variable rate PWM like signal I could send to 
the pumps power transistor. By turning the pump on for around 5 ms, and 
off for 250 ms, I get just enough mist to keep the tool cool when that 
teeny pulse of the pump is pushed to the workface with 3 or so lbs of 
air pressure with that air valve controlled by the same bit that enables 
the pwm oscillator for the motor. And I've pyvcp sliders in the gui to 
control how wet the spray is. Now I've been looking for a suitable air 
pump to drive the atomizer since regulators don't do well at the desired 
air flows and it heats the shop compressor needlessly.

I cut out a couple chuck wrenches from 1/2" thick alu plate, one to fit 
that spindle motors double flatted shaft and one to fit the ER nut, on 
half of that 8oz bottle of koolmist. And that was almost too much.

But it added to linuxcnc's job by making it do the pump timing. It does 
it, but I would have preferred to put that timing on the end of a cable 
that only had to be updated when the desired status changed. I think 
this might be the method I would have used had it been available 2 years 
ago, so thank you John. I believe you have added to linuxcnc's 
capabilities.

> > -----Original Message-----
> > From: John Dammeyer [mailto:jo...@autoartisans.com]
> > Sent: September-10-21 10:11 AM
> > To: 'Enhanced Machine Controller (EMC)'
> > Subject: Re: [Emc-users] Serial Port access
> >
> > Hi Andy,
> >
> > The output below shows CANopen PDO message #2 (0x300) to ID 0x18, 1
> > byte, alternating between 0x01 and 0x00 being issued once per
> > second.
> >
> > pi@raspberrypi:~/projects/python $ python TestSerial.py
> > Sent CAN message with relay value = t318101
> > Sent CAN message with relay value = t318100
> > Sent CAN message with relay value = t318101
> > Sent CAN message with relay value = t318100
> > Sent CAN message with relay value = t318101
> >
> > The little module shown in that photo I posted last time is
> > connected to a pneumatic valve on Output #1.  It clicks ON and OFF
> > once per second.   The code is running as a Python Command line
> > program on a standard Raspian distro.  I'll bring out the Pi4 with
> > LinuxCNC and take a look at linking into the HAL file.
> >
> > IMHO the Python serial is very clumsy for dealing with serial with
> > all the format and .encode parameters for simple character strings.
> > The source code is attached.
> >
> > John Dammeyer
> >
> > > From: andy pugh [mailto:bodge...@gmail.com]
> > >
> > > On Thu, 9 Sept 2021 at 05:31, John Dammeyer < 
<mailto:jo...@autoartisans.com> jo...@autoartisans.com> wrote:
> > > > I've been reading
> > > >  <http://linuxcnc.org/docs/2.4/html/hal_comp.html>
> > > > http://linuxcnc.org/docs/2.4/html/hal_comp.html
> > >
> > > For this application I think that a Python userspace component
> > > using Pyserial is probably the easier approach.
> > >
> > >  <http://linuxcnc.org/docs/2.8/html/hal/halmodule.html>
> > > http://linuxcnc.org/docs/2.8/html/hal/halmodule.html
> > >
> > > --
> > > atp


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 <http://geneslinuxbox.net:6309/gene>


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

Reply via email to