Gallery, Projects and General > The Design Shop

DIY DRO for lathe or mill

<< < (4/5) > >>

AdeV:
Some really good ideas coming through, thanks :) Hope to make this the DRO for Everyone (on Madmodder at least!) :D

Some specifics:
 
Bill - I do like your vertically scrolling fractional indications! That's a far better solution than the one I had in my head (where it just displayed the nearest /64th, or simplification thereof). With enough gap between each reading, you could very accurately creep up on a specific fraction. I'd probably change the colour when you were bob on (to +/- the nearest micron or tenth maybe), as a visual cue that you're on dimension. Obviously the digital readouts would confirm. With your permission, I'd like to steal that idea...

Regarding the entry of fractions (e.g. the 1/27" mentioned); you'd type that in, the machine stores it as 0.9407mm. This converts back to 0.0307" (to the nearest 10th); the fractional display would indicate it was somewhere between 1/32nd and 3/64ths, using the slider style per Bill's video.

To the speed of the Arduino - yep, going "bare metal" is definitely an option, although at the moment it seems that the Arduino is good for a fairly fast speed (80mm/sec seems OK). I could also look to using a Teensy - a bit more costly, but they seem to have some serious horsepower for not a lot of bucks ($20 for the latest Teensy 4.1). I've never tried a Teensy, this seems like a perfect excuse :D

I like your "overspeed" indicator idea as well. I may have mentioned there's an "R" signal as well, which I *think* is a pulse every Xmm (the manual is vague to the point of silence about this); but if there is an overspeed, I might be able to use the "R" pulses as a way of getting the scale back to a known good value... although if you're determined, you'll still be able to spoof it. Plus, if it misses one, it'll make matters worse.

Regarding the beeper: You'll be able to turn it off :)

Swapping between machines? Don't see why not. Storage is cheap, the DRO could easily have any number of "personalities". From a hardware POV, having an interface box which stayed on the machine with the scales, with a one-cable connection to the display unit, is easy peasy. There'd only be four wires: Power, ground, I2C. It would also open up the possibility of having a number of different DRO heads (with different capabilities) which would all attach to the same base unit... Scope creep! I like it!  :palm:  :)



------

Another one for the feature list:

 - Automatic edge-finder offset. Guess who had to do some edge finding this morning :) Now, this is easy enough when I'm working in Imperial (just preset the DRO to +/- 0.100" depending on which way the table is moving, presto). Much more of a pain with Metric - I have to edge-find in Imperial, move to zero-zero, THEN switch to mm. Why don't edge finder sets have 1 or 2 imperial edge finders and 1 or 2 metric edge finders, instead of mix/matching 1/2", 3/8" (with 0.200" indicator barrel), and the pointy ones that no-one ever uses? The way I see this function working is; you find your edge; press "Edge", choose the tool you're edge-finding with, choose the edge you just found on a graphic on the screen, and the appropriate axis gets set with the correct +/- offset.

BillTodd:
Re scrolling display. Ok by me:-)

I should have the source code somewhere,if it would help.

AdeV:
Update: Progress is being made.... I gave up with Python (horrid language), and Gtk (even more horrid)...

I've also decided (just now) to not use the Arduino; I finally bought me a Teensy 4.0, for the princely sum of around $20. Good GRIEF that thing is fast! Using the boggo Encoder library, and about a dozen lines of code, I can now read the encoder so quickly that I just can't make it miss steps! Mind you, I daren't REALLY slam it from one end to the other in case I damage it (they're not cheap, you know!). Not that surprising, the Arduino was doing "OK" (but could easily be provoked into losing position), and the Teensy 4.0 is around 600 times faster. Yes - six HUNDRED.

Mental...

SO... the current plan is:

- Teensy to read the axis (possibly one will now do all four axes, this has yet to be proven)
- Raspberry Pi running a Go service routine, to read the encoder via I2C, and output a stream of Server Sent Events over http.
- Also on the Pi - a React website (possibly served via the Go program), which provides the UI.
- It will run in a Chromium browser running full-screen in Kiosk mode.

Why React? Because I can do it, and because desiging a GUI in HTML/CSS is literally one point seven seven three two million percent easier than trying to figure out GTK.

The only fly in the ointment is - I don't yet know if the React app on the Pi will be fast enough. On my dev machine (which is old and not very fast), it needs the server events to be throttled down to 50Hz, or it gets laggy. Still, 50 updates a second is more than enough, I reckon anything down to 20Hz will be acceptable.

Oh, yeah, and in React, it took me about 2 hours to get the "tape measure" fractional display working. 3 days in Gtk and I couldn't even find out how to show a part of an image in a box...

BillTodd:

--- Quote ---Python (horrid language), and Gtk (even more horrid)...
--- End quote ---
Python has plenty of good points but it is quirky and takes a while to get used-to.

Gtk (also Tkinter ) yes really is horrid , it mixes C++ with python in a' WTF did they do that?' kind of way. BUT I've built a few applications with it and it works ok

Kivy is also horrid , though mainly because it is trying to be all things to all systems. BUT is useful because it is all things to all systems.

If you want fast for £20 look at sipeed Maix Dock dual 64bit core  risc-V @600Mhz , wifi display, camera ,digital audio , and a hardware neural network ! - has a reasonable IDE for windows and Linux  - documentation is - not all it could be ...

BillTodd:

--- Quote ---I couldn't even find out how to show a part of an image in a box...
--- End quote ---

I couldn't remember how I did mine - just checked .
I used a few of VB Label controls (three for fractions :current, positive and negative) drawn on a picture box control, updated the label.caption text on the fly  then cropped and positioned them to give the appearance of motion 


--- Code: ---Public Sub InitScale(Div As Integer)
'fractional scale is divided into Div parts
'e.g. if Div = 4 then scale = ---- 1/4, 1/2, 3/4 ----
Divisions = Div
Dim n As Integer, Y As Integer
Dim F As String
Dim Scl As PictureBox
Dim DivY As Integer 'height between scale divisions

    Set Scl = picSclFrac
    Scl.Cls
    DivY = Scl.TextHeight("1/2") + 50 '
    ActiveScaleHeight = DivY * Div
    Scl.Height = ActiveScaleHeight + (DivY * 4)
    'draw zeroline
    Y = (UserControl.ScaleHeight / 2)
    UserControl.Line (0, Y)-(UserControl.ScaleWidth, Y)
   
    'draw scale lines
    Y = DivY
    F = Format(Div - 1) & "/" & Format(Div)
    Scl.Line (0, Y)-(Scl.ScaleWidth, Y)
    Scl.CurrentX = (Scl.ScaleWidth / 2) - (Scl.TextWidth(F) / 2)
    Scl.CurrentY = Y - (Scl.TextHeight("1/2") / 2)
    Scl.Print F
   
    Y = DivY * 2
    Scl.Line (0, Y)-(Scl.ScaleWidth, Y)
    Scl.CurrentX = (Scl.ScaleWidth / 2) - (Scl.TextWidth("0") / 2)
    Scl.CurrentY = Y - (Scl.TextHeight("1/2") / 2)
    Scl.Print "0"
   
    For n = 1 To Div - 1
        'draw scale lines
        Y = DivY * (n + 2)
        F = strProperFraction(n, Div) 'Format(n) & "/" & Format(Div)
        Scl.Line (0, Y)-(Scl.ScaleWidth, Y)
        Scl.CurrentX = (Scl.ScaleWidth / 2) - (Scl.TextWidth(F) / 2)
        Scl.CurrentY = Y - (Scl.TextHeight("1/2") / 2)
        Scl.Print F
    Next n
   
    Y = DivY * (Div + 2)
    Scl.Line (0, Y)-(Scl.ScaleWidth, Y)
    Scl.Line (0, Y)-(Scl.ScaleWidth, Y)
    Scl.CurrentX = (Scl.ScaleWidth / 2) - (Scl.TextWidth("0") / 2)
    Scl.CurrentY = Y - (Scl.TextHeight("1/2") / 2)
    Scl.Print "0"
   
    Y = DivY * (Div + 3)
    F = "1/" & Format(Div)
    Scl.Line (0, Y)-(Scl.ScaleWidth, Y)
    Scl.CurrentX = (Scl.ScaleWidth / 2) - (Scl.TextWidth(F) / 2)
    Scl.CurrentY = Y - (Scl.TextHeight("1/2") / 2)
    Scl.Print F
    Scl.Refresh
    'calculate offset
    SclOffset = (UserControl.ScaleHeight / 2) - (DivY * 2)

    PositionScale 0
End Sub

Private Function strProperFraction(Numerator As Integer, Divisor As Integer) As String
'return correctly formatted proper fraction
Dim n As Integer
Dim nr As Single
Dim dr As Single

    For n = Numerator To 1 Step -1
        nr = Numerator / n
        dr = Divisor / n
        If (nr - Int(nr)) = 0 And (dr - Int(dr)) = 0 Then
            strProperFraction = Format(nr) & "/" & Format(dr)
            Exit Function
        End If
    Next n
   
End Function

Public Sub PositionScale(POS As Single)
'position picsclfrac
Dim IntPos As Integer
Dim FracPos As Single
IntPos = Int(POS)
FracPos = POS - IntPos
' set integer labels
labFracInte(2).Caption = Str(IntPos - 1) & " -"
labFracInte(1).Caption = Str(IntPos) & " -"
labFracInte(0).Caption = Str(IntPos + 1) & " -"
labFracInte(1).Top = (UserControl.ScaleHeight / 2) - (labFracInte(1).Height / 2) - (labFracInte(1).Height * FracPos)
labFracInte(2).Top = labFracInte(1).Top - labFracInte(1).Height
labFracInte(0).Top = labFracInte(1).Top + labFracInte(0).Height
picSclFrac.Top = SclOffset + (0 - (ActiveScaleHeight * FracPos))

End Sub
--- End code ---

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version