Jump to content

Jocman's Cockpit (will be a long, long work....)


Recommended Posts

Posted
Hi Jocman

 

Well, the value send to DCS:BS should be between 0 and 1, the smallest increment is 0.001 =>

if we divide 1 with 359 and multiply with the incoming sioc value (which is 0 to 359) and round this value to 3 decimals we should be home.

 

Sioc value is 0 => (1/359) * 0 = 0

Sioc value is 179 => (1/359) * 179 = 0.498

Sioc value is 359 => (1/359) * 359 = 1

 

This will give us 1 degree for each click of the encoder. Is that good enough resolution? Probably for a HSI but maybe not for the Abris cursor.

 

function Encoder(pValue, pDevice, pNumber, pMax, pDivide)
  GetDevice(pDevice):performClickableAction(pNumber + 3000,round( ((pMax /pDivide) * pValue),3))
end

and

[123] = {Encoder, [color=Red]25, 1[/color], 1, 359},

Want more resolution?

 

Make the sioc var go from 0 to 719 instead and

[123] = {Encoder, [color=Red]25, 1[/color], 1, 719},

This is all untested (I'm at work:)) but give it a try.

 

Red values need to match the device and button number.

 

/Oakes

 

Hi Oakes.

I gave a try to your code, and it works....

Well......not completely.....

In fact, I tried with the HSI knob.

 

[68] = {Encoder, 30, 1, 1, 359}

 

It works, but only one way.

I thougt to build a var like for the x position switch, but in SIOC the encoder doesn't work with IF...THEN condition.

 

In SIOC the encoder works fine both directions, but in LUA it doesn't work.

 

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

  • Replies 163
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Just to confirm, you have a SIOC var (nbr 68 ) that is a value between 0 and 359 and when you turn the encoder one way this value increases and when you turn it the other way this value decreases?

 

Could you post the SIOC code?

 

/Oakes

Posted

Yes I confirm. here's the SIOC:

 

Var 0067, Link IOCARD_ENCODER, Input 0, Aceleration 2, Type 2

 

// Head riferimento

{

L0 = V0067 // * -1 turning clockwise should be plus

V0068 = ROTATE 0 ,359 ,L0

}

 

Var 0068 // heading (0 .. 359)

 

 

Testing in SIOC, it works fine: rotating in one direction, it increases the value, in the opposite direction decreases, in a range 0-359

 

Looking at the clickabledata.lua (looing for an encoder to test), I'm wrong, or there are not all the cockpit switches / knobs / etc? I was especially interesting in the radio knobs, as I would like to set 2 concentric encoder to use it. But I didn't find them.

 

 

Btw, I wish all of you a Merry Christmas, and especially to you Oakes, as with your patience and willingness are giving to me the possibility to make such a dream come true. Thank you.

 

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

Well guys,

renewing my wishes for Christmas, here comes a picture of my room in Afghanistan: my BPV, my rifle, my laptop obviously with BS, and on the desk the OC cards.

 

 

dsc00406ou.jpg

 

Merry Christmas

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

Merry Christmas to you too...

 

I'm stumped as to why this doesn't work....lets try some debugging..

 

function EncoderDebug(pValue, pDevice, pNumber, pMax, pDivide)
   local calcValue
   calcValue = round((pMax /pDivide) * pValue,3)
   io.write("Encoder debug.\nSIOC Value(pValue) ="..pValue.."\nCalculated value = "..calcValue.."\n")
   io.flush()  
  GetDevice(pDevice):performClickableAction(pNumber + 3000,calcValue)
end

Add the above code to your ExportSupport.lua file + change the

[68] = {Encoder, 30, 1, 1, 359}

to

[68] = {EncoderDebug, 30, 1, 1, 359}

This code will write debug info to the ./Temp/Export.log file in the DCS:BS main directory. You can open this file with notepad etc but I suggest you use a log viewer instead (a log viewer will monitor new entries to the file and display them immediately, notepad etc doesn't do this)

http://www.kiwisyslog.com/kiwi-log-viewer-overview/

 

I suggest setting the encoder value to 180, start BS and then go a couple of steps up and then a couple of steps down and then check the log file. Are we sending the correct values to DSC:BS (i.e.. between 0 and 1)? Do the SIOC encoder value match the simulated value (we have assumed that SIOC Encoder value= 0 means that we should send 0 to BS, perhaps this is not correct?

 

What happens when you go from 359 to 0 (or the other way around?)

 

/Oakes

Posted

Is it possible this is not working because you're using io.write and io.flush? As I pointed out in this thread that method of io in lua has not worked in prior betas (not sure about beta 4 since I have not tried it yet)

 

edit: oh sorry I just realized it's only your debug function that has io.write in it. You might need to change those lines in order to debug

Posted

Hi oakes.

Currently i'm travelling home for some holidays.as soon i'll be at home i'll try your suggestion,hopefully in a couple of days.

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted
Is it possible this is not working because you're using io.write and io.flush? As I pointed out in this thread that method of io in lua has not worked in prior betas (not sure about beta 4 since I have not tried it yet)

 

edit: oh sorry I just realized it's only your debug function that has io.write in it. You might need to change those lines in order to debug

 

Hi y2kiah

 

I think we are building for DCS:BS not AC10 => io.write etc should work?...or..?

 

/Oakes

Posted
Merry Christmas to you too...

 

I'm stumped as to why this doesn't work....lets try some debugging..

 

function EncoderDebug(pValue, pDevice, pNumber, pMax, pDivide)
   local calcValue
   calcValue = round((pMax /pDivide) * pValue,3)
   io.write("Encoder debug.\nSIOC Value(pValue) ="..pValue.."\nCalculated value = "..calcValue.."\n")
   io.flush()  
  GetDevice(pDevice):performClickableAction(pNumber + 3000,calcValue)
end

Add the above code to your ExportSupport.lua file + change the

[68] = {Encoder, 30, 1, 1, 359}

to

[68] = {EncoderDebug, 30, 1, 1, 359}

This code will write debug info to the ./Temp/Export.log file in the DCS:BS main directory. You can open this file with notepad etc but I suggest you use a log viewer instead (a log viewer will monitor new entries to the file and display them immediately, notepad etc doesn't do this)

http://www.kiwisyslog.com/kiwi-log-viewer-overview/

 

I suggest setting the encoder value to 180, start BS and then go a couple of steps up and then a couple of steps down and then check the log file. Are we sending the correct values to DSC:BS (i.e.. between 0 and 1)? Do the SIOC encoder value match the simulated value (we have assumed that SIOC Encoder value= 0 means that we should send 0 to BS, perhaps this is not correct?

 

What happens when you go from 359 to 0 (or the other way around?)

 

/Oakes

 

Hi all, and Happy New Year.

Well, Oakes, I tried what you suggested, and this i the log I got:

 

---Log: Start-----

Encoder debug.

SIOC Value(pValue) =0

Calculated value = 0

Encoder debug.

SIOC Value(pValue) =1

Calculated value = 0.003

Encoder debug.

SIOC Value(pValue) =2

Calculated value = 0.006

Encoder debug.

SIOC Value(pValue) =3

Calculated value = 0.008

Encoder debug.

SIOC Value(pValue) =2

Calculated value = 0.006

Encoder debug.

SIOC Value(pValue) =1

Calculated value = 0.003

Encoder debug.

SIOC Value(pValue) =0

Calculated value = 0

Encoder debug.

SIOC Value(pValue) =359

Calculated value = 1

Encoder debug.

SIOC Value(pValue) =358

Calculated value = 0.997

Encoder debug.

SIOC Value(pValue) =357

Calculated value = 0.994

Encoder debug.

SIOC Value(pValue) =358

Calculated value = 0.997

Encoder debug.

SIOC Value(pValue) =359

Calculated value = 1

Encoder debug.

SIOC Value(pValue) =0

Calculated value = 0

 

It seems everything works fine (honestly I didn't make any change to my code, just the modify for the log you suggested me).

Values run between 0 and 1, in both ways (CW and CCW), so if I'm not wrong BS gets the correct value.

I realized anyway that the simulated knob doesn't follow the encoder rotation; now, I don't care very much about this "graphical" issue, as the goal of a "real" cockpit is to not look the "simulated" one. This means that if the simulated knob has is own animations not matching my encoder movement, but the BS software reads the encoder values in the right way, I don't care very much, as I'll never see the simulated knob.

What do you think about?

 

Anyway, maybe I'll make some test with the ABRIS encoder, so to check, i.e., if proramming the ABRIS the values sent to BS will really match the real movement (well, I hope to see some "numbers" in the ABRIS changing according my rotation).

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

UPDATE:

 

Well, I tried with the ABRIS right knob.

Once again, even if I rotate my encoder both the ways, in BS it rotates only CW. And the values are read by BS only in this way.

I checked once again the log file, but no changes, SIOC works fine.

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

Hi mate

 

Ok, I've had a look at this now.

 

Turns out, you need to send + or - to the device to move the rotary, +0.018 to go 1 degree positive and -0.018 to go 1 degree negative.

 

This code should do the trick:

 

function Encoder(pValue, pDevice, pNumber, pTick)
   if pValue ~= 0 then
     calcValue = round(pTick * pValue,3)
     GetDevice(pDevice):performClickableAction(pNumber + 3000,round(pTick * pValue,3))
   end  
end

and

 

[20] = {Encoder, 30, 1, 0.018},

or

[20] = {Encoder, 30, 1, -0.018},

depending on which way you want the encoder to turn.

 

You also need to replace (this function did not support negative sioc values previously, changes are marked in red) the SIOC_Parse function in ExportSuppoart.lua to

 

-- Used togheter with a for loop to extract Sioc parameters and their value from a string
function SIOC_Parse(pSIOC_String)
   local i = -1
   return function ()
       i= string.find(pSIOC_String, ":",i+1)
       if i ~= nil then
           return tonumber(string.match(pSIOC_String, ":(%d+)=[color=Red][+-]?[/color]%d+",i)) , tonumber(string.match(pSIOC_String, ":%d+=([color=Red][+-]?[/color]%d+)",i)) 
       end
   end
end

In you SIOC file, remove the Rotate etc and just use the line:

Var 0020, Link IOCARD_ENCODER, Input 34, Aceleration 1, Type 2

How it works:

Sioc will set var nbr 20 to +1 or -1 depending on which way we turn the encoder (and then reset var 20 back to 0). This varaible gets sent to our encoder function where we multiply it with 0.018 and send it of to DCS:BS => DCS:BS gets +0.018 or -0.018 depending on which way we turn the encoder.

 

You can change the 0.018 value up or down to get a perfect match (1 encoder detent = degree), it is a little bit off now.

 

There are some odd behavior when you change direction etc but we have the same behavior when we use the mouse wheel.

 

/brds

Oakes

  • Like 1
Posted

Hi Oakes.

I'll try to test your code tomorrow (from 4th to 7th I'll be out with my soulmate), as today I spent several hours programming OC Cards (I'm getting crazy: it's a huge challenge to find all the right commands in clickabledata.lua).

 

Anyway, just having a quick look to your code, I'm wrong or it means I must choose in which direction turn the encoder? meanings that using this choice:

 

[20] = {Encoder, 30, 1, 0.018},

or

Code:

[20] = {Encoder, 30, 1, -0.018},

I can only rotate in one direction? I.e., I will only increase or decrease the values with the encoder (depending on + or -), but not both? It should mean that I'll need to complete the full values cycle in case I need to go back with the values..... Or I'm wrong?

 

This is only my first impression, as I didn't test it again, but I find strange to put 2 vars with the same value (in this case [20]) but with 2 different strings.....

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

Hi Jocman

 

No, you need to choose one of the

[20] = {Encoder, 30, 1, 0.018}/

[20] = {Encoder, 30, 1, -0.018} lines to put into your siocConfig file.

 

The "-" sign will just reverse the rotation if needed.

 

When I connected my rotary and turned it clockwise the virtual rotary turned anti-clockwise so I need to reverse this => I added a "-" sign in front of the 0.018.

 

/Oakes

Posted

Hi Oakes.

Well, what to say???

It works great!!!!!

Just a question: why it needs to change the value (+-)? it wouldn't be enough just to swap fisically the 2 pins of the encoder on the OC card?

 

Anyway, I keep going on with the work. I just tought to set the encoder on separate master cards just to drive them, so by now I'll just keep programming the switches, leaving all the encoders at the end of all.

I'm having some problem only with the rotary switches with more than 9 positions: as OC cards can drive devices only grouped by 9 pins (and all my rotaries are 12 pos with 1 ground), i should use two different group of pins (9 + x); I suppose I must use rotary switches with 2 ground pins, right? I don't think it could be a good idea to weld the same ground pin to 2 different input groups, right?

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

Hi Jocman

 

Yes, changing the pins will work as well.

 

I don't know about the 9+ encoders, but at first glance it seems like one shouldn't connect two GND pins togheter.....

 

/Oakes

Posted

I've the same opinion, so I'll check out for some other rotaries with 2 separate grounds (I've seen them online).

But I think I'll do it in a couple of months: my holidays are going to finish, so in a couple of days I'll back to Afghan paradise, hopefully to back home definitivey at the end of february.

Well, at least I've something to do during the "exciting" afghan evenings...

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

  • 2 weeks later...
Posted

Hi all.

I almost finished with programming the inputs.

I miss just some switches and all the encoders, but there are some problems, so if someone can help me (I strongly hope in Oakes' support) it will be great.

 

VHF 1 AND 2 SWITCHES (SYSTEM PANEL):

They are linked to the following strings:

elements["COMM-PWR-UKV-1-PTR"]= {class = {class_type.TUMB,class_type.TUMB}, hint = LOCALIZE("VHF-1 (R828) power switch"), device = devices.R_828, action = {device_commands.Button_5,device_commands.Button_5}, arg = {285,285}, arg_value = {-direction*1.0,direction*1.0}, arg_lim = {{0, 1},{0, 1}}, use_OBB = true, updatable = true}

and

elements["COMM-PWR-UKV-2-PTR"]= {class = {class_type.TUMB,class_type.TUMB}, hint = LOCALIZE("VHF-2 (R-800) power switch"), device = devices.R_800, action =

{device_commands.Button_11,device_commands.Button_11}, arg = {286,286}, arg_value = {-direction*1.0,direction*1.0}, arg_lim = {{0, 1},{0, 1}}, use_OBB = true, updatable = true}

 

Actually they don't work at all: clicking the cockpit of course they works, but using OC no way to make them work.

 

ENCODER:

first I programmed the ABRIS Cursor, and it works fine; then I tried to program the ABRIS Brightness, but no sign of life; same story for HUD Brightness or NAV Brightness. I didn't change anything in the program lines, but the Device and Switch ID. So I suppose I can have similar problems with the other encoders; as the LEV lines' instructions are different concerning arg, arg_value, arg_limit, gain and other vars, my problem could be linked to this issue? If so, there's some way to fix it?

 

RADIO FREQUENCY KNOBS:

In clickabledata.lua, if I'm not wrong the commands are considered as switches (TUMB class), and there's also a LEV class (but deactivated). As I planned to use 2 concentric encoders to set the radio frequency, I think I've to activate the LEV class lines and deactivate the TUMB class lines, is it?

 

MISSING LINES IN CLICKABLEDATA.LUA

I realized there's at least a missing lines concerning the STBY SAI-ON switch (System panel, next to anti collision beacon's switch). So no way to program it. Suggestions?

 

EJECTION SEAT SYSTEM:

Can you have a look to my previous post (http://forums.eagle.ru/showpost.php?p=1050191&postcount=116), where I reported the lua code I used to drive the 3 Ejection switches? the problem still exists.....

 

POTENTIOMETER SUPPORT

Someone (I'm sorry, I forgot the name) submitted a code to set potentiomenters in lua, to use instead of encoders (HUD brightness, Volumes, etc). As it is a very good stuff, I woukld like to use it, but the question is: what kind of pots need to be used???

 

 

Thanks a lot to everyone

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

  • 3 weeks later...
Posted

Hi guys.

After a short relax pause in Dubai (the only commnent I can do about it is: WOW.......), I'm back to my cockpit project.

As my questions in the previous post are still waiting for some help, I decided to start with the outputs.

By checking some examples files of some of you guys, I understood that to program an output, I just need to know its ID (from Mainpanel_init.lua).

Then I started with the first test.

 

I decided to try with the Datalink's button LED "1" (ID = 17).

In configSioc.lua I put the line:

 

[1000] = {0, 17}

 

Well, honestly I really don't know if it works, but I've seen that some of you just programmed the outputs this way.... but why put the first value as 0? this value doesn't exist in device.lua, but it exists a devices["DBG_OUTPUT"] = 1, anyway I tried also by putting 1 instead of 0, but no changes in BS (see later down - I've some hardware problems).

 

In SIOC I put the line:

 

Var 1000, Link IOCARD_OUT, Output 11

 

When I run the sim, it doesn't work: in BS the "1" led is on or off but "outside" nothing.

 

Even because I have an hardware problem:

 

When I run SIOC (before run BS), the led switches automatically on....I don't know why. I'm currently dealing with OC about it, and they also say this is strange, because normally the leds should be off until I give the ON command.

 

Anyway, the procedure I use to program the outputs is right?

 

And.....any help concerning my previous post?? :cry::cry:

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

Update:

The problems with the OC outs have been fixed. After several tests, I realized that the flat cable I've been using was faulty. With a new one, everything works fine, so I programmed all the outputs I need, and they work fine.

 

In the next days I'll work on the rest of the inputs (encoders and few others) which still give me some problems, hoping to fix these problems too.

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

Guys, I feel like I'm having a monologue :megalol:

 

Anyway, after the outputs, I started with the encoders (ABRIS shunt, Latitude, Magnetic dev, HSI 1&2, ADI, Radar alt - I don't think I'm missing other encoders).

 

All of them work fine (some details to fix for the "resolution", but I'll do it "on field" running the sim).

 

The Baro Alt give me some problem: rotating the virtual encoder everything is fine (of course), but rotating the "real" one, it jump to 60mbar, then switchs only 1 step up and 1 down, no more, no matter how many steps I turn up or down.

Suggestion?

 

Radio Frequency encoder:

Clickabledate set them as TUMB, but there's an inactive LEV set; I switched the TUMB as inactive and the LEV as active, then programmed the encoder, but they don't work at all.

Any suggestion? It can be done?

 

For the rest of the knobs, I think I'll make it as pots, but here I don't have so I've to wait to back home to get them and do it

 

Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted

You may feel like that because you're so far ahead of where most of us are with the programming! I don't know anyone this far along other than y2kiah and Oakes (I'm sure there are others)! But rest assured, we're following with interest! I'm sure I'll be combing this thread for weeks once I actually start wiring things up!

Posted (edited)
You may feel like that because you're so far ahead of where most of us are with the programming! I don't know anyone this far along other than y2kiah and Oakes (I'm sure there are others)! But rest assured, we're following with interest! I'm sure I'll be combing this thread for weeks once I actually start wiring things up!

 

Hi Feed.

Well, it was only a joke I told (the monologue). :thumbup: I realize everytime that many people read my posts (curiosity or interest, it doesn't matter) and I'm happy for that.

About programming, I'm sorry to let you down, but my programming skill is very close to 0, as all the work I did til now has been done due to the outstanding support of Oakes and y2kiah so as other guys(and I'll report it at the end of this journey, even if I don't remember all the names). This is the reason why I always hope to some help more. Of course, I know that sometime I just need to try and experiment, but as the programming language aren't my food, any help and suggestion is always welcome.

 

Anyway, as soon I'll complete my cockpit, for sure I'll share all my "experiences" and results with the community.

 

Jocman

 

PS: BTW, some trouble listed 5 posts ago (#143) still exist.... :music_whistling:

Edited by Jocman

Jocman

"For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return" (L. Da Vinci)

Prev. Projects:

https://forums.eagle.ru/showthread.php?t=50071

Posted
The Baro Alt give me some problem: rotating the virtual encoder everything is fine (of course), but rotating the "real" one, it jump to 60mbar, then switchs only 1 step up and 1 down, no more, no matter how many steps I turn up or down.

Suggestion?

 

Yes :smilewink: This one works real well with a pot.

 

Cheers,

Colin

Posted

All this is so far ahead of my dreams lol...

HaF 922, Asus rampage extreme 3 gene, I7 950 with Noctua D14, MSI gtx 460 hawk, G skill 1600 8gb, 1.5 giga samsung HD.

Track IR 5, Hall sensed Cougar, Hall sensed TM RCS TM Warthog(2283), TM MFD, Saitek pro combat rudder, Cougar MFD.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...