This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Invert incoming?
#1
Hi.

Have done a simple script with the Fbeditor but I can´t get it to work so I am doing something wrong. 
I have a LUX value and have used the Hysteresis tp create limits when to tuirn on my outdoor lighting. 
The problem is that the output value is a 0 when it has gone below a certain LUX value but I need it to be a 1 and vice versa. 
Have used an Xor to invert the value but I get the same output from the Xor regardless of my setting. 
I also get the same output from my Xor from Output and from Output Not, always.

Any Ideas?

Code:
FB Resident (sleep 5)
require('custom.fbeditor20.Control')

Input = grp.getvalue('2/1/1')
Limit_1_ON = 110
Limit_1_OFF = 130
Limit_2_ON = nil
Limit_2_OFF = nil
Limit_3_ON = nil
Limit_3_OFF = nil
threshold1, threshold2, threshold3 = fbe_hysteresis_3_limits(Input, Limit_1_ON, Limit_1_OFF, Limit_2_ON, Limit_2_OFF, Limit_3_ON, Limit_3_OFF, 'fb__Ljus_ute__fbe_hysteresis_3_limits__id')
if threshold1 ~= nil then
    grp.write('32/1/5', threshold1)
end
FB Resident (sleep 3)
require('custom.fbeditor20.Gate')

functions_Gate_json_fbe_XOR_input_1 = grp.getvalue('32/1/5')
functions_Gate_json_fbe_XOR_input_2 = 0
functions_Gate_json_fbe_XOR_input_3 = nil
functions_Gate_json_fbe_XOR_input_4 = nil
functions_Gate_json_fbe_XOR_input_5 = nil
functions_Gate_json_fbe_XOR_input_6 = nil
functions_Gate_json_fbe_XOR_input_7 = nil
functions_Gate_json_fbe_XOR_input_8 = nil
out, out_not = fbe_XOR(functions_Gate_json_fbe_XOR_input_1, functions_Gate_json_fbe_XOR_input_2, functions_Gate_json_fbe_XOR_input_3, functions_Gate_json_fbe_XOR_input_4, functions_Gate_json_fbe_XOR_input_5, functions_Gate_json_fbe_XOR_input_6, functions_Gate_json_fbe_XOR_input_7, functions_Gate_json_fbe_XOR_input_8, 'fb__Ljus_ute__fbe_XOR__id')
if out ~= nil then
    grp.write('32/1/3', out)
end
if out_not ~= nil then
    grp.write('32/1/4', out_not)
end
Reply
#2
Second input for XOR must be 1, not 0.
Reply
#3
(26.12.2018, 13:01)admin Wrote: Second input for XOR must be 1, not 0.
Yes that was what i thought. 

Unfortunately that doesn´t change the output. The output remains the same regardless. 
The output from Xor is 0 regardles of input value and/or value of second input.
Reply
#4
Use filter and you have not output. Or just add not to grp.write('1/1/1), not threshold1)
------------------------------
Ctrl+F5
Reply
#5
(27.12.2018, 09:06)Daniel. Wrote: Use filter and you have not output. Or just add not to grp.write('1/1/1), not threshold1)

Thank you very much for your reply. 
Unfortunately I don´t undestand what your saying. Where in the code should this be?

Tried filters from the Fb editor but there are no filters that can invert an incoming signal. The filters are only active part of the time ie if a 1 comes in or a 0 but not both. Probably I have misunderstod something. 

As I am not accumstomed with the code I am working in the Fbeditor.

Thx
Reply
#6
(27.12.2018, 17:59)kenjirosama Wrote:
(27.12.2018, 09:06)Daniel. Wrote: Use filter and you have not output. Or just add not to grp.write('1/1/1), not threshold1)

Thank you very much for your reply. 
Unfortunately I don´t undestand what your saying. Where in the code should this be?

Tried filters from the Fb editor but there are no filters that can invert an incoming signal. The filters are only active part of the time ie if a 1 comes in or a 0 but not both. Probably I have misunderstod something. 

As I am not accumstomed with the code I am working in the Fbeditor.

Thx
Filter on-on/off-off will invert input if you set output to output_not.

If you want to do it in script then delete your xor and generate then open this script (in scripting tab) and change line 13 to  
Code:
grp.write('32/1/5', not threshold1)
------------------------------
Ctrl+F5
Reply
#7
(28.12.2018, 09:57)Daniel. Wrote:
(27.12.2018, 17:59)kenjirosama Wrote:
(27.12.2018, 09:06)Daniel. Wrote: Use filter and you have not output. Or just add not to grp.write('1/1/1), not threshold1)

Thank you very much for your reply. 
Unfortunately I don´t undestand what your saying. Where in the code should this be?

Tried filters from the Fb editor but there are no filters that can invert an incoming signal. The filters are only active part of the time ie if a 1 comes in or a 0 but not both. Probably I have misunderstod something. 

As I am not accumstomed with the code I am working in the Fbeditor.

Thx
Filter on-on/off-off will invert input if you set output to output_not.

If you want to do it in script then delete your xor and generate then open this script (in scripting tab) and change line 13 to  
Code:
grp.write('32/1/5', not threshold1)
Thank you!!!
Reply


Forum Jump: