Open qvisionsa opened 5 years ago
I think that SENDHEX 85 command it must not go into the bCNC buffer.
@qvisionsa Don't worry about sendhex. It's enough to send it as url-encoded byte.
@PCSDIAS There's no need for such sniffer as bCNC has this builtin. Just launch bCNC and select the debug option in serial connection. It will dump all serial traffic to little black commandline window.
If you have older version without this choice, you can manualy enter, eg.: spy://COM1?raw
In latest git version i've added "controller": "GRBL1"
flag to status JSON, so your new pendant can tell if it's possible to use $J=
jogging or not...
$ curl http://localhost:8080/state
{"G": [], "color": "OrangeRed", "state": "Not connected", "controller": "GRBL1", "msg": "", "wz": 0.0, "wy": 0.0, "wx": 0.0}
@ Harvie
There's no need for such sniffer as bCNC has this builtin. Just launch bCNC and select the debug option in serial connection. It will dump all serial traffic to little black command line window.
Thanks for pointing out this nice feature. bCNC always surprising me, in the good sense.
In latest git version i've added "controller": "GRBL1" flag to status JSON, so your new pendant can tell if it's possible to use $J= jogging or not...
This will allow the automatic selection of the jogging method commands. In order to implement the joystick jogging method with variable step and feed rate the script on the guest side will need to know the maximum feed rates for each axis. These are hardcoded on my prototype, but this is not a general solution. bCNC already retrieves these values from GRBL when the user selects Controller settings via Tools menu. Since feed rate values and the Controller identification are practically immutable after program starts, I think the better place for them is in the reply to the” /config” page. The script on my prototype requests the “/config” page as soon as the html page body is loaded. The reply is used to set corresponding global variables.
Here goes how I managed this in the “Pendant.py” file. I have hardcoded them because I am severely limited in Python coding.
elif page == "/config":
self.do_HEAD(200, content="text/text")
snd = {}
snd["rpmmax"] = httpd.app.get("CNC","spindlemax")
controller ={}
controller["name"] = "GRBL"
controller["version"] = "1.1f"
snd["controller"] = controller
maxFeedRate = {}
maxFeedRate["X"] = "250"
maxFeedRate["Y"] = "250"
maxFeedRate["Z"] = "250"
snd["maxFeedRate"] = maxFeedRate
self.wfile.write(json.dumps(snd))
I am convinced that, if we decide in favor of the variable step and feed rate jogging method we will need a way to clear the bCNC serial queue as soon as the user decides to stop jogging. In order to clear the queue my prototype script requests page “/send?cmd=FLUSH”. Here goes how I managed this in the “Pendant.py” file. I know this not much appropriate but, again, I did this way because of my limitations.
if page == "/send":
if arg is None: return
for key,value in arg.items():
if key=="gcode":
for line in value.split('\n'):
httpd.app.queue.put(line+"\n")
elif key=="cmd":
if value == "FLUSH":
while not httpd.app.queue.empty:
try:
httpd.app.queue.get(False)
except Empty:
continue
httpd.app.queue.task_done()
else:
httpd.app.pendant.put(urllib.unquote(value))
#send empty response so browser does not generate errors
self.do_HEAD(200, "text/text")
self.wfile.write("")
@Harvie @qvisionsa bCNC has already a fully functional web pendant, more adequate to a traditional portrait normal sized screen with a fixed step and feed rate jogging method. At this moment three guys are struggling to develop a web pendant more adequate to a cell phone screen with a 2D jogging method of variable step and feed rate.
I suppose the variable step and feed rate jogging method can be also applied to controllers not sensitive to the “J=” and “\0x85” commands if they are replaced by “G91G0" and “!~” (feed hold & resume).
I would like to hear what you think about the following questions:
Paulo
@PCSDIAS As I can't find a clear solution until now, I decided to implement a javascript queue, to control the jog commands that web pendand will send to pendant.py. Here attached is my work on this. Please take a look, test it and let me know if it is working good. My approach to have a 1D dial is only for test things. The concept in my solution is to put all commands from change event in jquery.rotaryswitch.js in a queue that is executed every 20ms. As it is a LIFO queue, the last command pushed to pendant.py. So, the stop command pushed to pendant.py as soon as it added to the queue and the queue is cleared for next jogging commands. In tmp folder you can find the pendant.py altered for this reason. pendant.zip
I guess we can add some parameter of /send that would avoid the queue...
Have you seen this?
if page == "/send":
if arg is None: return
for key,value in arg.items():
if key=="gcode":
for line in value.split('\n'):
httpd.app.queue.put(line+"\n")
elif key=="cmd":
httpd.app.pendant.put(urllib.unquote(value))
#send empty response so browser does not generate errors
I didn't realized there are two ways of calling /send?gcode=
and /send?cmd=
Maybe that was the problem with SENDHEX. Not that we need it, but it's good to know.
I wonder if tehere's way to add something to the head of the queue instead of its tail...
httpd.app.queue.put(line+"\n")
@Harvie I don't know if I understand well your point.
I didn't realized there are two ways of calling /send?gcode= and /send?cmd= Jog commands and Jog cancel are executed by
elif key=="cmd"
But sender.py distinguish them. Jog commands are executed by sendGCode function and SENDHEX is executed via sendHex function.
For me, a major problem (according to GRBL documentation) is that before send any next jog command from web pendant, we need to know the GRBL controller response. We must wait for on "ok" to send next jog command.
Did you tested my code?
@qvisionsa @Harvie I have spent the weekend and today’s morning trying to make the final adjustments of the bCNC Web pendant with X-Y jogging control as requested by @Harvie. Now that the project is 90% over, I will start paying the due attention to @quisionsa’s work. Everything is contained in a single HTML page, a CSS file and a JS file. The Pendandt.py file was patched as shown in https://github.com/vlachoudis/bCNC/issues/1121#issuecomment-453081180. As soon as one jog button is pressed, the jogging control is presented in a popup window. The three buttons toggle the jogging axis activation. Four modes are possible X, Y, XY and Z. When modes X, Y and Z are selected, the jogging control movement is constrained to the correspondent axis. When not a single jogging axis is activated the jogging control disappears automatically. The result is presented here. Paulo
@PCSDIAS I saw your video and it looks like it works like a charm! For small feed rates and axis displacement, it looks like it is working perfect! In my solution, for small displacements, it looks like to work good also. But when I change feed rate and X,Y displacements to a larger value, there is a problem. For example, I'm sending jo commands like $J=G91X5F500 of F1000 What are the dimensions of your machine? Can you share the joystick code to test it in my solution?
It looks cool :-)
@qvisionsa The feedrate is not a problem as long as the tool displacement is such as the gcode takes 50ms to be executed. My machine dimensions are 250 mm x 250 mm x 60 mm, designed to cut PCB. I hope be able to return to my desk in a few hours. Then I will send you the pendant.py, script.js style.css and index.html files. Just four files, no libraries at all. Since I have sent you a lot of stuff, I bet you have already seen everything you will find there. They are still rough, but the general idea is there.
Here are the files. (https://github.com/vlachoudis/bCNC/files/2757197/bCNC_Web_Pendant.zip)
Paulo.
@qvisionsa
@PCSDIAS As I can't find a clear solution until now, I decided to implement a javascript queue, to control the jog commands that web pendand will send to pendant.py. Here attached is my work on this. Please take a look, test it and let me know if it is working good. My approach to have a 1D dial is only for test things. The concept in my solution is to put all commands from change event in jquery.rotaryswitch.js in a queue that is executed every 20ms. As it is a LIFO queue, the last command pushed to pendant.py. So, the stop command pushed to pendant.py as soon as it added to the queue and the queue is cleared for next jogging commands. In tmp folder you can find the pendant.py altered for this reason. pendant.zip
I am sorry to tell you that it has not worked well. Besides the periodic state request-reply, it was only possible to see some network activity when the Z axis was selected and the knob was rotated. The pendant generated the jog requests but the server has never replied them, as you can see in the screenshot bellow.
The bCNC serial terminal pane also has shown no activity, This might indicate that the server is not processing the pendant jog requests.
Why do not you use the specific “send?gcode” instead of the general “send?cmd”? Probably, you are wasting processing time for command parsing.
Let me be frank with you. Until now I do not understand where you want to go. There is already an algorithm ready on the GRBL page, tested and approved, as I have already shown. Its implementation is very simple.
I fear can not help you if I do not know what you really want.
Paulo
@PCSDIAS I'm sorry for my late reply but I had a lot of work this week.
I have the same exact problem (as per your screenshot). The pendant is working from every computer (windows 10 or mac) connected to the cable or wireless network, but not from android or iphone.
Why do not you use the specific “send?gcode” instead of the general “send?cmd”? Probably, you are wasting processing time for command parsing.
I switched send?cmd with send?gcode and I will test it to see if there is any difference.
Let me be frank with you. Until now I do not understand where you want to go. There is already an algorithm ready on the GRBL page, tested and approved, as I have already shown. Its implementation is very simple.
The weird for me, is that even the original index.html is not working from mobile devices. It's sending 1 request every 5sec approximately. Regarding where I want to go, I would like to create a web interface that has more space to breath, be more clear and maybe with more options.
Stelios
@qvisionsa
Regarding where I want to go, I would like to create a web interface that has more space to breath, be clearer and maybe with more options.
This will be our goal.
For everything I have read in our conversation, I got the conclusion that the only problem you have in designing your web pendant is the jogging procedure. The other aspects of the design are not difficult to implement. They are only a matter of doing a HTML+JavaScript+CSS Graphical User Interface, to capture user input to send commands and g-Code and to display results based on the bCNC replies. Not a big deal. Everyone will have his or her favorite GUI, so I have no intention to deal with this subject.
From now on let us focus on the jogging problem. I hope you do not mind if I start from the beginning.
As far as I know there are two ways to implement the jogging in the GRBL+bCNC world. The one-step way employed by the original web pendant and the multi-step way proposed in Joystick Implementation . Since the first way is easy and already done, I guess you want to implement the multi-step approach. Please tell me if you want to implement a third way. Who knows I may be able to help you.
I guess I exhausted my words about the multi-step way. I suggest you to investigate the cause of problem outside of your design. Network latency may affect the performance. if not taken into account. You will need tools to start doing this. Since I do not know your setup I will describe mine.
I read your comment yesterday and I was glad to receive them, since I was thinking you have just given up of your project.
I put together this no frills tool to help you to investigate the problem. It is a small stand alone HTML file that allows you to test the multi-step jogging mechanism with a variety of parameter values. Updated.
Obviously the “jogger.html” is to be placed in the pendant folder and run in the computer or cellphone browser, at your choice. In order to use this utility you must select the axis and the jogging method. Jogging Rate is the jog command sending rate in Hz. The Feedrate based method calculates the individual step size based on the Jogging Rate and Feedrate. Conversely, the Step based method calculates the feedrate based on Jogging Rate and individual step size. Please note that you cannot set the three parameters entirely at your will since they are related by the equation.
F/(JxS) = 60. Where F: Feedrate, J: Jogging Rate and S: individual step size.
Then you fill in the two parameter values and press the “Start” button, wait as much you want and press the “Stop” button. Check if the information at the bottom agrees with what bCNC presents. Each jog command carries its index as a comment in order to facilitate your investigation.
Hoping this helps you.
Paulo
New features of pendant web api at #1230
Hallo, I'm play with some HW pendant (Arduino NANO and python bridge to webPendant) and I'm try send "Override Feed and Spindle". I can modify feed speed (and spindle speed) by milling/engraving.. For me just one method work by ?cmd=SENDHEX HH (with trouble) OV_FEED_i1 = chr(0x93) OV_FEED_d1 = chr(0x94) OV_SPINDLE_i1 = chr(0x9C) OV_SPINDLE_d1 = chr(0x9D) Value OvFeed (or OvSpindle) changed, but if is sended more requests, the bCNC indicate sertial timeout and hang up. So the bCNC togle dont change possition.
The method(with one Byte) just send ?cmd=0XHH doesn't work. (The JogStop by ?gcode=0x85 work fine and is accepted by bCNC) bCNC indicate unknon command
Have someone idea, what is wrong? or can help me how this have to be used? Thanks
@xFallon maybe you can look into how bCNC handles overrides. I think the bCNC does not expect that somebody else is changing the overrides, so it will overwrite your changes immediately. as a bonus it might get confused by it..
Solution would be to change the override value in the bCNC rather than in GRBL. Just take a look how GUI changes overrides and call the same method. This will need to add new HTTP API to do this obviously.
@Harvie Thank you for confirming that the feed and spindle values are not processed. I assumed that the sent control bytes (or HEXACODE XX or ??) would be processed by bCNC and then sent to the controller (GRBL / Smooty for compatibility) as you describe. I'm not very familiar with python and I wasn't sure if I overlooked this fact.
hey guys, when i try to use these pendants i get invalid command "flush" and i also get invalid command "stopjog" when i jog, i just upgraded to grbl 1.1 as i thought this was the reason i was getting those errors, but im still getting them, i have to press enter on the keyboard everytime it pops up so i can continue jogging, please help im using bcnc 0.9.14 and i have tried all 3 pendants to no avail, please help
@blayno These commands "flush" and "stopjog" were implemented in a customized version of "pendant.py" in order to allow jogging by means of a cell phone. Please see this post. You are supposed to replace the original "pendant.py" file located in the program folder by the "pendant.py" contained in the zip file.
what version of python were these written and work in ?? i have tried to get them to work still to no avail, ive tried python 2.7 and the newest 3.9. i am copying the pendant.py file over aswell
@blayno I use the recommended Python version 2.7 with respective PySerial. IMO you should do a bCNC fresh install as instructed in https://github.com/vlachoudis/bCNC and make sure everything is working well, original pendant included. Afterwards I can help you to install my pendant interface for the cell phone. Cheers.
i sorta got it working bud, theres an issue though, when i install your pendant and copy the pendant.py file over the xyz 0 function stops working, if u use the original bcnc pendant, the xyz 0 function works but i get the flush error and i lose most other functions = home, jog etc
I'm writing a new web interface for bCNC Pendant, using bootstrap 4 and font awesome. When testing the interface without using bCNC web server, all looks fine. Using bCNC web server, I miss all icons from font awesome. Is there some configuration parameter that I have to change or add?