EVENT / TIMER and "DDE"

More
02 Jul 2011 08:32 #11063 by Fremder
Hello,

bevor: my english is not very good :-)

i have 1 Laser (1500 w) and emc2 retrofit ... its runnig now "ok" ...

the laserpower on the edges and so ... ist sometimes to MUCH ...

to control the power i have a 0 ... 5 VOLT analog signal and i will
make this allways in relation to the feed/velocity but not 1 : 1

to control this i have no idea :(

with G-code i can send M123 P50 or antything but this is not perfekt
...
my "home" was bevor emc2 >>> win / visualstudio and visualbasic to make good programms :)
now i was a ~freshman~ :)
=====================================
can i make a "Timer-Event" at EMC2 ?
or
can i give signals at all 20 ms out to a C or python ?
OR
can i make a "DDE" / tcp / or any from python to EMC2 and look to the aktual FEED :-)

very thanks for a little input

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

More
02 Jul 2011 11:22 #11066 by andypugh
Replied by andypugh on topic Re:EVENT / TIMER and
Fremder wrote:

o control the power i have a 0 ... 5 VOLT analog signal and i will
make this allways in relation to the feed/velocity but not 1 : 1


I think you need to look to doing some processing in the HAL.
www.linuxcnc.org/docview/html/hal_basic_hal.html

You should be able to use the motion.current-vel HAL pin to modulate the laser power.
This might give you enough flexibility, it uses the G-code S-word (spindle speed) to control laser power. You will need to hook up the mult2.0.out pin to whatever currently controls the laser power. The example assumes a pwm generator exists.
loadrt scale count=2
loadrt mult2 count =1
…
addf scale.0.servo-thread
addf scale.1 servo-thread
addf mult2.0 servo-thread
…
net speed-in motion.current-vel => scale.0.in
#choose these numbers to suit
setp scale.0.gain 0.1
setp scale.0.offset -0.5

net power-in motion.spindle-speed-out => scale.1.in
#choose these numbers to suit
setp scale.1.gain 0.1
setp scale.1.offset -0.5

net scaled-speed scale.0.out => mult2.0.in0
net scaled-power scale.1.out => mult2.0.in1
net output-power mult2.0.out => pwmgen.0.in
If you need a more non-linear calculation (though the above has 4 numbers to play with) then you might have to write your own HAL component. We can give help with that if needed.

my "home" was bevor emc2 >>> win / visualstudio and visualbasic to make good programms :)
now i was a ~freshman~ :)

I use VBA an awful lot, but managed to get the hang of HAL and C.

can i make a "Timer-Event" at EMC2

Yes, but we would need more details about what you want, there are so many ways to do it.

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

More
02 Jul 2011 13:48 - 02 Jul 2011 14:22 #11070 by Fremder
Replied by Fremder on topic Re:EVENT / TIMER and
thank you for this code - now i am at home :) testing tomorro or monday :-)

i not sure - the POWER goes 1:1 form speed to "spindle speed" (the laser is for me begining)

i think:

Sample: Stainless 2 mm tickness ...
i give this to g-code:

F = 3000 mm / min
Prim.Power = 750 WATT = now 100%

and send to begin from cuting an Mnnn to start the "Spindle-speed"

then the power goes upAnddown / speed but not under ~2000

i think with spindle-speed.MIN = 2000 # ( ~> 375 W / 50% : F3000 = 100% or 2000 = 0% and 3000 = 100% from RANGE 375W)
the 1:1 was ok
=====================
can i make a "Timer-Event" at EMC2Yes, but we would need more details about what you want, there are so many ways to do it.
=====================
the timer event was my think to send a output to python and i give inside Py the power to laser :-)

now my wife is on POWER and i must out :)

thanks for help
Last edit: 02 Jul 2011 14:22 by Fremder.

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

More
02 Jul 2011 17:50 #11075 by andypugh
Replied by andypugh on topic Re:EVENT / TIMER and
Fremder wrote:

POWER goes 1:1 form speed to "spindle speed" (the laser is for me begining)

Yes, if you say M3 S1234.567 then the HAL "pin" called motion.spindle-speed-out takes the value 1234.567
Also, the M3 makes the pin motion.spindle-on take on the value "TRUE"
You need to be careful about the types of pins. They can either be integer, floating point or boolean and you can't "wire" "pins" of different types together.

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

More
02 Jul 2011 18:13 #11077 by Fremder
Replied by Fremder on topic Re:EVENT / TIMER and
hello and thanks

ok its 1:1 ...

i "found" this on "wiki.linuxcnc.org/emcinfo.pl?Using_HAL_In_Python"
===========
DESCRIPTION
This module allows the creation of userspace HAL components in Python.
This includes pins and parameters of the various HAL types.

Typical usage:

import hal, time

h = hal.component("component-name")
# create pins and parameters with calls to h.newpin and h.newparam
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready() # mark the component as 'ready'

try:
while 1:
# act on changed input pins; update values on output pins
time.sleep(1)
h = h
except KeyboardInterrupt: pass

When the component is requested to exit with 'halcmd unload', a
KeyboardInterrupt exception will be raised.

DATA
HAL_BIT = 1
HAL_FLOAT = 2
HAL_IN = 16
HAL_IO = 48
HAL_OUT = 32
HAL_RO = 64
HAL_RW = 192
HAL_S32 = 3
HAL_U32 = 4
==============
i have see the time.sleep(1) (one Sec or MS ?) and this was verry good
when i can make this:

the sample goes to M123

on cut-begin: Nxxx M123 2000 # Watt 100% for powerfeed ON
then i can control the power in the event from the python-file ? every 1 ms
on cut-end Nxxx M124

bevor i can't sleep tonight :-)

h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN) # makes a newpin ?

can i make a question to M5i20 pins from the event from python ?
*smile*

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

More
02 Jul 2011 19:07 #11078 by andypugh
Replied by andypugh on topic Re:EVENT / TIMER and
Fremder wrote:

This module allows the creation of userspace HAL components in Python.


I have no idea what you are trying to do, but I doubt that you want a userspace component for timing.
Have a look at:
linuxcnc.org/docs/html/hal_comp.html
And maybe:
wiki.linuxcnc.org/emcinfo.pl?SimpleCycleTimer

Can you explain what you want this timer to do?

If you want to do something every 1mS then do it in the HAL file, in the servo thread, then it happens absolutely certainly every 1mS.

The HAL example I gave earlier will update the power output every 1mS, based on the current cartesian velocity, and allows you to set laser power using S rather than M123.

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

More
03 Jul 2011 00:20 #11082 by Fremder
Replied by Fremder on topic Re:EVENT / TIMER and
hello and thanks

ok its 1:1 ...

i "found" this on "wiki.linuxcnc.org/emcinfo.pl?Using_HAL_In_Python"
===========
DESCRIPTION
This module allows the creation of userspace HAL components in Python.
This includes pins and parameters of the various HAL types.

Typical usage:

import hal, time

h = hal.component("component-name")
# create pins and parameters with calls to h.newpin and h.newparam
h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN)
h.newpin("out", hal.HAL_FLOAT, hal.HAL_OUT)
h.ready() # mark the component as 'ready'

try:
while 1:
# act on changed input pins; update values on output pins
time.sleep(1)
h = h
except KeyboardInterrupt: pass

When the component is requested to exit with 'halcmd unload', a
KeyboardInterrupt exception will be raised.

DATA
HAL_BIT = 1
HAL_FLOAT = 2
HAL_IN = 16
HAL_IO = 48
HAL_OUT = 32
HAL_RO = 64
HAL_RW = 192
HAL_S32 = 3
HAL_U32 = 4
==============
i have see the time.sleep(1) (one Sec or MS ?) and this was verry good
when i can make this:

the sample goes to M123

on cut-begin: Nxxx M123 2000 # Watt 100% for powerfeed ON
then i can control the power in the event from the python-file ? every 1 ms
on cut-end Nxxx M124

bevor i can't sleep tonight :-)

h.newpin("in", hal.HAL_FLOAT, hal.HAL_IN) # makes a newpin ?

can i make a question to M5i20 pins from the event from python ?
*smile*

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

More
04 Jul 2011 13:08 - 04 Jul 2011 14:07 #11137 by Fremder
Replied by Fremder on topic Re:EVENT / TIMER and
Thanks - i have insert your code ... and a "hal_meter1" from gladevcp to see the "power"
nearly its verry good

but i don't understand the correct way to give 0 to 5 V out correctly



#############################################
# Spindelsteuerung mit Pulsweitenmodulation
# es gibt 3 Typen, 0, 1 , 2
# Hierbei ist 1 der Typ mit Richtungssignal
# PWM Spindle Control
# there are 3 types
# beeing 1 with direction signal
#############################################

# PWM Signal Erzeugung / Setup PWM Generator signals
# setp hm2_5i20.0.pwmgen.02.output-type 1 # not sure for me ...
# setp hm2_5i20.0.pwmgen.02.scale 1000

setp hm2_5i20.0.pwmgen.02.enable 1


loadrt scale count=2
loadrt mult2 count=1

addf scale.0 servo-thread
addf scale.1 servo-thread
addf mult2.0 servo-thread



net speed-in motion.current-vel => scale.0.in 
#choose these numbers to suit
setp scale.0.gain 0.1
setp scale.0.offset 0.5


net power-in motion.spindle-speed-out => scale.1.in
#choose these numbers to suit
setp scale.1.gain 1500
setp scale.1.offset 0.5



net scaled-speed scale.0.out => mult2.0.in0
net scaled-power scale.1.out => mult2.0.in1
# net output-power mult2.0.out => pwmgen.0.in
net output-power mult2.0.out => hm2_5i20.0.pwmgen.02.value => gladevcp.hal_meter1

when 1500 W = 100% Power for the 100% Speed (gives the F param in the g-code)
and the V = 0 to 5 V
i think: Scale = 5 / 1500
...
i have make ~50 or more examples *g* combined sourceA / b c..d... etc. now i am deffekt ...
====
importend for me is this:

LaserPower to SET -> ON and OFF in Gcode

when i can set a min and maxRange for the speed-laser-powercontrol then i don't set a alternativ for allways the Snnn Power
otherwise i will make

GCodeA: with controled
N10 M123 1 # >>> set controlled-speed ON
N12 F100
N14 M124 S100 #LASER ON to 100W
N16 S750 # maybe: = 750 WATT or 50% or 2.5 V
N18 G1 X10 Y10 ..... # work controlled with speed
....
N200 M125 # LASER OFF its then Volt = 0 or the pin to enable = false ? good-think :(

GCodeB: with not controled
N10 M123 0 # >>> set controlled-speed OFF
N12 F100
N14 M124 S100 #LASER ON to 100W
N16 S750 # maybe: = 750 WATT or 50% or 2.5 V
N18 G1 X10 Y10 ..... # work allways with 750 WATT
....
N200 M125 # LASER OFF its then Volt = 0 or the pin to enable = false ? good-think :(

=========
i am not sure why the hm2_5i20.0.pwmgen.02.value = 3 but the Volts is not 3 *g*

verry thanks for a help next :)
Last edit: 04 Jul 2011 14:07 by Fremder.

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

More
04 Jul 2011 15:19 #11142 by andypugh
Replied by andypugh on topic Re:EVENT / TIMER and
Fremder wrote:

but i don't understand the correct way to give 0 to 5 V out correctly
...
# setp hm2_5i20.0.pwmgen.02.output-type 1 # not sure for me
# setp hm2_5i20.0.pwmgen.02.scale 1000 ...

It probably doesn't matter, but you might want to uncomment these lines
If you have pwmgen scale = 1500 then a value of 1500 on the pwmgen.value pin will give you 100% duty cycle.
What voltage that is depends on what the pwmgen is connected to.

when 1500 W = 100% Power for the 100% Speed (gives the F param in the g-code)
and the V = 0 to 5 V
i think: Scale = 5 / 1500
No, the pwmgen only goes between 0% and 100%. The output voltage depends on the pwm to voltage conversion circuit. What are you using?

Also, the example code I gave adds some more factors and offsets, which will complicate matters.

LaserPower to SET -> ON and OFF in Gcode

In the sample I gave, you should be able to turn the laser on with M3 and off with M5, just like a spindle.
What does your M123 command do?

N200 M125 # LASER OFF its then Volt = 0 or the pin to enable = false ? good-think :(

It ought to work. it depends on your physical wiring, ie how the laser is connected to the computer.

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

More
04 Jul 2011 16:08 #11145 by Fremder
Replied by Fremder on topic Re:EVENT / TIMER and
ok :( sorry

its ok

with M3 i set it ON and give the 100%
M3 S1500 gives 100% = 1500 ?
now when the speed goes to 50% the output = 50% = 750 = 2.5 V ?
...
M5 set Spindel OFF - verry good ...its ok

i make this now on the machine ... and
i 'l be come back :-)

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

Time to create page: 0.195 seconds
Powered by Kunena Forum