Home
Downloads
Mach3
Plugins
CAM Post Processors
Screensets
Purchase
Support
Forum
Tutorial Videos
Documentation
Yahoo Group
Mach Wiki
Resources
Contact Us
Links
CNCZone
German Forum
Italian Forum
Korean Forum
Portugese (Brazil) Forum
Russian Forum (RSK CNCROUTER)
Thai Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
May 28, 2012, 12:45:44 PM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Select from and to languages
Chinese-simp to English
Chinese-trad to English
English to Chinese-simp
English to Chinese-trad
English to Dutch
English to French
English to German
English to Greek
English to Italian
English to Japanese
English to Korean
English to Portuguese
English to Russian
English to Spanish
Dutch to English
Dutch to French
French to English
French to German
French to Greek
French to Italian
French to Portuguese
French to Dutch
French to Spanish
German to English
German to French
Greek to English
Greek to French
Italian to English
Italian to French
Japanese to English
Korean to English
Portuguese to English
Portuguese to French
Russian to English
Spanish to English
Spanish to French
Machsupport Forum
Mach Discussion
VB and the development of wizards
Error handling
Pages:
1
Go Down
« previous
next »
Author
Topic: Error handling (Read 1359 times)
0 Members and 1 Guest are viewing this topic.
Jeff_Birt
Active Member
Online
Posts: 809
Error handling
«
on:
March 12, 2007, 10:44:13 PM »
I've been playing with VB scripting a bit tonight to see if I can get a MCC miniLab-1008 (
http://www.measurementcomputing.com/cbicatalog/cbiproduct_new.asp?dept_id=412&pf_id=1522&mscssid=UQAPC1BR1GS68M5XNR5G403JEBKB291E
) to work for I/O in Mach3. I had used it previously to control a vise, enclosure door and misc in conjunction with a drip-feed program I wrote for our Dyna 2400 mill in the lab. I'm upgrading and would like to continue using this same unit as I have it and it gives me an excuse to delve into scripting (and then plugins).
Anyhow, I just did a basic script to try and discover the board name of the first MCC board hooked to the system. Since I'm sitting in my easy chair watching a MythBusters re-run
I of course do not have one hooked up and expect to have an error returned. So I do get an error, but have yet figured out a way to handle it from within the script (or even get the Long that is returned by the .dll). I've attached the code and error dialog box that pops up.
So, is there a method to handle/catch errors within the script? I've looked through the Cypress docs and did not locate anything. Thanks...
Here is the code:
Code:
Declare Function cbGetBoardName Lib "cbw32.dll" _
(ByVal boardNumber As Integer, ByRef boardName As String) As Long
GETFIRST = -2
cbGetBoardName (GETFIRST), bName$
mach_vb_error.PNG
(29.28 KB, 1338x954 - viewed 195 times.)
Logged
Happy machining , Jeff Birt
Check out
www.soigeneris.com
Jeff_Birt
Active Member
Online
Posts: 809
Re: Error handling
«
Reply #1 on:
March 13, 2007, 03:25:42 PM »
I hooked up the above mentioned board today and was able to make it's 'connect' LED blink via a script. Now I will work on gettign some I/O working via the macro-pump. Should work OK for thigns like coolant etc. The board is USB based has 28 digital I/O (24 of them throug a 27 pin d-sub that hooks right to an Opto-22 SSR board) as well as a few analog I/O for just over $100 USD.
I'd still be intersted if anyone knows how to do error handling in the script.
Thanks.
Logged
Happy machining , Jeff Birt
Check out
www.soigeneris.com
chad
Global Moderator
Offline
Posts: 361
When the going gets weird, the weird turn pro.
Re: Error handling
«
Reply #2 on:
March 14, 2007, 12:15:10 AM »
That looks pretty cool. Keep us updated. Sorry i can't help, i am programmatically challenged
chad
Logged
jemmyell
Active Member
Offline
Posts: 106
Re: Error handling
«
Reply #3 on:
March 14, 2007, 09:56:12 AM »
Hi,
Error handling in VBA is done with 'On Error Goto' the target of the Goto is a line label. There is an Err object that contains all the information you need about the error. To reset the error handler execute an 'On Error Goto 0'. After handling the error you can resume execution at the next VBA statement with a 'Resume Next'.
-James Leonard
Logged
-James Leonard
www.DragonCNC.com
-
www.LeonardCNCSoftware.com
-
www.CorelDRAWCadCam.com
Jeff_Birt
Active Member
Online
Posts: 809
Re: Error handling
«
Reply #4 on:
March 14, 2007, 10:01:40 AM »
I was able to get it configured and read one input last night. I'm going to start working on a 'Setup Wizard' today, which will both make it easier to see what the I/O do and allow it to be configured easier. The cool thing about the MCC stuff is that the programming interface is (generally) the same no matter what bus. So you can write one program to allow interfacing USB/PCI/PC104 based I/O.
EDIT: just saw the post above on error handling, Thanks!
I did find out how to do error handling - use 'On Error'!
The docs mention the use of a 'declares file', which presumably is a sort of header file but there is no information on its formatting nameing or referncing. Any ideas.
Logged
Happy machining , Jeff Birt
Check out
www.soigeneris.com
Ron Ginger
V4 Screen Contributor
Offline
Posts: 568
Re: Error handling
«
Reply #5 on:
March 14, 2007, 10:30:03 AM »
One of the weak links in the Mach VB is that all the parts of a VB application must be in the one file- either one button script, or one macro. So you cannot have a Declare File. You can, of course, declare (DIM) variables, etc at the top of any file, and you can have multiple subroutines in the file. What you cannot do is call a subroutine that is part of one button script from another button script.
Note a screen can have an init file, init.m1s in the same folder with the screen file. The init code will run before the its screen is opened. You cannot DIM objects there for use in your screen, but you can set DROs, and LEDs for initial values.
Since the Cypress docs talk about things like declare file I assume it would be possible for a better VB environment, just not the way Mach uses the scripting engine.
Logged
jemmyell
Active Member
Offline
Posts: 106
Re: Error handling
«
Reply #6 on:
March 14, 2007, 10:37:49 AM »
Hi,
If you want to do a lot of programming for this device, then write a DLL and call it from Mach3 VBA. If you want to use VB, then write the DLL in VB6, otherwise C++ would be good. Once you call the DLL you can do anything you want there, subroutines, etc.
-James Leonard
«
Last Edit: March 14, 2007, 10:39:44 AM by jemmyell
»
Logged
-James Leonard
www.DragonCNC.com
-
www.LeonardCNCSoftware.com
-
www.CorelDRAWCadCam.com
Jeff_Birt
Active Member
Online
Posts: 809
Re: Error handling
«
Reply #7 on:
March 14, 2007, 11:19:35 AM »
James, the MCC board ships with a .dll a.k.a. the 'universal Library'. I was just trying to avoid having all the declare statements for the various dll functions in the script itself (rather put them in a header file). No big deal, just messier looking code.
Idealy, the interface for the MCC boards would be through a plug-in. But I'm not ready to try that yet. For now being able to turn things on/off via a script will be fine.
Thanks for the help everyone, I'll work on this a bit more tonight.
Logged
Happy machining , Jeff Birt
Check out
www.soigeneris.com
Pages:
1
Go Up
« previous
next »
Jump to:
Please select a destination:
-----------------------------
Mach Discussion
-----------------------------
=> General Mach Discussion
=> Mach3 under Vista
=> Quantum
=> Mach SDK plugin questions and answers.
===> Finished Plugins for Download
=> VB and the development of wizards
=> Brains Development
=> Video P*r*o*b*i*n*g
=> Mach Screens
===> Screen designer tips and tutorials
===> Works in progress
===> Finished Screens
===> Flash Screens
===> JetCam screen designer
===> Machscreen Screen Designer
===> CVI MachStdMill (MSM)
=> Feature Requests
=> Non English Forums
===> Italian
===> French
===> Spanish
===> Chinese
===> German
===> Russian
===> Romanian
===> Japanese
===> Vietnamese
=> FAQs
-----------------------------
*****VIDEOS*****
-----------------------------
=> *****VIDEOS*****
-----------------------------
General CNC Chat
-----------------------------
=> Share Your GCode
=> Show"N"Tell ( What you have made with your CNC machine.)
=> Building or Buying a Wood routing table.. Beginnners guide..
=> Show"N"Tell ( Your Machines)
-----------------------------
G-Code, CAD, and CAM
-----------------------------
=> G-Code, CAD, and CAM discussions
=> LazyCam (Beta)
-----------------------------
Third party software and hardware support forums.
-----------------------------
=> LazyTurn
=> GearoticMotion Preliminary testing
=> Tempest Trajectory Planner
=> Contec
=> dspMC/IP Motion Controller
=> HiCON Motion Controller
=> Third party software and hardware support forums.
=> Galil
=> Newfangled Solutions Wizards
=> Mach3 and G-Rex
=> Mesa
=> Modbus
=> NC Pod
=> PoKeys
=> SmoothStepper USB
=> Sieg Machines
=> Promote and discuss your product
-----------------------------
Tangent Corner
-----------------------------
=> Tangent Corner
=> Competitions
=> Polls
=> Bargain Basement
-----------------------------
Support
-----------------------------
=> Downloads
===> XML files
===> Post Processors
===> Macros
===> Tutorials
===> Others
===> Beta Brains
===> Screen Sets
===> Documents
===> MACH TOOL BOX
=> One on one phone support.
=> Forum suggestions and report forum problems.
-----------------------------
Mach4
-----------------------------
=> Mach4 pre-Alpha Testing
Loading...