Hello Guest it is November 13, 2019, 09:18:14 AM

Author Topic: How Much interest is there in an UPDATE to the Mach specific VB??  (Read 12089 times)

0 Members and 1 Guest are viewing this topic.

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
How Much interest is there in an UPDATE to the Mach specific VB??

   I have seen lately a rash of VB releated issues on this and the other site. I have TWO quetions.
I am willing to post up an "Mach VB Update" manual, IF some others would ALSO step up and offer to help.

Question1:  Would you like to see the above manual done?

Question2: If you would, who amoung you would be willing to HELP with it, I mean post up not just code, but code examples.

Needed: Would be two other people: One who could take the code and examples, and put them into a PDF and perhaps another guy
to update the WAY-OUT-OF-DATE   WIKI.

if it looks like a doable thing, then I will post for those willing to contribute, a central email, to collect the stuff, I will then add your stuff to my stuff that
I have collected through the years, and then get the Draft to someone who has SKILL doing Editing and Publishing (not me).

scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #1 on: March 22, 2009, 12:08:03 PM »
Hi Scott,
#1. Yes
#2. I am a relative Mach Noob, so I am not sure how helpful would be with Mach VB code,
     But I am in the same spot that others are. Wishing that the documentation was better.

I have programmed in Pascal , Visual Basic and also program Pic controllers so I have some knowledge in that area.
For some family members I have written and maintain websites, so I have  the ability to write and publish to the web.
I can produce PDF's or other document types. I have never done a Wiki , but it is just a web page.
I would be willing to put some time in getting the information in a readable, orderly manner.
regards,
RJ

Offline Chaoticone

*
  • *
  •  5,628 5,628
  • Precision Chaos
    • View Profile
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #2 on: March 22, 2009, 12:30:19 PM »
Scott, I can help put the info. into PDF format and update the WIKI.

Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #3 on: March 22, 2009, 10:37:46 PM »
Cool, well it looks like we have a team.........

Now to the Contributors:

   If you have VB (Mach Specific), code snippits that like me, you have gathered from here or there, (i.e. Art was/is famous for dropping here before never seen before VB calls and functions).

So for those who have VB that is NOT documented in the currently existing WIKI, or other source. Please Email me your Code Snippits Plus examples of how it is used to my Email at: (replace the AT with @)    poppabearAThughes.net

I will add your code(s) to my list of "Undocumented" codes and then Brett I will send you a Draft to put into PDF format.
You name and the code you contributed will be listed at the back of the doc, assuming it is differerent from what, Brett, Jay, Ron, and I have.........

scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #4 on: March 23, 2009, 12:55:20 AM »
Scott,

Obviously, I would be really happy to see this.  I doubt I know enough to be useful (just dangerous....) but I'd be happy to proof-read and provide feedback.

Regards,
Ray L.
Regards,
Ray L.

Offline Greolt

*
  •  956 956
    • View Profile
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #5 on: March 23, 2009, 01:20:39 AM »
Like Ray I too would be very interested to see what can be done in this area.

However I don't see that I could make any meaningful contribution.

My dad always said...... "you can know just enough to get yourself into trouble".....Well that's me.  ;D ;D

Greg
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #6 on: March 23, 2009, 06:56:35 AM »
Having just recently learned how to copy and paste, program my VCR, set-up my telephone and configure my wrist watch, I'm certain that this would be a most helpful pdf for us VERY basic beginners. :)
I can only help by asking questions......hope I don't get in the way.
GREAT idea !
Thanks,
RC

Offline Bill_O

*
  •  250 250
    • View Profile
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #7 on: March 23, 2009, 08:21:16 AM »
Scott,
Like many that have answered I can not help very much but could really use this.
Bill

Offline poppabear

*
  • *
  •  2,233 2,233
  • Briceville, TN, USA
    • View Profile
    • S S Systems, LLC
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #8 on: March 26, 2009, 08:21:03 PM »
Here is some of the little "Tid Bits", I have picked up here and there, that adds to the already existing "Mach Specific Subroutines". IF you have some that are not listed on the Wiki, or in this list, please post them here, and we can when all is said and done, collect it all in a single "Community" document.

GetMasterInput(0-127)
GetMasterOutput(0-127)

SetMasterOutput(0-127, 0-15bit)

SetMasterInput(0-127, 0-15bit)

Serial port
You can send bytes of raw data to a serial port. The port number (i.e. n in COMn) to be used and the baud rate for transmission is set in Config>Logic. RTS/CTS hardware flow control protocol will be used to control large volumes of data but this will not be normally required. Data is transmitted 8 data bits, 1 stop bit No Parity by a call of SendSerial.
Sub SendSerial (chars as String)
Example: to write the value of X DRO to an LCD display connected to the serial (RS232) port.
Call SendSerial ("X-Axis = " & GetDRO (0))

[edit]
Foreign ports
Scripts can access ports on the PC which are additional to the one (or perhaps two) parallel port(s) defined in Config>Ports and Pins. These are accessed at the basic hardware port address level and you will have to be aware of the details of the individual port addresses, allocation of data and status bits etc.
Function GetPortByte (pAddr as Integer) as Byte
Sub PutPortByte (pAddr as Integer, bData as Byte)
This feature should be used with great care as, if misused, it can interfere with any peripheral on your system, including the hard-drive.

[edit]
Waiting and system features
As described above the script code and Mach3 itself run in two separate processes. You can test to see in Mach3 is busy or idle by calling:
Function IsMoving () as Boolean
This will return True if Mach3 is busy. You should call it in a loop after commanding an axis move or other function which could take a significant time and before reading DROs or LEDs that could be affected by the move.
Example:
Call Code ("G0X12Z100")
While IsMoving ()
WEnd
x = GetOEMDRO (802)  ' get Z value in case it has been Z inhibited
Function IsStopped () as Boolean
Returns True if Mach3 is not in the process of executing a part-program. ??? Can anyone clarify what happens when in Feedhold, SingleStep and waiting for a Shuttle Jog pulse between blocks of code?
Function IsLoading () as Boolean
Returns true if the part program is loading rather than being actually run (e.g. so the toolpath is being generated or regenerated). This can be used to inhibit script actions like Question() in this situation.
Sub SystemWaitFor (sigNo as Integer)
Waits for the given signal to become active. This allows interfacing with physical controls on the machine.
Sub WaitForPoll ()
Waits until a Modbus Poll has taken place. Not sure if this is safe if Modbus is not turned on???. Use this in a loop, e.g. in macropump macro waiting for interesting things to come from the Modbus device.

Function IsFirst () as Boolean
Returns True if this is the first call of the function after Mach3 has exited from the EStop state. This can be used to re-initialse data that would be lost at a n EStop.
Sub LoadLinTable()
Reloads the table giving linearisation data for Mach3 spindle speed.
VB Timers
There are 24 timers, numbered from timer 0 to timer 23.
SetTimer(x) , will reset that timer to 0.
N = GetTimer(x) , will tell you how much time has passed since it was set to
zero. Granularity is in micro seconds.

Example:
if IsActive( INPUT1 ) then
if( Timer( 1 ) > 30 ) then
Speak" 30 seconds have elapsed"
SetTimer( 1 )
endif
else
SetTimer(1)
end if

Swap Axis:

SwapAxix( 2,5)

ResetAxisSwap()

Spindle Speed OVR from outside:
SetParam( "RPMOverRide" , 1 )

Macrocall to plugins:

There is currently a macro call that will notify a plugin.
NotifyPlugins( x) which sends a one number message that can be seen in the
plugins OnNotify function. You cant pass variables, but you can access the
parameters and other system variables, so the macro woudl have to store the call
paramaters somewhere, then notify the plugin with the notify call, the plugin
can then grab whatever parameters it likes in the system variables.

Hello,
You could use a NotifyPlugins(int Message_Number) in VB and that will be
picked up by all plugins in the void myNotify(int message) function..
Use a message of 10000 or greater please when you are doing this



Number Format:

Variable = nfmt(Variable, decimal places truncated to)

Xstep = nfmt(Xstep, 3)

Open HTML G code helpfile:

Shell("explorer.exe " + GetMainFolder()+"Mach3MillGcode.htm")

Set Trigger Macro using "Push User Button" in Brians:

First, you dont put the code in a button, you put it in a macro file. For
example file: m600.m1s
SetMessage( "This is a macro call..")

Then , you have to set that macro to be the default macro call with a call to
SetTriggerMacro( 600 ) at some point in the program, an init string could do
that if the SetTriggerMacro call were in another macro file that is called on
startup.  Then the brain will execute m600 whenever that brain termination code is
called.

To Write the Tool Table Data (and tool desc), out to a file to print:

textFilePath = "C:\mach3\ToolInfo.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile(textFilePath)
Do Until num=225
num=num+1
N = GetToolDesc(num)
D = GetToolParam(num,1)
L = GetToolParam(num,2)
WD= Gettoolparam(num,3)
WL= Gettoolparam(num,4)
Dt= Date()
Tm= Time()

If N <>"Empty" Then

objTextFile.WriteLine("*Tool"& num &" * "& N &" *Diameter: "& D &"
*Length: "& L &" *Wear Diam"&WD &" *WearLength"&WL & Chr(13) & Chr
(10))
Else
End If
Loop

objTextFile.WriteLine("**")
objTextFile.WriteLine(" Date: " &Dt &" Time: " &Tm)

objTextFile.Close
Dim sCOMMAND As String
sCOMMAND="print c:\mach3\toolinfo.txt"
Shell("c:\winnt2\system32\cmd.exe /c" & sCOMMAND)
End

Deg = Rad* 57.29577

For Mach3 turn there is no A axis but if you want to thread then this
is the way to do it

ToolNum = GetOEMDRO(824)
Desc = GetToolDesc(ToolNum)
Call SetTicker(1, "    " & Desc)

Also, here is some other Stuff Art Posted on the Yahoo forum dealing with getting and setting the Tool table:

To Set and Get Tool Table Parameters:

SetToolParam(SHORT toolnum, SHORT param, DOUBLE data) 'param { 1 = tool diamter, 2 = ZOffset, 3 = xwear, 3 = zwear }

GetToolParam(SHORT toolnum, SHORT param) 'param { 1 = tool diamter, 2 = ZOffset, 3 = xwear, 3 = zwear }

Put in #99066 = start angle for the thread in the code

so if you want to do 3 start thread then
#99066 = 0
threading code
#99066 = 120
same threading code
#99066 = 240
same threading code

66 is the DRO number of the start angle for a thread. When used with
#99(DRO number) the DRO is accessible in Gcode.

Serial Port:

Writing:-

Call SendFIFO("M104 S" & S$ & Chr(10)& Chr(13))

Reading:-

D$ = GetFifoEntry()

ClearFiFo()

Parmetric Programming:
THe macro code is shown in the ( ) after the macro call
We have run senarios that redirected all over the place and it still
work.
Example code:

#3=3
o100
G0X#3
#3=[#3+1]
M9999 (If (GetVAR(3) > 6) Then Code" (END M9999)" Else
code"M98 P100 " )
m30
%


SendKeys that will activate Video plugin.
SendKeys "+%(P)V"

Sending Keys
You can easily send keys to the active window, as if the user was pressing keys on the keyboard by using the SendKeys statement.
Shell "notepad", vbNormalFocus
SendKeys "This is a test string"
The code above runs notepad, and sends the keys 'This is a test string' to it. If you want to use special keys, such as  ENTER or TAB, and keys that represent actions rather than characters, use the codes shown below:
Key    Code
BACKSPACE   {BACKSPACE}, {BS}, or {BKSP}
BREAK   {BREAK}
CAPS LOCK   {CAPSLOCK}
DEL or DELETE   {DELETE} or {DEL}
DOWN ARROW   {DOWN}
END   {END}
ENTER   {ENTER}or ~
ESC   {ESC}
HELP   {HELP}
HOME   {HOME}
INS or INSERT   {INSERT} or {INS}
LEFT ARROW   {LEFT}
NUM LOCK   {NUMLOCK}
PAGE DOWN   {PGDN}
PAGE UP   {PGUP}
PRINT SCREEN   {PRTSC}
RIGHT ARROW   {RIGHT}
SCROLL LOCK   {SCROLLLOCK}
TAB   {TAB}
UP ARROW   {UP}
F1   {F1}
F2   {F2}
F3   {F3}
F4   {F4}
F5   {F5}
F6   {F6}
F7   {F7}
F8   {F8}
F9   {F9}
F10   {F10}
F11   {F11}
F12   {F12}
F13   {F13}
F14   {F14}
F15   {F15}
F16   {F16}

To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes:
Key    Code
SHIFT   +
CTRL   ^
ALT   %
To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify to hold down SHIFT while E and C are pressed, use "+(EC)". To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use "+EC".
To specify repeating keys, use the form {key number}. You must put a space between key and number. For example, {LEFT 42} means press the LEFT ARROW key 42 times; {h 10} means press H 10 times.

Run two separate G code files.
Store your file in the subroutines directory within Mach and call them with a program like this

O0001 (MAIN PROGRAM)
M98 (SUB_PROG1.TAP)
M98 (SUB_PROG2.TAP)
M30

scott
Commercial Mach3 & Mach 4, Design/Build/Retrofit CNC and Industrial machines.
http://www.ss-systems-llc.com/

Offline Bill_O

*
  •  250 250
    • View Profile
Re: How Much interest is there in an UPDATE to the Mach specific VB??
« Reply #9 on: March 27, 2009, 08:20:35 AM »
Scott,
One more send keys. If you need to send an enter.

Sendkeys "{Enter} , True"

We found this one when you were here to help with my tcp camera issue.
Bill