Hello Guest it is September 29, 2020, 10:09:02 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - smurph

Mach4 General Discussion / Re: Keep track of OB axis
« on: February 01, 2019, 02:05:50 AM »
Brett is right.  Once the carousel is homed, and brought to the first pod (either ABS or INC move), the distance between each pod on the carousel is going to be the same.  You don't have to do anything except move incrementally forward or backward from there.  You can keep track of the current pod in the code. 

Say you have a 20 pod carousel that has 3600 counts per rev.  The pods will have 180 counts between them.  Pod one is 20 counts positive from home pos.

1. Home (motor is now at 0)
2. Got to pod 1 (20 counts positive offset from home).  Set the pod variable.  pod = 1;
3. Calc what it takes to move to to pod 10.  Do shortest path math (say we go positive for grins).
4. Move to pod 10:  9 * 180 = 1620.  jog incrementally 1620 counts.  set pod var to 10.
5. Calc what it takes to move to to pod 8.  Do shortest path math.  We are going to go negative this time.
6. Move to pod 8:  -2 * 180 = -360.  jog incrementally -360 counts.  set pod var to 8.

And we never have to even look at an encoder.  This is how my Geneva drive works on my carousel tool changer.  No encoder what so ever on it.  Just a pod #1 switch.  It is all math from there.


Mach4 General Discussion / Re: Keep track of OB axis
« on: January 31, 2019, 11:48:36 PM »
Well...  get over it already!  :)

Just think of the scripts as translation scripts.  Update translates the system value into the human readable value.  Modify translates the human value that is input into the DRO into the system value.

The distinction between update and modify pertains to who/what is changing the value of the DRO.  The update script is run when the system changes the value of the DRO.  The modify script is run when the user clicks on the DRO, changes the value, and then hits enter. 

Maybe that helps?  It is about as clear as mud, I know.  But once you see the light, it will make sense. 


Mach4 General Discussion / Re: Keep track of OB axis
« on: January 31, 2019, 10:57:26 PM »
Ok, and encoder isn't a great example for the modify script because typically you only read an encoder.  But here goes...

The update script is for when the encoder updates the DRO.  So you have the ability to translate the encoder's value to what you want to see.  I think we are all on the same page about this one. 

The modify script is to do the reverse when the user (you) edit the DRO.  Convert the displayed (or typed in) value to encoder counts.  But like I said, unless you have hardware that will let you set the encoder value, it doesn't fit.

But you could use the encoder reading, plus the value of another register as an offset if you wanted.  Then using the modify script to set the offset register so that the DRO reads whatever you put in it.  :)

update: encoder value + offset register value -> displayed value.
modify: input value -> encoder value + offset register value.  (only the offset register value is modified because the encoder is read only.)


Mach4 General Discussion / Re: Uninstalling Mach4
« on: January 31, 2019, 10:42:58 PM »
You can uninstall it by just deleting the C:\Mach4Hobby.  Then reinstall with the official release available on the web page, not a development version.  Development versions are just that, for developers and testers. 


Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 27, 2019, 12:33:17 PM »
Wow!  Nice catch Daz.

I guess one could do

True = true
False = false

At the top of the code. 


Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 26, 2019, 07:30:33 PM »
Ha!  I'm NEVER right, according to wifey.  But that's ok.  :) 

Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 26, 2019, 06:03:44 PM »
Did you use a frame or a dialog?  For a dialog, you use

rc = UI.<your dialog variable name>:ShowModal()

For a frame:

UI.<your frame variable name>:Show()

Code: [Select]
-- Lua code generated with wxFormBuilder (version Aug  8 2018)
-- http://www.wxformbuilder.org/

-- Load the wxLua module, does nothing if running from wxLua, wxLuaFreeze, or wxLuaEdit
package.cpath = package.cpath..";./?.dll;./?.so;../lib/?.so;../lib/vc_dll/?.dll;../lib/bcc_dll/?.dll;../lib/mingw_dll/?.dll;"

UI = {}

-- create MyDialog1
UI.MyDialog1 = wx.wxDialog (wx.NULL, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxSize( 226,133 ), wx.wxDEFAULT_DIALOG_STYLE )
UI.MyDialog1:SetSizeHints( wx.wxDefaultSize, wx.wxDefaultSize )

UI.bSizer1 = wx.wxBoxSizer( wx.wxVERTICAL )

UI.bSizer2 = wx.wxBoxSizer( wx.wxHORIZONTAL )

UI.m_staticText1 = wx.wxStaticText( UI.MyDialog1, wx.wxID_ANY, "Steve:", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.m_staticText1:Wrap( -1 )

UI.bSizer2:Add( UI.m_staticText1, 0, wx.wxALL, 2 )

UI.m_textCtrl1 = wx.wxTextCtrl( UI.MyDialog1, wx.wxID_ANY, "", wx.wxDefaultPosition, wx.wxDefaultSize, 0 )
UI.bSizer2:Add( UI.m_textCtrl1, 1, wx.wxALL, 2 )

UI.bSizer1:Add( UI.bSizer2, 1, wx.wxEXPAND, 5 )

UI.m_sdbSizer1 = wx.wxStdDialogButtonSizer()
UI.m_sdbSizer1OK = wx.wxButton( UI.MyDialog1, wx.wxID_OK, "" )
UI.m_sdbSizer1:AddButton( UI.m_sdbSizer1OK )
UI.m_sdbSizer1Cancel = wx.wxButton( UI.MyDialog1, wx.wxID_CANCEL, "" )
UI.m_sdbSizer1:AddButton( UI.m_sdbSizer1Cancel )

UI.bSizer1:Add( UI.m_sdbSizer1, 1, wx.wxEXPAND, 5 )

UI.MyDialog1:SetSizer( UI.bSizer1 )

UI.MyDialog1:Centre( wx.wxBOTH )

-- Connect Events

UI.m_sdbSizer1Cancel:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements m_Cancel()

end )

UI.m_sdbSizer1OK:Connect( wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event)
--implements m_OnOk

end )


To show the above dialog code:

rc = UI.MyDialog1:ShowModal()

rc will be wx.wxID_OK or wx.wxID_CANCEL, depending on what button was pressed.

The frame's Show() method isn't modal, as it is a top level window.  Frame and dialogs each have their pros and cons.


Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 22, 2019, 04:10:37 AM »
Nah...  you guys are making too much of the generated code.  Why?  Because you don't know the paradigm that wxFormBuilder is using.  Once you understand that, it becomes a tool to help you work smarter, not harder.  :)  Anyway, I was talking to Brett and he said he might do a video on how to make something useful with wxFormBuilder.  It is one of those things that is hard to explain but easy to show.  And when you get past that, the generated code will actually teach you what is doing what by example. 

Not say you HAVE to.  But I'm just thinking you guys would be REALLY dangerous :) and have fun with it at some point. 


Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 21, 2019, 03:11:36 PM »
But sizers rule!!!  That was the greatest invention since beer cans.  They can be a bit confusing at first.  But once you get them, you'll wonder how the world got along without them in the past. 


Mach4 General Discussion / Re: Un-Supported wxNumberEntryDialog
« on: January 21, 2019, 12:54:39 AM »
It isn't necessary.  But I would say it is desirable.  Because if you can't use the stock "data grabber" dialogs and require something juuuuust a bit more complex, the wxFormbuilder thing pays big dividends.   Otherwise, you start to have to know MORE about wxWidgets to code a dialog by hand. 

Maybe someone can do a video on how to work with wxFormBuilder.