Setting a signal to a constant value

More
26 Jun 2019 09:22 #137874 by JetForMe
I don't have a pressure sensor yet in my system, but I wanted to fake it by setting a signal `pressure-ok` to TRUE. I can do that with newsig and setp, but as soon as I connect that signal to a lut5 input pin, it gets set to false again.

This works:

newsig pressure-ok bit
sets pressure-ok TRUE

If I then add this line to my HAL file:

net pressure-ok => lut5.0.in-2

Then the value of the signal is FALSE (as shown by HAL Configuration in Axis).

Is there a way to get a constant TRUE output pin of bit type?

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

More
26 Jun 2019 11:06 #137883 by pl7i92
this is redundant
so just setp
setp lut5.0.in-2 1

you can set pins from wherever you want in Mcode
ocodes
python .....

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

More
26 Jun 2019 17:14 #137912 by andypugh
Try doing the "sets" after the "net"

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

More
26 Jun 2019 17:29 #137915 by pl7i92
that worked on my testsetup
is there a documentation on the behavior of lut5 backporting to signals

or a general Rule on setting pins and signals fix at the end of the HAL or on the last Hal loaded
so a preset.hal woudt be good to set things at the end

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

More
26 Jun 2019 21:37 - 26 Jun 2019 22:03 #137930 by JetForMe

this is redundant
so just setp
setp lut5.0.in-2 1

you can set pins from wherever you want in Mcode
ocodes
python .....


The problem is not setting an input pin of the lut5 to a constant value. The problem is I want to set a net to a constant value so that later I can set it to an input pin, and have it used throughout my HAL.

I should be able to write
net pressure-ok <= TRUE

...

net pressure-ok => lut5.0.in-2

...

net pressure-ok => lut5.1.in-4

...

net pressure-ok => lut5.2.in-3
Last edit: 26 Jun 2019 22:03 by JetForMe.

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

More
27 Jun 2019 00:37 #137942 by rodw
I think it needs to be more like this.
setp lut5.0.in-2 TRUE

comment some lines out maybe?

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

More
27 Jun 2019 00:38 #137943 by rodw
Actually try using sets (set signal). Not sure if it will work

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

More
27 Jun 2019 00:53 #137945 by lorenzn
andypugh is correct of course. The "sets" must come after "net" if this is a newly created signal. For my own understanding I did some testing:
$ halrun -I testdelayname.hal 
Note: Using POSIX realtime
halcmd: gets mynet
<stdin>:1: signal 'mynet' not found
halcmd: newsig mynet bit
halcmd: sets mynet 1
halcmd: gets mynet
TRUE
halcmd: net mynet mydelay.in
halcmd: gets mynet
FALSE

In the next test, the signal is not reset to FALSE.
$ halrun -I testdelayname.hal 
Note: Using POSIX realtime
halcmd: net mynet mydelay.in
halcmd: sets mynet 1
halcmd: gets mynet
TRUE
halcmd: net mynet anotherdelay.in
halcmd: gets mynet
TRUE

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

More
27 Jun 2019 01:04 #137946 by JetForMe
Do I have to do `sets` after all the possible `net` expressions I might have (if this is an input to several different components)? If not, then I'd argue the first `net` is doing something that `newsig` should do.

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

More
27 Jun 2019 01:08 #137947 by lorenzn
I'm still a new user, but no it does not appear that you have to do the "sets" after all the possible "net" expressions. The unconnected signal appears to be reset but if the signal already exists it was not reset by the second "net" expression.
The following user(s) said Thank You: JetForMe

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

Time to create page: 0.090 seconds
Powered by Kunena Forum