External buttons function

More
17 Aug 2012 14:54 #23341 by raychar
Hello, everybody,

I am new in this forum and hope you can read this long writings..

Recently, I switch from using Mach3 to EMC2. Thanks to the forum that came from John for the following codes of the Run/Step Hold/Resume Buttons.


loadrt and2 count=4
loadrt or2 count=1
loadrt toggle count=1
loadrt toggle2nist count=1

addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf or2.0 servo-thread
addf toggle.0 servo-thread
addf toggle2nist.0 servo-thread

# External Program Pause/Resume and Run/Step Buttons
# Pause/Resume Section
net pause-resume-btn and2.0.in0 and2.1.in0 <= hm2_5i20.0.gpio.027.in_not (this is your input)
net pause-on toggle2nist.0.is-on and2.0.in1 and2.3.in1 <= halui.program.is-paused
net run-on and2.1.in1 <= halui.program.is-running
net pause-sig or2.0.in0 <= and2.0.out
net resume-sig or2.0.in1 <= and2.1.out
net toggle-ok toggle.0.in <= or2.0.out
net togglesig toggle2nist.0.in <= toggle.0.out
net toggleon halui.program.pause <= toggle2nist.0.on
net toggleoff halui.program.resume <= toggle2nist.0.off
# Run/Step Section
net run-step-btn and2.2.in0 and2.3.in0 <= hm2_5i20.0.gpio.026.in_not (this is your input)
net idle-on and2.2.in1 <= halui.program.is-idle
# net pause.on and 2.3.in1 <= halui.program.is-paused
# and2.3.in1 was added in the net pause-on statement in Pause/Resume Section
net run-sig halui.mode.auto halui.program.run <= and2.2.out
net step-sig halui.program.step <= and2.3.out

Knowing that these codes work. However, I don't know what's wrong on my side as I have limited knowledge in it.

I added the codes for my second parallel card's as below, its port address was tested and correct:

loadrt hal_parport cfg="0x378 out 0xd000 out"
addf parport.1.read base-thread
addf parport.1.write base-thread

For the above Ru/Step Hold/Resume buttons' code, I replaced

hm2_5i20.0.gpio.027.in_not
to
parport.1.pin-10-in

and
hm2_5i20.0.gpio.026.in_not
to
parport.1.pin-11-in

as for pins 10 & 11 are for the inputs of the two buttons to my card. I put them in xx.hal file.

There is no error message prompting but the buttons don't function. Please help to see if there are mistakes committed by me. By the way, the two buttons are made by puting pull-up resistor 47k ohm to 5V rail, the 5V and ground of these buttons connect to USB dock's power in computer.

Thanks,

Please Log in or Create an account to join the conversation.

More
17 Aug 2012 15:13 - 17 Aug 2012 15:17 #23342 by PCW
Replied by PCW on topic Re:External buttons function
First step is to use halmeter or watch to look at the state of
the parport.1.pin-10-in and parport.1.pin-11-in pins and see if
they change when you press the buttons
Last edit: 17 Aug 2012 15:17 by PCW. Reason: sp

Please Log in or Create an account to join the conversation.

More
17 Aug 2012 15:34 #23343 by BigJohnT
Another option is to run your config and go to Machine > Show Hal Configuration and add the two parallel port pins to the Watch Window. Then as Peter suggested toggle your inputs and check for status change in the watch window.

John

Please Log in or Create an account to join the conversation.

More
17 Aug 2012 16:04 #23346 by raychar
Hello,

I added the two pins to hal config watch window. Indicators did flick when I toggled buttons.

Then, what can I do to the not functioning.

Thanks,

Please Log in or Create an account to join the conversation.

More
17 Aug 2012 16:08 #23348 by BigJohnT
Next I would add all the signals for one button to the watch window and make sure they are working.

John

Please Log in or Create an account to join the conversation.

More
17 Aug 2012 16:36 #23351 by raychar
Hello,

Sorry for my least knowledge and not understanding. Could you elaborate...

Thanks,

Please Log in or Create an account to join the conversation.

More
17 Aug 2012 17:46 #23356 by BigJohnT
Just like you did for the parallel port pins open up signals and find pause-resume-btn signal and the rest of the signals that work with the pause/resume button and add them to your watch window. Then press the button to see if the signals change as expected. Of course you will need to be running a program for the pause/resume button to actually do anything.

John

Please Log in or Create an account to join the conversation.

More
18 Aug 2012 17:05 #23385 by raychar
Hello,

I managed to understand and put followings in watch window, are they correct and enough?:

1)halui.program.resume
2)halui.program.pause
3)haluiprogram.is-running
4)halui.program.is-paused
5)halui.program.is-idle
6)halui.mode.is-auto
7)parport.1.pin-10-in
8)part.1.pin-11-in

At the first place, items 5), 7) &8) were lit.
As I can't start running program by pushing button(pin-11), I manually started it by on-screen 'Run program' on pull down menu. I observed above item 3) & 6) lamps also lighted. Then, I toggle button(pin-10) or button(pin-11) from Hi to Lo or Lo to Hi, only item 7)& 8) blinked, no other lamps changed in state.

BTW, I directly wrote and added the previous codes on original default .hal file. Was it a
problem, or I need to write them seperately in custom .hal file instead for running program?

Thanks,

Please Log in or Create an account to join the conversation.

More
18 Aug 2012 23:51 #23388 by BigJohnT
The signals (the first word after net) might have been more informative than the pins.

Hal command are interpreted in order so for the most part it doesn't matter unless the pin is generated by the GUI then you have to put them in the postgui.hal file.

If you copied my example I would expect to see this signal on when running a program
run-on
When you press the "Pause/Run" button when running
pause-resume-button
pause-on
When you press the "Pause/Run" button when paused
pause-resume-button
run-on
# External Program Pause/Resume Button
net pause-resume-btn and2.3.in0 and2.4.in0 <= hm2_5i20.0.gpio.029.in_not
net pause-on toggle2nist.0.is-on and2.3.in1 <= halui.program.is-paused
net run-on and2.4.in1 <= halui.program.is-running
net pause-sig or2.5.in0 <= and2.3.out
net resume-sig or2.5.in1 <= and2.4.out
net toggle-ok toggle.0.in < or2.5.out
net togglesig toggle2nist.0.in <= toggle.0.out
net toggleon halui.program.pause <= toggle2nist.0.on
net toggleoff halui.program.resume <= toggle2nist.0.off

You might zip up and attach your configuration files to a message

John

Please Log in or Create an account to join the conversation.

More
19 Aug 2012 10:57 #23389 by raychar
Hello,

I tracked the mistake by writing line by line again and watch window. In the course of it, I merely understand the manipulations of functions and logic. Thanks,

None of mistake found. I just re-type the original code again. And now, it Works! (Will it be the copy and paste problem, better to re-type code
every time???)

Thanks,

BTW, I have another askings in new thread...

Please Log in or Create an account to join the conversation.

Time to create page: 0.080 seconds
Powered by Kunena Forum