Hello
Guest
it is
May 14, 2025, 07:16:06 PM
Guest
Login
Register
Menu
Home
Help
Search
Login
Register
YouTube
Machsupport Forum
/
Mach Discussion
/
VB and the development of wizards
/
Edge detection on input
« previous
next »
Print
Pages:
1
2
»
Go Down
Author
Topic: Edge detection on input (Read 9866 times)
0 Members and 1 Guest are viewing this topic.
tantan
130
Edge detection on input
«
on:
January 13, 2016, 01:15:19 PM »
i need to detect a falling edge of an input to control my turret
i think the code is right but it hangs mach3?
wanted_position = 6
counter = 0
marker = 0
'input 1 = the couter of the turretpostion
message "c = " &counter
sleep(100)
activatesignal(output3) 'start run turret
While ismoving()
Wend
While (counter <> wanted_position)
If Not isactive(input1) And marker = 0 Then
counter = counter + 1
marker = 1
End If
If isactive(intput1) And marker = 1 Then
marker = 0
End If
message "c = " &counter
Wend
deactivatesignal(output3) 'stop turret
tnx for your reply!
Logged
BR549
6,965
Re: Edge detection on input
«
Reply #1 on:
January 13, 2016, 02:18:01 PM »
OK what do you mean by it hangs Mach3 ?? Have you single stepped through the code to see what line causes it to hang ?
Logged
tantan
130
Re: Edge detection on input
«
Reply #2 on:
January 13, 2016, 02:45:21 PM »
hi,
the counter does not count up futher than 1. then the while loop hangs mach3 because the counter never reaches 6.
i did use the right input, i did checked that
tnx tantan
Logged
BR549
6,965
Re: Edge detection on input
«
Reply #3 on:
January 13, 2016, 04:34:30 PM »
If you single step down through the code you will see the problem as to WHY you are stuck in an endless loop with no way out(;-)
The first loop sets specific conditions after that the escape conditions do not exist as I see it from here so around and around you go.
The counter can NEVER count up past teh first loop because teh count incrementing is in the wrong position inside teh loop. As teh condition is not met it hops over teh counting code .
(;-) TP
«
Last Edit: January 13, 2016, 04:37:15 PM by BR549
»
Logged
TPS
2,577
Re: Edge detection on input
«
Reply #4 on:
January 13, 2016, 05:51:45 PM »
can you see Input1 changing signal in diagnostic Screen ?
While is moving
Wend
is useless because no 'real' axis is moving.
TPS
Logged
anything is possible, just try to do it.
if you find some mistakes, in my bad bavarian english,they are yours.
BR549
6,965
Re: Edge detection on input
«
Reply #5 on:
January 13, 2016, 06:23:11 PM »
Ismoving() does not only pertain to motion it is about any time that mach3 is doing something internally such as uipdating a dro writing something to mem ,etc
(;-) TP
Logged
tantan
130
Re: Edge detection on input
«
Reply #6 on:
January 14, 2016, 11:33:37 AM »
hi
yes the input changes in the diagnostic screen. i hope the frequency of the inputsignal is not to high for this basic code. i will test it tomorrow with a manual switch,
as far as i can see the code should detect an edge...
tnx for your replies.
Logged
tantan
130
Re: Edge detection on input
«
Reply #7 on:
January 16, 2016, 03:01:29 PM »
hi,
it works,
mach does not read inputs within a while loop.
https://youtu.be/39QgfGTrPZo
tnx for your replies
Logged
BR549
6,965
Re: Edge detection on input
«
Reply #8 on:
January 16, 2016, 04:23:15 PM »
I do not think that is true "" mach does not read inputs within a while loop. "" Can you give me an example of where you that is true
(;-) TP
Logged
tantan
130
Re: Edge detection on input
«
Reply #9 on:
January 17, 2016, 10:40:00 AM »
see code i posted in my first post. that did not see input1 changing.
i call a sub in the while loop that reads the input. that works.
tnx
Logged
Print
Pages:
1
2
»
Go Up
« previous
next »