Machsupport Forum
Mach Discussion => VB and the development of wizards => Topic started by: Sweep on September 10, 2012, 03:03:11 PM
-
I have absolutley no understanding or experience of programming of any kind.
I have downloaded the VB script command document and have installed Screen 4 but I am at a loss as how to start.
My mammoth task of converting my Denford Triac to Mach3 has been ongoing for around 5 years and the end is in sight but I now have to tackle programming the ATC. I have posted a topic on the main forum but, whilst I appreciate the replies, I am not really following what's being said!
http://www.machsupport.com/forum/index.php/topic,22055.0.html (http://www.machsupport.com/forum/index.php/topic,22055.0.html)
In hope ...Sweep
-
There's a video on creating a toolchange macro, and the sample code is also available for download. It might get you started.
http://www.machsupport.com/videos/
Sample macro - http://www.machsupport.com/downloads/M6Start.zip
-
Hi Ger21,
I have run the video a couple of times and it seems to relate more to the layout of the screen than to the operation of the functions.
My first experiment was to modify the REF ALL HOME (RAH) button on the standatd screenset to add a stream of text sent to the ATC to start the ATC dtaum function after the axis had found home.
Using Screen4 when i click on the RAH button the input box that appears notes that the "VB script function is edited within Mach3" but how do i do that?
i.e. how do i edit within Mach3 and how do I instruct the code to go to the, say, serial port as opposed to the parallel port etc?
...Sweep
Ok. Found the "edit button script" button within Mach3 which allows me to add to the existing code. Now to figure out what DoButton and DoOEMButton means
-
There are 2 manuals you need to download.
The mach3 macro programmers manual AND the VB programmers manual.
They are located here http://www.machsupport.com/documentation.php
With as many triacs that have been converted their MAY be an example of how it was programmed on this site.
Just a thought, (;-) TP
-
Thanks for that TP,
I had the VB script command reference guide but had completely missed the Programmer's reference !
...Sweep
-
Yep the programmers reference is the holy grail to Mach3 and support macros.
I know several people have converted the Triac to Mach3 complet with tool changer you just have to find them and ask for help with the macro that drives the ATC. Most will willing help out.
I will look to see IF there is any info floating on the Web for ya.
(;-) TP
-
Ok, having now spent 10 minutes glancing through the Holy Grail that is The programmer's Reference Guide I am now an expert ;)
...well not really as nothing happened.
Using the "Edit Button Script" command in Mach3's Operator tab menu I highlighted the REF ALL HOME button and added the following code:
SendSerial("B0000133E167R25") in a feeble attempt to send B0000133E167R25 to the serial port. Of course, nothing happened when I cycled through the code.
I have changed the baud rate in General Logic Configurations and ticked Event Friven Serial Control in Engine Configuration, though I am unsure what that does.
REF ALL HOME script now looks like this:
DoButton( 24 )
DoButton( 23 )
DoButton( 22 )
DoButton( 25 )
SendSerial("B0000133E167R25")
DoOEMButton(133)
DoOEMButton(134)
DoOEMButton(135)
So what am I doing wrong?
...Sweep
-
That was going to be the next question (;-) were you going to talk serial to the atc of rebuild the mechanism to use a stepper drive and i/os.
Did you setup the mach3 serial port to be the same as far as buad rate , bits, stop bits. It has to be exactly the same as the ATC uses or no talky.
You probably need to start with using Windows hyperterm to SEE if you can talk to the ATC. Set up the hyperterm as to the Comport settings and then type in the comand data and see IF the atc responds to commands.
(;-) TP
-
I already have full control via Hyperterminal which works great. All the datums and tool changes are ok.
Before I stripped out the old Denford motherboard I captured all the data flow on my oscilloscope. I adjusted the baud rate but, because of the age of the machine, I had to introduce an inttercharacter delay of a few milliseconds to allow the ATC time to digest the data.
Does the code look ok?
-
Just checked the Hyperterminal settings and I have a 1200 baud rate, 7 data bits, parity = none, stop bits =1, flow control = none, and a 10 millisecond character delay and it controls the ATC perfectly every time. Unfortunately since capturing the data my oscilloscope has packed in working otherwise I would see if I am getting any serial output when Sendserial from Mach3
...Sweep
-
In Mach3 you have a serial monitor you can setup.
I think what you want to use is event driven serial as it stays open and active the entire time MAch3 is active. The others open and close the session each time it is called. Also there is VERY little info on the serial side of Mach3.
First make SURE you have the MAch3 serial setup the same way you have hyperterm set up.
(;-) TP
-
Will do.
A strange thing happened when I edited the vbscript in Mach was that Mach3 needed a restart as everything froze. Very strange.
Managed to borrow a digital oscilloscope from work so will try and capture what is being sent.
Thanks for your help so far TP.
...Sweep
-
In reallity the scope will not help much (;-).
Try using the Mach3 serial monitor it should show what is going in and out of the port. I think once you get the serial port setup in mach3 it may do as you need
(;-) TP
-
Using the scope I can see the string of code being sent in Hyperterminal so have tried to replicate the same string in Mach.
I have managed to run the ATC from Mach even though the string wasn't identical; I think this is to do with the intercharacter delay.
The problem is that Mach seems to be pretty unreliable though!
I have used operator/edit button script to add code to the Ref All Home (RAH) button but when i add code SendSerial("D44") the whole of Mach 3 locks up and the "normal Condition" LED changes to "Abnormal Condition"?
I press RAH but nothing happens
If i then enter a tab menu, say "about Mach3" and then exit that menu all the dorment commands, e.g. RAH, are executed in series. So if iv'e pressed RAH three times it exwcutes it three times.
very strange ...Sweep
-
OK when it went abnormal did you click on it to get the message??
It is best to test from the editor screen. That eliminates all outside mach3 interference. When you get it working there THEN you work out the other kinks.
(;-) TP
-
Yes. It mentioned something about axis not properly datumed. I got a reply on the General Forum which more or less said disregard it as it detects things that are unusual, and as I started messing with the code then this was to be expected.
Anyway, good news! Not sure how or why but the SendSerial command is now working fine so I started experimenting with a little bit of coding on the RAH switch which works well.
DoButton( 24 )
DoButton( 23 )
DoButton( 22 )
DoButton( 25 )
Sleep(100)
While IsMoving()
Sleep(100)
Wend
DoOEMButton(133)
DoOEMButton(134)
DoOEMButton(135)
SendSerial("B0000133E167R25")
Sleep 3000
SendSerial("D44")
The first SendSeial is to check whether air is present and the D44 datums the carousel stepper motor.
I dont think the DoOEMButton 133, 134 and 135 are used as I don't have encoders fitted so I will delete these tomorrow and see if all works well. I will also remove the 2nd Sleep command and replace it with an input from the ATC that runs D44 when the ATC relay changes over after the first procedure completes.
With my new found confidence, and with many thanks to you TP, i have started to work on my Toolchanger screen for Mach3. I have tested the basic commands and they work too. Yippee!
The next big question is whether to have my tool offsets held within Mach or my CAM program. My first thought was to have them within Mach so I could use the machine manually as well as fully automatic but i wasn't sure if the CAM will try and bring across tool offsets of, say zero, when I load the Gcode?