Arduino Control panel
19 Sep 2013 03:54 - 19 Sep 2013 15:35 #39005
by RomainM
Arduino Control panel was created by RomainM
Hi everybody,
My topic has probably already been addressed in other posts but despite all the reading I've done, I 'm not progressing quickly. So I ask for your help !
I've built a CNC router a year ago. I plan to make a Control panel. It will be equipped with 2 buttons ( a green button that will act as Start Home sequence/ Start Program /Resume ; and a red button that will act as Pause program), 2 rotary encoders to adjust feeds and spindle speed.
http://www.usinages.com/ressources/image/129670
I plan to use an arduino to talk to Hal via an Userspace Module using Pyserial. I did some successful tests according to the tutorial of Colin's blog ckcnc.wordpress.com/basic-arduino-emc-howto/.
My first question is about or2. If I have 2 inputs to trigger 1 output. I wrote 2 things that it seems to me the same things, e.g:
#1
#2
What is the right syntax ?
My 2nd question is about where is the best place to do test ? It seem that HAL allow to test pins only 2 by 2. But for my project i need to test more than 2 pins in the same time.
For example, if i would like to start a home sequence in pushing the green button, I could make this test:
if ( arduino.green-btn = 1 & halui.joint.0.is-homed =0 & halui.joint.N.is-homed =0 & ....):
halui.all-home=1
Do you think that I should do the test in the Userspace or in the HAL with some logic component like and2 or2 xor2 ?
I hope that my questions are understandable (and my English too).
Thanks
Romain
My topic has probably already been addressed in other posts but despite all the reading I've done, I 'm not progressing quickly. So I ask for your help !
I've built a CNC router a year ago. I plan to make a Control panel. It will be equipped with 2 buttons ( a green button that will act as Start Home sequence/ Start Program /Resume ; and a red button that will act as Pause program), 2 rotary encoders to adjust feeds and spindle speed.
http://www.usinages.com/ressources/image/129670
I plan to use an arduino to talk to Hal via an Userspace Module using Pyserial. I did some successful tests according to the tutorial of Colin's blog ckcnc.wordpress.com/basic-arduino-emc-howto/.
My first question is about or2. If I have 2 inputs to trigger 1 output. I wrote 2 things that it seems to me the same things, e.g:
#1
net pause-btn-sig <= pyvcp.pause-btn
net pause-btn-sig <= arduino.pause-btn
net pause-btn-sig => halui.program-pause
#2
net pause-pyvcp-btn-sig or2.0.in0 <= pyvcp.pause-btn
net pause-arduino-btn-sig or2.0.in1 <= arduino.pause-btn
net pause-sig or2.0.out => halui.program-pause
What is the right syntax ?
My 2nd question is about where is the best place to do test ? It seem that HAL allow to test pins only 2 by 2. But for my project i need to test more than 2 pins in the same time.
For example, if i would like to start a home sequence in pushing the green button, I could make this test:
if ( arduino.green-btn = 1 & halui.joint.0.is-homed =0 & halui.joint.N.is-homed =0 & ....):
halui.all-home=1
Do you think that I should do the test in the Userspace or in the HAL with some logic component like and2 or2 xor2 ?
I hope that my questions are understandable (and my English too).
Thanks
Romain
Last edit: 19 Sep 2013 15:35 by RomainM.
Please Log in or Create an account to join the conversation.
19 Sep 2013 14:39 #39013
by ArcEye
Replied by ArcEye on topic Arduino Control panel
Hi
Q1, No2 is correct, No1 will not work because you are connecting 2 OUT pins to a signal
www.linuxcnc.org/docs/devel/html/hal/bas...#_net_a_id_sub_net_a
Q2, HAL does not allow conditional tests, beyond anything contained in components
Some sort of test logic like that will have to be in the component and output a bit value to a pin connected to halui.all-home say
If you simply want a signal to go TRUE if either input does, then the or2 component may be easier
I am not entirely sure what you are after, but the way I test test very often is to start with all the variables in a component declared as pins
Then you can track the values of them through Hal Configuration as you run and debug
regards
Q1, No2 is correct, No1 will not work because you are connecting 2 OUT pins to a signal
www.linuxcnc.org/docs/devel/html/hal/bas...#_net_a_id_sub_net_a
Q2, HAL does not allow conditional tests, beyond anything contained in components
Some sort of test logic like that will have to be in the component and output a bit value to a pin connected to halui.all-home say
If you simply want a signal to go TRUE if either input does, then the or2 component may be easier
I am not entirely sure what you are after, but the way I test test very often is to start with all the variables in a component declared as pins
Then you can track the values of them through Hal Configuration as you run and debug
regards
Please Log in or Create an account to join the conversation.
19 Sep 2013 14:52 #39015
by cncbasher
Replied by cncbasher on topic Arduino Control panel
here's some hal configs i use for similar function
note that i use a mesa 7i43 card so the pins will need to be changed to suit
hope it helps .
note that i use a mesa 7i43 card so the pins will need to be changed to suit
hope it helps .
Please Log in or Create an account to join the conversation.
19 Sep 2013 20:21 - 19 Sep 2013 20:39 #39023
by andypugh
The best HAL component for this type of logic is LUT5. It isn't obvious from the name what it does, and it isn't all that obvious from the docs how to use it.
www.linuxcnc.org/docs/html/man/man9/lut5.9.html
However, what it allows you to do is to define an output signal value for every combination of up to 5 input values.
A few ways to figure out the LUT5 setup are here
wiki.linuxcnc.org/cgi-bin/wiki.pl?Lut5
Personally I do write down the full truth-table and then work out the binary number.
I have created a Google Docs spreadsheet that does the calculations for you:
docs.google.com/spreadsheet/ccc?key=0Ahj...fWGtfTEE&usp=sharing
Replied by andypugh on topic Arduino Control panel
My 2nd question is about where is the best place to do test ? It seem that HAL allow to test pins only 2 by 2. But for my project i need to test more than 2 pins in the same time.
For example, if i would like to start a home sequence in pushing the green button, I could make this test:
if ( arduino.green-btn = 1 & halui.joint.0.is-homed =0 & halui.joint.N.is-homed =0 & ....):
halui.all-home=1
The best HAL component for this type of logic is LUT5. It isn't obvious from the name what it does, and it isn't all that obvious from the docs how to use it.
www.linuxcnc.org/docs/html/man/man9/lut5.9.html
However, what it allows you to do is to define an output signal value for every combination of up to 5 input values.
A few ways to figure out the LUT5 setup are here
wiki.linuxcnc.org/cgi-bin/wiki.pl?Lut5
Personally I do write down the full truth-table and then work out the binary number.
I have created a Google Docs spreadsheet that does the calculations for you:
docs.google.com/spreadsheet/ccc?key=0Ahj...fWGtfTEE&usp=sharing
Last edit: 19 Sep 2013 20:39 by andypugh.
Please Log in or Create an account to join the conversation.
19 Sep 2013 21:18 #39024
by RomainM
Replied by RomainM on topic Arduino Control panel
thank you very much to all of you. I 'll have a good evening to learn all yours recommendations!
I'll will post my code once it will write .
I'll will post my code once it will write .
Please Log in or Create an account to join the conversation.
21 Sep 2013 05:23 - 21 Sep 2013 05:29 #39068
by RomainM
Replied by RomainM on topic Arduino Control panel
Hi !
Lut5 component saved me ! My home sequence, start, resume and pause buttons work very well. Hopefully there was the calculator of Andy, because without I would be very lost ...
So thanks !
So I was writting to you, because I didn't get to work the rotary encoder to adjust feed rate. But during my writing I solved my problem.
So, this is attached my files for an arduino with 2 buttons (green for home sequence, start, resume program and red for pause) and a rotaty encoder to adjust feed rate (same job for spindle).
Next step will be talk to Huanyang Inverter with RS482 protocol and add when the Pause button will push a Z retract, stop spindle, jog allow and when resume button will push go back to X Y Pause position, start the spindle, go to Z pause position and go back to mill. If you have ideas I'll be very glad.
Thanks. Romain
Lut5 component saved me ! My home sequence, start, resume and pause buttons work very well. Hopefully there was the calculator of Andy, because without I would be very lost ...
So thanks !
So I was writting to you, because I didn't get to work the rotary encoder to adjust feed rate. But during my writing I solved my problem.
So, this is attached my files for an arduino with 2 buttons (green for home sequence, start, resume program and red for pause) and a rotaty encoder to adjust feed rate (same job for spindle).
Next step will be talk to Huanyang Inverter with RS482 protocol and add when the Pause button will push a Z retract, stop spindle, jog allow and when resume button will push go back to X Y Pause position, start the spindle, go to Z pause position and go back to mill. If you have ideas I'll be very glad.
Thanks. Romain
Last edit: 21 Sep 2013 05:29 by RomainM.
Please Log in or Create an account to join the conversation.
21 Sep 2013 05:49 #39069
by cncbasher
Replied by cncbasher on topic Arduino Control panel
Attached Modbus user component for Hyuang vfd
if you do not already have it
if you do not already have it
Please Log in or Create an account to join the conversation.
26 Sep 2013 03:47 #39194
by RomainM
Replied by RomainM on topic Difficulties with RS485 Huanyang hal component
Hi,
I downloaded the hy_vfd-linuxcnc. I added the lines in my custom.hal, postgui.hal and panel.xml. But I'm not really sure of the way to instal the rest of the files, I done "makefile" then "INSTALL". I think that these operations compile the diferrent files in a "hy_vfd" and copy it in /usr/bin. Am I in the right direction (i'm a begginer in Linux...)?
Whatever, I launched Linuxcnc 2.6.0. Now I can see the Pyvcp. But the modbus com led is red. When I sent a M3 S18000, nothing happen Do you have an idea how debug my problem ?
Some setting will be helful:
vfd: PD001=2, PD002=2, PD163=1, PD164=2 and PD165=3.
custom.hal:
loadusr -Wn spindle-vfd hy_vfd -n spindle-vfd -v -d /dev/ttyS0 -p even -r 19200 -s 1
How I could be sur e that the ttyS0 port is working?
My RS232/485 converter is an ebay model like .
I use a 3 wires cable with shield. I connect A/RS+ (converter) => RS+ (VFD), B/RS- (converter) => RS- (VFD), GND (Converter) => ACM (VFD)
I measure 0V betwenn GND and RS- and +5V beteween GND and RS+
I hope that all of these inspire one of you.
Thanks
I downloaded the hy_vfd-linuxcnc. I added the lines in my custom.hal, postgui.hal and panel.xml. But I'm not really sure of the way to instal the rest of the files, I done "makefile" then "INSTALL". I think that these operations compile the diferrent files in a "hy_vfd" and copy it in /usr/bin. Am I in the right direction (i'm a begginer in Linux...)?
Whatever, I launched Linuxcnc 2.6.0. Now I can see the Pyvcp. But the modbus com led is red. When I sent a M3 S18000, nothing happen Do you have an idea how debug my problem ?
Some setting will be helful:
vfd: PD001=2, PD002=2, PD163=1, PD164=2 and PD165=3.
custom.hal:
loadusr -Wn spindle-vfd hy_vfd -n spindle-vfd -v -d /dev/ttyS0 -p even -r 19200 -s 1
How I could be sur e that the ttyS0 port is working?
My RS232/485 converter is an ebay model like .
I use a 3 wires cable with shield. I connect A/RS+ (converter) => RS+ (VFD), B/RS- (converter) => RS- (VFD), GND (Converter) => ACM (VFD)
I measure 0V betwenn GND and RS- and +5V beteween GND and RS+
I hope that all of these inspire one of you.
Thanks
Please Log in or Create an account to join the conversation.
26 Sep 2013 15:21 #39204
by cncbasher
Replied by cncbasher on topic Difficulties with RS485 Huanyang hal component
firstly see if you have a compiled binary in your /usr/bin called hy_vfd
to compile go to the directory hyvfd and in terminal type make && sudo make install
you may also need to make sure that your rs232 port has permissions for ttyS0
and that you have the tty device belonging to the dialout group
a few checks are good here ...
first check that you are a member of the dialout group
in a terminal type groups $(USER)
this will list all groups you are a member of ...
if you are not a member of dialout group then add yourself to the list by
sudo (your password ) --add ${USER} dialout
then logout and back in
to compile go to the directory hyvfd and in terminal type make && sudo make install
you may also need to make sure that your rs232 port has permissions for ttyS0
and that you have the tty device belonging to the dialout group
a few checks are good here ...
first check that you are a member of the dialout group
in a terminal type groups $(USER)
this will list all groups you are a member of ...
if you are not a member of dialout group then add yourself to the list by
sudo (your password ) --add ${USER} dialout
then logout and back in
The following user(s) said Thank You: RomainM
Please Log in or Create an account to join the conversation.
26 Sep 2013 16:09 #39205
by RomainM
Replied by RomainM on topic Difficulties with RS485 Huanyang hal component
Thanks for your advices, I'll check all of that at noon or tonight.
Have a good day !
Have a good day !
Please Log in or Create an account to join the conversation.
Time to create page: 0.103 seconds