XHC-WHB04-4 Python component

More
7 years 7 months ago #128225 by fixer
EDIT 2020:

The driver and sample config is now availiable on github: github.com/MZot/whb04

-written in Python
-display now works
-display is refreshed only when data actually changes and when axis selector is not in "off "state This should preserve battery life and better comply with EMC rules (not sure).
-connects directly to LinuxCNC stat channel to read values
-shows workpiece coordinates on display
-automatically switches to manual mode when operated
-reset button sends abort() command to LinuxCNC
-macro1-macro10 buttons send MDI command with o-call to subroutines with axis selector and "fn" button state as parameters #1 and #2

Tested and works with LinuxCNC 2.7. I did not test with master.

Please Log in to join the conversation.

More
7 years 7 months ago #128251 by pl7i92
Replied by pl7i92 on topic XHC-WHB04-4 Python component
Why dont you simple use the internal XHC component
i added my personel mashine

there is a image inside ANLEITUNG JPG that tells you the functions

Please Log in to join the conversation.

More
7 years 6 months ago #131677 by andypugh

fixer wrote: LCD display does not work. I need some help there. If anyone knows how to send packets for strings on LCD, please tell. :) Some info about this is here: forum.planet-cnc.com/viewtopic.php?f=12&t=1125


Is this component any good?

linuxcnc.org/docs/2.7/html/man/man9/lcd.9.html

(The answer is likely to be "maybe not" as it rather depends on sending one character per servo-thread, and your component runs in userspace rather than in a realtime thread)

Is there any chance that a common component could support bit XHC types?

Please Log in to join the conversation.

More
7 years 6 months ago #131690 by fixer
Replied by fixer on topic XHC-WHB04-4 Python component

Is this component any good?

No. It is an usb transmission, it is also not realtime.
XHC expects packet for string in some weird format, it shouldn't be hard to generate it, but I didn't bother with it.

Is there any chance that a common component could support bit XHC types?

Yes, this should be simple. Different devices have different usb PIDs. I would try to connect to the first one, if that fails the script should continue to try with the other PID.

Please Log in to join the conversation.

More
7 years 2 months ago #143708 by serafim
Thanks for the script! I had to grant permitions to make it work.

Create file /etc/udev/rules.d/99-my.rules and add a line in it:
SUBSYSTEM=="usb", ATTR{idVendor}=="10ce", ATTR{idProduct}=="eb93", MODE="666"

Reload udev with "sudo udevadm trigger" and unplug/plug adapter.

Please Log in to join the conversation.

More
7 years 2 months ago #143711 by pl7i92
Replied by pl7i92 on topic XHC-WHB04-4 Python component
her is my main hal for the xhc i use on lots of mashines 4plasmas
Code:
loadusr -W xhc-hb04 -I mars_xyz_xhc.ini -H -s 4 #loadusr -W xhc-hb04 -H -I wbcnc_2.7.9.ini -s 4 loadrt flipflop names=flipflop_resume,flipflop_pause,flipflop_run,flipflop_icon addf flipflop_resume servo-thread addf flipflop_pause servo-thread addf flipflop_run servo-thread addf flipflop_icon servo-thread # RESET/ESTOP button loadrt multiclick names=click_estop,click_macro1,click_zero,click_spindel,click_stop,click_mode,click_macro2,click_macro3,click_probe_z addf click_estop servo-thread addf click_mode servo-thread addf click_macro2 servo-thread addf click_probe_z servo-thread #click_probe_z in postgui net xhc-macro2 xhc-hb04.button-macro-2 => click_macro2.in net xhc-mode xhc-hb04.button-mode => click_mode.in net estop-xhbutton xhc-hb04.button-reset => click_estop.in net estop-activated halui.estop.activate <= click_estop.single-click net estop-reset halui.estop.reset <= click_estop.double-click # Home button addf click_macro3 servo-thread net xhc-macro3 xhc-hb04.button-macro-3 => click_macro3.in net home halui.home-all <= click_macro3.double-click # maschine on/off addf click_macro1 servo-thread net maschine-on-off-xhbutton xhc-hb04.button-macro-1 => click_macro1.in net joy-mashine-off halui.machine.off <= click_macro1.single-click net joy-mashine-on halui.machine.on <= click_macro1.double-click # Program control addf click_stop servo-thread net button-stop xhc-hb04.button-stop => click_stop.in net stop-prog-run halui.program.stop <= click_stop.single-click net set-prog-to-start click_stop.double-click => halui.mdi-command-12 net button-start-pause xhc-hb04.button-start-pause => flipflop_pause.clk flipflop_resume.clk flipflop_run.clk net is-paused halui.program.is-paused => flipflop_resume.data flipflop_pause.reset net is-running halui.program.is-running => flipflop_pause.data flipflop_run.reset flipflop_resume.reset net is-idle halui.program.is-idle => flipflop_run.data net resume flipflop_resume.out => halui.program.resume net pause flipflop_pause.out => halui.program.pause net run flipflop_run.out => halui.mode.auto halui.program.run net step xhc-hb04.button-rewind => halui.program.step # Absolute position LCD net pos-x halui.axis.0.pos-feedback => xhc-hb04.x.pos-relative net pos-y halui.axis.1.pos-feedback => xhc-hb04.y.pos-relative net pos-z halui.axis.2.pos-feedback => xhc-hb04.z.pos-relative net pos-a halui.axis.3.pos-feedback => xhc-hb04.a.pos-absolute # Relative position LCD net pos-rel-x halui.axis.0.pos-relative => xhc-hb04.x.pos-absolute net pos-rel-y halui.axis.1.pos-relative => xhc-hb04.y.pos-absolute net pos-rel-z halui.axis.2.pos-relative => xhc-hb04.z.pos-absolute net pos-rel-a halui.axis.3.pos-relative => xhc-hb04.a.pos-relative # jog Speed loadrt mux8 count=2 addf mux8.0 servo-thread addf mux8.1 servo-thread #wheel speed per tick setp mux8.0.in0 0 setp mux8.0.in1 0.1 setp mux8.0.in2 0.5 setp mux8.0.in3 0 setp mux8.0.in4 1 #speed for moving axes setp mux8.1.in0 0 # this one must be 0 to prevent motion unless a button is pressed setp mux8.1.in1 250 setp mux8.1.in2 1000 setp mux8.1.in3 0 setp mux8.1.in4 2500 # step logic loadrt updown count=1 addf updown.0 servo-thread setp updown.0.wrap true setp updown.0.min 0 setp updown.0.max 6 net stepcount updown.0.countup <= xhc-hb04.button-step => xhc-hb04.stepsize-up #reset step to zero net updownreset updown.0.reset <= click_mode.single-click #convert count s32 to float loadrt conv_s32_float count=1 addf conv-s32-float.0 servo-thread net conv-step conv-s32-float.0.in updown.0.count #step signal compare loadrt comp count=7 addf comp.0 servo-thread addf comp.1 servo-thread addf comp.2 servo-thread addf comp.3 servo-thread addf comp.4 servo-thread addf comp.5 servo-thread addf comp.6 servo-thread setp comp.0.in0 0 setp comp.1.in0 1 setp comp.2.in0 2 setp comp.3.in0 3 setp comp.4.in0 4 setp comp.5.in0 5 setp comp.6.in0 6 loadrt or2 count=5 addf or2.0 servo-thread addf or2.1 servo-thread addf or2.2 servo-thread addf or2.3 servo-thread addf or2.4 servo-thread net stepcounter-out conv-s32-float.0.out => comp.0.in1 comp.1.in1 comp.2.in1 comp.3.in1 comp.4.in1 comp.5.in1 comp.6.in1 #jog scale selector from step to mux net scale-selectorA mux8.0.sel0 <= comp.1.equal => or2.0.in0 net scale-selectorB mux8.0.sel1 <= comp.2.equal => or2.0.in1 net scale-selectorC mux8.0.sel2 <= comp.3.equal => or2.1.in0 net led-wheel-sectorA or2.1.in1 <= or2.0.out # postgui net pyvc-led-wheel or2.1.out => pyvcp.wheel_select net jog-scale mux8.0.out => axis.0.jog-scale axis.1.jog-scale axis.2.jog-scale axis.3.jog-scale net joy-speed-1 mux8.1.sel0 <= comp.4.equal => or2.2.in0 net joy-speed-2 mux8.1.sel1 <= comp.5.equal => or2.2.in1 net joy-speed-3 mux8.1.sel2 <= comp.6.equal => or2.3.in0 net led-button-sectorA or2.3.in1 <= or2.2.out # postgui net pyvc-led-button or2.3.out => pyvcp.button_select net joy-speed-final halui.jog-speed <= mux8.1.out #logic for Button velomotion loadrt and2 count=12 addf and2.0 servo-thread #Jog positiv X addf and2.1 servo-thread addf and2.2 servo-thread addf and2.3 servo-thread #jog negativ X addf and2.4 servo-thread addf and2.5 servo-thread addf and2.6 servo-thread # Zeroing X addf and2.7 servo-thread addf and2.8 servo-thread addf and2.9 servo-thread #a plus addf and2.10 servo-thread #a minus addf and2.11 servo-thread #azero # Jog wheel and axis selection button net jog-x axis.0.jog-enable <= xhc-hb04.jog.enable-x => and2.0.in0 and2.3.in0 and2.6.in0 net jog-y axis.1.jog-enable <= xhc-hb04.jog.enable-y => and2.1.in0 and2.4.in0 and2.7.in0 net jog-z axis.2.jog-enable <= xhc-hb04.jog.enable-z => and2.2.in0 and2.5.in0 and2.8.in0 net jog-a axis.3.jog-enable <= xhc-hb04.jog.enable-a and2.9.in0 and2.10.in0 and2.11.in0 net joy-pos xhc-hb04.button-macro-7 and2.3.in1 and2.4.in1 and2.5.in1 and2.9.in1 net joy-neg xhc-hb04.button-macro-6 => and2.0.in1 and2.1.in1 and2.2.in1 and2.10.in1 net jog-counts xhc-hb04.jog.counts => axis.0.jog-counts axis.1.jog-counts net jog-counts-neg xhc-hb04.jog.counts-neg => axis.2.jog-counts #net jog-speed halui.jog-speed <= halui.max-velocity.value net joy-xpos-jog halui.jog.0.plus <= and2.3.out net joy-xneg-jog halui.jog.0.minus <= and2.0.out net joy-ypos-jog halui.jog.1.plus <= and2.4.out net joy-yneg-jog halui.jog.1.minus <= and2.1.out net joy-zpos-jog halui.jog.2.plus <= and2.5.out net joy-zneg-jog halui.jog.2.minus <= and2.2.out net joy-apos-jog halui.jog.3.plus <= and2.9.out net joy-aneg-jog halui.jog.3.minus <= and2.10.out # Wheel for feedrate and spindle setp halui.feed-override.scale 0.1 net jog-counts => halui.feed-override.counts net jog-feed halui.feed-override.count-enable <= xhc-hb04.jog.enable-feed-override net jog-feed2 halui.feed-override.value => xhc-hb04.feed-override setp halui.spindle-override.scale 0.01 net jog-counts => halui.spindle-override.counts net jog-spindle halui.spindle-override.count-enable <= xhc-hb04.jog.enable-spindle-override net jog-spindle2 halui.spindle-override.value => xhc-hb04.spindle-override net spindle-rps motion.spindle-speed-cmd-rps => xhc-hb04.spindle-rps #buttons #net reset-jog updown.0.reset <= click_mode.single-click net goto-partzero xhc-hb04.button-goto-zero => halui.mdi-command-03 net park halui.mdi-command-04 <= xhc-hb04.button-home net safe-z halui.mdi-command-05 xhc-hb04.button-safe-z # X=0, Y=0, Z=0 XYZ=0 addf click_zero servo-thread net xh-button-zero xhc-hb04.button-zero => click_zero.in net zerobutton-single-click click_zero.single-click => and2.6.in1 and2.7.in1 and2.8.in1 and2.11.in1 net zerobutton-double-click click_zero.double-click => halui.mdi-command-06 net x0 halui.mdi-command-00 and2.6.out net y0 halui.mdi-command-01 and2.7.out net z0 halui.mdi-command-02 and2.8.out #net a0 halui.mdi-command-02 and2.11.out # halfzero net halfzero-x halui.mdi-command-07 <= xhc-hb04.button-half-x net halfzero-y halui.mdi-command-08 <= xhc-hb04.button-half-y #plasma torch addf click_spindel servo-thread net xh-button-spindel xhc-hb04.button-spindle => click_spindel.in net plasma-off halui.mdi-command-09 <= click_spindel.single-click net plasma-on halui.mdi-command-10 <= click_spindel.double-click net plasma-thc-on halui.mdi-command-11 <= click_spindel.triple-click #load gcode by double click the macro2 net xhloadfile click_macro2.double-click => halui.mdi-command-13 #test icons #net is-running => xhc-hb04.icon-cycle #net test-icon xhc-hb04.button-macro-7 => xhc-hb04.hb-mode #net home-icon halui.joint.0.is-homed xhc-hb04.icon-ref #net in-position => xhc-hb04.icon-pos # this needs to be set in postgui file #net reseterror click_mode.double-click => axisui.notifications-clear

the coresponding INI
Code:
[XHC-HB04] BUTTON=17:button-reset BUTTON=16:button-stop BUTTON=01:button-goto-zero BUTTON=02:button-start-pause BUTTON=03:button-rewind BUTTON=04:button-probe-z BUTTON=0C:button-spindle BUTTON=06:button-half BUTTON=07:button-zero BUTTON=08:button-safe-z BUTTON=09:button-home BUTTON=0A:button-macro-1 BUTTON=0B:button-macro-2 BUTTON=05:button-macro-3 BUTTON=0F:button-macro-6 BUTTON=10:button-macro-7 BUTTON=0D:button-step BUTTON=0E:button-mode [HAL] HALUI = halui HALFILE = mars_xyz_xhc.hal HALFILE = custom.hal HALFILE = xhc-hb04.hal POSTGUI_HALFILE = custom_postgui_hb04.hal [HALUI] # HalUI-MDI-Befehle hier einfügen (max. 64) erste =MDI 0 MDI_COMMAND=G10 L20 P1 X0 MDI_COMMAND=G10 L20 P1 Y0 MDI_COMMAND=G10 L20 P1 Z0 MDI_COMMAND=G0 G54 X0 Y0 Z25 MDI_COMMAND=G0 G53 X50 Y460 Z-25 MDI_COMMAND=G0 G53 Z-25 MDI_COMMAND=G10 L20 P1 X0 Y0 Z0 MDI_COMMAND=o<halfx> call MDI_COMMAND=o<halfy> call MDI_COMMAND= M5 MDI_COMMAND=S100 M3 MDI_COMMAND= M5 MDI_COMMAND= M5 MDI_COMMAND= M5 MDI_COMMAND = o<znullen> call MDI_COMMAND = G10 L20 P1 X 0.0 M100 MDI_COMMAND = G10 L20 P1 Y 0.0 M100 MDI_COMMAND = G10 L20 P1 X0.0 Y0.0 M100 MDI_COMMAND = G54 G1 X0.0 Y0.0 F2000 MDI_COMMAND = G53 G1 X50.0 Y460.0 Z-10 F800 MDI_COMMAND = M5

Please Log in to join the conversation.

More
7 years 2 months ago #143713 by serafim
Thanks, pl7i92. Can you or somebody share hal for the WHB04B? I can see that designated pins work but drives are not moving. I guess I'm missing some pin connection.
Code:
loadusr -W whb04b net axis0jogenable axis.x.jog-enable whb04b.sel_x net axis1jogenable axis.y.jog-enable whb04b.sel_y net axis2jogenable axis.z.jog-enable whb04b.sel_z net joginc whb04b.inc net joginc axis.x.jog-scale net joginc axis.y.jog-scale net joginc axis.z.jog-scale net jogcnts whb04b.mpg_cnt net jogcnts axis.x.jog-counts net jogcnts axis.y.jog-counts net jogcnts axis.z.jog-counts setp axis.x.jog-vel-mode 1 setp axis.y.jog-vel-mode 1 setp axis.z.jog-vel-mode 1

Please Log in to join the conversation.

More
7 years 1 month ago #143727 by pl7i92
Replied by pl7i92 on topic XHC-WHB04-4 Python component
this is only the base connection
So do you got a COMP called whb04b
otherwise use the internal for the base XHC it will work for all pins

its alot more to be connected to run the B version
WHERE are the BUTTONS Discribed INI file

loadusr -W xhc-hb04 -H -I wbcnc_2.7.9.ini -s 4


linuxcnc.org/docs/html/man/man1/xhc-hb04.1.html

you need to understand how the postgui system workes together with HALUI
Get signal from external and do somthing in the servo tread time

Please Log in to join the conversation.

More
6 years 5 months ago #167967 by fixer
Replied by fixer on topic XHC-WHB04-4 Python component
I edited fist post, component is now on github.
It does behave a bit different, it produces much less traffic on the USB bus than the "official" driver.

Please Log in to join the conversation.

More
5 years 9 months ago #196547 by probotix
Good job on this. I have it running on 2.8.1

Can you explain this syntax for me?
Code:
h.fn = data[2] == 12 or data[3] == 12

Also, when running inches, the 1.0 jog increments only moves 0.48 inches. Any ideas?

Please Log in to join the conversation.

Time to create page: 0.162 seconds
Powered by Kunena Forum