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 > G-Code Programing


G-Code Programing Discuss G-code programing and problems here!


This forum is sponsored by:

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Ban this user!
Old 06-17-2005, 03:29 PM
 
Join Date: Mar 2003
Location: USA
Posts: 332
keithorr is on a distinguished road
Any Way to Improve Processing G Code with Excel?

I have a need to convert text to code. I can do it with Excel, but I can only do one line at at time.
I am using a kinematics program to produce six axis joint angles for a robot arm. The information represents a point to point move and is usually around 50 lines of text as follows:

0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
-0.000000 7.819982 14.789516 0.000002 6.969540 0.000003
0.000000 16.114470 30.837702 -0.000001 14.723211 -0.000001
0.000000 23.386688 45.481628 -0.000000 22.094950 -0.000000
-0.000000 29.612301 59.122925 0.000000 29.510695 -0.000001
-0.000000 33.830772 70.922791 0.000001 37.153328 -0.000000
-0.000000 33.830772 70.999458 0.000001 37.168625 -0.000000

I can copy and paste one line at a time into excel, then copy and paste the result into another text file for use as g code. I am using Excel to round down to four places, add the axis letter and recalculate axis z,b,c:

X 0.0000 Y 7.8200 Z 22.6095 A 0.0000 B 6.9695 C 0.1882
X 0.0000 Y 16.1145 Z 46.9522 A 0.0000 B 14.7232 C 0.3975
X 0.0000 Y 23.3867 Z 68.8683 A 0.0000 B 22.0950 C 0.5966
X 0.0000 Y 29.6123 Z 88.7352 A 0.0000 B 29.5107 C 0.7968
X 0.0000 Y 33.8308 Z 104.7536 A 0.0000 B 37.1533 C 1.0031
X 0.0000 Y 33.8308 Z 104.8303 A 0.0000 B 37.1686 C 1.0036

Very slow moving one line at a time. I don't know what terms to google. I would like a more automated method of converting blocks of space delimited text.

Any clues?
Thanks
Reply With Quote

  #2   Ban this user!
Old 06-17-2005, 04:13 PM
 
Join Date: Nov 2004
Location: USA
Age: 50
Posts: 446
murphy625 is on a distinguished road

Not sure what your trying to do but Microsoft Access is very good at manipulating data.

Murph
Reply With Quote

  #3   Ban this user!
Old 06-17-2005, 09:45 PM
 
Join Date: Jul 2003
Location: New Zealand
Posts: 1,039
Kiwi is on a distinguished road

If you can copy the whole file, paste into notepad or wordpad. Then import into excel as a delimiter, space, which will put the coords into separate cells.

Kiwi
Reply With Quote

  #4  
Old 06-17-2005, 10:33 PM
HuFlungDung's Avatar
Moderator
 
Join Date: Mar 2003
Location: Canada
Posts: 4,825
HuFlungDung is on a distinguished road

Keith,
You need the services of someone who can write a visual basic script for you. If the programs are always short like you said, visual basic will likely run fast enough to do the job.

Are the equations you use always exactly the same format, or is there variation required for that aspect?
__________________
First you get good, then you get fast. Then grouchiness sets in.

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

  #5   Ban this user!
Old 06-17-2005, 11:21 PM
 
Join Date: Mar 2003
Location: USA
Posts: 332
keithorr is on a distinguished road
Thumbs up Online Scripting Utilities

Thanks for the reply.
I did find scripting utilities online based on both VB and C++. I tried a demo version of one this afternoon and it looks like it will do the job.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 06-18-2005, 05:21 AM
 
Join Date: Jul 2003
Location: New Zealand
Posts: 1,039
Kiwi is on a distinguished road

keithorr

If you paste all text data into MSWord this Macro will convert to NC.
(If unsure how to run please advise.)

The "C" NC needs adjusted as I'm not sure how you value is calculated.
If you let me know I will alter as required.

Kiwi

Converted From
-0.000000 7.819982 14.789516 0.000002 6.969540 0.000003
0.000000 16.114470 30.837702 -0.000001 14.723211 -0.000001
0.000000 23.386688 45.481628 -0.000000 22.094950 -0.000000
-0.000000 29.612301 59.122925 0.000000 29.510695 -0.000001
-0.000000 33.830772 70.922791 0.000001 37.153328 -0.000000
-0.000000 33.830772 70.999458 0.000001 37.168625 -0.000000

To this with Macro
X0.0000 Y7.8200 Z22.6095 A0.0000 B6.9695 C0.0000
X0.0000 Y16.1145 Z46.9522 A0.0000 B14.7232 C0.0000
X0.0000 Y23.3867 Z68.8683 A0.0000 B22.0950 C0.0000
X0.0000 Y29.6123 Z88.7352 A0.0000 B29.5107 C0.0000
X0.0000 Y33.8308 Z104.7536 A0.0000 B37.1533 C0.0000
X0.0000 Y33.8308 Z104.8302 A0.0000 B37.1686 C0.0000

=======================================================
Sub Data2GCode()
'
' Macro recorded 16/8/2005 by Kiwi

numLines = 6 'Number of Lines
EOLine = 80

ActiveDocument.Characters.First.Select

For Line = 1 To numLines

XFlag = 1

For charCount = 1 To EOLine
Selection.Characters(1).Select
MyChar = Selection.Characters(1)

If Asc(MyChar) = 13 Then
LineCount = charCount
charCount = EOLine 'End of Line
End If

If CFlag = 1 Then strC = strC & MyChar
If CFlag = 1 And MyChar = " " Then CFlag = 0

If BFlag = 1 Then strB = strB & MyChar
If BFlag = 1 And MyChar = " " Then BFlag = 0: CFlag = 1

If AFlag = 1 Then strA = strA & MyChar
If AFlag = 1 And MyChar = " " Then AFlag = 0: BFlag = 1

If ZFlag = 1 Then strZ = strZ & MyChar
If ZFlag = 1 And MyChar = " " Then ZFlag = 0: AFlag = 1

If YFlag = 1 Then strY = strY & MyChar
If YFlag = 1 And MyChar = " " Then YFlag = 0: ZFlag = 1

If XFlag = 1 Then strX = strX & MyChar
If XFlag = 1 And MyChar = " " Then XFlag = 0: YFlag = 1

If Asc(MyChar) = 13 Then

X = Int(Val(Trim(strX)) * 10000 + 0.5) / 10000
Y = Int(Val(Trim(strY)) * 10000 + 0.5) / 10000
Z = Val(Trim(strY)) + Val(Trim(strZ))
Z = Int(Z * 10000 + 0.5) / 10000
A = Int(Val(Trim(strA)) * 10000 + 0.5) / 10000
B = Int(Val(Trim(strB)) * 10000 + 0.5) / 10000
C = Int(Val(Trim(strC)) * 10000 + 0.5) / 10000

strData = "X" & Format(X, "####0.0000") & " Y" & Format(Y, "####0.0000") & " Z" & Format(Z, "####0.0000") & " A" & Format(A, "####0.0000") & " B" & Format(B, "####0.0000") & " C" & Format(C, "####0.0000") & Chr(10) & Chr(13)

For BS = 1 To LineCount
Selection.TypeBackspace
Next BS

Selection.Font.Color = wdColorBlue
Selection.TypeText Text:=strData
Selection.TypeBackspace
Selection.MoveLeft Unit:=wdCharacter, Count:=1
strData = ""
X = 1: Y = 0: Z = 0: A = 0: B = 0: C = 0
strX = "": strY = "": strZ = "": strA = "": strB = "": strC = ""
XFlag = 1
charCount = EOLine 'End of Line
End If 'If Asc(MyChar) = 13 Then

Selection.MoveRight Unit:=wdCharacter, Count:=1
Next charCount

Next Line

End Sub
====================================
Reply With Quote

  #7  
Old 06-18-2005, 06:59 AM
ger21's Avatar
Community Moderator
 
Join Date: Mar 2003
Location: Shelby Twp, MI....USA
Posts: 20,454
ger21 is on a distinguished road
Buy me a Beer?

Originally Posted by keithorr
Thanks for the reply.
I did find scripting utilities online based on both VB and C++. I tried a demo version of one this afternoon and it looks like it will do the job.
Use VBA, it's built into Excel. You can also record what you do as a macro, and play it again, which might work for you.
__________________
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

  #8   Ban this user!
Old 06-18-2005, 01:09 PM
 
Join Date: Mar 2003
Location: USA
Posts: 332
keithorr is on a distinguished road

Ger21,
WTF???
Do I have a lot to learn!

How you do that? I can start to understand what you have done, but not knowing the specific syntax for math operations, I can't modify what you've done to rejigger the C axis. I'll be search the net just as soon.

Very much appreciated. I was just going to use a macro recorder to duplicate my keyboard strokes-ha!

This looks like the way I need to adjust my thinking cap. Of course I don't know any of the syntax so I'll need to start reading.

The formula is:

X=x, Y=y, Z=y+z, A=a, B=b+(a*.0144), C=c+(a*.02299)+(b*.02299)

In Excel, 15.6183 16.11447 30.837702 3.429 14.723211 26.7743

is converted to:X 15.6183 Y 15.6183 Z 46.9522 A 3.4290 B 14.7575 C 27.1916


I think an improvement for later might be to learn how to enter this in CamSoft G Code directly, which might be an incremental step to learning how to embed the kinematics completely into CamSoft and use XYZ fixed and euler angles for input.

Thanks for the reply.
Reply With Quote

  #9   Ban this user!
Old 06-18-2005, 01:20 PM
DieGuy's Avatar  
Join Date: Apr 2005
Location: USA
Posts: 420
DieGuy is on a distinguished road

linux shell, put it in a file named cnv.sh and run as ./cnv.sh <input_file_name> <output_file_name>
Code:
#!/bin/sh
cat $1 | while read line
do
    F1=`echo $line | cut -f1 -d" "`
    F2=`echo $line | cut -f2 -d" "`
    F3=`echo $line | cut -f3 -d" "`
    F4=`echo $line | cut -f4 -d" "`
    F5=`echo $line | cut -f5 -d" "`
    F6=`echo $line | cut -f6 -d" "`
    echo "X $F1 Y $F2 Z $F3 A $F4 B $F5 C $F6" >> $2
done
That is what Unix was written for originally, text proccessing.

Edit:
For you windows boys, you can get Cygwin to do the work for you.
Reply With Quote

  #10   Ban this user!
Old 06-18-2005, 01:56 PM
Karl_T's Avatar  
Join Date: Mar 2004
Location: Dassel,MN,USA
Posts: 1,318
Karl_T is on a distinguished road

Do you have a level of Camsoft where you define your own Gcodes? If so, this looks like a piece of cake to just write a custom Gcode and be done with it. Come up with a G# and six parameter letters you aren't using and Gcode lines like so:

G123 M15.6183 N16.11447 O30.837702 P3.429 Q14.723211 R26.7743

In G123, do your math:
\999=m
\998=n
\997= {m+n}

and so on.

Then put your motion move in the Gcode after you've calculated everything.

Karl
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 06-18-2005, 02:48 PM
RotarySMP's Avatar  
Join Date: Mar 2004
Location: Vienna, Austria
Posts: 1,048
RotarySMP is on a distinguished road

If you can open that text file in excel with the delimiter set to space, then all you will need to do is insert extra columns, type the Axis letters and formulars in the top line, and then drag fill the lines down.
__________________
Regards,
Mark
www.wrathall.com
Reply With Quote

  #12   Ban this user!
Old 06-18-2005, 02:53 PM
 
Join Date: Mar 2003
Location: USA
Posts: 332
keithorr is on a distinguished road
Too much information, or not enough

Well,

I couldn't get the VB example to replicate the results listed in the earlier post.

I do have a macro that works, not as elegant as the idea of the vb macro but...

Thanks for all the suggestions.

Last edited by keithorr; 06-18-2005 at 06:38 PM.
Reply With Quote

Reply




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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
looking for g code 3d from bobcadcam or simmilar for indexer lpt v5 with g code soft troyswood Ability Systems - LPT Indexer and G-Code 2 12-24-2006 09:21 PM
parametric programming Karl_T CamSoft Products 21 05-24-2005 02:58 PM
Link a Mastercam File to Excel stampman Mastercam 3 03-07-2005 04:16 PM
I need sample G code program bunalmis G-Code Programing 1 08-24-2004 03:50 AM
Getting The Most Out of CNCzone's Posting Features CNCadmin CNCzone.com FAQ 0 03-01-2003 11:08 PM




All times are GMT -5. The time now is 07:48 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