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, 11:58:18 AM
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
Code Won't Load
Pages:
«
1
2
Go Down
« previous
next »
Author
Topic: Code Won't Load (Read 2576 times)
0 Members and 2 Guests are viewing this topic.
poppabear
S S SYSTEMS, LLC
Global Moderator
Offline
Posts: 1,707
Briceville, TN, USA
Re: Code Won't Load
«
Reply #10 on:
January 02, 2007, 05:28:54 PM »
Oh, one other thing, and this is something Art told me, he said stay as FAR away from While loops as possible, since it realy hogs procssor and can cause lockups/crashes.........yep, been there, lots of times. That is UNLESS you have to wait, then you might want to look at a "SystemWait()" command, instead of the While loop.
So you could do something like this if you don't need a "Hand shaking function":
If IsActive(INPUT2) Then
ActivateSignal(OUTPUT8)
End If
If IsActive(INPUT3) Then
DeActivateSignal(OUTPUT8)
End If
One other Note: If for some reason, you need the signal status of OUTPUT8 to "Stay on or off" after the switch is made. You can send your signals through the Modbus to a PLC, or peters board or other Modbus device. When you turn on a signal, in Modbus, it stays on, till you turn it off. Another option: if you need that, but don't want to use a modbus device. You could send you PP signal to a self Latching relay, and the off signal, would "cut" the coil.
Scott
Logged
Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
01sporty
Active Member
Offline
Posts: 44
Re: Code Won't Load / Back Again
«
Reply #11 on:
January 02, 2007, 06:11:25 PM »
After more playing, things weren't working as well as I thought.
You're exactly right about the while loop. Things started hanging and running really, really s l o w. Checked my processes and Mach3 was using 98-99 percent CPU. Yikes.
I really like the idea of the SystemWaitFor command, but it just isn't happening for me. Here's what I scripted:
ActivateSignal(OUTPUT8)
SystemWaitFor(INPUT2)
DeActivateSignal(OUTPUT8)
SystemWaitFor(INPUT3)
It sure looks simple enough but it just sits there when I try to run it. (I think I heard it chuckling. Must be time for a nap.)
Regards,
Walt
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
Offline
Posts: 1,707
Briceville, TN, USA
Re: Code Won't Load
«
Reply #12 on:
January 03, 2007, 12:58:56 PM »
Sorry that wasn't clear, the "SystemWaitfor()" You need to put it on your INPUTS, before the Outputs that are slaved to it.
But you would have to rewrite your code somewhat like the example below. All it will do there, is when INPUT2 turns on OUTPUT8 turns on, then the system will pause for 2 seconds then it will move on.
If IsActive(INPUT2) Then
ActivateSignal(OUTPUT8)
Code "G4 P2" 'Pause for 2 seconds for what ever mecanical action is happening to complete
End If
While IsMoving ()
WEnd
If IsActive(INPUT3) Then
DeActivateSignal(OUTPUT8)
Code "G4 P2" 'Pause for 2 seconds for what ever mecanical action is happening to complete
End If
While IsMoving ()
WEnd
Scott
«
Last Edit: January 03, 2007, 01:11:03 PM by poppabear
»
Logged
Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
01sporty
Active Member
Offline
Posts: 44
Re: Code Won't Load
«
Reply #13 on:
January 03, 2007, 05:23:38 PM »
Hi Scott,
I see what you're saying. That's really not what I want to happen. I'm trying to avoid simply putting in a timing delay if possible. I want all my actions to occur in a linear fashion. That way, the machine runs at it's maximum speed and has no chance of crashing if there is any decrease in air supply.
To expand on this, here's what I'd like to see happen: The INPUT3 switch is on the air cylinder in it's normally relaxed position. The INPUT2 switch is at the end of the stroke of the air cylinder. The air cylinder is OUTPUT8. Both switches are normally closed but I don't think that matters since Mach3 lets you define normally high or low. So, what I'm trying to accomplish is: trigger the cylinder, wait for the cylinder to reach the end of stroke, de-activate the cylinder, wait for the cylinder to get back to the beginning of its stroke and finally, continue the program.
The while loop routine I originally came up with accomplished this very well, --- when run by itself from the MDI line. I still find it odd that it runs there but won't run inside a program.
As confused as ever,
Walt
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
Offline
Posts: 1,707
Briceville, TN, USA
Re: Code Won't Load
«
Reply #14 on:
January 03, 2007, 06:52:56 PM »
Your choices are timing delay, OR, While Loop.........
Try this code:
'Piston Macro M********* (Label the Macro number instead of *********).
'It wasn't clear, so I am assuming that this is a macro in your running G-code, if it is a button, then paste it in.
'Using SystemWaitFor(), and While Loops, will both suck down, major processor time.
ActivateSignal(OUTPUT8) 'Solinoid to extend cylinder.
Code "G4 P1" 'Pauses for 1 second for cylinder to extend, set pause higher if needed.
While Ismoving() 'Waits for pause to time out.
WEnd
If IsActive(INPUT2) Then 'After 1 second, if INPUT2 (extended limit switch), is active then deactivate cylinder.
DeActivateSignal(OUTPUT8) 'Drop Air cylinder
Else
Question("Did your Cylinder Extend? Check your Air") 'So if INPUT2 don't turn on, and pause times out, error message.
End If
Code "G4 P1" 'Pause 1 second, for cylinder to drop.
While Ismoving() 'Waits for pause to time out.
WEnd
If NOT(IsActive(INPUT3)) then 'If INPUT3 (cylinder back home), is not on/closed, then Error
Question("Did your Cylinder Retract?") 'Error question.
End If
Let me know,
Scott
Logged
Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
01sporty
Active Member
Offline
Posts: 44
Re: Code Won't Load / Success!!!
«
Reply #15 on:
January 05, 2007, 12:11:41 AM »
In a nutshell, The Code Won't Load because there's no IsLoading() function.
To elaborate. The following code works fine by itself:
While IsActive(Input2)
ActivateSignal(OUTPUT8)
Wend
While IsActive(Input3)
DeActivateSignal(OUTPUT8)
Wend
But when Mach3 loads a program, it does a run simulation as it loads each command. This way it checks commands for syntax and draws the toolpath display. When it encounters code that depends on a mechanical action to continue, it will sit there and wait for that action to occur. Obviously this will never happen since it's a simulation.
Fortunately, there's a command just for this situation. IsLoading: "Returns true if the part program is loading rather than being actually run (e.g. so the toolpath is being generated or regenerated)."
So my little while loop code becomes:
If IsLoading() Then
Else
While IsActive(Input2)
ActivateSignal(OUTPUT8)
Wend
While IsActive(Input3)
DeActivateSignal(OUTPUT8)
Wend
End If
This tells Mach to go on to the next command if it's loading, otherwise do the code.
I knew I had to be missing something simple.
Then again, I guess it's only simple once you've figured it out.
Regards,
Walt
Logged
poppabear
S S SYSTEMS, LLC
Global Moderator
Offline
Posts: 1,707
Briceville, TN, USA
Re: Code Won't Load
«
Reply #16 on:
January 05, 2007, 09:54:59 AM »
Perhaps, I misunderstood what you where doing. If your wanting that to run in your code, why don't you just make a custom Macro??
If you are worried about it trying to activate the Macro, you can avoid that by Loading the code while the machine is in a "Reset" active condition.
I have a machine that will "Hang", if I try to load a certain macro, since it requires an hand shake with a PLC. BUT, I can load that same program with the RESET button activated.
Scott (perhaps you will post up some pics of what ever it is, your building doing, sounds neat).
Logged
Commercial Mach3: Screens (regular and flash), Wizards, Plug-ins, Brains, PLCs, Macros, ATC's, machine build, retrofit and Prototyping
http://sites.google.com/site/volunteerfablab/
01sporty
Active Member
Offline
Posts: 44
Re: Code Won't Load
«
Reply #17 on:
January 05, 2007, 06:00:22 PM »
Oh yes, I'll certainly put together a picture album but it will be a while. Other jobs have a higher priority right now and I've got a couple of engineering changes that I'd like to implement not to mention a couple of things that need changing just because they're wrong. I figure it will be a month before it's completely on line.
Oh, it's a float wire bender for gas tank manufacturer.
Regards,
Walt
Logged
Pages:
«
1
2
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...