First steps with 6i25+7i77 : how to read a home switch ?

More
7 years 11 months ago #121054 by JC10
Hello,

I am starting with LinuxCNC and MESA boards.

Reading various posts on the forum, I managed to connect all and supply the field power with 24v DC.

I started with what andypugh showed in this topic : forum.linuxcnc.org/9-installing-linuxcnc...nuxcnc-configuration

andypugh wrote:
Open a terminal window and type:

Code:
sudo dmesg -c halrun loadrt hostmot2 loadrt hm2_pci show pin *5i25* exit dmesg

The "show pin" displays all the HAL pins created by the firmware on the card.


I am able to see all my I/O from the 7i77 :
Code:
user@LINUXCNC:~/Downloads/5i25/configs/hostmot2$ halrun halcmd: loadrt hostmot2 halcmd: loadrt hm2_pci halcmd: show pin *7i77* Component Pins: Owner Type Dir Value Name 5 bit OUT FALSE hm2_5i25.0.7i77.0.0.input-00 5 bit OUT FALSE hm2_5i25.0.7i77.0.0.input-00-not ... 5 bit OUT FALSE hm2_5i25.0.7i77.0.0.input-31 5 bit OUT FALSE hm2_5i25.0.7i77.0.0.input-31-not 5 bit IN FALSE hm2_5i25.0.7i77.0.0.output-00 .... 5 bit IN FALSE hm2_5i25.0.7i77.0.0.output-15 5 bit IN FALSE hm2_5i25.0.7i77.0.1.analogena 5 float IN 0 hm2_5i25.0.7i77.0.1.analogout0 .... 5 float IN 0 hm2_5i25.0.7i77.0.1.analogout5 5 bit IN FALSE hm2_5i25.0.7i77.0.1.spinena

Using again andypugh suggestion from this topic : forum.linuxcnc.org/38-general-linuxcnc-q...-done-init-mesa-6i25

andypugh wrote: Just type this at the terminal:

Code:
halrun loadrt hostmot2 loadrt hm2_pci
(Nothing happens with the card without being attached to a real-time thread)
Code:
loadrt thtreads addf hm2_5i25.0.read thread1 addf hm2_5i25.0.write thread1 start show pin
(I am guessing the next pin name, but it will appear in the list created by the command above, and you can use tab-completion to do most of the typing)
Code:
setp hm2_5i25.0.led.cr0 1
Should turn an LED on
Code:
setp hm2_5i25.0.led.cr0 0
Should turn it off


I played with the two leds first.

Now I would like to read a home limit switch. I read from the 7i77 manual that I have to wire my switch to power field and to an input terminal of the 7i77, I am ready to do this.

Keeping andypugh hal instructions here above, is "addf hm2_5i25.0.read thread1 " suitable to read such a home limit switch input in case of a 7i77 ?

My plan is to observe from Halscope the changing state when toggling the switch.

Thank you for help.

My machine rebuilt can be seen at : here

Please Log in to join the conversation.

More
7 years 11 months ago #121062 by andypugh
Yes, you need to load the driver and add the read function to a thread.

To monitor the output you might like to try:
Code:
loadusr halmeter

(you can repeat this command to open as many halmeters as you need).

To test outputs (which need the write function added to a thread) you can either use "setp" as you did with the LEDs or
Code:
loadusr sim_pin hm2_5i25.0.gpio.00-out
linuxcnc.org/docs/2.7/html/man/man1/sim_pin.1.html

Please Log in to join the conversation.

More
7 years 11 months ago #121087 by JC10
Thank you Andy it worked like a charm.

Here the short shooting link : Here

Please Log in to join the conversation.

Time to create page: 0.138 seconds
Powered by Kunena Forum