custom M code

More
23 Jan 2015 14:44 #55283 by KobeYang
custom M code was created by KobeYang
Dear Sir,
Now I used emc2.4.6 with hm2_5i20 card.I want to use IO 42 to output a pulse which width is 100us ,Can I use the costom M code to finish it?
the following is I wrote,but I measure the pluse width with electronic oscilloscope is >=4ms.
#!/bin/sh
# open the collet closer
halcmd setp hm2_5i20.0.gpio.042.out TRUE
halcmd setp hm2_5i20.0.gpio.042.out FALSE
exit 0

Can you help me? thanks.

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

More
24 Jan 2015 20:36 #55309 by ArcEye
Replied by ArcEye on topic custom M code
Hi

If you want to generate a pulse, have a look at siggen

www.linuxcnc.org/docs/devel/html/man/man9/siggen.9.html

regards

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

More
26 Jan 2015 05:13 #55342 by andypugh
Replied by andypugh on topic custom M code

Now I used emc2.4.6 with hm2_5i20 card.I want to use IO 42 to output a pulse which width is 100us ,Can I use the costom M code to finish it?.


With a typical 5i20 setup you have a 1mS servo thread and no base thread. This means that there is no way to have a pulse length < 1mS generated in the software without changing the configuration.

You could _create_ a base thread specifically to run a "oneshot" HAL component. You would also have to add the hm2_5i20.write_gpio function to the fast thread.
www.linuxcnc.org/docs/html/drivers/hostmot2.html#_functions
Describes this, but also suggests that it would be very unusual.
Does it have to be pin 42? You can probably set up low-frequency PWM with a very low duty cycle and enable and disable it from an M-code-triggered oneshot running in the base thread.

It should be possible to create a hardware oneshot with a 555 timer.

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

More
26 Jan 2015 05:35 #55344 by PCW
Replied by PCW on topic custom M code
You might also be able to do this with a hardware stepgen with steplength set to 100 usec

You would add a 1/stepscale sized position offset to the position command every time you wanted a pulse

Too bad theres no hm2 one shot module

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

Time to create page: 0.189 seconds
Powered by Kunena Forum