585,708 active members*
3,808 visitors online*
Register for free
Login
IndustryArena Forum > Machine Controllers Software and Solutions > Mach Software (ArtSoft software) > Time logging of position, velocity and acceleration
Results 1 to 9 of 9
  1. #1
    Join Date
    Apr 2009
    Posts
    11

    Time logging of position, velocity and acceleration

    Hi,

    I recently ordered a 4-axis Taig CNC machine. I want to use it, aside of standard metal working, to perform repeated trajectories in space. I'd need mach3 to output the current poistion (x,y,z,a), velocity components and acceleration components at every time step (say 10-1000Hz)

    I'd like some pointers on how to do that with mach3, I'm a software engineer, I'm not afraid of coding some plugin, macro, etc.

    Thank you

  2. #2
    Join Date
    Mar 2003
    Posts
    35538
    I think you can use the macropump feature to read the DRO's. Not sure if it can write to a file fast enough, though?
    Gerry

    UCCNC 2017 Screenset
    http://www.thecncwoodworker.com/2017.html

    Mach3 2010 Screenset
    http://www.thecncwoodworker.com/2010.html

    JointCAM - CNC Dovetails & Box Joints
    http://www.g-forcecnc.com/jointcam.html

    (Note: The opinions expressed in this post are my own and are not necessarily those of CNCzone and its management)

  3. #3
    Join Date
    Apr 2009
    Posts
    11

    Get/SetParam() Vars

    Looks simple!

    I Should be ok with these, and CDate function. I don't how how precise it is though (I need at least milisecs, ideally usecs)

    Wiki

    "ZMachine" = Z Mach Positions (G53 Coordinates)

    "XMachine" = X Mach Positions (G53 Coordinates)

    "YMachine" = Y Mach Positions (G53 Coordinates)

    "Encoder1" = X Encoder Position

    "Encoder2" = Y Encoder Position

    "Encoder3" = Z Encoder Position

    "Encoder4" = A Encoder Position


    However, how can-I make sure that I don't over-stress mach3?

  4. #4
    Join Date
    Jul 2007
    Posts
    887
    Hi,
    Reading DRO's and writing those values to a .txt file is easy to do (as you've discovered) but you'll NEVER get the update rate that you are looking for. The macro-pump runs at roughly 10Hz and AFAIK that is as fast as it gets without going to a custom plugin. Besides, the Mach3 application (which is what calculates and displays the info in the DROs) runs at 10Hz (again AFAIK) so even if you would find a way to read the DROs at 10kHz it wouldn't give you much.

    Writing a custom plugin might allow you to do it quicker but it's a much steeper learning curve. I see you are a software engineer so that'll help a lot but I'm pretty sure you'll never get uS or even mS timing resolution.

    To be sure though contact ArtSoft, post on the Machsupport forum or on Mach3 Yahoo's usergroup as the author(s) of Mach3 hangs around there and they'll give a correct answer for sure.

    /Henrik.

  5. #5
    Join Date
    Apr 2009
    Posts
    11

    "Type Mismatch"

    10Hz would be better than nothing. I found a way to get the kernel timer (see below). But now I want to slow it down with som sleeps, but it refuses with a "Type Mismatch" error.

    I'm getting a lot of "Type Mismatch" errors in the script engine

    For example Code from this guy :
    Henrik

    Code:
    '---=== M3 Macro ===---
    Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
    
     'ActivateSignal(Output3)            'Release the break
      Sleep 200                                'Wait 200mS
      'DoSpinCW()                             'Start spindle
    Fails with a type mismatch. It seems to be because the cypress vbscript types are 16-bit style (i.e. 16-bit int, 32-bit long) while the Kernel's type are 32-bit type.

    I tried with a custom type :

    Code:
    Type MyType
    low As Long
    high As long
    End Type
    Wich worked for

    Code:
    Type HighResTimer
    	low As Long
    	high As Long
    End Type
    
    Declare Function QueryPerformanceCounter Lib "Kernel32" (ByRef current As HighResTimer) As Boolean
    But it wont do for Sleep()

    Edit : ok found this
    http://www.cnczone.com/forums/showthread.php?p=522304

  6. #6
    Join Date
    Jul 2007
    Posts
    887
    Hi,
    Yes, the Sleep command has now been "integrated" so you should no longer declare the Sleep as being in the Kernel32 library. I don't know if you realised but henriksplace.se is actually my site ;-) I'll have to update that section of the site to reflect this change as it's been like this for quite some time now......

    Good luck!
    /Henrik.

  7. #7
    Join Date
    Apr 2009
    Posts
    11

    Lol!

    no I didn't realize!

    Thanks for the ressource, it is what got me started!

    I finally managed to finish a first version of the script. It seems to work fine, but I wonder if it could affect Mach3's normal behaviour.

    What is this macro pump checkbox thing?

    Right now I run the script from the script editor start button. I suits my needs, but is there a cleaner way?


    Here it is

    Code:
    Type HighResTimer
    	low As Long
    	high As Long
    End Type
    
    Declare Function QueryPerformanceCounter Lib "Kernel32" (ByRef current As HighResTimer) As Boolean
    Declare Function QueryPerformanceFrequency Lib "Kernel32" (ByRef  current As HighResTimer) As Boolean
    
    Const TimeSteps = 1000
    Const Dimensions = 4
    
    Dim positions(Dimensions,TimeSteps) As Double
    Dim timestamps(TimeSteps) As Long
    Dim timestamp As HighResTimer
    Dim frequency As HighResTimer
    Dim fileNumber As Integer
    
    
    
    DoOEMButton(1000) 'Cycle Start
    
    
    
    For timeStep = 0 To TimeSteps
    
    	For dimension = 0 To Dimensions
    		positions(dimension, timeStep) = GetDRO(dimension)
    	Next
    	
    	If(QueryPerformanceCounter(timestamp)) Then
    		timestamps(timeStep) = Abs(timestamp.low)
    	Else
    		MsgBox("QueryPerformanceCounter returned false!")
    		
    	End If
    
    
    Sleep (10)
    
    Next
    
    DoOEMButton(1001) 'Cycle Pause
    
    fileNumber = FreeFile
    
    If Not Kill("C:\Mach3\log.txt") Then
    End If
    
    Open "C:\Mach3\log.txt" For Output As fileNumber
    
    If QueryPerformanceFrequency(frequency) Then
    	Print #fileNumber, "Timer frequency: " & Abs(frequency.low) & "Hz"
    End If
    
    For timeStep = 0 To TimeSteps
    
    	For dimension = 0 To Dimensions
    		Print #fileNumber, positions(dimension, timeStep) & "    " & timestamps(timeStep)
    	Next
    	Print #fileNumber, " "
    Next  
    
    Close
    
    MsgBox ("Succes!")

  8. #8
    Join Date
    Jul 2007
    Posts
    887
    Hi,
    A macropump is a script that is automatically called at rouhly 10Hz. You save the script with the name Macropump.m1s in your machine profiles Macros folder and then activate it with the checkbox. You may need to restart Mach3 as well. Now the script Macropump.m1s is called 10 times/second. Not sure it's the right aproach for your particualr code though.

    /Henrik.

  9. #9
    Join Date
    Apr 2009
    Posts
    11

    Interesting..

    No it doesn't suit my needs, as i don't want to open/close the data file at 10hz. I prefer to use an array. Good to know, though.


    Thanks

Similar Threads

  1. Max Velocity and acceleration
    By Jamy in forum CNC (Mill / Lathe) Control Software (NC)
    Replies: 2
    Last Post: 12-04-2008, 06:35 AM
  2. time logging
    By rgee in forum Community Club House
    Replies: 0
    Last Post: 06-23-2008, 12:42 PM
  3. Taig velocity/acceleration
    By juzwuz in forum Taig Mills / Lathes
    Replies: 5
    Last Post: 02-12-2007, 09:38 PM
  4. Velocity/Acceleration question
    By studysession in forum Mach Software (ArtSoft software)
    Replies: 2
    Last Post: 01-09-2007, 11:01 PM
  5. Fine Tuning Velocity and Acceleration.
    By sunmix in forum Mach Software (ArtSoft software)
    Replies: 6
    Last Post: 09-30-2006, 07:46 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •