set and reyset by pyvcp, but how to config ?

More
28 Jul 2011 07:02 #11941 by wbeppler
hello,



i'm new here but i want to select my handweel by touch-panal

so have configured my hal like:


newsig b_sel_x bit
newsig b_sel_y bit
newsig b_sel_z bit
newsig b_selected_x bit
newsig b_selected_y bit
newsig b_selected_z bit


and i have designed my xml panel:

<hbox>
<led>
<halpin>"b_selected_x"</halpin>
</led>

<button>
<halpin>"b_sel_x"</halpin>
<text>"X Auswahl"</text>
</button>
</hbox>
<hbox>
<led>
<halpin>"b_selected_y"</halpin>
</led>

<button>
<halpin>"b_sel_y"</halpin>
<text>"Y Auswahl"</text>
</button>
</hbox>
<hbox>
<led>
<halpin>"b_selected_z"</halpin>
</led>

<button>
<halpin>"b_sel_z"</halpin>
<text>"Z Auswahl"</text>
</button>
</hbox>

###################### question ###########################################
but now i need to save that for example X-Axis was touched and so i have to move X-servo when i use the weel
and i have to reset X-selected value when i touch Y or Z button

is it possible to use if, then, else or AND OR or logic ?
in manuals always only the word is described, but i'm stupid, so i need a sample-code and i need to know in what file the comman has to be paced

thanks a lot to this EMC forum, i hope i can help too, send me questions about electronic....

best regards

Wolfgang :-)

###########################
Elektronik u. Softwareentwicklung
###########################
Wolftec GmbH
Wolfgang Beppler
Kratellen 23
DE-78355 Hohenfels-Kalkofen
This email address is being protected from spambots. You need JavaScript enabled to view it.
############################

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

More
28 Jul 2011 11:53 - 28 Jul 2011 11:54 #11943 by BigJohnT
Newsig is replaced by net so you can create signals and connect them up on the same line.

A good primer on Hal is here:

www.linuxcnc.org/docview/html/hal_basic_hal.html

Scroll to the bottom of this page for all the Hal components

www.linuxcnc.org/docview/html/

and last but not least a MPG example from the manual:

www.linuxcnc.org/docview/html/examples_mpg.html

and how I connected my MPG on my lathe

gnipsel.com/shop/hardinge/files/mpg.xhtml

John
Last edit: 28 Jul 2011 11:54 by BigJohnT.

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

More
28 Jul 2011 12:08 #11946 by wbeppler
thanks !
is many info so i read this weekend, thanks so long

wolfgang :-)

###########################
Elektronik u. Softwareentwicklung
###########################
Wolftec GmbH
Wolfgang Beppler
Kratellen 23
DE-78355 Hohenfels-Kalkofen
This email address is being protected from spambots. You need JavaScript enabled to view it.
############################

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

More
28 Jul 2011 12:35 #11952 by andypugh
wbeppler wrote:

is it possible to use if, then, else or AND OR or logic ?

There are no conditional functions as such in HAL, but there are logic functions (and, or, not). You can often use a musx component to pass one value or another to a destination, controlled by a boolean.
However, for pendant jogging you don't need that, as the axis jogging interface has "enable" bits so only the selected axes will move when the wheel is moved. The sample that JT linked to uses this (so you can jog all axes at the same time as long as you want them to go the same direction) and uses mux4 in quite a clever way to choose the jog speed.
I have a gamepad controller set up for jog and use a slightly different combination, so that no speed buttons = no jog, top = fast, bottom = slow, both = very slow.

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

More
28 Jul 2011 13:54 #11958 by wbeppler
hi,
i know how to select axes by using a IN-Pin or by software with radio-button

but i want so use a push-button in hardware (big one) for every axis.
so i need to set a value by push the button (X) and reset by push with other button (Y,Z)

the radio-button with 3 values can allways have only one value. if i touch 2nd the 1st is off, also by touch the 3rd or more if more axis.

i want to use this by hardwarebutton because i want to light a LED for each axis, too.

now i use a 2*3 rotation switch where i give power to one of 1*3 input by one contact and the other 1*3 contact to the LED. but this is not good because so it is not possible to modify by softbutton using pyVCP too.

if there is a better idea it would be great

thank

wolfgang

###########################
Elektronik u. Softwareentwicklung
###########################
Wolftec GmbH
Wolfgang Beppler
Kratellen 23
DE-78355 Hohenfels-Kalkofen
This email address is being protected from spambots. You need JavaScript enabled to view it.
############################

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

More
28 Jul 2011 16:29 #11961 by BigJohnT
There are components like or, and, not, xor that you use to choose between two things.

www.linuxcnc.org/docview/html/man/man9/or2.9.html

The easiest way to start is to write up what you want to happen in pseudo code then convert to HAL components something like this.

If button1 is on and switch 2 is on turn on valve 3

then in HAL it would be something like this with button1 connected to the parallel port pin 10 and switch2 conncted to pin 11 and the valve is connected to pin 9
net button1state paraport.0.pin-10.in and2.0.in0
net switch2state paraport.0.pin-11.in and2.0.in1
net valvestate paraport.0.pin-09.out.08 and2.0.out

John

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

More
28 Jul 2011 16:59 #11962 by wbeppler
hi john,

thanks for help

my question to this is:

1) net button1state paraport.0.pin-10.in and2.0.in0
if paraport.0.pin-10.in changes to low or high back (it is a button not a swich) the buttonstate goes back too.
it should be set and only reset if paraport.0.pin-11.in 's button is pressed.

so i need a var that i can SET and i can RESET (or set to 0 , set to 1)

2) net switch2state paraport.0.pin-11.in and2.0.in1
what do you mean with "and2.0.in1"

sorry that i'm so stupid

best regards

wolfgang :-)

###########################
Elektronik u. Softwareentwicklung
###########################
Wolftec GmbH
Wolfgang Beppler
Kratellen 23
DE-78355 Hohenfels-Kalkofen
This email address is being protected from spambots. You need JavaScript enabled to view it.
############################

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

More
28 Jul 2011 17:28 #11963 by andypugh
wbeppler wrote:

if paraport.0.pin-10.in changes to low or high back (it is a button not a swich) the buttonstate goes back too.
it should be set and only reset if paraport.0.pin-11.in 's button is pressed.


Try: www.linuxcnc.org/docview/html/man/man9/flipflop.9.html
(though I am not sure if that needs the clock pin connecting, it seems a little odd)

net switch2state paraport.0.pin-11.in and2.0.in1
what do you mean with "and2.0.in1"


There is a function called "and2" which takes two inputs and performs a logical AND.
There can be many of these in a HAL network. They are numbered from 0 up, so and2.0 is the first one.
and2 has two inputs, in1 and in2. So and2.0.in1 is input 1 of the first and2 function.

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

More
28 Jul 2011 18:01 #11965 by BigJohnT
Andy,

I just wrote this comp to give a simple latching output and briefly tested it... what do you think?
component latch "Latching Output";

pin in bit set;
pin in bit reset;
pin out bit out;
variable int current_state;
function _;
license "GPL";
;;
FUNCTION(_) {
    if(set) {current_state = 1;}
    if(reset) {current_state = 0;}    
    if(current_state) {out = 1;}
    if(!current_state) {out = 0;}
}

John

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

More
28 Jul 2011 18:14 #11967 by andypugh
BigJohnT wrote:
[quoteI just wrote this comp to give a simple latching output and briefly tested it... what do you think?[/quote]

I think it is a little more complicated than it needs to be :-)
component latch "Latching Output";

pin in bit set;
pin in bit reset;
pin out bit out;
function _;
license "GPL";
;;
FUNCTION(_) {
    if(set) {out = 1;}
    if(reset) {out = 0;}    
}

Seems to work.

I might be tempted to make it edge triggered:
pin in bit set;
pin in bit reset;
pin out bit out;
variable unsigned old_set;
variable unsigned old_reset;
function _;
license "GPL";
;;
FUNCTION(_) {
    if(set && !old_set) {out = 1;}
    if(reset && !old_reset) {out = 0;}    
    old_set = set;
    old_reset = reset;
}

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

Time to create page: 0.087 seconds
Powered by Kunena Forum