WHB04B-6 for Smoopi

131 views
Skip to first unread message

Moi Toi

unread,
May 14, 2019, 4:04:50 AM5/14/19
to Smoothie-Dev
Hi all

I try to update HB04 modules from smoopi for use with XHC WHB04b-6.



For now i have all push button working.

I try to manage the wheel and rotary speed setting but for start i have i think a noob error :


[DEBUG  ] whb04b: btn_1: 0, btn_2: 0, speed: 1, axis: Z, wheel: 1
[ERROR  ] WHB04B: Exception - Traceback (most recent call last):
  File "/home/machinekit/smoopi/kivy-smoothie-host/modules/whb04b.py", line 452, in _run
    dist = 0.001 * step * self.mlut[speed_mode]
TypeError: can't multiply sequence by non-int of type 'float'







I have commented all call to update lcd for the moment.


Any help really appreciated my knowledge for kivy is near 0.


Br

Wolfmanjm

unread,
May 14, 2019, 5:17:21 AM5/14/19
to Smoothie-Dev
self.mlut[speed_mode] returns a string not a float. You need to fix mlut to look up floats rather than strings.

Moi Toi

unread,
May 14, 2019, 6:56:16 AM5/14/19
to Smoothie-Dev
Thanks a lot it's really better now !

I have implemented Mpg Step mode


                            if self.status == 2:     // mode continu or mpg
                                dist = 0.001 * step * self.mlut[speed_mode]
                            if self.status == 1:     // mode step
                               dist = self.slut[speed_mode] * step

But did you know what does Lead mode ?


Wolfmanjm

unread,
May 14, 2019, 7:58:16 AM5/14/19
to Smoothie-Dev
> But did you know what does Lead mode ?
No Sorry.

Moi Toi

unread,
May 14, 2019, 11:41:46 AM5/14/19
to Smoothie-Dev

I have use lead for create a safe and reset for mode Step/Mpg



Now it's time for check Display Dro on the pendant but off course i don't understand something.

[DEBUG  ] SerialConnection: send_message: $I


[DEBUG  ] SerialConnection: send_message: ?
[DEBUG  ] Comms: incoming_data: ['ok\r\n']
[DEBUG  ] Comms: incoming_data: ['<Idle|MPos:6.5530,0.0000,0.0000,92.4469|WPos:6.5530,0.0000,0.00']
[DEBUG  ] Comms: incoming_data: ['00|F:1000.0,100.0>\n']
[DEBUG  ] Comms: Got status: ['Idle', 'MPos:6.5530,0.0000,0.0000,92.4469', 'WPos:6.5530,0.0000,0.0000', 'F:1000.0,100.0']
[DEBUG  ] Comms: got status:Idle - rest: {'WPos': [6.553, 0.0, 0.0], 'MPos': [6.553, 0.0, 0.0, 92.4469], 'F': [1000.0, 100.0]}
[DEBUG  ] SerialConnection: send_message: M221 S100
[DEBUG  ] Sent 27 out of 24
[DEBUG  ] LCD [254, 253, 1, 1, 6, 0, 154, 21, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 100, 0, 0, 0, 0, 0]

note : The empty line is done directly in the log

from computer Machinekit to device:
size 24B hdr 0xfdfe seed 0xaa status 0x42 coord1 +0087.4873 coord2 +0000.0000 coord3 -0208.3624 feed 0000 spindle rps 00000

06 fe fd aa 42 57 00 09  
06 13 00 00 00 00 d0 00  
06 28 8e 00 00 00 00 00

I don't understand how work this parts of your code 

    def _setv(self, off, a):
        self.lock.acquire()
        for v in a:
            (f, i) = math.modf(v)  # split into fraction and integer
            f = int(round(f * 10000))  # we only need 3dp
            (l, h) = self.to_le(int(i))
            self.lcd_data[off] = l
            self.lcd_data[off + 1] = h
            (l, h) = self.to_le(f, v < 0)
            self.lcd_data[off + 2] = l
            self.lcd_data[off + 3] = h
            off += 4
        self.lock.release()


I hope you can help me.

Br

Moi Toi

unread,
May 14, 2019, 12:28:34 PM5/14/19
to Smoothie-Dev
[DEBUG  ] SerialConnection: send_message: $I

[DEBUG  ] SerialConnection: send_message: ?
[DEBUG  ] Comms: incoming_data: ['ok\r\n']
[DEBUG  ] Comms: incoming_data: ['<Idle|MPos:6.8090,0.0000,0.0000,92.4469|WPos:6.8090,0.0000,0.00']
[DEBUG  ] Comms: incoming_data: ['00|F:1000.0,100.0>\n']
[DEBUG  ] Comms: Got status: ['Idle', 'MPos:6.8090,0.0000,0.0000,92.4469', 'WPos:6.8090,0.0000,0.0000', 'F:1000.0,100.0']
[DEBUG  ] Comms: got status:Idle - rest: {'F': [1000.0, 100.0], 'WPos': [6.809, 0.0, 0.0], 'MPos': [6.809, 0.0, 0.0, 92.4469]}
[DEBUG  ] SerialConnection: send_message: M221 S100
[DEBUG  ] Sent 24 out of 21
[DEBUG  ] LCD [254, 253, 1, 0, 6, 0, 154, 31, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 100, 0, 0]



I have corrected the padding lengt but not work better ^^

I don't understand where is generated the first byte 06 at the start of the usb data packet

Br

Moi Toi

unread,
May 14, 2019, 12:39:00 PM5/14/19
to Smoothie-Dev
Finally understand my error :


#        n += self.hid.send_feature_report(data[0:8], 0x07)
#        n += self.hid.send_feature_report(data[8:16], 0x07)
#        n += self.hid.send_feature_report(data[16:24], 0x07)
        n += self.hid.send_feature_report(data[0:7], 0x06)
        n += self.hid.send_feature_report(data[7:14], 0x06)
        n += self.hid.send_feature_report(data[14:21], 0x06)


Moi Toi

unread,
May 14, 2019, 3:25:45 PM5/14/19
to Smoothie-Dev
Well


now need to found the way for update axis ABC when switch is higher than 0x14


Need a way for switch MCS WCS ?


    def setwcs(self, a):
       
self._setv(4, a)


#    def setmcs(self, a):
#        self._setv(15, a)



I think for MCS/WCS need to check a flag something like :

If self._mcs: 

                    self.setmcs(self.app.mpos[0:3])
elif: 

                    self.setwcs(self.app.wpos)



But for A axis no idea.

Moi Toi

unread,
May 14, 2019, 7:04:36 PM5/14/19
to Smoothie-Dev
Hi again


I have some trouble with "UnboundLocalError: local variable 'data' referenced before assignment"


Please if you can check this commit especially :

- near line 319 moved near line 392 and code changed for show XYZ or ABC
- near line 475  code changed and removed for show XYZ or ABC

I'm sorry for ask many things.

Br

Wolfmanjm

unread,
May 15, 2019, 4:54:54 AM5/15/19
to Smoothie-Dev
that means you are accessing the data variable before it has been set. 
Just set data before you try to use it. Moving the stuff where you have moved it to is wrong.

Moi Toi

unread,
May 15, 2019, 6:20:03 PM5/15/19
to Smoothie-Dev
Hi

Thanks a lot for reply but for now i does not found how to implement the DRO update with check some flag for XYZ or ABC

I also does not found how to display correctly RESET when rotary knob a OFF


One question it is normal than some comms.write sequence have \n and some other does not have ?

                                    self.app.comms.write("M220 S{}".format(self.f_ovr))


                                   
self.app.comms.write('\x18')    ?? can you explain what is that value ??


                                   
self.app.comms.write('$X\n')


                                   
self.app.comms.write("{}\n".format(cmd))


                                   
self.app.comms.write("$J {}{} F{}\n".format(axis, dist, speed))


else for ";" but is a commented line :

                                    self.app.comms.write("M220 S{}".format(self.f_ovr))
                               
# if self.s_ovr != self.app.sr:
                               
#     self.app.comms.write("M221 S{}".format(self.s_ovr));


Br

Wolfmanjm

unread,
May 16, 2019, 6:37:38 AM5/16/19
to Smoothie-Dev
self.app.comms.write('\x18') sends a control X which is immediate kill and go into HALT state. (Does not work over network, only over USB or serial).

commands always have to be terminated with \n

Moi Toi

unread,
May 17, 2019, 9:50:47 PM5/17/19
to Smoothie-Dev
Hi

I really like if you can check my last revision and says if something is wrong for you.

Your review is precious i hope you can check.


Br

Wolfmanjm

unread,
May 18, 2019, 8:16:12 AM5/18/19
to Smoothie-Dev
It looks ok but the real question is does it work, I obviously cannot test it.

If it works then it is ok :)

Golfo

unread,
May 18, 2019, 10:45:32 AM5/18/19
to Wolfmanjm, Smoothie-Dev
Hi

Many many thanks for checking

Yes this work correctly but I think display refresh can be better (more fast)

Any suggest for better coding near line 589 ?

Sometime ligne 386 report error one time at startup but not allways.
UnboundLocalError: local variable 'axis_mode' referenced before assignment




-need to add abs/rel display mode (work for this asap)

-Any idea for use CON mode is welcome (have already step and mpg)

-clear DRO for BC axis : need to be reviewed if more than 4 axis for make this automatic 
Is there a available command able to report AXIS=?

Br.



--
You received this message because you are subscribed to the Google Groups "Smoothie-Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smoothie-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smoothie-dev/5502c54c-e944-4f9b-8f8f-5bf8fb0b0543%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Moi Toi

unread,
May 19, 2019, 8:56:27 PM5/19/19
to Smoothie-Dev
Hi


I have added  abs/rel display mode and found a simple way for clear DRO for ABC.

For now i rewrite some button command for more accuracy/usability with smoopi.
But this point me for one question, it is something planned/wanted later to allow smoopi to use some macro or sdcard file after pause and before resume and if possible after homing ?

-after homing i like to reset WCS and maybe clear some G92
-after pause i like to ask machine go to park and stop spindle/coolant/mist
-beffore resume i like to ask return to last position and restart spindle/coolant/mist before restart gcode

Br

Wolfmanjm

unread,
May 20, 2019, 5:17:46 AM5/20/19
to Smoothie-Dev
you can use a macro button to do all this. it is not something smoothie needs to do

Moi Toi

unread,
May 20, 2019, 6:42:36 AM5/20/19
to Smoothie-Dev
I'm finally not really convinced for resume/suspend macro in pendant or also in host because the best way, "i think" is allowing smoothie to execute correctly :
after_suspend_gcode                 M32_pause.g          
before_resume gcode                 M32_resume.g

because the goal are to have pause/resume sequence same for all case Gcode, M32, suspend, resume, push button or other.

Thanks for reply

Wolfmanjm

unread,
May 20, 2019, 6:44:40 AM5/20/19
to Smoothie-Dev
That will not be possible M32 cannot be used that way and will not be supportable in the future.

Moi Toi

unread,
May 20, 2019, 5:50:45 PM5/20/19
to Smoothie-Dev
It is possible to propose patch for smoopi suspend smoothie ?




    def start_print(self):
        if self.is_printing:
            if not self.paused:
                # we clicked the pause button
                self.app.comms.stream_pause(True)
                self.app.comms.write('suspend\n')

Moi Toi

unread,
May 20, 2019, 7:08:13 PM5/20/19
to Smoothie-Dev
this does not work allways have some proble like no move or all at same time or only XY :
after_suspend_gcode                 G59.3G10L20P9X0Y0Z0G53G0Z0M5M9M107G53X0Y0
after_suspend_gcode                 G59.3G10L20P9X0Y0G53G0Z0M5M9G28
after_suspend_gcode                 G10L20P9X0Y0Z0G4P0.1G53G0Z0
after_suspend_gcode                 G10L20P9X0Y0Z0G53G0Z0      
+ several other test failed      


this work like a charm:
after_suspend_gcode                 M32_pause.g                                            # work fine

pause.g:
G59.3
G10 L20 P9 X0 Y0 Z0
G53 G0 Z0
M5
M9
M107
G53 G0 X0 Y0



this work like a charm
before_resume_gcode                 G59.3G0X0Y0M3M7M106     #smoothie does herself return to working Z position before restart



Regardless to my attempt i hope you think like me and : 

-pause/resume from smoopi ask smoothiboard serial command resume/pause after et before  : self.app.comms.stream_pause(True)/self.app.comms.stream_pause(False).
-pendant ask smoopi to pause/resume by : self.app.main_window.start_print()
-if they are mecanical button or other GLCD ask smoothieboard by switch to do resume/pause cmd

I hope in this way all the system is synced and know the actual pause/resume state correctly.

What do you think about this ?

Br

Wolfmanjm

unread,
May 21, 2019, 5:53:59 AM5/21/19
to Smoothie-Dev
No

Wolfmanjm

unread,
May 21, 2019, 5:54:41 AM5/21/19
to Smoothie-Dev
a pause is NOT a suspend they are totally different operations.

Wolfmanjm

unread,
May 21, 2019, 5:57:11 AM5/21/19
to Smoothie-Dev
G53 cannot be used this way. It MUST be on a line by itself or at the start of a line, so You cannot use G53 this way.

Wolfmanjm

unread,
May 21, 2019, 7:06:27 AM5/21/19
to Smoothie-Dev
Instead of using G53 (which you can't here), define and save a park position G28.1 and then just issue a park G28 (if in cnc mode) in your after suspend gcode

Moi Toi

unread,
May 22, 2019, 8:15:19 PM5/22/19
to Smoothie-Dev
Hi

If you can check my last release i have some question inside comment on line :

372
384
433 and the block on the bottom
561



Br

Wolfmanjm

unread,
May 23, 2019, 3:59:28 AM5/23/19
to Smoothie-Dev
It happens on mine when there is no data or a timeout. It may not happen on yours as you have a different unit.

Moi Toi

unread,
May 23, 2019, 5:35:07 PM5/23/19
to Smoothie-Dev
Hi

are you agree for PR (if coded correctly off course)  if i try to add a config option into smoopi for select pause vs suspend for GUI button ?

Br

Wolfmanjm

unread,
May 24, 2019, 3:42:55 AM5/24/19
to Smoothie-Dev
no i won't accept an option like that. pause and suspend are not interchangeable and I won't accept that change.

the rest I would accept.

Wolfmanjm

unread,
May 24, 2019, 7:39:20 AM5/24/19
to Smoothie-Dev
You can put a suspend operation in your whb04b module though if you like but you cannot change what the pause button does in smoopi as that would be completely wrong and would break many other things.

Golfo

unread,
May 24, 2019, 9:46:17 AM5/24/19
to smooth...@googlegroups.com
Hi

No problem I have ask but I can understand.

The whole problem still the same for me, I simply want a coherent solution for park machine after pause with possible Z first and a solution for resume to working solution using XY first. 
I can’t find a clean working solution undependently from where this pause/resume is asked.

From smoothie something is possible with the use of suspend and after_suspend_gcode and before_resume_gcode this can also be mapped to panel button switch and console command, so in this way all the chain are synched perfectly and can also keep in synch with pendant command.

But from smoopi you incorporate the use of pause but this pause is only know and managed by the host smoopi itself and for me this break the chain. 
You can check my code I have make some minor change for remove some console commande like self.app.main_window.abort_print in place of self.app.comms.write(‘x18’). In this way this is the host the master and pendant are only slave, but maybee another time I’m in wrong...

I can understand you have some good reason for use a new state pause  but I dislike this approach. Or this approach for me need to be enhanced in smoothie for make possible to know this pause state and make possible to do a after_pause_gcode. 

Maybee in reality something than add pause to console command and add the before_pause_gcode to smoothieware is the best and simple way for restore a full synched chain.

It’s difficult for me to be clear and choose the good word i really don’t wants to worry you, I apologize if something is hurting or badly writed.

I’m ok (but saad) for close this subject if you don’t share what I think and in this way you can be sure i can understand no problem for me.

 Now I’m able change 2/3 line of code for have something not clean but working and stop to not sleeping lool.

You have my whole thanks and full respect for sharing/support/(other lol)

Br
--
You received this message because you are subscribed to the Google Groups "Smoothie-Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smoothie-dev...@googlegroups.com.

Moi Toi

unread,
Sep 10, 2019, 6:36:07 PM9/10/19
to Smoothie-Dev
Hi all.

Driver is now ready to test, if someone have this device i can help for startup.




At same time i have a question for you wolfmanjm

It is something possible and wanted to add the possibility to parse script like "@scripts/resetG92-1.g" from pendant ini file macro ?
Did you think these need to be done on the driver or elsewhere in the smoopi code ?

br

Moi Toi

unread,
Sep 10, 2019, 6:50:36 PM9/10/19
to Smoothie-Dev
M32 work from the pendant ini file but i use the same script from Macro widget and from pendant, i think i'm potentialy not alone for this case.

For now i need to copy the script both in the smoopi folder and in the smoothieboard sdcard, i think with the risk to forget to sync both.

On my opinion the pendant is managed fully from smoopi so it's really better to have all in the same directory and share the same script from Macro widget and from pendant macro.

I hope your agreement and maybee some starting point.

Golfo

unread,
Sep 12, 2019, 6:59:42 AM9/12/19
to Smoothie-Dev
Upgrade for use script done inside driver file.

Br
--
You received this message because you are subscribed to the Google Groups "Smoothie-Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smoothie-dev...@googlegroups.com.

Moi Toi

unread,
Dec 22, 2019, 6:34:49 PM12/22/19
to Smoothie-Dev
Hi

This is not really related but i think is better to ask here.

Is there a way for copy past or upload smoothieware config file from smoopi ?

Br

Moi Toi

unread,
Dec 22, 2019, 9:03:49 PM12/22/19
to Smoothie-Dev
Another question regarding smoopi.

I do not fully understand how to use script probe centre from macro (nothing move)

[script probe hole]
name=Hole Probe
io= true
exec=ruby scripts/probe.rb --job center
args=--diameter,--tool-diameter





I suspect these line from probe.rb to not work properly on my config (ignored '?') :

# send query to get current position
def getpos(mpos=false)
  STDOUT.write("?")

Can you confirm ?


DIsplay write only :
script : M120
script : Position tool approx in the center of the hole

Br


Moi Toi

unread,
Dec 22, 2019, 9:21:35 PM12/22/19
to Smoothie-Dev
changing   STDOUT.write("?") to   STDOUT.write("?\n") seems to be better but i have a error 

script : M120
script : ?
script : Position tool approx in the center of the hole
script : M121
script : "send" unexcepted response 
<Idle|MPos:3.3637,2.1275,0.0000,0.0000|WPos:-0.0175,2.1275,0.0000|F:1800.0,100.0>


Br

Wolfmanjm

unread,
Dec 23, 2019, 4:27:33 AM12/23/19
to Smoothie-Dev
?\n would be wrong.

No idea why it doesn't work on your system. However there is a find center builtin and you do not need to use the script. it is in the tools menu

If sending ? doesn't work that is a fundamental issue with your system, it should be able to write single characters.

Moi Toi

unread,
Dec 23, 2019, 5:39:48 AM12/23/19
to Smoothie-Dev
Hi

I don't know why send "?" does not work fine with the script, i have change nothing from your original smoopi files.
Sorry for not remember tool menu : find center, work very fine, many thanks
Reply all
Reply to author
Forward
0 new messages