Hello Guest it is March 28, 2024, 07:56:02 AM

Author Topic: Using VB script to wait for an external event and then execute G code  (Read 30801 times)

0 Members and 1 Guest are viewing this topic.

Re: Using VB script to wait for an external event and then execute G code
« Reply #20 on: September 14, 2008, 10:14:51 AM »
The issue with running on one machine has to do with the spectrometer program.  I don't have the install program for that as it came with the machine.  All I have is the computer with the app installed (and an image of the drive in case it goes down).  So it's  fine that it's running on two machines.  I've got a stack of boxes all going through one KVM switch to run various machines in the lab anyway.

I have a question:  Is there a way to use an output signal (I guess 5V on the parallel port cable) to turn off my spectrometer when the data is finished? The laser source has a finite lifetime.  I'm guessing this would be some kind of power/solenoid type electrical switch.  Is there such a device?  I assume it would be fairly simple to add some code that tells mach 3 to go hi on a certain pin when file #96 is reached, yes? 

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Using VB script to wait for an external event and then execute G code
« Reply #21 on: September 14, 2008, 10:33:16 AM »
Octa, are you using a breakout board on your Mach PC? If so, what kind is it? Either way, it would be no trouble to add the code to your macro to do this for you if all you need to do is kill the power to it.

ActivateSignal (Output1)
DeActivateSignal (Output1)

These could control and Opto relay if one is needed.

Brett
« Last Edit: September 14, 2008, 10:36:08 AM by Chaoticone »
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Using VB script to wait for an external event and then execute G code
« Reply #22 on: September 14, 2008, 10:56:41 AM »
I am using a breakout board, I think it is a Xylotec. 

To be clear, although it would also be handy to turn off the juice to the motors, what I want to control is the power cord to the spectrometer.  A Photo-coupled SSR normally open would do it I believe.  Then I coudl send 5V after file 96 and open the relay and kill the power to the spectrometer.  This should be pretty easy once I find the right part.

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Using VB script to wait for an external event and then execute G code
« Reply #24 on: September 14, 2008, 04:08:47 PM »
Great!  I ordered a relay.  I think I can figure out the output pins and put the code in there to do the hi/low switching as needed. 
Re: Using VB script to wait for an external event and then execute G code
« Reply #25 on: October 09, 2008, 04:43:42 PM »
Hello all,

First, let me say that the system is working very well and I have been collecting a lot of data!  I still run it on two different computers with a switcher, but it works fine that way. 

I am writing now to ask if anyone has a suggestion concerning the wiring of the relay that I would like to use to shut off power to the spectrometer when the data collection is complete.

I have an Opto 22 (mentioned above) relay that accepts 3 to 32 V DC input.  I have been able to identify and wire the pins for an output that I set up in Mach3.  I can use the VB script editor to turn the voltage to this pin on and off.  It sends about 4.25V DC to the output.  I am using a Dell optiplex to drive the on-board parallel port (in ECP mode with no DMA assigned).   When I hook the output from the parallel port to the relay (with nothing on the 120VAC side) the voltage drops to 2.6 C DC and the other side of the relay shows no change.  I suspect that the parallel port can not manage to supply enough current to make the relay function.  I am wondering if the parallel port is wimpy or perhaps I have a relay that needs lots of power.  I would guess that folks have run into this problem before so if anyone has any advice I would appreciate it.

I have a nice parallel port card but it is full height and the Dell that I have (got it free...) has half-height card slots.  I can get a different box and use the card to drive the parallel port if folks think that this will supply enough current to control the relay. 

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Using VB script to wait for an external event and then execute G code
« Reply #26 on: October 09, 2008, 10:15:43 PM »
It should only take about 5ma to operate the relay. I haven't checked you exact specs though. On the pic., coil isn't a coil, but hopefully it makes sense.

Brett
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Using VB script to wait for an external event and then execute G code
« Reply #27 on: October 09, 2008, 10:47:20 PM »
That is the way that I have it wired - although when I tested it I did not put anything on the 110V side except a voltmeter.  I'll check it again tomorrow and confirm.

A bit of googling suggests that the parallel port is not supposed to drive the relay directly, but rather an external power source is used to drive the relay using the logic signal from the parallel port.  An example schematic is here:

http://www.winfordeng.com/download/rly102_schematic.pdf

This is the part link:

http://www.winfordeng.com/products/rly102.php

« Last Edit: October 10, 2008, 07:51:08 AM by Octathorpe »

Offline Bodini

*
  •  216 216
    • View Profile
Re: Using VB script to wait for an external event and then execute G code
« Reply #28 on: October 10, 2008, 07:46:48 AM »
I'd run it from the breakout board if possible.  Also, those opto relays are WEIRD.  I seem to remember that the ones I have did not totally cut off the voltage, even when 'off'. 

Offline Bodini

*
  •  216 216
    • View Profile
Re: Using VB script to wait for an external event and then execute G code
« Reply #29 on: October 10, 2008, 07:51:56 AM »
Oh yeah, if you do run it from breakout board, dont miss the 'Automated setting of inputs' (or whatever that button is called, but thats close) in the 'ports and pins'.  It automaticly finds what port/pin you're hooked up to.  Another fantastic Mach feature.  However, do it a few times, sometimes it gets a false reading (sounds like you know how to conduct an experiment anyway  :D)