Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: TadyTheFish on January 29, 2016, 05:43:41 PM

Title: VB scripts and Brains
Post by: TadyTheFish on January 29, 2016, 05:43:41 PM
Hello everybody!

This is my first post on the forum.

My friend has a lathe with a 12 position toolchanger. The machine is quite old and has a an outdated control computer. He asked me if we could upgrade it.
For the past few weeks i have been writing VB scripts and brain logic and changed the screen. everything was working perfectly when bench testing.
Now i got a Smoothstepper and when i configured it i get alot of errors.

The thing is im using OEMTriggers as internal variables to send bits from VB scripts to Brains. i don't use them as inputs to the outside world. But smoothstepper's plugin does not like that.
If i dong configure the OEMTriggers i get errors from the smoothstepper plugin.

My question is how can i send bits from VBscpripts to Brains and vice versa without using OEMTriggers?

This is a section from my M6start.m1s

DeActivateSignal(OUTPUT3) 'tool found
   While Not IsActive(OEMTRIG2)
     Message ("Waiting for confirmation - tool lock ")
     Sleep(100)
   Wend
   Message ("Tool ready")
   End If

The OEMTRIG2 is set high by the Brain and the Brain gets the signal from modbus.

What can i use instead of OEMTRIG or INPUT or OUTPUT. so i can link Brains to VB scripts?

Thank you.
Title: Re: VB scripts and Brains
Post by: BR549 on January 29, 2016, 07:07:58 PM
I have absolutly no idea about what you are attempting to do. But why not have teh Script display the data in a DRO and the Brains read it.
Title: Re: VB scripts and Brains
Post by: TadyTheFish on February 01, 2016, 12:00:05 PM
So i should use a dro for "0" and "1"? I need to pass booleam logic. Is ir possible with a dro?
Thank you
Title: Re: VB scripts and Brains
Post by: TadyTheFish on February 01, 2016, 12:01:19 PM
This woul be alot simpler if i could manipulate the inputs and outputs directly from VB scripts. But i cant find any commands or examples that do that on a arduino :/
Title: Re: VB scripts and Brains
Post by: BR549 on February 01, 2016, 12:18:42 PM
Sure you can manilpulate teh I/O from CB scripts  you can turn on /off inputs or outputs. It is all in the manuals.

You can run the Tool changer directly  from Mach3

(;-) TP
Title: Re: VB scripts and Brains
Post by: TadyTheFish on February 01, 2016, 01:03:02 PM
Yes i saw in a manual the codes but i dont understand how to use them... It doesn't work...
In this manual:
https://www.google.si/url?sa=t&source=web&rct=j&url=http://d1.amobbs.com/bbs_upload782111/files_20/ourdev_492319.pdf&ved=0ahUKEwjs5pTnktfKAhXDtA4KHTHoAxo4ChAWCBcwAA&usg=AFQjCNE9qLuf2L24g04ap7tpgXqIoNnf9A&sig2=RH-NwvG6CMPxpbX4iHxkvw
I tried to use: SetOutBit(buffIndex, Bit Number) as Integer.. But i don't know what buffIndex is and what bit number is...  I thought you just enter the cfg number and set it high or low but i doesn't work. Maybe someone else made it work?
Title: Re: VB scripts and Brains
Post by: BR549 on February 02, 2016, 10:10:41 AM
Are you trying to talk to a serial port or a USB port ????   OF just trying to turn outputs on/off or read inputs

(;-) TP
Title: Re: VB scripts and Brains
Post by: TadyTheFish on February 02, 2016, 11:50:52 AM
Arduino is loaded with the Modbus program.... And it is connected to the usb port. But windows sees the arduino as a virtual com port (com7 for example). Tgeoretically it is a com port but it communicates as modbus... In config you have to enable modbus communication and you have to setup tables for modbus (cfg1 output-coil and pin number) then you just call a modbus config from brains...
I dont use inpits and outputs of a LPT port. All non-time critical inputs and outputs go via modbus. Homing and index and limit switches go trough Smoothstepper.
Title: Re: VB scripts and Brains
Post by: BR549 on February 02, 2016, 12:08:27 PM
AH ok you device speaks modbus (;-) Mach3 speaks ModbusRTU. Teh commands are covered in one of the mach3 manuals. You can talk to modbus via Macropump,Brains,serial or TCP.

(;-) TP
Title: Re: VB scripts and Brains
Post by: TadyTheFish on February 02, 2016, 12:42:20 PM
I was looking in all kind of manuals... Only the one that i posted has a section that describes VB commands to acces modbus directly.... But as i said i dont know how to use them... I tried all kind of variables to define the vb command but nothing works...
Title: Re: VB scripts and Brains
Post by: BR549 on February 02, 2016, 01:02:15 PM
USe this search it should give you places to get your info

https://www.google.com/search?q=Mach3+Modbus+Commands&ie=utf-8&oe=utf-8
Title: Re: VB scripts and Brains
Post by: TadyTheFish on February 03, 2016, 04:13:20 AM
Yes i have searched on google and read al kinds of manuals... But i cant access modbus directly from VB scripts. I cant find any working examples on the net that work with arduino modbus.
Anyway i made it work using UserLEDs (1000 and up) so there is no need for me to directly access modbus from vb scripts i use brains as a pass troug ;) so thank you very much for your idea for using DROs :)) and thank you for your time :)