Help needed with self build modules

The forum for all issues related to the new OC4BAv5 and the new OCP4NGXu driver for PMDG B737NGXu.
mvr1918
Site Admin
Posts: 1628
Joined: Thu Aug 30, 2012 3:35 pm

Re: Help needed with self build modules

Post by mvr1918 »

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
veefe
Posts: 11
Joined: Thu Dec 30, 2021 1:43 pm

Re: Help needed with self build modules

Post by veefe »

mvr1918 wrote: 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
So, what I really need to do is re-wire my rotary to the inputs be in a successive order. Right?
The guy who did the wire job must did a wrong wiring
mvr1918
Site Admin
Posts: 1628
Joined: Thu Aug 30, 2012 3:35 pm

Re: Help needed with self build modules

Post by mvr1918 »

It could also be an issue with the wiring of the digits, you have to check. If you understand the script it is easy to do any modification to fit your hardware wirings.
veefe
Posts: 11
Joined: Thu Dec 30, 2021 1:43 pm

Re: Help needed with self build modules

Post by veefe »

mvr1918 wrote: Thu Mar 03, 2022 7:59 pm It could also be an issue with the wiring of the digits, you have to check. If you understand the script it is easy to do any modification to fit your hardware wirings.
I understand just the basics.
for example, I do not know how to solve this problem modifying the script without re-wire the encoder to be successive inputs.
And I cant understand the example given with the encoder changing the HDG values because cant figure out how to write a code that sends 500ft to the var PRESS_F_ALT_K
I dont know why PRESS_F_ALT_K is equal to 16384 instead of 500 or whats means and whats do the var L0.

The maximum I was able to did is increase the flt_alt by turning 1 time right and 1 time left. With this when I starting turning the rotary to the the right this make flt_alt increase. if I move the rotary as mentioned before (one to right one to left, one to right one to left) but starting turning from the left, the value from flt_alt decrease. But this is a litle bit annoying to do every time till I reach 37000ft.

If the only way to make this work with the script, without need to code new lines, is changing the rotary wiring to give successive inputs, Is more likeable to me accomplish the re-wire instead learn how to code a new var to suits to my wiring.

In my mind, is possible to modify the existing var to only add a value to PRESS_F_ALT_K=16384 only when input 27 is = 1? In this way I can ignore the sequential rotary encoder order

something like that:
if input 27 = 1
PRESS_F_ALT_K=16384
if input 29 = 1
PRESS_F_ALT_K=0

or

Is possible to modify the link from being a encoder to be a switch (only in the script, not physically) in other words, is possible emulate a switch from a encoder in the script?
mvr1918
Site Admin
Posts: 1628
Joined: Thu Aug 30, 2012 3:35 pm

Re: Help needed with self build modules

Post by mvr1918 »

You can't send 500 or 0 to the var as it would not help anything. You should not modify anything in the code but the input/output numbers. How many times must I tell you that you should change the input/output numbers so they match your hardware?

This is my last response as you seem not to do as told. Sorry! I really have no time for this any more as I will only repeat myself.
veefe
Posts: 11
Joined: Thu Dec 30, 2021 1:43 pm

Re: Help needed with self build modules

Post by veefe »

mvr1918 wrote: Fri Mar 04, 2022 8:16 am You can't send 500 or 0 to the var as it would not help anything. You should not modify anything in the code but the input/output numbers. How many times must I tell you that you should change the input/output numbers so they match your hardware?

This is my last response as you seem not to do as told. Sorry! I really have no time for this any more as I will only repeat myself.
First of all you dont need to be rude in any way. Yes you keep telling the same thing and so do I. I already said that I already change the script to fit my inputs but it did not work.

I tried to reproduce the problem because i think, or tought, maybe there is a way to change the scrip. If not, you already told me that the rotary encoder must have successive inputs, so I will do the encoder re-wire, because, as told before, the inputs are not successive right now.

Once again, I just tought that could have a modification in the script to cactch diferente inputs when a dumb persson like me did the wrong wiring job.

Sorry for make you lost your time
Post Reply