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 26, 2012, 05:04:49 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
General Mach Discussion
Reading IO issues
Pages:
1
Go Down
« previous
next »
Author
Topic: Reading IO issues (Read 455 times)
0 Members and 1 Guest are viewing this topic.
tbyrd0918
Active Member
Offline
Posts: 12
Reading IO issues
«
on:
June 08, 2010, 01:54:18 PM »
I've been using this exact code on 3 machines with good success for several months. All of a sudden, wham!! No worky!! I have the v. 3.042.040 of Mach and 2.06.00 driver for my SmoothStepper version v015ogx2 plugin. When I run the M1000 macro, it moves the cylinder down, but it never says "made it". I can look on the diagnostics screen in Mach and it shows the switch is made. The logic is I keep recurring the codes until it makes the switch. When it makes, it drop out of the code. I have this same code only reversed and checking a different switch for "up" and it still works fine. What I would really like is a word like "IsNotActive". It would allow me to stay in the same M code with a "while" statement. Any clues, or better way of coding?
T.Byrd
'rem M1000 down cylinder till switch
DeActivateSignal (output4)
ActivateSignal (output9)
If IsActive (input2) Then
Code "(made it)"
Else
Code "M3000"
End If
'rem M3000 cylinder down return
Code "M1000 (I AM WORKING ON IT!)"
Logged
Hood
Active Member
Offline
Posts: 17,345
Carnoustie, Scotland
Re: Reading IO issues
«
Reply #1 on:
June 08, 2010, 02:18:25 PM »
Not much of a clue with VB but this is what I would do.
DeActivateSignal (output4)
ActivateSignal (output9)
If Not IsActive(Input2) Then
Do
Message ("I am working on it!")
Sleep 10
If IsActive(InPut1) Then Exit Do
Loop
End If
Message ("made it")
Hood
Logged
stirling
Global Moderator
Offline
Posts: 1,189
UK
Re: Reading IO issues
«
Reply #2 on:
June 09, 2010, 04:40:05 AM »
One thing I notice is you appear to be calling a macro from a macro which is generally a no no in Mach, so maybe that's been tightened up on as versions have progressed and that's why it used to work but now doesn't.
Not only that but you also appear to be calling M3000 from M1000 and then calling M1000 from M3000 i.e. indirect recursion. This is probably best avoided even if you intended it and understand recursion as CVB is broken and doesn't handle it properly at all.
Anyway - here's my shot at what you describe.
DeActivateSignal (output4)
ActivateSignal (output9)
While Not IsActive(Input2)
Message ("Switch is Inactive")
Sleep 10
'Something must cause the switch to make at some point, otherwise this is an infinite loop
Wend
Message ("Switch is Active")
Ian
EDIT: Not sure of course on the whole picture - but you do know about G31?
«
Last Edit: June 09, 2010, 04:42:38 AM by stirling
»
Logged
tbyrd0918
Active Member
Offline
Posts: 12
Re: Reading IO issues
«
Reply #3 on:
June 09, 2010, 06:52:29 AM »
Thanks a bunch for the replies. I knew that M codes from M codes was bad news, but didn't know how else to do it. I guess the obvious was looking right at me. I am not a VB student, just learned from looking at examples in Mach. I think the "NOT" word is the answer for me. I will try as soon as possible. Thanks again.
T. Byrd
Logged
HimyKabibble
V4 Screen Contributor
Offline
Posts: 1,347
Re: Reading IO issues
«
Reply #4 on:
June 09, 2010, 11:11:54 PM »
If you're going to do that, you have to use a semaphore to keep the first macro from exiting before the second one has completed. Mach provides no synchronization between macros at all.
For example:
M1000.m1s:
Code "M01 ("This is M1000")
M2000.m1s:
Code "M1000"
Code "M01 ("This is M2000")
If you execute M2000, it will queue up the M1000 macro, then proceed executing. So what you'll see is:
"This is M2000"
"This is M1000"
Which is exactly opposite what you want and expect.
Here's what you need to do:
M1000.m1s:
SemaphoreVar = 1000 ' This can be any unused Var number - Must be same one as in M2000.m1s
Code "M01 ("This is M1000")
SetVar (SemaphoreVar, 0)
M2000.m1s:
Code "M1000"
SemaphoreVar = 1000 ' This can be any unused Var number - Must be same one as in M1000.m1s
SemaphoreVal = 1
SetVar (SemaphoreVar, SemaphoreVal)
Code "M01 ("This is M1000")
While SemaphoreVal > 0
SemaphoreVal = GetVar(SemaphoreVar)
Sleep 10
Wend
Code "M01 ("This is M2000")
The semaphore ensures that the M1000 macro completes execution *before* the M2000 macro progresses beyond the While/Wend loop. You can actually nest macros several deep if you initialize the semaphore to zero in the top-most macro, then have the calling macro increment the semaphore value, and make the While condition wait for it to be decremented back to its original value, and have the called macro decrement the semaphore, instead of simply clearing it. This is the only way I know of to make nested macros behave in a predictable manner. Without this, you have no way of knowing the exact order in which they'll execute, so it will behave differently at different times. This is another of the MANY things that will be fixed in v4.
Regards,
Ray L.
Logged
Regards,
Ray L.
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...