CNCzone.com-The Largest Machinist Community on the net!



Home Page Mark Forums Read Today's Posts My Replies Classifieds Reviews Photo Gallery Web Links Share Files Advertise With Us Ad List
Go Back   CNCzone.com-The Largest Machinist Community on the net! > Machine Controllers Software and Solutions > Mach Software (ArtSoft software)


Mach Software (ArtSoft software) Discuss Mach 1 , 2 and the new Mach3 here NC software here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 04-14-2009, 09:45 AM
 
Join Date: Apr 2009
Location: Canada
Posts: 11
maxlem is on a distinguished road
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
Reply With Quote

  #2  
Old 04-14-2009, 10:29 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,463
ger21 is on a distinguished road
Buy me a Beer?

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

Mach3 2010 Screenset
http://home.comcast.net/~cncwoodworker/2010.html

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

  #3   Ban this user!
Old 04-14-2009, 11:12 AM
 
Join Date: Apr 2009
Location: Canada
Posts: 11
maxlem is on a distinguished road
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?

Last edited by maxlem; 04-14-2009 at 11:32 AM.
Reply With Quote

  #4   Ban this user!
Old 04-14-2009, 11:55 AM
H.O H.O is offline
 
Join Date: Jul 2007
Location: Sweden
Posts: 886
H.O is on a distinguished road

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.
Reply With Quote

  #5   Ban this user!
Old 04-14-2009, 03:24 PM
 
Join Date: Apr 2009
Location: Canada
Posts: 11
maxlem is on a distinguished road
"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

Last edited by maxlem; 04-14-2009 at 03:46 PM.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 04-14-2009, 03:59 PM
H.O H.O is offline
 
Join Date: Jul 2007
Location: Sweden
Posts: 886
H.O is on a distinguished road

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.
Reply With Quote

  #7   Ban this user!
Old 04-14-2009, 04:46 PM
 
Join Date: Apr 2009
Location: Canada
Posts: 11
maxlem is on a distinguished road
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!")
Reply With Quote

  #8   Ban this user!
Old 04-15-2009, 12:24 AM
H.O H.O is offline
 
Join Date: Jul 2007
Location: Sweden
Posts: 886
H.O is on a distinguished road

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.
Reply With Quote

  #9   Ban this user!
Old 04-15-2009, 08:15 AM
 
Join Date: Apr 2009
Location: Canada
Posts: 11
maxlem is on a distinguished road
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
Reply With Quote

Reply

Tags
logging, mach3, position, programming, velocity




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Max Velocity and acceleration Jamy General CNC (Mill and Lathe) Control Software (NC) 2 12-03-2008 11:35 PM
time logging rgee CNCzone Club House 0 06-23-2008 06:42 AM
Taig velocity/acceleration juzwuz Taig Mills & Lathes 5 02-12-2007 02:38 PM
Velocity/Acceleration question studysession Mach Software (ArtSoft software) 2 01-09-2007 04:01 PM
Fine Tuning Velocity and Acceleration. sunmix Mach Software (ArtSoft software) 6 09-30-2006 01:46 AM




All times are GMT -5. The time now is 11:03 PM.





Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Content Relevant URLs by vBSEO
Template-Modifications by TMS

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361