M1xx code

More
04 May 2009 19:25 - 04 May 2009 20:59 #207 by melhima
M1xx code was created by melhima
Hi,

I would like to create my own function with M1xx
I would like to know if I can "control" if an output pin is "on" or "off" to make my function
For example :

M102
#!/bin/sh

halcmd setp motenc.0.out-00 True #to make sur the signal is off
sleep .5

while [ motenc.0.in.00 != True ]; do #control if the signal is back

halcmd setp motenc.0.out-00 True #rot motor 1
halcmd setp motenc.0.out-01 True #rot motor 2
sleep .2
halcmd setp motenc.0.out-00 False #stop motor 1
sleep .5

done
halcmd setp motenc.0.out-01 False #to stop a motor
exit 0

I'm not sur with this line it's not working
while [ motenc.0.in.00 != True ]; do #control if the signal is back

I just want to know how to control an input or output pin
With getp also is not working halcmd getp motenc.0.out-00 but if i write on hal config getp.motenc.0.out-00 it told me it's False so my function is ok why she's not working in my M1xx file??

Thanks a lot!!!
Last edit: 04 May 2009 20:59 by melhima.

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

More
05 May 2009 08:58 #209 by alex_joni
Replied by alex_joni on topic Re:M1xx code
I would rather attempt to do this in g-code.
Use M66 to check a value, or wait for a value.
And M64,65 to set digital bits on/off.

Regards,
Alex

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

More
05 May 2009 09:11 - 05 May 2009 09:13 #211 by melhima
Replied by melhima on topic Re:M1xx code
Hi Alex

Thanks for your answer, but i would like to control my input and output pin
In hal config if I enter : getp motenc.0.in-04 I can see True or False
So why in my function i can't do the same thinks with that :

control=$[halcmd getp motenc.0.in-04] or maybe control=halcmd getp motenc.0.in-04
while [ $control = False ]; do
...
.....
done

Thanks again
Last edit: 05 May 2009 09:13 by melhima.

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

Time to create page: 0.056 seconds
Powered by Kunena Forum