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 02-02-2011, 07:46 AM
TXFred's Avatar  
Join Date: Aug 2009
Location: USA
Posts: 880
TXFred is on a distinguished road
Question: Importing spreadsheet data into g-code.

Some background first:

I'm a fairly new programmer, with one year of experience programming with MasterCAM. I'm slowly but surely learning manual programming. I'm just getting started with macro programming.

I've been handed a project that I think could be accomplished with macros. I have to program engraving for a set of labels. There are a total of 229 labels. Each label lists different information that is provided in an Excel spreadsheet.

The simple way to do this is use G47 engraving (Haas Mill) and have the operator enter the values for each part. I don't like this. There's too much manual entry and too much opportunity for error.

I am envisioning a way to do this with macros. Here is the basic structure of what I want to have in the program. Additional features, such as turning the spindle on, will be added later.


Assign variable #100 to track the number of times the program has run.

GOTO #100

Then there will be a list of N entries. Inside each N entry is code that assigns
the excel spreadsheet values to macro variables. I think that I can talk Excel into outputting what I need. For example:

N1
#101=Tag Name
#102=Tag Number
etc. until all tag values are assigned.
Jump past the remaining list of entries.
GOTO N1000

Engrave the information
N1000
G47 P0 X1.703 Y-2.440 I0 J0.18 R0.1 Z-.025 E4. F4.0 (TAGNUMBER)
G47 P0 X2.866 Y-1.137 I0 J0.18 R0.1 Z-.025 E4. F4.0 (TAGNAME)

Increment the cycle counter
#100=#100+1
M30


That's my current plan. I'd like to get feedback on it. Will it work? Are there better ways to accomplish this? Are there any macro functions that might make this easier? I don't need a detailed explanation, just tell me what to look up and I'll go from there.

Sincerely,
Frederic
__________________
Pure Geometry LLC
Vertical Lathe tool holders and more.
Reply With Quote

  #2   Ban this user!
Old 02-02-2011, 07:58 AM
TXFred's Avatar  
Join Date: Aug 2009
Location: USA
Posts: 880
TXFred is on a distinguished road

While we're on the subject of macro programming, can anyone recommend me a good book to buy?

Frederic
__________________
Pure Geometry LLC
Vertical Lathe tool holders and more.
Reply With Quote

  #3   Ban this user!
Old 02-02-2011, 11:25 AM
 
Join Date: Feb 2008
Location: The Edge of Obscurity
Posts: 229
ProProcess is on a distinguished road

One way to do this is to have a sub program like this...

Code:
O123(DATA-FILE)
N1
#101={TAG NUMBER HERE}
#102={TAG NAME HERE]
M99

N2
#101={TAG NUMBER HERE}
#102={TAG NAME HERE]
M99

(So on and so forth for remaining data)

then in your main program ...

Code:
O1(MAIN-PROGRAM)


M98P123H#100(GET-DATA-FROM-SUB)

(ENGRAVE-HERE-USING)
(VALUES-ASSIGNED-TO-#101-AND-#102)

#100=#100+1(INCREMENT-COUNTER)
We've done some pretty complex things with this type of schema.
It's simple and managable.
HTH
Good luck.
Let us know how you make out.
__________________
Control the process, not the product!
Machining is more science than art, master the science and the artistry will be evident.
Reply With Quote

  #4   Ban this user!
Old 02-02-2011, 03:03 PM
TXFred's Avatar  
Join Date: Aug 2009
Location: USA
Posts: 880
TXFred is on a distinguished road

Thanks for the help. I'll let you know how it turns out.

Frederic
__________________
Pure Geometry LLC
Vertical Lathe tool holders and more.
Reply With Quote

  #5   Ban this user!
Old 02-07-2011, 01:35 PM
TXFred's Avatar  
Join Date: Aug 2009
Location: USA
Posts: 880
TXFred is on a distinguished road

I've got some code written and hopefully ready to run.

As it turns out, we only have 200 hours of Macro language time available on the Haas mill. I don't want to waste it on debugging newbie mistakes, so I am posting a sample of the code here. I would appreciate it if somebody could look over it and point out any obvious flaws.

This first program calls the subroutine, and then performs the engraving.

Code:
(BEGIN MANUALLY ENTERED ENGRAVING CODE)

(CALL SUBROUTINE)
M98 P03128

(ENGRAVE-HERE-USING VALUES ASSIGNED TO)
(101 - 115 IN SUBROUTINE O03128)

(ENGRAVE THE TAG NUMBER)
G47 P0 X3.067 Y-1.782 I0 J0.15 R0.05 Z-.015 E24.4 F48.9 (#101)

(INCREMENT THE CYCLE COUNTER)
#100=#100+1

(END MANUALLY ENTERED ENGRAVING CODE)
The subroutine performs a simple GOTO command, assigns the variables, and then exits back to the engraving program.

Code:
%
O03128

(Go to the current variable set)
GOTO#100

N1
#101=1
#102=7/23/2010
#103=A10340353
#104=Allentown I
#105=Sika 2100 and Sika Plastiment
#106=0.45
#107=Jane Doe
#108=John Doe
#109=0
#110=700
#111=0
#112=Instrument Cube Block
#113=NULL
#114=Yes
#115=No
M99
Does that look OK?

Frederic
__________________
Pure Geometry LLC
Vertical Lathe tool holders and more.
Reply With Quote

Sponsored Links
  #6   Ban this user!
Old 02-08-2011, 09:25 AM
 
Join Date: Feb 2008
Location: The Edge of Obscurity
Posts: 229
ProProcess is on a distinguished road

Originally Posted by TXFred View Post


Code:
...

#103=A10340353
#104=Allentown I
#105=Sika 2100 and Sika Plastiment
...
M99
Does that look OK?

Frederic

I do not believe that you can perform these types of "String" asignments to Macro variables.
I think the asignments have to be numeric or macro in nature.
That would be easy enough to test in MDI...

Code:
#101=THIS IS A TEST
Let us know and good luck
__________________
Control the process, not the product!
Machining is more science than art, master the science and the artistry will be evident.
Reply With Quote

  #7   Ban this user!
Old 03-31-2011, 10:41 AM
TXFred's Avatar  
Join Date: Aug 2009
Location: USA
Posts: 880
TXFred is on a distinguished road
The solution.

It took some doing, but I was able to make Excel output workable Gcode. Since I've lost count of the amount of help I've gotten from the Zone, I think it's worth my time to make a writeup of this method.

Step 1. Modify the excel file that you were given until it looks like step1.xls. Some fields contain the original data, and the other fields contain Haas G47 gcode. The very last column in each line contains code to shift the work offset to the next position, so you can engrave multiple tags in a single operation. (Note, save your original work offsets. If you stop the program in mid cycle, you will lose your original offsets.)

Step 2. Save the Excel file as a .csv file. Ignore the warnings that Excel gives you about losing formatting.

Step 3. Open the csv file in Word. Bring up the Find/Replace dialog.
A: Replace "," with nothing. This removes all the commas from the file.
B: Replace "CR" with "^p". This turns all the CR's into carriage returns.
C: Replace "^p " with "^p". This aligns all the text. Not necessary, but easier on the eyes.
D: Save as a .txt file.

Step 4. Rename the .txt file to .nc

Step 5. Paste the contents of the .nc file into your program at a convenient location. Anywhere after a retract move should be safe. I put mine at the end of the program for simplicity.

If your tags will have fields that do not change, program then in MasterCAM using the MCX Box font. It's almost identical to the font that Haas G47 engraving uses. On a completed tag, I cannot tell the difference.

Thanks again to all of you for offering advice and suggestions.
Attached Files
File Type: zip Example Tags for CNCZone.zip‎ (3.6 KB, 42 views)
__________________
Pure Geometry LLC
Vertical Lathe tool holders and more.
Reply With Quote

  #8   Ban this user!
Old 03-31-2011, 09:05 PM
 
Join Date: Jun 2008
Location: United States
Posts: 1,507
stevo1 is on a distinguished road

Frederic,
Great work on this project.

I really just had to comment on your signature. LMAO.....what about the polishers that have to clean the welds? These are the people you want to keep in your good graces. #1 should always be the payroll lady.

Stevo
Reply With Quote

  #9   Ban this user!
Old 03-31-2011, 11:43 PM
 
Join Date: Feb 2006
Location: india
Posts: 1,187
sinha_nsit is on a distinguished road

Fred,
You seem to have a good knowledge of Excel. So, I have a question:
Excel has limited editing options. For example, "Change Case" is not available. Can we save the .csv file opened in Word, back in .xls format, after necessary editing?
Reply With Quote

  #10   Ban this user!
Old 04-01-2011, 12:54 AM
dcoupar's Avatar  
Join Date: Mar 2003
Location: USA
Posts: 2,312
dcoupar is on a distinguished road

Originally Posted by sinha_nsit View Post
Fred,
You seem to have a good knowledge of Excel. So, I have a question:
Excel has limited editing options. For example, "Change Case" is not available. Can we save the .csv file opened in Word, back in .xls format, after necessary editing?
Excel has the UPPER function. You could write a macro to check each cell and convert it to UPPER case.
Reply With Quote

Sponsored Links
  #11   Ban this user!
Old 04-01-2011, 02:30 AM
 
Join Date: Feb 2006
Location: india
Posts: 1,187
sinha_nsit is on a distinguished road

Is a function for Title Case also available (upper case for first letter of each word, such as in a name)?
Reply With Quote

  #12   Ban this user!
Old 04-01-2011, 07:12 AM
dcoupar's Avatar  
Join Date: Mar 2003
Location: USA
Posts: 2,312
dcoupar is on a distinguished road

Originally Posted by sinha_nsit View Post
Is a function for Title Case also available (upper case for first letter of each word, such as in a name)?
Yes, PROPER
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
Need Help!- Sorting code in spreadsheet twoartistic General CNC (Mill and Lathe) Control Software (NC) 7 12-14-2010 02:35 PM
Question about importing scanned part for geometry. l u k e OneCNC 8 12-09-2010 10:28 PM
inventor question on spreadsheet 1cnchogger Autodesk Software (Autocad, Inventor etc) 1 07-13-2008 10:15 PM
Data server question npinto General CNC (Mill and Lathe) Control Software (NC) 2 11-09-2007 03:47 PM
text data to G code? zcases G-Code Programing 14 11-14-2006 08:12 AM




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