Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 01:54:50 PM

Login with username, password and session length
Search:     Advanced search
* Home Help Search Calendar Links Login Register
+  Machsupport Forum
|-+  Mach Discussion
| |-+  VB and the development of wizards
| | |-+  Event Based Code
Pages: 1   Go Down
Print
Author Topic: Event Based Code  (Read 1610 times)
0 Members and 2 Guests are viewing this topic.
davidimurray
Active Member

Offline Offline

Posts: 118


View Profile
« on: June 05, 2006, 04:10:05 PM »

Hi

I'm writing a wizard to assist in calibrating the spindle. What I want to do is this :-

1) Have a 'start calibration' button that contains the main code
2) When you click this, the spindle starts and the spindle speed is incremented by an amount previously chosen by the user.
3) The user then measures the speed and enters it into a DRO.
4) The user then clicks a 'Next' button which stores the two values in an array, and then increments the spindle speed again
5) The procedure continues as above until the max speed is reached.

I've got some of it working. But I don't know how to implement the 'Next' button - any ideas greatly appreciated !

Cheers

Dave
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #1 on: June 05, 2006, 05:33:21 PM »

The best way to do this in Mach3 is to have each Inc take you to a new screen... OR you can do it on the same screen with a counter running in the background. You could then do Counter * inc = Speed    Call SetOEMDRO(1200.Speed)  Something like that should work...
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
davidimurray
Active Member

Offline Offline

Posts: 118


View Profile
« Reply #2 on: June 06, 2006, 07:54:27 AM »

Hi Brian

I've got the speed increment working - but I'm not quite sure where is the best place to put the code. Two theories :-
1) Have a 'start' button which initiates everything then the actual increment button writes the values to a 2d array. Each time I click the button will the array remain there? Oh and so far I can only get 1d arrays to work!
2) Have a start button that contains all the code and while loops looking for a button condition - I've tried this and can't get it to work.

The idea I'm working on is to interpolate points between those entered by the user to create enough to allow linearity.dat to be written to and produce a series of straight lines between known points. By allowing the user to enter the value there is no need to have a spindlex index sensor as I would never need one on the mill for what I do.

Cheers

Dave
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #3 on: June 06, 2006, 12:45:25 PM »

I have not setup any array's in VB Sad I can tell you how to do it in C++.. I will have a look at the house and see what I have for code that I can give you Wink
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
davidimurray
Active Member

Offline Offline

Posts: 118


View Profile
« Reply #4 on: June 07, 2006, 04:34:56 AM »

Brian

I may have an alternative, allthough cheating, method. Simply append each entry to a text file and then re-read it later. I've got the text file creation working, now I just need to spend some time reading it back in - that will have to wait until my next coffee break at work!

Cheers

Dave
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #5 on: June 07, 2006, 06:14:18 AM »

If you are going to do that write theit as a Ver in Mach3... This is how I did a 2X10 array:
     For i=0 To 19 Step 2
        Call setVar ((120 + i), GetUserDRO(1140 +i))
        Call setVar ((121 + i), GetUserDRO(1141 +i))
     Next

to read the array I did the following:

For i=1 To 10
  onOff = Int( LEDonOff / ((10^ i)/10)) - Int( LEDonOff / ((10^(i+1))/10))*10
  X = FormatNumber (GetVar(100 +((i-1)*2)),4)
  Y = FormatNumber (GetVar(101 +((i-1)*2)),4)
  If onOff = 1 Then
        If Nc=0 Then
          Call Drill_cycle(X,Y,Z,Q,R,F)
        Else
          Code " X" & X & " Y" & Y
        End If
        Nc=1
  End If
Next

I did this so I could have a gobal variable... I also used a register to save the led's states and that tells the loop if the point is used... I know it is not how you would do it if you were doing real VB but it works!
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
davidimurray
Active Member

Offline Offline

Posts: 118


View Profile
« Reply #6 on: June 07, 2006, 07:14:05 AM »

Ah ha

Strangely, doing it that way had crossed my mind but I decided not to go down that route - haven't got a clue why!

The only potential issue is how many user variables are there available ? I imagine that other users with a greater spindle speed range may want to use a large numbered of measured speeds. My spindle only goes from 0-2200 in high gear!

Cheers

Dave
Logged
Brian Barker
Administrator
*
Offline Offline

Posts: 3,383



View Profile
« Reply #7 on: June 07, 2006, 05:21:04 PM »

You have from 0-1999 that you can use if you need to Smiley
Logged

Fixing problems one post at a time Wink

www.newfangledsolutions.com
www.machsupport.com
Pages: 1   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!