My oneshot won't shoot...

More
11 Sep 2018 21:25 #117363 by pferrick
Hi all-

Now that I've successfully flashed a 7i76-connected LED from a button within gmoccapy, I figured it shouldn't be too hard to flash it for, say two seconds with oneshot. But for some reason, it isn't working. Here's what I'm doing:

In custom.hal I have:

loadrt oneshot count=1
addf oneshot.0 servo-thread
setp oneshot.0.width 2

and in custom_postgui.hal I have:

net led oneshot.0.in <= test.hal_button1
net led hm2_5i25.0.7i76.0.0.output-07 <= oneshot.0.out

This causes Linuxcnc to crash....maybe connecting the oneshot input to its output is a problem!?

I have also tried using different signal names (led1 and led2) for these, which doesn't crash but also does not work. I'm sure that I'm overlooking something pretty obvious, but after a half hour of banging on it I'm ready for a clue...!

Thanks.

Patrick

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

More
11 Sep 2018 23:46 #117373 by andypugh
Replied by andypugh on topic My oneshot won't shoot...
LinuxCNC won't be crashing. It will be exiting elegantly while telling you exactly what the problem is.

You need to read the error report.

The problem is that you are connecting the led signal to both the input and output of the oneshot.

Try:
net led-raw oneshot.0.in <= test.hal_button1
net led-oneshotted hm2_5i25.0.7i76.0.0.output-07 <= oneshot.0.out

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

More
12 Sep 2018 00:58 #117375 by pferrick
Replied by pferrick on topic My oneshot won't shoot...
Thanks for the reply.

I stand corrected on the manner in which LinuxCNC...fails to proceed, shall we say? I have read the error report, and was unable to find anything specific to the lines of HAL code in question. Not to say that it isn't in there, of course. I will take another close look and post anything suspicious.

However, as I said I did try using two different signal names as you suggested...still no go. Connecting <in> to <out> doesn't make a whole lot of sense.

So...having the button connected to the oneshot input, and the halpin connected to the oneshot output...what else could be preventing things from working?

thanks again,
Patrick

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

More
12 Sep 2018 02:44 - 12 Sep 2018 02:47 #117377 by PCW
Replied by PCW on topic My oneshot won't shoot...

However, as I said I did try using two different signal names as you suggested...still no go. Connecting <in> to <out> doesn't make a whole lot of sense.


Two different signal names are required because they convey different information, one is the connection
between the pushbutton signal (out) to oneshot input (in), the other is the connection between the oneshot
output (out) and physical output pin (in).

In fact you can only connect out --> in pins in hal, there can only be one output (the signals "driver") but many
input pins per signal.

What pin is an input and output may seem a bit confusing at first because physical output pins are inputs on the hal side
of things and physical input pins are hal outputs. You can determine the direction of hal pins by using halcmd;

halcmd show pin
Last edit: 12 Sep 2018 02:47 by PCW.

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

More
16 Sep 2018 01:37 #117588 by blazini36
Replied by blazini36 on topic My oneshot won't shoot...
As PCW said it looks like you're using the same signal "led" to connect your GUI button to the oneshot.in pin and your oneshot.out pin to the hardware.

That signal is your "wire". the input and output pins of your oneshot component are shorted out by using the same wire. You really do need to look at the LinuxCNC output error, just above the debug section.

HAL is a programming language that was once explained to me resembles an electrical schematic. As different programmers like to write code in their own style you may want to do the same so it is visually easier for you to look at. For example, I would write that like this:
net led_in               <= test.hal_button1
net led_in                 => oneshot.0.in
net oneshot_led       <= oneshot.0.out
net oneshot_led       =>  hm2_5i25.0.7i76.0.0.output-07
This is probably what initially confused you as you may have seen an example like this with the same signal name written on 2 lines but this is the same as this:
net led_in oneshot.0.in <= test.hal_button1
net oneshot_led  hm2_5i25.0.7i76.0.0.output-07 <= oneshot.0.out.
This is the same as above and the only difference between this and the original hal exmple is 2 unique signal names.

Honestly I would have made the connections in the custom.hal file and just carried the signal over to the postgui.hal

in custom.hal:
loadrt oneshot count=1
addf oneshot.0 servo-thread
setp oneshot.0.width 2

net led_in                 => oneshot.0.in
net oneshot_led       <= oneshot.0.out
net oneshot_led       =>  hm2_5i25.0.7i76.0.0.output-07

in custom_postgui.hal:
net led_in               <= test.hal_button1
The custom_postgui.hal file is needed because these connections get made after the GUI loads, so you must connect the GUI button in this file. Here, I load the realtime components and make their connections in the costum.hal file and I only connect the oneshot.0.in pin to the signal. I carry that signal to the custom_postgui.hal file where it's connected to the GUI button. I don't know if that will solve your problem but that is my standard practice and it's probably why I adopt the format I use.
The following user(s) said Thank You: Clive S

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

More
16 Sep 2018 08:58 #117597 by Clive S
Replied by Clive S on topic My oneshot won't shoot...
Thank you for a brilliant explanation above. I know and have read many times in the manual re the net, signal and pin relationship.

But the way you explained it gave me another light bulb moment :)

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

Time to create page: 0.160 seconds
Powered by Kunena Forum