Re: Help needed with self build modules
Posted: Thu Mar 03, 2022 12:05 pm
A rotary knob uses 2 successive inputs.
Using the default script means that the rotary needs to be connected to inputs 126 and 127.
Turning the knob to the right will set 126=1 127=0, then 126=1 127=1, then 126=0 127=1, then 126=0 127=0 and so on.
In your case use your script should be modified to the lowest input number and those inputs must be in successive order, i.e. 27-28
Maybe this will help:
The rotary encoder has three terminals, one common ground and one for each direction. We
can connect a Gray Type rotary encoder directly to the Master Card in the same way as a
three terminal On/off Switch (see above), with the restriction that you have to use two
(logically) consecutive inputs of the Master Card.
In SIOC one codes a gray type rotary encoder like this (note the Type 2 attribute):
Var 1 Link IOCARD_ENCODER Input 40 Aceleration 2 Type 2
Input 40 is the first logical input, the second input is assumed to be input 41. With aceleration
you can specify if you want to increase with higher delta's if you turn faster.
Here an example from a Heading Rotary:
Var 1 Link IOCARD_ENCODER Input 40 Aceleration 2 Type 2
{
L0 = v1 // * -1 turning clockwise should be plus
v2 = ROTATE 0 359 L0
}
Var 2 // heading (0 .. 359)
Var 1 contains the encoder value (increment/decrement) caused by turning the rotary encoder.
With the ROTATE function this delta is added/subtracted to Variable 2.
The ROTATE function does so by taking the actual value of Var 2 first, then it adds the
increment and checks the resulting value against the range (defined by the first two attributes
supplied to the ROTATE function) and if necessary wraps around and then assigns the
resulting heading to Var 2. Var 2 contains the value of the heading, ranging from 0 to 359. By
default var 2 starts with 0, if necessary give it another initial value with the Value attribute.
Make sure the encoder is generating positive values when turning clockwise. Note that the
encoder value is dependent on the way you have connected the two pins of the encoder to the
two inputs of the Master Card. If turning clockwise does not increment the value (but
decrement) you can correct that that by interchanging the two wires. You can also do that
quite easily in SIOC (without hardware changes) by multiplying the value coming from the
encoder by -1, so the example above would then read:
Var 1 Link IOCARD_ENCODER Input 40 Aceleration 2 Type 2
{
L0 = v1 * -1 // turning clockwise should be plus
v2 = ROTATE 0 359 L0
}
Dual Rotary Encode
Using the default script means that the rotary needs to be connected to inputs 126 and 127.
Turning the knob to the right will set 126=1 127=0, then 126=1 127=1, then 126=0 127=1, then 126=0 127=0 and so on.
In your case use your script should be modified to the lowest input number and those inputs must be in successive order, i.e. 27-28
Maybe this will help:
The rotary encoder has three terminals, one common ground and one for each direction. We
can connect a Gray Type rotary encoder directly to the Master Card in the same way as a
three terminal On/off Switch (see above), with the restriction that you have to use two
(logically) consecutive inputs of the Master Card.
In SIOC one codes a gray type rotary encoder like this (note the Type 2 attribute):
Var 1 Link IOCARD_ENCODER Input 40 Aceleration 2 Type 2
Input 40 is the first logical input, the second input is assumed to be input 41. With aceleration
you can specify if you want to increase with higher delta's if you turn faster.
Here an example from a Heading Rotary:
Var 1 Link IOCARD_ENCODER Input 40 Aceleration 2 Type 2
{
L0 = v1 // * -1 turning clockwise should be plus
v2 = ROTATE 0 359 L0
}
Var 2 // heading (0 .. 359)
Var 1 contains the encoder value (increment/decrement) caused by turning the rotary encoder.
With the ROTATE function this delta is added/subtracted to Variable 2.
The ROTATE function does so by taking the actual value of Var 2 first, then it adds the
increment and checks the resulting value against the range (defined by the first two attributes
supplied to the ROTATE function) and if necessary wraps around and then assigns the
resulting heading to Var 2. Var 2 contains the value of the heading, ranging from 0 to 359. By
default var 2 starts with 0, if necessary give it another initial value with the Value attribute.
Make sure the encoder is generating positive values when turning clockwise. Note that the
encoder value is dependent on the way you have connected the two pins of the encoder to the
two inputs of the Master Card. If turning clockwise does not increment the value (but
decrement) you can correct that that by interchanging the two wires. You can also do that
quite easily in SIOC (without hardware changes) by multiplying the value coming from the
encoder by -1, so the example above would then read:
Var 1 Link IOCARD_ENCODER Input 40 Aceleration 2 Type 2
{
L0 = v1 * -1 // turning clockwise should be plus
v2 = ROTATE 0 359 L0
}
Dual Rotary Encode