How to Control XYZ With a analog Joystick (model: r400b-m4)
- Kasper-001
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 78
- Thank you received: 5
12 Dec 2021 15:27 #228930
by Kasper-001
Hello im not that much into Hal Programming, so i really would be happy if someone can guide/help me to get my analog joystick to move my 3 axis, while holding down a safety button.
my board is a mesa 7i76 connected by 7i92m. on AXIS
Have attach my Hal file
my board is a mesa 7i76 connected by 7i92m. on AXIS
Have attach my Hal file
Attachments:
Please Log in or Create an account to join the conversation.
12 Dec 2021 15:53 #228932
by andypugh
Replied by andypugh on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
Step 1 is to get the analogue positions into HAL.
I think you can do this by changing the 7i76 mode to 1 or 2.
Changeto
I suggest first making a pin list as things currently are. Start LinuxCNC then open a terminal window. Type:
halcmd show pin > all.txt
and maybe
halcmd show pin *7i76* > 7i76.txt
to create text files of the pins.
Then make the changes above and repeat (with new file names) to see if the analogue input pins appear.
Note that the analopgue inputs are only 8 bit and have a 33V range, so you might want to run the joystick at 24V if it can handle that.
Your HAL already has the halui analog jog pins set up, which will help.
I think you can do this by changing the 7i76 mode to 1 or 2.
Change
loadrt hm2_eth board_ip="10.10.10.10" config=" num_encoders=1 num_pwmgens=0 num_stepgens=5 sserial_port_0=00xxxx"
loadrt hm2_eth board_ip="10.10.10.10" config=" num_encoders=1 num_pwmgens=0 num_stepgens=5 sserial_port_0=10xxxx"
I suggest first making a pin list as things currently are. Start LinuxCNC then open a terminal window. Type:
halcmd show pin > all.txt
and maybe
halcmd show pin *7i76* > 7i76.txt
to create text files of the pins.
Then make the changes above and repeat (with new file names) to see if the analogue input pins appear.
Note that the analopgue inputs are only 8 bit and have a 33V range, so you might want to run the joystick at 24V if it can handle that.
Your HAL already has the halui analog jog pins set up, which will help.
The following user(s) said Thank You: Kasper-001
Please Log in or Create an account to join the conversation.
12 Dec 2021 18:08 #228935
by cakeslob
Replied by cakeslob on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
Attachments:
Please Log in or Create an account to join the conversation.
- Kasper-001
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 78
- Thank you received: 5
13 Dec 2021 18:03 #229021
by Kasper-001
Replied by Kasper-001 on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
yes, i now have 4 analog pins which is unused in mode 1
but how to link this in hal ?
but how to link this in hal ?
Please Log in or Create an account to join the conversation.
16 Dec 2021 15:21 #229196
by Michael
Replied by Michael on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
Most of the stuff is already in hal for you, just connect the physical pins to the halui pins
net jog-x-analog halui.axis.x.analog
linuxcnc.org/docs/2.8/html/man/man1/halui.1.html
This should give you an idea what is what
net jog-x-analog halui.axis.x.analog
linuxcnc.org/docs/2.8/html/man/man1/halui.1.html
This should give you an idea what is what
The following user(s) said Thank You: Kasper-001
Please Log in or Create an account to join the conversation.
- Kasper-001
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 78
- Thank you received: 5
16 Dec 2021 20:01 #229201
by Kasper-001
Replied by Kasper-001 on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
Thanks, but do i also need to convert the analog input signal, so it goes both directions X- X+?
with this:halui.axis.L.increment float inpin for setting the jog increment for axis L when using increment-plus/minushalui.axis.L.increment-minus bit ina rising edge will will make axis L jog in the negative direction by the increment amounthalui.axis.L.increment-plus bit ina rising edge will will make axis L jog in the positive direction by the increment amount
with this:halui.axis.L.increment float inpin for setting the jog increment for axis L when using increment-plus/minushalui.axis.L.increment-minus bit ina rising edge will will make axis L jog in the negative direction by the increment amounthalui.axis.L.increment-plus bit ina rising edge will will make axis L jog in the positive direction by the increment amount
Please Log in or Create an account to join the conversation.
17 Dec 2021 05:36 #229267
by Michael
Replied by Michael on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
I think the analog jog is setup more for the joypad controllers as it is looking for a value of -1 to +1
Just looking at your joystick picture it appears each direction of the stick is a potentiometer. Assuming you are going to have it powered by 24v then the output range would be 0-24v and that will need to be scaled down to 0-1 using the scale component. On the X+ side just use a scale gain that brings the range down appropriately. On the Y- side use the scale gain as a negative value to scale and convert to the 0 to -1 range.
Both of those scale outputs would be feed into the halui jog pin and could use a mux2 component of you wanted to make it super tidy.
There is probably a better way to do it but this is just a thought.
Just looking at your joystick picture it appears each direction of the stick is a potentiometer. Assuming you are going to have it powered by 24v then the output range would be 0-24v and that will need to be scaled down to 0-1 using the scale component. On the X+ side just use a scale gain that brings the range down appropriately. On the Y- side use the scale gain as a negative value to scale and convert to the 0 to -1 range.
Both of those scale outputs would be feed into the halui jog pin and could use a mux2 component of you wanted to make it super tidy.
There is probably a better way to do it but this is just a thought.
The following user(s) said Thank You: Kasper-001
Please Log in or Create an account to join the conversation.
- Kasper-001
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 78
- Thank you received: 5
18 Dec 2021 17:17 #229415
by Kasper-001
Replied by Kasper-001 on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
thanks but i think i leave this stand for now, it´s to difficult for me find this out, so i just order a joystick with 4 switch,
Please Log in or Create an account to join the conversation.
19 Dec 2021 00:12 - 19 Dec 2021 00:13 #229456
by Michael
Replied by Michael on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
Here is what the hal may look like for X that should scale 24v analog joystick down to -1 to 0 to +1 scale for the analog jog
loadrt scale names=scale.xminus,scale.xplus
addf scale.xminus
addf scale.xplus
#net jog-x-analog => halui.axis.x.analog
net jog-x-analog <= scale.xminus.out
net jog-x-analog <= scale.xplus.out
setp scale.xminus.gain -0.0417
net x-minus-scale => scale.xminus.in
net x-minus-scale <= hm2_7i92.0.7i76.0.0.analogin0
setp scale.xplus.gain 0.0417
net x-plus-scale => scale.xplus.in
net x-plus-scale <= hm2_7i92.0.7i76.0.0.analogin1
You should be able to test this without the machine moving. Once you can confirm in hal show that "net jog-x-analog" moves from -1 to +1 correctly you can remove the # and that should jog the axis. I believe the jog speed will be a multiple of your jog speed setting.
loadrt scale names=scale.xminus,scale.xplus
addf scale.xminus
addf scale.xplus
#net jog-x-analog => halui.axis.x.analog
net jog-x-analog <= scale.xminus.out
net jog-x-analog <= scale.xplus.out
setp scale.xminus.gain -0.0417
net x-minus-scale => scale.xminus.in
net x-minus-scale <= hm2_7i92.0.7i76.0.0.analogin0
setp scale.xplus.gain 0.0417
net x-plus-scale => scale.xplus.in
net x-plus-scale <= hm2_7i92.0.7i76.0.0.analogin1
You should be able to test this without the machine moving. Once you can confirm in hal show that "net jog-x-analog" moves from -1 to +1 correctly you can remove the # and that should jog the axis. I believe the jog speed will be a multiple of your jog speed setting.
Last edit: 19 Dec 2021 00:13 by Michael.
Please Log in or Create an account to join the conversation.
- Kasper-001
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 78
- Thank you received: 5
19 Dec 2021 09:40 #229476
by Kasper-001
Replied by Kasper-001 on topic How to Control XYZ With a analog Joystick (model: r400b-m4)
maybe it´s me that don't understand it
the joystick has one potmeter for right and left, one for up and down, and the last one for twisting
example for readout on pot meter:
neutral value is 12vdc
left 0vdc
right 24vdc
so why is the use of 2 analog inputs ?
the joystick has one potmeter for right and left, one for up and down, and the last one for twisting
example for readout on pot meter:
neutral value is 12vdc
left 0vdc
right 24vdc
so why is the use of 2 analog inputs ?
Please Log in or Create an account to join the conversation.
Time to create page: 1.252 seconds