Re: [Emc-users] Serial Port access

2021-09-11 Thread Gene Heskett
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 < 
 jo...@autoartisans.com> wrote:
> > > > I've been reading
> > > >  
> > > > 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.
> > >
> > >  

Re: [Emc-users] Serial Port access

2021-09-11 Thread John Dammeyer
Hi Gene,
Hi Gene,
> 
> I don't know much about the CAN bus, but this does sound like a howto to
> do a relay.

I'm working on the input side of things next.  
> 
> 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.

I'm still waiting for mine to arrive.  Latest is that it arrived at Canada Post 
in Toronto.  I'm going to guess it's going via surface from there to here.  So 
another week.

> 
> 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've gone the pressurized method with a small needle valve to regulate the flow 
and 5PSI to pressurize the reservoir.  But if there are issues I will have a 
pump to do what you are doing.  However, I'll use the same module I'm using for 
the power draw bar.  It has PWM 0-10V capabilities so I can include the PWM 
value with the relay values.

Not sure how to do sliders yet on the AXIS interface.  And I will continue to 
post the code as it develops.  I'm already up to Rev 0.2 now.  Moved the read 
routine outside the send routine as it was in the original serial code.   The 
CANUSB would signal buffer overruns because unless one of the outputs changed 
the function might not be called for hours.

More as things progress.
John

> 
> 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 <
>  jo...@autoartisans.com> wrote:
> > > > > I've been reading
> > > > >  
> > > > > 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
> > > >
> > > > --
> > > > 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 
> 
>

Re: [Emc-users] Serial Port access

2021-09-11 Thread Gene Heskett
On Saturday 11 September 2021 05:02:47 John Dammeyer wrote:

> Hi Gene,
> Hi Gene,
>
> > I don't know much about the CAN bus, but this does sound like a
> > howto to do a relay.
>
> I'm working on the input side of things next.
>
> > 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.
>
> I'm still waiting for mine to arrive.  Latest is that it arrived at
> Canada Post in Toronto.  I'm going to guess it's going via surface
> from there to here.  So another week.

I take it you are sorta out in the toulies then? I got mine from ebay, 
bought 4 of them knowing the limited lifetime of the silicon hose the 
the pump squeezes with rollers. Its now been close to 2 years & about a 
gallon of koolmist thru it, and 3 of them are still in the bag. About $9 
usd a copy on ebay.
>
> > 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've gone the pressurized method with a small needle valve to regulate
> the flow and 5PSI to pressurize the reservoir.

Finding a quality needle valve is quite a challenge.

I did similar in version .001 but I didn't have adequate control, so the 
plastic coke bottle is no longer pressurized in version .01.  The pump 
is straped to the gantry riser above the little shelf the coke bottle 
sits on with a broom handle hanger loop dropped over the top of the 
bottle so if Y jerks, the bottle has to follow.

If idle for weeks, it might lose prime, but catches up and fills the weed 
eater fuel hose (that stuffs expensive) to the nozzle in around a 
minute, quicker if I speed up the motor. Sorta complex but suits my 
needs well.

I've considered doing that on the other machines but would need to 
recycle the drainage better. That plus I'd druther not get cast iron 
wet. Koolmist is wetter than water and carry's the way lube away.  
Somewhat Like a mild photoflow that was used in a chemical darkroom 
before digital cameras took over 40 years ago.

I used to do that too, in a past life, even formulated my own color print 
developer that didn't fade sitting in the warm bath for 4 hours. My 
stuff could make 8 identical 8x10 wedding photos in a row, all at the 
same filter settings on the enlarger. Commercial mix couldn't do that, 
it faded too fast.

But that was then, now I'll be 87 in a couple weeks. And alone again.

> But if there are 
> issues I will have a pump to do what you are doing.  However, I'll use
> the same module I'm using for the power draw bar.  It has PWM 0-10V
> capabilities so I can include the PWM value with the relay values.
>
> Not sure how to do sliders yet on the AXIS interface.

Piece of cake John, the pyvcp .xml file snippet that draws them:
but there's a wagon load of stuff above it too. :o)

  

  

  ("5")
  "mist-on-adj"
  .000
  .025
  .005
  0.001
  ".3f"
  ("Helvitica",12)
  0


  ("5")
  "mist-off-adj"
  .000
  .250
  .100
  0.001
  ".3f"
  ("Helvitica",12)
  0

  

  
==
then in postgui.hal:

# for mister pump motor speed ctrl
net mister-spdon<= pyvcp.mist-on-adj  => timedelay.3.off-delay
net mister-spdoff   <= pyvcp.mist-off-adj => timedelay.3.on-delay

then in the main.hal:

6040-5i25-7i76-rs485.hal:addf  xor2.1servo-thread
# turns mister on/off
6040-5i25-7i76-rs485.hal:net mist-on => xor2.1.in0
# turn on pump motor speed control
6040-5i25-7i76-rs485.hal:net osc-fdbck  <= xor2.1.out => timedelay.3.in
# make speed timer oscillator
6040-5i25-7i76-rs485.hal:net mister-out  <= timedelay.3.out => xor2.1.in1

and:

loadrt timedelaycount=4 #.3 is mist motor timer
loadrt xor2 count=2 #.1 one is mist-ctl
6040-5i25-7i76-rs485.hal:addf  timedelay.3  servo-thread 
# is mist oscillator
6040-5i25-7

Re: [Emc-users] Serial Port access

2021-09-11 Thread John Dammeyer
Hi Gene,
On Vancouver Island so other end of the country and about 4 days by road if one 
is not driving 24/7.

Thanks for the code fragment.  Very helpful.

I do have two buttons

#  Tag buttons 
net remote-rapid-to-Z-home halui.mdi-command-16 <= pyvcp.rapid-to-Z-home
net remote-rapid-to-XY-home halui.mdi-command-17 <= pyvcp.rapid-to-XY-home

And they are coupled to the system in the .INI file along with the pendant 
buttons as #16 and #17 in the list to create the G-Code for motion.

[HALUI]
# These are the commands for the HB04 and PyVCP screen buttons.
# a halui hal pin is created for each MDI_COMMAND below
# halui.mdi-command-00, halui.mdi-command-01,... etc
# 
MDI_COMMAND=G0 X0 Y0 Z0
MDI_COMMAND=(debug, example: mdi-01)
MDI_COMMAND=(debug, example: mdi-02)
#03 M110: clears notifications
MDI_COMMAND=M110
MDI_COMMAND=(debug, example: mdi-04)
MDI_COMMAND=(debug, example: mdi-05)
MDI_COMMAND=(debug, example: mdi-06)
#07 M101: example print to stdout
MDI_COMMAND=M101
MDI_COMMAND=(debug, example: mdi-08)
MDI_COMMAND=(debug, example: mdi-09)
MDI_COMMAND=(debug, example: mdi-10)
MDI_COMMAND=(debug, example: mdi-11)
#12 Set current physical X position to be 0
MDI_COMMAND= G10 L20 P0 X0
#13 Set current physical Y position to be 0
MDI_COMMAND= G10 L20 P0 Y0
#14 Set current physical Z position to be 0
MDI_COMMAND= G10 L20 P0 Z0
#15 Set current physical A position to be 0
MDI_COMMAND= G10 L20 P0 A0
# 16 pyVCP button Full speed to Z0
MDI_COMMAND= G0 Z0
MDI_COMMAND= G0 X0 Y0

If I understand the HAL file code then your mister is totally controlled by the 
slider.  No simple button for ON/OFF?

John


> -Original Message-
> From: Gene Heskett [mailto:ghesk...@shentel.net]
> Sent: September-11-21 7:01 AM
> To: emc-users@lists.sourceforge.net
> Subject: Re: [Emc-users] Serial Port access
> 
> On Saturday 11 September 2021 05:02:47 John Dammeyer wrote:
> 

> > I'm still waiting for mine to arrive.  Latest is that it arrived at
> > Canada Post in Toronto.  I'm going to guess it's going via surface
> > from there to here.  So another week.
> 
> I take it you are sorta out in the toulies then? I got mine from ebay,
> bought 4 of them knowing the limited lifetime of the silicon hose the
> the pump squeezes with rollers. Its now been close to 2 years & about a
> gallon of koolmist thru it, and 3 of them are still in the bag. About $9
> usd a copy on ebay.

> But that was then, now I'll be 87 in a couple weeks. And alone again.
> 

You're more than 20 years further along on this than I am.


> > Not sure how to do sliders yet on the AXIS interface.
> 
> Piece of cake John, the pyvcp .xml file snippet that draws them:
> but there's a wagon load of stuff above it too. :o)
> 
>   
> 
>   
> 
>   ("5")
>   "mist-on-adj"
>   .000
>   .025
>   .005
>   0.001
>   ".3f"
>   ("Helvitica",12)
>   0
> 
> 
>   ("5")
>   "mist-off-adj"
>   .000
>   .250
>   .100
>   0.001
>   ".3f"
>   ("Helvitica",12)
>   0
> 
>   
> 
>   
> ==
> then in postgui.hal:
> 
> # for mister pump motor speed ctrl
> net mister-spdon<= pyvcp.mist-on-adj  => timedelay.3.off-delay
> net mister-spdoff   <= pyvcp.mist-off-adj => timedelay.3.on-delay
> 
> then in the main.hal:
> 
> 6040-5i25-7i76-rs485.hal:addf  xor2.1servo-thread
> # turns mister on/off
> 6040-5i25-7i76-rs485.hal:net mist-on => xor2.1.in0
> # turn on pump motor speed control
> 6040-5i25-7i76-rs485.hal:net osc-fdbck  <= xor2.1.out => timedelay.3.in
> # make speed timer oscillator
> 6040-5i25-7i76-rs485.hal:net mister-out  <= timedelay.3.out => xor2.1.in1
> 
> and:
> 
> loadrt timedelaycount=4 #.3 is mist motor timer
> loadrt xor2 count=2 #.1 one is mist-ctl
> 6040-5i25-7i76-rs485.hal:addf  timedelay.3  servo-thread
> # is mist oscillator
> 6040-5i25-7i76-rs485.hal:net osc-fdbck  <= xor2.1.out => timedelay.3.in
> # make speed timer oscillator
> 6040-5i25-7i76-rs485.hal:net mister-out  <= timedelay.3.out => xor2.1.in1
> 
> The xor2.1 is the on-off switch for te oscillator, interrupting the
> feedback path when the mist button is off
> 
> Note too, that depending on what else you already have in the .hal file,
> the .number. may change.
> 



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


Re: [Emc-users] Serial Port access

2021-09-11 Thread Gene Heskett
On Saturday 11 September 2021 13:33:30 John Dammeyer wrote:

> Hi Gene,
> On Vancouver Island so other end of the country and about 4 days by
> road if one is not driving 24/7.
>
> Thanks for the code fragment.  Very helpful.
>
> I do have two buttons
>
> #  Tag buttons 
> net remote-rapid-to-Z-home halui.mdi-command-16 <=
> pyvcp.rapid-to-Z-home net remote-rapid-to-XY-home halui.mdi-command-17
> <= pyvcp.rapid-to-XY-home
>
> And they are coupled to the system in the .INI file along with the
> pendant buttons as #16 and #17 in the list to create the G-Code for
> motion.
>
> [HALUI]
> # These are the commands for the HB04 and PyVCP screen buttons.
> # a halui hal pin is created for each MDI_COMMAND below
> # halui.mdi-command-00, halui.mdi-command-01,... etc
> #
> MDI_COMMAND=G0 X0 Y0 Z0
> MDI_COMMAND=(debug, example: mdi-01)
> MDI_COMMAND=(debug, example: mdi-02)
> #03 M110: clears notifications
> MDI_COMMAND=M110
> MDI_COMMAND=(debug, example: mdi-04)
> MDI_COMMAND=(debug, example: mdi-05)
> MDI_COMMAND=(debug, example: mdi-06)
> #07 M101: example print to stdout
> MDI_COMMAND=M101
> MDI_COMMAND=(debug, example: mdi-08)
> MDI_COMMAND=(debug, example: mdi-09)
> MDI_COMMAND=(debug, example: mdi-10)
> MDI_COMMAND=(debug, example: mdi-11)
> #12 Set current physical X position to be 0
> MDI_COMMAND= G10 L20 P0 X0
> #13 Set current physical Y position to be 0
> MDI_COMMAND= G10 L20 P0 Y0
> #14 Set current physical Z position to be 0
> MDI_COMMAND= G10 L20 P0 Z0
> #15 Set current physical A position to be 0
> MDI_COMMAND= G10 L20 P0 A0
> # 16 pyVCP button Full speed to Z0
> MDI_COMMAND= G0 Z0
> MDI_COMMAND= G0 X0 Y0
>
> If I understand the HAL file code then your mister is totally
> controlled by the slider.  No simple button for ON/OFF?

On/Off is the mister checkmark. Perhaps my grepping failed?
try this:
gene@sixty40:~/linuxcnc/configs/6040-5i25-7i76-rs485$ grep mist *
6040-5i25-7i76-rs485.hal:loadrt xor2 count=2 #2nd one is mist-ctl
6040-5i25-7i76-rs485.hal:loadrt and2 names=and-prb1,and-prb2,mist-ctl
6040-5i25-7i76-rs485.hal:addf  xor2.1servo-thread # turns mister on/off
6040-5i25-7i76-rs485.hal:addf  timedelay.3   servo-thread # mist oscillator
6040-5i25-7i76-rs485.hal:# output for coolant-mist air ctrl - WORKS! Valve coil 
gets HOT
6040-5i25-7i76-rs485.hal:net mist-on <= iocontrol.0.coolant-mist => 
hm2_5i25.0.7i76.0.0.output-01 <--this one?
6040-5i25-7i76-rs485.hal:# turns on tool mister air valv, and supplies pump 12 
volts
6040-5i25-7i76-rs485.hal:net mist-on => xor2.1.in0  # turn on pump motor speed 
control
6040-5i25-7i76-rs485.hal:net mister-out  <= timedelay.3.out => xor2.1.in1
6040-5i25-7i76-rs485.hal:net mister-out  => hm2_5i25.0.gpio.024.out # to pump 
pwr control

That whole thing:

#***
# output for coolant-mist air ctrl - WORKS! Valve coil gets HOT
net mist-on <= iocontrol.0.coolant-mist => hm2_5i25.0.7i76.0.0.output-01
# turns on tool mister air valv, and supplies pump 12 volts
net mist-on => xor2.1.in0  # turn on pump motor speed control
net osc-fdbck  <= xor2.1.out => timedelay.3.in # make speed timer oscillator
setp hm2_5i25.0.gpio.024.is_output true
net mister-out  <= timedelay.3.out => xor2.1.in1
net mister-out  => hm2_5i25.0.gpio.024.out # to pump pwr control
# note, get pump power from output of relay driven by 1st line above.
# Otherwise pump runs when lcnc off/ stopped/shut down
#***

that should help.

Take care, John
> > Note too, that depending on what else you already have in the .hal
> > file, the .number. may change.

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