Home made DRO for axis positions

HI all
I’m going to have a try at building a home brew digital readout for the axis positions based on Arduino and the TM1637 6 digit LED Displays.
Is the position data of each axis available easily or should I stop before I start :sweat_smile:
cheers
TP

I don’t think it will be all that straight forward to get at the position data with an Arduino. The UI gets the data using WebSockets, so I suppose if you have an Ethernet shield or WiFi enabled microcontroller you might have a shot at it. A Raspberry Pi would be easier if using WebSockets. Alternatively, you could write some kind of Python HAL component that would run on the Pocket NC which could forward the position data over a USB serial connection. Neither of these options are as straightforward as your last Raspberry Pi solution.

Thanks John. I have a spare RPI so I’ll head down that path.
Cheers
TP

Hi John
Do you have any tips for connecting to the rockhopper server. I just started to sniff the network for commands and found some stuff but I guess it’s a bit more complicated than i thought. Before i start digging further is it a simple ws.send or much more involved to return the axis values? After I get the axis values I can write out to the LED display no problem. Been messing around with the LED’s already and the work fine with the correct library.

I was hoping for something simple like this to get started but… i guess not. :sweat_smile:

import websocket

ws = websocket.WebSocket()
ws.connect(“ws://192.168.1.23:8000/websocket/”, timeout=3)
ws.send(“axis”, “jointIndex”, “actualPosition” ) # something along these lines
print(ws.recv())
ws.close()

You’re not far off. I recommend checking out the documentation on your machine. I believe it’s at: http://192.168.1.23:8000/LinuxCNCWebServerDoc.html

Here are a few tips for starters. All commands sent must be valid JSON strings. Before sending any commands for axis positions, you’ll need to send a login command. Commands should have an id property (you choose the id), a command property (put for a command, get for getting a single piece of information, or watch to register for updates) and a name property. You’ll want to watch the axes_data status item, which will send you position and velocity data for all axes whenever something changes (max of one update per 50ms).

Thanks John. I suspected JSON was the requirement. I didn’t know about the login requirement so that’s a big help. I’ll check the documentation and have another try.
Cheers.

Hi John
I’m close to the result i think. Could you check why this code fails. The payload result is not working as i assume the send is wrong but I don’t know why. I write out the .json file but it’s empty so i expect the error. I don’t know why the file is empty as i thought these json payloads would work.
Regards
Paul
json_loop.py (1.4 KB)

The port is incorrect (should be 8000) and the property name for the username is “user” when logging in.

1 Like

Hi John
Thanks for finding my mistakes :sweat_smile:
Looking so hard at it I couldn’t see the obvious copy paste errors.
All working now. Cheers. I’ll share the full project when done. Just waiting for a couple more LED displays to arrive.
Cheers
Paul

1 Like

Glad I could help, Paul! I’m excited to see what you came up with :slight_smile:

1 Like

Hi John
Got it all formatted and displaying on the LED displays great. just working on the LED display loop now. If I debug step through the code it’s fine but fails after maybe three loops on the tm1637 command when I run normally. Some GPIO thing I need to sort out. Again, all kind of new to me me. Should be completed in a day or two. Golf games getting in the way of hobbies at the moment. :laughing:
Cheers again for your support.
TP

Hello John
This is what I have so far. Just waiting for the other LED modules to arrive and will make a case etc to package it. I’ll share the code and details once I add some comments and clean it up a bit and take out all the testing stuff.
Cheers again for your help.
TP

1 Like

And B axis which is the one I don’t have a great solution for as the B axis can realistically go to a signed 4.3 digit number but I can only display a maximum of 6 of the 8 possible. I guess I’ll just drop off the 2nd and third digits only happens on program execution and not a big deal. Jogging is usually limited to +/- 360 or maybe 720 to dial things in. I may just programmatically limit it to show +/- 360. Haven’t decided yet.
Anyway, all working in each axis.

1 Like

Looking great @TokyoPav! I think dropping a couple digits would be a reasonable solution for B. You may also have a negative sign, so that would take off another digit sometimes. Alternatively, you could try scrolling through the digits.

Unfortunately the scroll call doesn’t work with the 6 digit implementation of this module without a lot of work. The tm1637 is an extended 4 digit module so lots of stuff doesn’t work. Even had to dig deep into the tm1637 module to find a hidden class just to get this far. :joy:

Quick update for John. I got the DTG values working so I’ll put a toggle switch on the panel to switch between actual position and distance to go with a signal to a gpio pin.
Still waiting for some more LED displays to arrive. The batches I received are slightly different colour so 4 more of each on the way. Just need to wire it all up for testing then make a case.
It’s been a handy project so far to understand the websocket interface.
Cheers
TP

1 Like

Hardware and software working.
I change the number formatting of the b axis display based on the current value. +/- numbers all have different formatting. Seems to be the best solution. Physical switch coded in to change the display from actual to distance to go. In the video I switch from dtg to actual.
Just designing a case now and will also have a pi camera inside so can watch remotely.




1 Like


Rendering of the case I’m getting 3D printed. Additional switches for Inch/Metric conversion and maybe something else. Future proof :slight_smile:

1 Like

3D printed case arrived. Test fitting spare LED modules and pi camera. Will complete the build next week. I’ll add a metric / imperial switch to the code and case as a final tweak.
I’ll share all the code and 3D models for those who are interested after the build. I had the case printed through Shapeways.





1 Like

Need to add a small tripod/gopro attachment to the bottom and I think it’s done.



1 Like