Python HAL script, Pins not working

More
26 Jun 2023 05:56 - 26 Jun 2023 05:59 #274223 by Faggan
Hi,
Im working on a automatic tool changer and have decided to adapt code from the hal_manualtoolchange component that already exists. Mostly because this solves the "what if the tool asked for is not in the magazine" question already. 

Anyway. I have added more hal pins to the component and they show up fine in hal show (see attached image). however when i write a command to one of the outputs from the python script i get an error saying that "pin or parameter xxxx not found" (see attached image)

The original hal pins from the base script work fine however. Do i need to add the pins somewhere else as well to get things rolling?
Reading the "Creating userspace python components" manual doesnt mention any thing more than what is already done in the script. 

I have attached my script as well. 
 

File Attachment:

File Name: Toolchanger_v2.py
File Size:12 KB
Attachments:
Last edit: 26 Jun 2023 05:59 by Faggan.

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

More
01 Jul 2023 09:23 #274564 by andypugh
This might just be that you are trying to net the pins before the component is loaded.
You could try loadusr -W to wait for the component to finish loading, or just move all the net commands for it to the postgui HAL file.

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

More
01 Jul 2023 09:29 #274566 by Faggan
The signals that work are in the base hal file.
Come to think of it the once that doesn't work are in a postgui hal.

I will try and play around with when they are loaded to see if it makes any difference.

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

More
01 Jul 2023 09:36 #274569 by andypugh
You can put a "show pin" in the HAL file to get a list of pins that exist at that point in the loading process.

Or "show pin *tool*" or similar for a shorter list.
The following user(s) said Thank You: rodw

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

More
02 Jul 2023 13:23 #274637 by Faggan
I have played around with connecting the pins in different stages of boot with no luck.

I also realized i may have been a bit unclear as to the nature of the error.
The error i have attached a image of in the first post is generated when i run a setp command i hal show. Its not really related to when the pins are being connected to each other or not. To be able to run the setp i had to comment out the connection in hal file. Otherwise it wouldn't let me run the setp command at all. Maybe this narrows down the problem a bit more.

The same error occurs when the python script tries to alter the state of that same pin. (with it connected in hal file)

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

More
02 Jul 2023 22:14 #274667 by andypugh
You can't "setp" a pin that is connected to a signal.

You can "sets" the signal, unless it contains a writer (ie, HAL "out" pin)

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

More
03 Jul 2023 07:49 #274678 by Faggan
Ok, then that's why I cant write to it with setp then? But that shouldn't stop the python component from writing to that pin?

Is that connected to the error I'm seeing or is there something else?

I'm not sure. But it feels like the signals that are being created in the python script needs to be declared somewhere else as well. Since the signals from the original hal_manualtoolchange script works. I cant find anything supporting this in the "Creating Userspace Python Components" manual how ever.

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

More
03 Jul 2023 08:47 #274683 by andypugh
Are you using "hal getp" and "hal_setp" in the Python script? That seems strange, as you would normally access the pin values for pins "belonging" to the component as variables.

eg
if h.current_tool_return == 0:

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

More
03 Jul 2023 09:20 - 03 Jul 2023 09:21 #274687 by Faggan
I am not using getp or setp in the script.

Most of the hal variables created in the script are outputs to transfer parameters from the script to a ngc subroutine.

the h.current_tool_return is an output to tell the ngc if the tool in the spindle should be returned to the magazine automatically or manually removed by the user and stored outside the machine.

eg:
if current_tool_return == 1
h.current_tool_return = True

current_tool_return is an internal variable in the python script that is set depending on various things.. Its not really relevant to this.
Last edit: 03 Jul 2023 09:21 by Faggan.

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

Time to create page: 0.254 seconds
Powered by Kunena Forum