Jump to content
The simFlight Network Forums

Newbee building panel for Flight 1 Mustang (Intro)


Recommended Posts

Hello Everyone,

I am an electronic technician who has embarked on, what seems to me at least, the monumental task of building a working Flight One Cessna Mustang Panel/Cockpit, for the least I can get away with (my wife's restriction, not mine :mrgreen: ). I have a little ability with arduino programming and will work on LUA as quickly as time permits.

I decided to start with the Autopilot panel so, after some research, I purchased Mr. Bodnars BU0836X USB joystick controller. This seemed to be the best solution allowing for the use of both switches and rotary controllers without much fuss. I also purchased locally the five rotary controllers (3 w/switches 2w/o) and 14 push button switches to allow duplication of the panel (even though some of the switches will have no function on the Mustang). These have been installed on a circuit board and are wired to the controller for testing.

I had already installed FSUIPC and, after reading the comments on the forum regarding the slow speed of rotary encoders, I also installed the rotaries.lua to help overcome that obstacle. I discovered today that I was loading the wrong lua program (toggle_rotaries.lua instead of just rotaries.lua) so I will make the change tonight and see how that works.

I also noticed that some of the switch assignments do not duplicate the mouse click actions perfectly, so I am also researching via this fabulous forum, fixes for those problems.

I believe that running a lua utility (?) will allow me to log the mouse click actions providing me with the information (which I am still at a loss as how to impliment) that I require to fix these small bugs.

I would like to thank Mr. Dowson for his excellent program and the advice he offers to users of this forum. If not for gentlemen like him, it would be impossible for amateurs such as myself to even get started in an endeavour such as this.

As I run into problems, I hope that I can burden the forum with, (what are bound to be), stupid question on how to proceed. For my part I will do my best to thouroughly research my problems before I ask for help.

I will post some pictures of what I have so far in the near future.

Kraig Krumm

Canton, Ohio

USA

Link to comment
Share on other sites

I believe that running a lua utility (?) will allow me to log the mouse click actions providing me with the information (which I am still at a loss as how to impliment) that I require to fix these small bugs.

There are currently no mouse-specific facilities implemented in the Lua libraries. What were you thinking of here?

There's already some work done of working out the ways to control the mustang. not seem anything on the autopilot, but this item in the User Contributions section might be of use:

http://forum.simflight.com/topic/63155-flight1-mustang-commands-upd-15th-mar-2010/page__hl__mustang__fromsearch__1

so it looks like examining the local gauge variables (L:Vars) used in that aircraft may prove fruitful. There is an FSUIPC control which will list them for you, and a Lua plug-in to monitor them.

Regards

Pete

Link to comment
Share on other sites

Yes, thats the direction (L;Vars) I was heading. Hopefully things will become clearer once I have studied the process. As an example, right now pressing the heading sync button syncs the heading bug, but also turns off the NAV hold. I will look at the link you gave me and see if that helps. Thanks again for your great program!

Kraig

Link to comment
Share on other sites

  • 4 weeks later...

Pete,

The more I delve into this project, the more I am thankful for your FSUIPC program. I have most of the buttons working on my Autopilot Control Panel at this point. Using the mouse macro utility allowed me to duplicate the functions of each switch very easily. The remainder of the switches simply need to be wired to Mr. Bodnars BU0836X board (a remarkable tool also) and I have no doubt I will be fully up and running.

I do have one problem (hence this post) that I have been unable to resolve with the rotary encoders. To wit: I have four out of five of the rotary encoders wired to the bodnar BU0836X board. I changed the

rotaries line in the rotaries.lua program to read "rotaries = {31, 30, 29, 28, 27, 26, 25, 24}". The first two sets work fine and the rotaries output is converted by the program to the appropriate high and slow speed values which, and I am going from memory as I am currently at work, are 64,1 & 64,2 64,3 & 64,4 for the first rotary and 64,5 & 64,6 64,7 & 64,8 for the second rotary encoder. I have these button presses set in fsuipc to give both fast and slow heading bug incr and decr for the first rotary encoder and slow and fast Vert Spd inc and dec for the second rotary encoder and they work fine. However, the last two rotary encoders are not being picked up by the program. I have double checked the encoder wiriing and it is correct. Also FSUIPC sees the rotaries working as they are showing up when I turn the dial, just not converting over to fast and slow button pushes. Long story short, two out of four rotaries working with the rotaries.lua, two not working. Any ideas? Thank you for your time!

Kraig

Edited by kkrumm
Link to comment
Share on other sites

Long story short, two out of four rotaries working with the rotaries.lua, two not working. Any ideas? Thank you for your time!

Sorry, this is so long ago I've forgotten everything. Could you paste in the Lua as you have it now, please. Also maybe an FSUIPC log with button logging enabled and those two rotaries being used.

Pete

Link to comment
Share on other sites

Hi Pete,

Here is the file that is currently loading:

-- Set device details here (use HidScanner to find these if not known)

Vendor = 0X1DD2

Product = 0X1001

Device = 0 -- Multiple devices of the same name need increasing Device numbers.

-- Use separate Lua plug-ins for separate cards!

-- NOTE: this can handle up to 16 rotaries only, using the first 64 "virtual buttons"

-- List the pairs here:

Rotaries = {31,30,29,28,27,26,25,24}

-- Example { 31, 30, 25, 22 } would be 31+30 for one, 25+22 for the next, and so on

-- Which is clockwise and which counterclockwise doesn't matter -- you'll get

-- fast and slow of each in any case

dev, rd, wrf, wr, init = com.openhid(Vendor, Product, Device, Report)

if dev == 0 then

ipc.log("Could not open HID")

ipc.exit()

end

-- Set the boundary time in milliseconds between

-- "fast" (shorter) and "slow" (longer) signalling

FastTimeLimit = 90 -- Adjust to taste

-- Polling time in milliseconds: should be much shorter than

-- the boundary time

Pollrate = 10 -- same as 50 times per second

-- Initialise variables used to keep track of things

LastTimes = {}

Buttons = 0

PrevButtons = 0

Diff = 0

-- This function will be called by a time event, set at the end of the program before exit.

function poll(Time)

-- read any data available from the device (only need most recent report)

data, n = com.readlast(dev, rd)

if n ~= 0 then

-- Data was returned, so get the status of all the possible "buttons" we are using

-- one value of 32 bits

Buttons = com.gethidbuttons(dev, data)

-- See if any changes occurred:

Diff = logic.Xor(Buttons, PrevButtons)

PrevButtons = Buttons

if Diff ~= 0 then

offset = 0x3340

buttonbit = 1

j = 1

while Rotaries[j] ~= nil do

mask = logic.Shl(1, Rotaries[j])

if logic.And(Diff,mask) ~= 0 then

-- This one changed

-- See if changed in less than the "boundary" time

thisbutton = buttonbit

if (LastTimes[j] ~= nil) and ((Time - LastTimes[j]) < FastTimeLimit) then

thisbutton = buttonbit + buttonbit -- Use next higher button for fast

end

LastTimes[j] = Time

-- Toggle a virtual button accordingly

ipc.togglebitsUB(offset, thisbutton)

end

j = j+1

buttonbit = 4 * buttonbit

if logic.And(j,15) == 0 then

buttonbit = 1

offset = offset + 4

end

end

end

end

end

event.timer(Pollrate, "poll")

And here is the log of button pushes:

********* FSUIPC4, Version 4.745 by Pete Dowson *********

User Name="Kraig Krumm"

User Addr="kkrumm@neo.rr.com"

FSUIPC4 Key is provided

WIDEFS7 not user registered, or expired

[Continuation log requested by user]

Running inside FSX on Windows 7

Module base=61000000

Wind smoothing fix is fully installed

298071 System time = 11/01/2012 16:32:01, Simulator time = 16:27:20 (00:27Z)

298071 LogOptions changed, now 40000000 00000001

310302 KEYDOWN: VK=80, Waiting=0, Repeat=N, Shifts=0

310302 .. Key not programmed -- passed on to FS

310583 KEYUP: VK=80, Waiting=0

Here are the two working rotaries rotated in both directions. Buttons 31 30 29 28 on the Bodnar Iinterface

318133 Button changed: bRef=0, Joy=64, Btn=4, Pressed

318133 [buttons.F1_Cessna_Mustang1] 6=P64,4,C65879,0

318133 FS Control Sent: Ctrl=65879, Param=0

318258 Button changed: bRef=0, Joy=64, Btn=4, Released

320286 Button changed: bRef=0, Joy=64, Btn=6, Pressed

320286 [buttons.F1_Cessna_Mustang1] 8=P64,6,C65880,0

320286 FS Control Sent: Ctrl=65880, Param=0

320395 Button changed: bRef=0, Joy=64, Btn=6, Released

320598 Button changed: bRef=0, Joy=64, Btn=6, Pressed

320598 [buttons.F1_Cessna_Mustang1] 8=P64,6,C65880,0

320598 FS Control Sent: Ctrl=65880, Param=0

320707 Button changed: bRef=0, Joy=64, Btn=6, Released

324638 Button changed: bRef=0, Joy=64, Btn=0, Pressed

324638 [buttons.F1_Cessna_Mustang1] 13=P64,0,CM1:9,0

324638 Macro: mouse action="Flight1_GarminG1000_510.GAU":X192d0*X5500

324748 Button changed: bRef=0, Joy=64, Btn=0, Released

327212 Button changed: bRef=0, Joy=64, Btn=2, Pressed

327212 [buttons.F1_Cessna_Mustang1] 10=P64,2,CM1:8,0

327228 Macro: mouse action="Flight1_GarminG1000_510.GAU":X377d0*X55cc

327337 Button changed: bRef=0, Joy=64, Btn=2, Released

327540 Button changed: bRef=0, Joy=64, Btn=2, Pressed

327540 [buttons.F1_Cessna_Mustang1] 10=P64,2,CM1:8,0

327540 Macro: mouse action="Flight1_GarminG1000_510.GAU":X377d0*X55cc

327743 Button changed: bRef=0, Joy=64, Btn=2, Released

Here are the two non-working rotaries being rotated each way Buttons 27 26 25 24 on the Bodnar Interface

330317 Button changed: bRef=0, Joy=2, Btn=27, Pressed

330317 [buttons.F1_Cessna_Mustang1] 17=P2,27,CM1:7,0

330317 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

330410 Button changed: bRef=0, Joy=2, Btn=27, Released

330520 Button changed: bRef=0, Joy=2, Btn=27, Pressed

330520 [buttons.F1_Cessna_Mustang1] 17=P2,27,CM1:7,0

330520 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

330535 Button changed: bRef=0, Joy=2, Btn=27, Released

333468 Button changed: bRef=0, Joy=2, Btn=26, Pressed

333468 [buttons.F1_Cessna_Mustang1] 16=P2,26,CM1:6,0

333468 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19460*X55cc

333577 Button changed: bRef=0, Joy=2, Btn=26, Released

336323 Button changed: bRef=0, Joy=2, Btn=27, Pressed

336323 [buttons.F1_Cessna_Mustang1] 17=P2,27,CM1:7,0

336338 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

336557 Button changed: bRef=0, Joy=2, Btn=27, Released

338632 Button changed: bRef=0, Joy=2, Btn=26, Pressed

338632 [buttons.F1_Cessna_Mustang1] 16=P2,26,CM1:6,0

338647 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19460*X55cc

338741 Button changed: bRef=0, Joy=2, Btn=26, Released

339162 Button changed: bRef=0, Joy=2, Btn=26, Pressed

339162 [buttons.F1_Cessna_Mustang1] 16=P2,26,CM1:6,0

339162 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19460*X55cc

339271 Button changed: bRef=0, Joy=2, Btn=26, Released

342641 Button changed: bRef=0, Joy=2, Btn=25, Pressed

342641 [buttons.F1_Cessna_Mustang1] 20=P2,25,CM1:7,0

342641 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

342750 Button changed: bRef=0, Joy=2, Btn=25, Released

342750 [buttons.F1_Cessna_Mustang1] 21=U2,25,CM1:7,0

342750 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

344263 Button changed: bRef=0, Joy=2, Btn=24, Pressed

344263 [buttons.F1_Cessna_Mustang1] 18=P2,24,CM1:6,0

344263 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19460*X55cc

344373 Button changed: bRef=0, Joy=2, Btn=24, Released

344373 [buttons.F1_Cessna_Mustang1] 19=U2,24,CM1:6,0

344373 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19460*X55cc

345402 Button changed: bRef=0, Joy=2, Btn=25, Pressed

345402 [buttons.F1_Cessna_Mustang1] 20=P2,25,CM1:7,0

345402 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

345402 Button changed: bRef=0, Joy=2, Btn=25, Released

345418 [buttons.F1_Cessna_Mustang1] 21=U2,25,CM1:7,0

345418 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

345511 Button changed: bRef=0, Joy=2, Btn=25, Pressed

345511 [buttons.F1_Cessna_Mustang1] 20=P2,25,CM1:7,0

345511 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

345636 Button changed: bRef=0, Joy=2, Btn=25, Released

345636 [buttons.F1_Cessna_Mustang1] 21=U2,25,CM1:7,0

345636 Macro: mouse action="Flight1_GarminG1000_510.GAU":X19490*X55cc

354715 Sim stopped: average frame rate for last 56 secs = 8.2 fps

354715 Average weather filter write interval in that time = 2322.5 msecs

Thank You for your help!

Kraig

Link to comment
Share on other sites

Hi Pete,

Here is the file that is currently loading:

The error is in this line:

ipc.togglebitsUB(offset, thisbutton)

That should be

ipc.togglebitsUD(offset, thisbutton)

because "UB" is an unsigned byte (8 bits) so is only coping with 2 x 4 buttons, your first two encoders. "UD" is an unsigned double word, which is 32-bits or 4 bytes. This is what is also assumed by the line:

offset = offset + 4

which moves on by 4 bytes -- i.e. the 32 bits which should have been dealt with by then.

Regards

Pete

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.