CamBam
News:
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 12, 2019, 19:34:04 pm


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Spindle Speed manual change.  (Read 1719 times)
dkemppai
Storm Trooper
***
Offline Offline

Posts: 121


View Profile
« on: October 16, 2018, 02:07:58 am »

Hi,

So, I run a Chinese auxiliary spindle on my mill. I'm setting up a second post process for use with this spindle. The speed settings are done manually via a potentiometer.

Now, my mill has a M00 code, which displays a message to the user, pausing until the dialog box accepted. This is very useful for cases where manual intervention is required.

Now, I'd like to use this M00 code to throw a message telling me to change the spindle speed. Currently I have it set up int the start of the MOP portion of the post, using {$s} command do display the spindle speed. However the issue here is if there are many MOPS with the same spindle speed, the M00 message is displayed for every mop. I'd like that onlty to display for MOP's where the spindle speed actually needs to change.

So, any suggestions on where or how I can trap this situation and send the message when speed changes are required???

I'm thinking maybe some conditionals with variables in the MOP header that makes G code which will catch this???  I haven't even begun to figure that out yet...


Thanks!
Dan


Logged
lloydsp
CNC Jedi
*****
Online Online

Posts: 8084



View Profile
« Reply #1 on: October 16, 2018, 02:16:21 am »

Dan, it would be super-easy to write a post-build processor in (say) VBS to scan that file for sequential duplicates and remove them.  It would be automatically invoked by your post-processor, so you'd never need to see it happen... just 'automagically'.

Lloyd
(attached is a sample file of a post-build processor I use to convert 'normal' .nc files into a form my ShopSabre router can use.  It's in the form of a text file right now.  All that has to be done to make it work is to change the file-extension to .vbs, and place the vbs file in your post folder.  You must either reboot or reload post-processors whenever you make a change to one of them.)
LS

* ShopSabreCorrectvbs.txt (3.48 KB - downloaded 73 times.)
« Last Edit: October 16, 2018, 02:28:59 am by lloydsp » Logged

"Pyro for Fun and Profit for More Than Fifty Years"
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5676



View Profile WWW
« Reply #2 on: October 16, 2018, 02:37:56 am »

Hello

I've one !  Cheesy I use it to remove the duplicate S value. maybe you can use it as is, or use it as model for coding ...

You must first set your PP to write the S command alone on a line. It is in the (header) mop macro

{$comment} {$mop.name} {$endcomment}
{$toolchange}
{$velocitymode} {$workplane}
{$mop.header}
{$spindle} {$s}
{$blocks}
{$mop.footer}


must be changed to

{$comment} {$mop.name} {$endcomment}
{$toolchange}
{$velocitymode} {$workplane}
{$mop.header}
{$s}
{$spindle}

{$blocks}
{$mop.footer}


The "Post-Build Command Args" must contain "{$outfile}"  (with the ")
The "Post-Build Command" must contain the filepath of the .exe file given in attachment, so the exe will be run by the PP.

This is the code of the RemDuplicateSxx.exe file, for information Wink (Visual basic)

Code:
Imports System.IO

Module Module1
    'supprimer les changement de vitesse inutiles qui génère une pause dans l'usinage.
    'pour post pro Mach3, Sxxx seul en début de ligne (pas de n° de ligne)
    'le M3 et le S doivent être sur des lignes séparée, voir dans le post pro
    ' dh42 08/2016
    Sub Main(args() As String)

        Dim line As String
        Dim fname, outname As String
        Dim previous_speed As Double = 0
        Dim current_speed As Double

        fname = args(0)

        If fname <> "" Then
            outname = Left(fname, Len(fname) - 3)   'filename without .nc'
            Try
                Using sr As StreamReader = New StreamReader(fname)
                    FileOpen(1, outname & ".tmp", OpenMode.Output)
                    Do
                        'read a line
                        line = sr.ReadLine()

                        'test for "S" as firt char
                        If Left(line, 1) <> "S" Then 'no speed alone on this line
                            PrintLine(1, line)
                        Else 'speed found
                            'get the speed value (remove the S and convert to number)
                            current_speed = Val(Right(line, Len(line) - 1))

                            'test if current speed = previous speed
                            If current_speed = previous_speed Then 'duplicate speed
                                'skip the line
                                PrintLine(1, "(duplicate S" & current_speed & " removed)")
                            Else
                                previous_speed = current_speed
                                PrintLine(1, line)
                            End If
                        End If
                    Loop Until line Is Nothing

                    sr.Close()
                    FileClose(1)

                    FileSystem.Kill(fname)  'delete previous .nc file
                    FileSystem.Rename(outname & ".tmp", outname & ".nc")   'rename temp file to .nc

                End Using

            Catch E As Exception
                MsgBox("Error" & E.Message)

            End Try
        End If
    End Sub
End Module

++
David


* RemDuplicateSxx.zip (4.85 KB - downloaded 74 times.)
Logged
dkemppai
Storm Trooper
***
Offline Offline

Posts: 121


View Profile
« Reply #3 on: October 16, 2018, 04:34:17 am »

Loyd and David,

Both of these examples look very visual basic...   ...something I can actually code in. So this is a very awesome start for me! Based on what I'm seeing here, maybe the best thing is to just post process any {$s} commands into the "M00" codes, and delete duplicates as they're encountered...

Quick questions: So, where do I find some more info on the object model to actually write these sorts of scripts for CB? And what vb versions/editors are you guys using? I do A LOT of VB (DSP, FFT, DFT, data analysis, etc.),  but it's VB5/6 and VBA. No VBS code at all, yet...

Thanks!
Dan
Logged
dh42
Administrator
CNC Jedi
*****
Offline Offline

Posts: 5676



View Profile WWW
« Reply #4 on: October 16, 2018, 05:53:12 am »

Hello

I used visual basic 2010 express (Visual studio) free version

In the project settings in Application tab, you must select Console application for Application type

I attach the full project in VS format

VB can also been used to make plugins ; in this case the Application type must be set to Class library to obtain a .dll

not sure for the exact names, my Visual studio version is in French.

++
David

* RemDuplicateSxx.zip (51.47 KB - downloaded 72 times.)
Logged
EddyCurrent
CNC Jedi
*****
Offline Offline

Posts: 4078



View Profile
« Reply #5 on: October 16, 2018, 10:45:13 am »

For scripts I use Notepad++ ; https://notepad-plus-plus.org/

Then I refer to threads like this one; http://www.cambam.co.uk/forum/index.php?topic=3878.msg25796#msg25796
but there are many other threads containing code. Use the search box at the top of the page to find stuff.
Also this; http://www.cambam.info/doc/api/Introduction.htm

The files Lloyd and David posted however contain no CamBam specific code as they are just processing basically a text file.
« Last Edit: October 16, 2018, 10:55:35 am by EddyCurrent » Logged

Made in England
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.102 seconds with 19 queries.

Copyright © 2018 HexRay Ltd. | Sitemap