Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Dave3891 on August 11, 2010, 09:34:50 AM

Title: VB or Brains Question
Post by: Dave3891 on August 11, 2010, 09:34:50 AM
I don't know if this would be a VB Script or Brains question, but I need to know how to set a flag or something when a canned cycle has started (of a G81 as been started)

The machine I am working on has motion clamps that once the drill cycle starts the clamps are activated and then deactivated once the Z returns to the top. Then the machine positions to the next hole and the clamps are active again.

So I need to add this into mach.
Title: Re: VB or Brains Question
Post by: BR549 on August 12, 2010, 01:24:21 PM
The only way I know of would be to use a brain to monitor the Z positions and activate IF you went below a certain height and then deactivate above that height. You would also need a safety to ONY active if a condition were true. That way it would only work when you called the function pror to running the Cycle. then deactivate the function after the cycle was cancelled.

COuld you not just activate the clamp before the cycle and deactivate after??
Title: Re: VB or Brains Question
Post by: Dave3891 on August 12, 2010, 01:54:25 PM
Right now with the DOS software the clamps activate with a M code before the G81, then it will position with the clamps off, turn on the clamps, the drill the hole, retract the bit, deactivate the clamps, then position to next hole.

Is it posible to make a custom canned G code (like G81 but with clamp code in it)?
Title: Re: VB or Brains Question
Post by: BR549 on August 12, 2010, 02:25:13 PM
NOT a gcode but it may be possible to do it as a SUB or possibly a Mcode.

Is there a reason for wanting to clamp from inside the Cycle and not from a simple Mcode. Most CNCs that I am aware of do it like your DOS version.
Title: Re: VB or Brains Question
Post by: Dave3891 on August 12, 2010, 04:35:40 PM
A Mcode would work good as well, I just don't know how to make a M code that will activate the clamps with the drill cycle. The code would be like

M15 (motion clamps)
G81 Z-1.5 R1. F5.
X10. Y10.
X10. Y9.
X10. Y8.
etc

I am unsure how to make the mcode
Title: Re: VB or Brains Question
Post by: Hood on August 12, 2010, 04:43:42 PM
To make a m code you just open notepad and type the VB you wish then save as the name of the mcode you want, you save it to the macro folder of your profile. for example open notepad and type

ActivateSignal(OutPut1)

That will activate OutPut 1 of Mach
Save it as m7777.m1s to your profiles macro folder, so if you use the standard Mach3Mill profile you would save it to C:|Mach3\macro\Mach3Mill

Then each time you call m7777 from code it will switch on OutPut 1

To switch it off you will need another macro so the VB fro that would be

DeActivateSignal(OutPut1)

and if you saved as m8888.m1s it would work when your code has m8888 in it.

It is best to leave numbers under 100 for Mach internal and I think it was pointed out to me  that numbers between 1000 and ????( sorry I forget) is best left for OEM macros. However in practice as long as you check that no other macro has that number you should be fine but best to stay over 100.

Hood

Title: Re: VB or Brains Question
Post by: Dave3891 on August 12, 2010, 06:29:19 PM
So would I have to write my gcode like

M7777
G81 Z1.5 R1. F5.
M8888
X10. Y10.
X10. Y9.
X10. Y6.

And would it cycle the M codes with each position and drill cycle?
Title: Re: VB or Brains Question
Post by: Hood on August 12, 2010, 06:31:15 PM
That I am not sure of but will test in a second and see :)
Hood
Title: Re: VB or Brains Question
Post by: Hood on August 12, 2010, 06:41:31 PM
Looks like its only for the first one it works :(
Will have a think about this, maybe Terry will have an idea as he usually can come up with something.
Hood
Title: Re: VB or Brains Question
Post by: Dave3891 on August 12, 2010, 06:44:16 PM
It would be nice if the G81 was just like a macro file, then I could just make it look for a flag that the M code would set and have it turn on and off the output from within the G81 code.
Title: Re: VB or Brains Question
Post by: Hood on August 12, 2010, 06:52:51 PM
A few of the canned cycles are visible macros, G76 (m1076.m1s) and G83 (m1083.m1s) for example but I cant seem to locate the G81 so it may be coded internally into Mach.
 Suppose if you were good at VB (I am crap) you could write your own drill cycle macro with the clamp releases etc and just call it from your code.

Hood
Title: Re: VB or Brains Question
Post by: Dave3891 on August 12, 2010, 07:37:51 PM
Is it possible to make a G79 for example by making a m1079.m1s file?
Title: Re: VB or Brains Question
Post by: Hood on August 12, 2010, 07:48:03 PM
Afraid I dont know, I would imagine it would have to be linked to internally in Mach.
You should be able to do it by calling a m code instead of a G but that would likely require you to  have DROs to enter the data into similar to the wizard screens. Making a wizard may be another option but again my VB is crap so you would need help from others for that unless yours is good. I muddle through for the things I want but it takes me a long time of trial and error for anything thats more than basic.

Maybe Terry (BR549) will have other ideas or be able to advise on VB.

Hood
Title: Re: VB or Brains Question
Post by: BR549 on August 12, 2010, 09:24:47 PM
What you would have to do is program a macro that does an actual drill cycle LIKE the G81 but it would include a clamp/unclamp function as part of the routine. You woul d also have to use Variables to be able to preset your hole locations. Then you could call the macro with Vars and have what you want .

You can also do the same thing using Gcode SUBS.

Each have their pitfalls and good points.

THAT is why I asked what is so important about being able to clamp/unclamp midcycle. I still don't understand the need to do that.

If you really have a need to do it we can help you work it out. BUT if you are doing it just because it seems cool to do so then I can point you to the resourses and answer questions as they come up.

Just a thought, (;-)
Title: Re: VB or Brains Question
Post by: Dave3891 on August 12, 2010, 11:26:38 PM
It is a feature that is critical to getting the machine working right.

The reason why it must be done mid cycle it to allow the machine to move to the next position.
The clamps are small hydraulic rams that hold the machine in position so that it won't move with vibration since it rides on a gear rack.

Here is the newer version of the machine
http://www.quickmill.com/products.php?show=machine&machine=8&nav=drilling
Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 10:57:33 AM
OK the easy way (programmer,operator and machine) is to use Gcode and Mcodes that way it is easy to CAM the project and let the post write all the code.

G0 X1 Y1 (move to drill point)
M1001 (Lock Bed)
G81 X1.000 Y1.000  Z-1.000 R.5 F5  (drill Cycle)
G80 (cancell cycle)
M1002 (Unlock Bed)
G0 X2.000 Y2.000 (move to new drill point)
M1001 (Lock Bed)
G81 X2.000 Y2.000 Z-1.000 F5 (drill cycle )
G80 ( cancell cycle)
M1002 (Unlock Bed)
G0 X3.000 Y3.000 ( Move to new drill point)
M1001 (Lock Bed)
G81 X3.000 Y3.000 Z-1.000 F5 (drill cycle)
G80 Cancell cycle)
M1002 (Unlock Bed)
G0 X0.000 Y0.000  Move to new drill cycle )
etc
etc
etc

The mcodes code would look like this

'M1001 , Macro to lock bed
Activate(output3)


'M1002 , Macro to unlock bed
Deactivate(output3)

Output 3 would be wired to the bed lock controller


DOES that suite your needs or do you require something more. From here on out it gets more complicated for the Programmer/operator/machine

Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 12:09:15 PM
NOW another way is to use a Mcode to do the entire drill cycle including the lock unlock as one cycle. In this function we use 3 param calls from the macro to set things such as Zdepth Ztop and Retract height and Feedrate. In the example we use P= Zdepth Q= Ztop R= retract height and F=feedrate

THis IS a little simplier as you do NOT have to cancel the cycle before you move to the next location BUT you will have to modify the Cam post to use the Mcode in lou of the G81cycle


G0 X1.000 Y1.000
M2001 P-1.000 Q0.010 R.555 F5
G0 X2.000 Y2.000
M2001 P-1.100 Q0.010 R.555 F10
G0 X0.000 Y0.000


The Mcode code is this:

'M2001 , macro for G81 drill cycle
ActivateSignal(output3)
Sleep(1000)
Code"G0 Z" & (param2)
While Ismoving()
Sleep(10)
Wend
Code"G1 Z" & (param1)
While Ismoving
Sleep(10)
Wend
Code"G0 Z" & (Param3)
While Ismoving
Sleep(10)
Wend
DeactivateSignal(output3)
Sleep(1000)
End    
Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 12:27:45 PM
(;-) A little more testing shows we can combine a few things and make it better.

The mcode process (m2001) allows the positional date to process first( g0 x1 y1) then the Mcode runs such as

M2001 X1.000 Y1.000 P-1.000 Q.010 R.500 F20  S1000    (moves to the drill point FIRST then preceeds with the drill cycle)
M2001 X2.000 Y2.000 P-1.500 Q.010 R1.000 F5  S500

This simplifies the Gcode program a bit and still allows a self contained Drill cycle WITH lock and unlock as you need.

Title: Re: VB or Brains Question
Post by: Dave3891 on August 13, 2010, 12:29:02 PM
Is it possible to make the M code work like a canned cycle so that it is only called once?

I make the NC files and do the cam so its not a problem for me, but the operators are used to seeing it as a starting drill code then just X and Y positions.
And they change the feed and depth often, so having to change it for every liine wouldnt work.

Some programs drill 4000 holes for one job.
Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 01:44:16 PM
Are all the holes in one program the same depth,feed retract etc ?? If so there is an easy way  Or if there are groups of the same do you group them as such?
Title: Re: VB or Brains Question
Post by: Dave3891 on August 13, 2010, 02:30:17 PM
They are all the same depth and feedrate.

We just make a layout program with a small bit first, then the operator changes the depth and feedrate for the drilling.

So one program will have only one G81 line followed by over 1000 X and Y position lines
Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 02:42:52 PM
OK here is another way that is very close. This way the param values remain modal until you change them . You just have to add the M81 to each drill point.

HUM, BUT there is a "BUG" in MACH that prevents us from using this approach. When Mach see the empty Q parameter call it should call "null" BUT instead it calls  -1.  The P and R work as they are suppose to.     THat puts a monkey wrench in the works, Close but no cigar again.

G0X0Y0
M81 X1.000 Y1.000 P-1.000 Q0.010 R.500 F5 S1000
M81 X2.000 Y2.000
M81 X3.000 Y3.000
M81 X4.000 Y4.000
M81 X5.000 Y5.000 P-1.5
M81 X6.000 Y6.000 Q.1 R1.000 F4 S500
M81 X7.000 Y7.000
M81 X8.000 Y8.000


The Mcode M81 code is this:

'M81 , Macro for G81 function
SetVar(300,(Param1))
Sleep(10)
Setvar(301,(Param2))
Sleep(10)
SetVar(302,(Param3))
Sleep(10)

ActivateSignal(output3)
Sleep(1000)
Code"G0 Z#301"
While Ismoving()
Sleep(20)
Wend
Code"G1 Z#300"
While Ismoving
Sleep(20)
Wend
Code"G0 Z#302"
While Ismoving
Sleep(20)
Wend
DeactivateSignal(output3)
Sleep(1000)
End         
Title: Re: VB or Brains Question
Post by: Dave3891 on August 13, 2010, 04:52:58 PM
Hmmm, what about a M code that sets a flag or led that a brain could see and when set the brain would activate the clamps if the Z is moving in the down direction and deactivates if it is moving in the up direction.

I havent looked at the brains that much so I don't know if it can look for direction changes or not.
Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 06:02:20 PM
I think we may be able to do some along that line we will have to built a routine modual that can TELL if the axis is moving down or UP or is not moving .

I'll take a look.
Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 07:46:32 PM
IF we look at a Userled as a trigger and Zfeedrate as a trigger

Then look at  Zposition(a)  &  Zposition(b)   and

IF (Userled>0 )  AND  (Zfeedrate>0)   AND  (Zposition (a) > Zposition(b))    then  ActivateSignal(output3)

That should work as a brain to trigger the BedLock anytime all the conditions are met.

You would just need to turn on the UserLED by a Mcode  just before the G81 cycle.

Then if the led is on and the Zfeedrate shows movement AND the Positions show it is going DOWN then it turns ON the Bedlock. Otherwise the Bedlock is OFF



Title: Re: VB or Brains Question
Post by: Dave3891 on August 13, 2010, 08:18:31 PM
So would I need to run that as a brain or as a pump script?
Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 10:17:06 PM
I am testing it as a brain (;-) I will let you know if it works.

A vb script would be way too slow to sense the changes
Title: Re: VB or Brains Question
Post by: Dave3891 on August 13, 2010, 10:37:16 PM
Right on, thanks a lot for all the help.

Now if only single block worked with a canned drill cycle I would be all set  :)
Title: Re: VB or Brains Question
Post by: BR549 on August 13, 2010, 11:50:25 PM
Single block does work with a canned cycle, But you have to turn it ON before the cycle starts. Mach runs a buffer system and you cannot undo the loaded buffer to be able to single block after the buffer has already loaded.

Title: Re: VB or Brains Question
Post by: Dave3891 on August 14, 2010, 11:38:26 AM
All the operators here are used to using single block to pause after the current hole to go for break.
It works well with our DOS and Fanuc controllers.

But when I test this with mach is will pause the hole, but then when you resume with a cycle start, it will just use the drilling feed rate to position to the next hole and not drill it. And then continues with this positioning and not drilling.
Title: Re: VB or Brains Question
Post by: BR549 on August 14, 2010, 12:08:42 PM
That is because your dos and fanuc controllers are running in real time(;-)

OK I have to ask (;-) Why do you stop the machine to go on break? 

So far testing brains I have not found a dependable way to use the bedlock feature inside of the G81 cycle . I have gotten close BUT the Computer I am testing with DOES NOT like brains and runns them very slow ,about as slow as the macropump. But testing continues(;-)

Title: Re: VB or Brains Question
Post by: Dave3891 on August 14, 2010, 03:46:39 PM
They pause it for breaks because the drilling we do can go really wrong really fast in no one is watching.

I think brains should run fast on my system since it is using a galil motion card on ethernet and a Click PLC with modbus for the outputs, so no printer port.

I have the card and plc all setup with mach but I havent connected it to the servo amps since I want to get all the motion clamps and tool change setup first.
Title: Re: VB or Brains Question
Post by: BR549 on August 14, 2010, 09:19:25 PM
HUM, Galil motion card. You may want to ask SteveMurphy about this one. Sometimes the motion card controls things differently than direct control from a PP.

So far The brains don't have the resources available to do this. I can get close but not close enought that "I" would use it. The problem comes when the Z cross the 0.000 and positional values reverse sign. There is no way I can find to address the problem. I can make the Bedlock active when it crosses the 0.000 and stay on until it comes back across. But you need it to lock as soon as it moves going down and release after it stops going up

(;-)
Title: Re: VB or Brains Question
Post by: Dave3891 on August 17, 2010, 05:14:02 PM
Well I think I have a working brain program for this.
I took 3 values, Xtogo Ytogo Ztogo
Made them all have a =0 check
Inverted the Ztogo = 0 check
Then did a AND on all 3 and route it to Output #1

So it is basicly If (Xtogo and Ytogo = 0) AND (Ztogo is not 0) then clamp the bed.

It looks like it is working in simulation, but do you see any problems with it?
Title: Re: VB or Brains Question
Post by: BR549 on August 17, 2010, 07:38:32 PM
WEll if the brains are fast then when the Zaxis gets to the end point of the Zmove the bed will unclamp then reclamp as it starts the next up move. The TOGO should report the distance to the end of each linear move. So when it gets to the bottum of the stroke it should reset for the move up.

It should be as simple as if Z axis is moving then clamp.    IF  Zfeedrate > 0 then activate output#1        SO then IF Zis moving clamp but then you need to deal with the bottom of stroke when vel = 0 and it restarts the upstroke.  YOu could then add a routine that prevents the unclamping unless Zpos > 0.000 so it can only unclamp if the stroke is above 0.000


During the drill cycle there are no z interpolated moves with x/y. BUT here the brain does not release controll and unclamp when Z actuall stop at the top of the stroke. IT SHOULD but does not.

This computer and brains have never really gotten along(vista) SO it it hard to tell what is real or not.

SO only real world testing is going to tell the story. Give it a whirl
Title: Re: VB or Brains Question
Post by: Dave3891 on August 17, 2010, 10:55:23 PM
I have mapped the output#1 to a relay on the PLC and I cannot see it unclamping at the bottom of the stroke. It seems to stay clamped from the start of the hole till the retract is finished.
But I don't have motors hooked up yet to fully see how it plays together.
Title: Re: VB or Brains Question
Post by: BR549 on August 18, 2010, 01:03:23 AM
Give it a try (;-)
Title: Re: VB or Brains Question
Post by: poppabear on August 18, 2010, 03:11:48 PM
Dave3891,

     Here is a little plug that you can use, you can use a custom M code to turn on and off a User LED that while it is on, then when Z goes below 0.0 the OUTPUT1 goes hot, the config on it is so you can pick what ever UserLED number you want, and you can also pick OUTPUTs 1-6,

further you can choose to use the Para Port, and/or you can also send the result of the Output you choose, to the Serial Plugin Modbus and you can choose the Config and Local var you want. NOTE: you will HAVE to have the Serial Plugin Modbus configured and working otherwize if you send to the modbus that is NOT working it will estop mach since it is an error.

The built in Modbus is so you can send the result of the OUTPUT1 directly to the Serial Plugin Modbus.

Defaults are:  Z level 0.0, OUTPUT1, ParaPort output (it has a memory so you can configure something different). the LESS than Z 0.0 is hardcoded in the plugin.

so once you run lets say M8888 that inside it you turn on "SetUserLED(1500,1)"
then once that LED is ON, any time your Z goes below 0.0 the OUTPUT1 (or 1-6 as options), which that output can be sent via standard PP (that in turn could be used in Brians or VB, or paraport direct), AND/OR you could send it out directly over the modbus.

Once all your many drilling cycles are done, you would run for example M8889 that would turn OFF  User LED1500 and that would disable the clamp function.  "SetUserLED(1500,0)"

You could also put 2 custom BUTTONs on your run screen that could turn on the other off the UserLED 1500 for example.

scott
Title: Re: VB or Brains Question
Post by: BR549 on August 18, 2010, 09:17:58 PM
Hiya Scott, I think the idea was to have the clamp set as the z starts to move down(before0.000) and release after the z clears 0.000 going up to the top again. I was working on a brain to sense Zdirection but could not get it perfected, close but not perfect.
(;-)
Title: Re: VB or Brains Question
Post by: poppabear on August 18, 2010, 10:50:21 PM
Ok I will modify the plugin for you, in such that you put the Activate/Deactive clamp value (as a double), into the Z height box.  for instance if you Z Negative is going down toward your table and Z positive is away from the table.

I will set it like this, the Clamp will activate, when the Z axis is moving down AND the Z axis is below the clamp trigger hiegth. Then the Clamp will Unclamp when the Z is moving up ward and also be above the Clamp hiegth.

So you could put your Z travel, somewhere between the Top of your material, but below the Z Clamp hieght while your in the Drill cycle(s).

scott
Title: Re: VB or Brains Question
Post by: poppabear on August 18, 2010, 11:57:06 PM
Ok here it is, I put the default Z ht. for 0.25" 

so when the UserLED 1500 is ON, and the Z is lower than 0.25" that activates the clamp, and it stays on, until you go above 0.25" (or what ever you set it for). once above 0.25 it will unclamp.....

is that what you wanted?? or did you want it that when it is below the Z trigger hieght, but only clamp on the down direction and unclamp on the up directions??

at any rate, here is the revised version.....

scott
Title: Re: VB or Brains Question
Post by: Dave3891 on August 19, 2010, 01:05:39 AM
It sounds like it will work pretty good.
Are you able to make it so that the clamp will activate as soon as the X and Y distance to go reach 0, and then they deactivate when the Z has retracted to a set value? And possibly a time delay between the turn off and the start of the next XY movement?

I know I am asking alot, but would I be able to get the source to the plug in? I want to learn how to start making them as well.  :)

Thanks.
Title: Re: VB or Brains Question
Post by: poppabear on August 19, 2010, 09:19:27 AM
Ok here are my questions/answers......

It sounds like it will work pretty good.
Are you able to make it so that the clamp will activate as soon as the X and Y distance to go reach 0, and then they deactivate when the Z has retracted to a set value? And possibly a time delay between the turn off and the start of the next XY movement?

***  Ok, are you wanting the above INSTEAD of what you have now, or in addition to what you have, if you want them both do you want to be able to choose between the two type of clampong functions?

So if I understand you correctly, you now want where the OUTPUT1 will not activate until the X and Y ToGo DROs become 0.  But the only thing that will DeActive OUTPUT1 is the Z axis going over a specific hiegth?
Further once it goes above that Z hiegth, you would like a "Time Delay" before the OUTPUT1 would Deactivate, correct?
IF I have above what you are wanting, then yes it can be done....  If I dont understand explain what you want better, I will also need to know, would this take the place of how the Z clamp is currently working??
ALSO:  The Time Delay would need to be in 100ms units, since that is the loop rate of the plugin. If you would like to "Set" a variable delay vs. a hard coded delay, I can add a place on the config screen where you can enter the amount, in 1 ms intervals.

I know I am asking alot, but would I be able to get the source to the plug in? I want to learn how to start making them as well. 

If you want to learn plugins I HIGHLY, HIGHLY recommend you read Jemels "Plugin Tutorial" in the memeber docs, he takes you from Ground 0, to writing a usuable plugin.  I will send the source to you off list for a example as well.
Also the "Plugin Wizard" that Ed Bryson did (complete with trianing videos), is a MUCH easier way to do plugins!! If your going to learn them I would recommend you use his Wizard!!!!!!!!

Email me at: poppabear"AT"hughes.net

scott
Title: Re: VB or Brains Question
Post by: BR549 on August 19, 2010, 11:36:18 AM
HIYA Scott, If you have not figured it out yet we are CLAMPING the gantry to the bed from  INSIDE of a canned drill cycle(;-) so obviously it cannot clamp while XY are moving.

 From my perspective it would need to clamp as soon as the Z started to move down to secure the gantry before the bit gets to 0.000. or else the gantry can jitter if the bit gets to the material before the gantry gets clamped tight

On the Z up stroke it needs to wait until after 0.00 is reached before it unclamps to insure the bit does not wobble in the hole AND give the unclamp cycle time to unclamp before the z reaches the Rlevel and the xy starts to move to the next hole. If the clamp does not unclamp fast enough OR you do not allow enough time based on teh retract level the xy drives may fault or steppers loose steps.

My thoughts are instead of a preset height "trigger" the clamping would begin on the start of the downstroke and end after it clears 0.00 on the way up. That way the operator/programmer can adjust the clearance height needed to allow cycle time for the clamp to work via the retract level of the Drill cycle and could be set from the Cam post.

Also remember some drill cycles are not like the G81 where you have a straight move to the bottom and a straight move to the top again. The g83 is a peck cycle and there are dwell drill cycles as well so if that can be worked in it would be great

This could be a very handy MACH  Mcode utility.

Just a thought
Title: Re: VB or Brains Question
Post by: poppabear on August 19, 2010, 11:55:07 AM
what you have now does that.......

   Currently the trigger hight is set to 0.25 +.  as the Z goes down below that value, and still above the 0.00 vlaue the OUTPUT1 is told to clamp, in your Drill cycle put your retract level to above  +0.25", as it retracts above that it will unclamp
depending on your retract feed rate and how far up past 0.25 your are retracting there is some time involved there to give the clamp, time to unclamp. If that is not enough time, add a G4 P1 or what ever following your Drill cycle, prior to the next XY moves..... make all your XY moves above the 0.25" trigger point.

If I am still not following, educate........

scott
Title: Re: VB or Brains Question
Post by: BR549 on August 19, 2010, 02:22:30 PM
CLOSE enough(;-)



 It is probably best to just leave it at a custom thing and not a general Mcode function unless Brian can add it to all the drill cycles

(;-) TP
Title: Re: VB or Brains Question
Post by: poppabear on August 19, 2010, 05:03:17 PM
ok, run it on your machine to see if it works for you like you think it should.

scott
Title: Re: VB or Brains Question
Post by: poppabear on August 19, 2010, 09:23:11 PM
Hey Dave,

    Here is the Code that operates the plugin, this code is just dropped into the UpDate() loop part of the plugin, all else of the plugin is Boiler plate of the "Universal Blank" plugin templete I posted up on the Plugins section.

After looking this over though, you could have done the exact same thing with VB in the Macro pump coupled with Brains to use the Serial Plugin Modbus to set your modbus IO......

void   myUpdate () // 10Hz update loop
{//====================START my update================================   

   if (GetLED(m_TriggerLEDNum)) //UserLEDnumber var (int) from dialog
   {   
      if ( GetDRO(802) < m_Zhiegth ) //Z height trigger var (double) from dialog
      {
         if ( GetDRO(802) < OldZhiegth ) //internal var as double
         {
            if (m_UsePPoutput) //bool check box from dialog
            { Engine->OutSigs[m_OutputNumber + 6].Activated = 1; }
                                                                 //the Mach internal var sturct/var for outputs 1-6
            if (m_UseMBSerialoutput) //bool check box from dialog
            { MainPlanner->ModBusData.cgf[m_CfgNum].Data[m_SerialMBlocalvar] = 1; }
                                                                 //if using the Serial plugin modbus, gets the Config#, and Local Var# from
                                                                 //the dialog box
         }
      }
      OldZhiegth = GetDRO(802);

      if ( m_Zhiegth < GetDRO(802)){      
         if (m_UsePPoutput)
         { Engine->OutSigs[m_OutputNumber + 6].Activated = 0; }
         if (m_UseMBSerialoutput)
         { MainPlanner->ModBusData.cgf[m_CfgNum].Data[m_SerialMBlocalvar] = 0; }
      }
   }
}

//   have fun........  Scott
Title: Re: VB or Brains Question
Post by: Dave3891 on August 19, 2010, 09:27:07 PM
Thanks.

I am trying to get a temp wiring bypass from the old controller to the new one with mach so I can test this out soon, so I will let you know how it works out either way.