Jump to content
The simFlight Network Forums
AK Mongo

rotary encoder input speed

Recommended Posts

I have a question. I don't have a Bodnar card but use an interface called a pokeys card. I have copied over the HID name below. What do I put in the Vendor and Product code lines and does it need the quotations? I have 8 encoders hooked up to this card that is seen as a vitual joystick and has 32 button inputs and supports encoders in paired inputs just like the Bodnar card.

Thanks,

Rob

  
  Device at "\\?\hid#vid_1dc3&pid_1001&mi_00#b&323e0194&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
  Vendor=1DC3, Product=1001 (Version 16.0)
  Manufacturer= PoLabs
  Product= Virtual Joystick
  Serial Number= PoKeys 
  Usage Page: 1
  Input Report Byte Length: 17
  Output Report Byte Length: 0
  Feature Report Byte Length: 0
  Number of Link Collection Nodes: 2
  Number of Input Button Caps: 1
  Number of InputValue Caps: 6
  Number of InputData Indices: 38
  Number of Output Button Caps: 0
  Number of Output Value Caps: 0
  Number of Output Data Indices: 0
  Number of Feature Button Caps: 0
  Number of Feature Value Caps: 0
  Number of Feature Data Indices: 0
  Buttons range 1 -> 32 at indices 6 -> 37
  Value U/RX at index 0, range 0 -> 1023, using 16 bits
  Value V/RY at index 1, range 0 -> 1023, using 16 bits
  Value Z at index 2, range 0 -> 1023, using 16 bits
  Value Y at index 3, range 0 -> 1023, using 16 bits
  Value X at index 4, range 0 -> 1023, using 16 bits
  Value Thr at index 5, range 0 -> 1023, using 16 bits
  **************************************************************************

  Device at "\\?\hid#vid_1dc3&pid_1001&mi_01#b&1f0de556&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
  Vendor=1DC3, Product=1001 (Version 16.0)
  Manufacturer= PoLabs
  Product= Communication Interface
  Serial Number= PoKeys 
  Usage Page: FF00
  Input Report Byte Length: 65
  Output Report Byte Length: 65
  Feature Report Byte Length: 0
  Number of Link Collection Nodes: 1
  Number of Input Button Caps: 0
  Number of InputValue Caps: 1
  Number of InputData Indices: 1
  Number of Output Button Caps: 0
  Number of Output Value Caps: 1
  Number of Output Data Indices: 8
  Number of Feature Button Caps: 0
  Number of Feature Value Caps: 0
  Number of Feature Data Indices: 0
  Value 0x01 at index 0, range 0 -> 255, using 8 bits
  **************************************************************************

  Device at "\\?\hid#vid_1dc3&pid_1001&mi_02#b&bddc918&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
  Vendor=1DC3, Product=1001 (Version 16.0)
  Manufacturer= PoLabs
  Product= Virtual keyboard
  Serial Number= PoKeys 
  Device is a keyboard
  Usage Page: 1
  Input Report Byte Length: 35
  Output Report Byte Length: 0
  Feature Report Byte Length: 0
  Number of Link Collection Nodes: 1
  Number of Input Button Caps: 2
  Number of InputValue Caps: 0
  Number of InputData Indices: 110
  Number of Output Button Caps: 0
  Number of Output Value Caps: 0
  Number of Output Data Indices: 0
  Number of Feature Button Caps: 0
  Number of Feature Value Caps: 0
  Number of Feature Data Indices: 0
  **************************************************************************

Share this post


Link to post
Share on other sites

I had to use the first example you gave to get it to work, somewhat. The problem I am having now is that virtual joy buttons 1 and 3 bounce back and forth and never stop. I tried changing fasttime and poll rate to no avail. I checked in the game controller properties and the buttons are not showing this on/off cycle so i'm not sure what is causing it. I also checked the inputs via a 3rd party software and monitored the inputs, no bouncing or erroneous inputs shown. So why is FSUIPC seeing a rapidly changing input? ( I labled the input as Polabs and Virtual, per my question above, is this correct?)

Thoughts?

Thanks,

Rob

Share this post


Link to post
Share on other sites

I have a question. I don't have a Bodnar card but use an interface called a pokeys card. I have copied over the HID name below. What do I put in the Vendor and Product code lines and does it need the quotations? I have 8 encoders hooked up to this card that is seen as a vitual joystick and has 32 button inputs and supports encoders in paired inputs just like the Bodnar card.

Thanks,

Rob

  
  Device at "\\?\hid#vid_1dc3&pid_1001&mi_00#b&323e0194&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"
  Vendor=1DC3, Product=1001 (Version 16.0)
  Manufacturer= PoLabs
  Product= Virtual Joystick

You appear to have three such devices. The Vendor and Product names or numbers are defined at the beginning of the Lua program, strangely enough in variables which reflect this, i.e:

Vendor = ...

Product = ...

If you use the names, then they are strings and need to be in "", as:

Vendor = "PoLabs"

Product = "Virtual Joystick"

Alternatively you can use the hex numbers instead if you wish:

Vendor=0x1DC3

Product=0x1001

Because you have three you will also need to be sure to select the cirrect device using: this line:

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

The three will be numbered 0, 1 and 2 respectively.

On your second message:

I had to use the first example you gave to get it to work, somewhat.

Can't see why. What did you do to the later one?

The problem I am having now is that virtual joy buttons 1 and 3 bounce back and forth and never stop. I tried changing fasttime and poll rate to no avail. I checked in the game controller properties and the buttons are not showing this on/off cycle so i'm not sure what is causing it. I also checked the inputs via a 3rd party software and monitored the inputs, no bouncing or erroneous inputs shown. So why is FSUIPC seeing a rapidly changing input?

I really don't have enough information to be able to advise I'm afraid. Are those the only buttons connected? If not what of the others?

It is near impossible to debug from afar an interface between hardware I do not have and a program I have not seen. If you add some logging lines to the Lua coding you should be able to find out what is happening. You can log information simply by inserting, temporarily, lines like:

ipc.log("This is the value of x: " .. x)

Of course you don't need to be so verbose, and could log several values in each line, so:

ipc.log("x =" .. x .. " y=" .. y .. " z=" .. z)

The ".." parts just join things together.

Regards

Pete

Share this post


Link to post
Share on other sites

Pete,

I'm attempting the same encoder setup as Reid and haven't got it working yet. I'm reading (and re-reading) the thread to see if I can glean more, but not getting very far. I'm going to start experimenting with the timing values after I get a few hours sleep, but this is what the debug log is giving me so far:

********* LUA: "ipcReady" Log [from FSUIPC version 4.70b] *********

52051995 System time = 02/10/2011 01:34:56, Simulator time = 01:07:00 (05:07Z)

52051995 LUA: 0

52051995 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua

52051995 LUA: return

52051995 LUA:

52051995 LUA: 0

52051995 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua

52051995 LUA: call

52051995 LUA:

52052011 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua:38

52052011 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"

52052011 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:1

52052011 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:2

52052011 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:3

52052011 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:5

52052011 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:6

52052011 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:8

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:10

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:18

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:22

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:26

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:27

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:28

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:29

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:69

52052136 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:32

52052151 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:71

52052198 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:34

52052198 *** LUA Error: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:34: attempt to call field 'readlast' (a nil value)

52052229 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:34

From a single click of the decoder I got the above plus about 400 repeats of the error message on the last two lines.

Share this post


Link to post
Share on other sites

From a single click of the decoder I got the above plus about 400 repeats of the error message on the last two lines.

Without sight of the actual Lua program you are using I haven't any way to comment meaningfully I'm afraid, except to point out that this is an obvious error which you need to correct:

*** LUA Error: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:34: attempt to call field 'readlast' (a nil value)

Whatever 'readlast' is it isn't defined as a field to whatever precedes it. Check your line 34.

Pete

Share this post


Link to post
Share on other sites

Thanks

I was using the code from the older post dated 10 May 2011 - 07:41 AM, above. I've now replaced that with the updated code from the 14 June 2011 - 06:58 AM post. Sorry for the confusion.

Before figuring out my blunder though I found the code causing the error on line 34 of the 10 May 2011 - 07:41 AM reads "data, n = com.readlast(dev, rd)" Reading the library reference doc I find a routine template for n = com.read (handle, max) but no reference to a variant called "readlast". Hope I'm reading the most up to date doc.

Since replacing it with the code with what you posted on 14 June 2011 - 06:58 AM and editing line 9 to match my encoder buttons "Rotaries = {31, 30}" here's what I am getting:

********* LUA: "ipcReady" Log [from FSUIPC version 4.70b] *********

10765973 System time = 02/10/2011 11:06:03, Simulator time = 10:31:55 (14:31Z)

10765973 LUA: 0

10765973 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua

10765973 LUA: return

10765973 LUA:

10765973 LUA: 0

10765988 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua

10765988 LUA: call

10765988 LUA:

10765988 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua:38

10765988 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"

10765988 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:1

10765988 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:2

10765988 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:3

10765988 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:9

10765988 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcReady.lua:15

10767018 >>> Thread killed <<<

10767018 System time = 02/10/2011 11:06:04, Simulator time = 10:31:56 (14:31Z)

********* LUA execution terminated: Log Closed *********

Still not seeing any activity from the virtual buttons.

Share this post


Link to post
Share on other sites

I checked for a "readlast" at line 34. If the debugger counts literal lines of code, including comment lines, then line 34 reads "data, n = com.readlast(dev, rd)".

Reading the library reference doc I find a routine template for n = com.read (handle, max) but no reference to a variant called "readlast". Hope I'm reading the most up to date doc.

Evidently not.!

"readlast" and the Hid facilities were all added this year, since April 2011. From this:

from FSUIPC version 4.70b

I see you are using the current main release. As you will see from the interim update notes in Download Links subforum we are now up to version 4.734 with lots of new facilities, all listed there. There are also updated Lua documents in one of the threads there.

Regards

Pete

Share this post


Link to post
Share on other sites

Pete,

Sorry for the confusion. I realized my mistake with the script and must have been editing my post when you were replying. At this time I'm running the more up to date script. you posted and the current release of FSUIPC. It's working for counter clockwise rotation. Sometimes on the first click I get a fast dec instead of a dec, but after that I get expected behavior. Other than that first click all seems good counter clockwise.

But, I'm not getting anything when turning clockwise. When I look at the buttons tab in options I see Joy# 64 Btn# 0 and Btn# 1 come up as I turn the encoder counter clockwise, but when I turn it clockwise all I get is my device Joy# 3 Btn# 31.

Here's the debug log from 1 ccw click and one cw click.

********* LUA: "ipcDebug" Log [from FSUIPC version 4.734] *********

113522 System time = 02/10/2011 14:43:58, Simulator time = 14:43:30 (18:43Z)

113522 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcDebug.lua"

113522 LUA: 0

113522 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua

113522 LUA: return

113522 LUA:

113522 LUA: 0

113522 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua

113522 LUA: call

113522 LUA:

113522 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua:38

113522 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcDebug.lua"

113522 System time = 02/10/2011 14:43:58, Simulator time = 14:43:30 (18:43Z)

********* LUA execution terminated: Log Closed *********

********* LUA: "ipcDebug" Log [from FSUIPC version 4.734] *********

147826 System time = 02/10/2011 14:44:32, Simulator time = 14:44:04 (18:44Z)

147826 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcDebug.lua"

147826 LUA: 0

147826 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua

147826 LUA: return

147826 LUA:

147826 LUA: 0

147826 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua

147826 LUA: call

147826 LUA:

147826 LUA: ...es\Microsoft Flight Simulator X\Modules\ipcDebug.lua:38

147826 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcDebug.lua"

147826 System time = 02/10/2011 14:44:32, Simulator time = 14:44:04 (18:44Z)

********* LUA execution terminated: Log Closed *********

And, Here's the script:

Vendor = "Leo Bodnar"

Product = "BU0836A Interface"

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}

-- 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 = 60 -- Adjust to taste

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

-- the boundary time

Pollrate = 20 -- 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]-1)

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")

Share this post


Link to post
Share on other sites

But, I'm not getting anything when turning clockwise. When I look at the buttons tab in options I see Joy# 64 Btn# 0 and Btn# 1 come up as I turn the encoder counter clockwise, but when I turn it clockwise all I get is my device Joy# 3 Btn# 31.

The button is being seen via the normal joystick interface as well as via the Lua file settings for the virtual buttons, but the former is getting in first. You'll need to suppress it in order to program the virtual buttons in the dialogue -- or else just program those by editing the INI file. Your choice.

To ignore specific buttons search for "IgnoreThese" in the FSUIPC Advanced User's guide. Instructions for Button definitions for the INI file are also in that document.

Regards

Pete

Share this post


Link to post
Share on other sites

Pete,

Thanks for your patients and help with this. I added the IgnoreThese statement, and made sure all the buttons showed in the INI file, but I'm still not getting clockwise action.

My encoder is coming in through button inputs 30 and 31. 30 is ccw and 31 is cw.

In the FSUIPC INI file I added "IgnoreThese=3.30, 3.31"

The following buttons are defined in association with this

77=P3,31,CL3:R,0

78=P3,30,CL3:R,0

and

51=P64,0,C65880,0

52=U64,0,C65880,0

53=P64,1,C1024,0

54=U64,1,C1024,0

55=P64,2,C65879,0

56=U64,2,C65879,0

57=P64,3,C1025,0

58=U64,3,C1025,0

I'm getting a little bit better understanding of the code, but still haven't digested it all. I'm not sure if I understand how it increments the button assignments for Joy 64. 64 0 and 64 1 are working for the ccw dec and fast dec rotation. Are 64 2 and 64 3 the correct next assignments for inc and fast inc cw rotation?

When looking at the Button tab in FSUIPC Options the ignore statement has taken out the hits on 30 and 31 as you indicated it would. When I rotate the encoder counter clockwise I see Joy# 64 Btn# 0 and Btn# 1 come up, but when I turn it clockwise it's not giving me anything.

I greatly appreciate any assistance you can offer.

Tom G.

Share this post


Link to post
Share on other sites

Thanks for your patients and help with this. I added the IgnoreThese statement, and made sure all the buttons showed in the INI file, but I'm still not getting clockwise action.

The code is completely symmetrical for any number of buttons. It doesn't care about which is which and will work the same with all. It doesn't know about CW or CCW, it just does the same with each listed and connected button -- a pair of virtual buttons for each.

Checking the code and your settings I also see that the button 3,31 is set to generate the virtual buttons 64,0 and 64,1 due to the order 31,30 in the Rotaries = { ... line. The first button numbered there will produce virtual buttons 0, 1 the next 2,3 and so on.

So, I think you've only got one of the two buttons you have declared working. Button 3,30 is not connected -- which is why you never saw it and had to inhibit it too. Maybe it is a different number you have instead (though then you should see it , so this is less likely)? Check your wiring.

Regards

Pete

Share this post


Link to post
Share on other sites

I am at real loss here. I'm going to check to see if Reid has gotten any further with this. I've checked wiring, tested with different inputs (31-30, 29-28, 27-26, and so on), swapped out the encoder for two others I have on my bench. I can trigger other functions with any of them on any of those input. When looking at the FSUIPC Options page I can see the buttons coming up and can assign various functions to them. For example my last test before going back to the the Lua script was to use those various inputs to rotate the VOR1 OBS and the Heading Bug. Both worked in both directions using standard FSUIPC functions. I also reversed the leads to be sure that I was getting the expected reversal in button indications with direction of rotation. I think that should prove out my encoders and wiring unless I'm missing something. Thoughts?

According to the logging, and assuming you haven't removed the relevant lines, it never executes any lines between 53 and 79 inclusive. In other words, in this test:

-- See if any changes occurred:
Diff = logic.Xor(Buttons, PrevButtons)
PrevButtons = Buttons

if Diff ~= 0 then

ii never seeing buttons change.

If it never sees any buttons change there's something drastically wrong. Don't do "Luadebug" any more, just add logging to the Lua to find out more. In this case, after

Diff = logic.Xor(Buttons, PrevButtons)
PrevButtons = Buttons

insert

if (Buttons ~= 0) or (PrevButtons ~= 0) then
	ipc.log("Datalength=" .. n .. " Buttons=" .. Buttons .. " PrevButtons=" PrevButtons)
end

This will show which, if any, of the first 32 buttons are setting or not. Just run it without the Luadebug part and operate your dials.

After all that I set up the FSUIPC config and IPCReady LUA script again. To my great frustration now I am not seeing movement in either direction even though on the FSUIPC Options page I can see at least buttons 64.0 and 64.1 coming up with the correct functions of Heading Dec and Heading Fast Dec.

Where's the Lua debug log showing buttons 64.0 and 64.1 then? All you said you omitted was loads of lines that were the same, so presumably never any button changes! Something isn't making sense in your report.

Please do this. Find the Example Lua Plugins ZIP in your Modules \ FSUIPC Documents folder. Extract the "HidDemo.lua" file and place it into the Modules folder. Edit the lines

Vendor  =
Product  =
Device =

to match your device, and change the line

Logging = false

to

Logging = true

Then run the Lua by assigning a (working) button or keypress to "Lua HidDemo", and run it. Operate the switches or dials or whatever on your device and check the log. Show it to me if you like.

Regards

Pete

Share this post


Link to post
Share on other sites

Pete,

I setup the HidDemo.lua on a spare toggle switch on my instrument panel. I started the hiddemo, turned my encoder 2 clicks ccw and 2 clicks cw and stopped the hiddemo.

The HidDemo.log shows this:

 ********* LUA: "HidDemo" Log [from FSUIPC version 4.734] *********
  1729037 System time = 05/10/2011 23:42:16, Simulator time = 23:36:51 (03:36Z)
  1729037 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\HidDemo.lua"
  1729162 LUA: Device has 1 x Hat axis, Max= 7
  1729271 LUA: Hat = 15 0 0 0
  1751673 LUA: Buttons= 80000000 0 0 0 0 0 0 0
  1751751 LUA: Buttons= 0 0 0 0 0 0 0 0
  1754028 LUA: Buttons= 80000000 0 0 0 0 0 0 0
  1754059 LUA: Buttons= 0 0 0 0 0 0 0 0
  1756618 LUA: Buttons= 40000000 0 0 0 0 0 0 0
  1756649 LUA: Buttons= 0 0 0 0 0 0 0 0
  1758365 LUA: Buttons= 40000000 0 0 0 0 0 0 0
  1758427 LUA: Buttons= 0 0 0 0 0 0 0 0
  1766118 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\HidDemo.lua"
  1766118 System time = 05/10/2011 23:42:53, Simulator time = 23:37:27 (03:37Z)
********* LUA execution terminated: Log Closed *********

The corresponding events in the FSUIPC log show this:

 1729037 Button changed: bRef=0, Joy=2, Btn=2, Pressed
 1729037 [Buttons] 27=P2,2,CL2:R,0
 1729271 WRITElua 3BBE,   2 bytes: 92 08                                            ..
 1751501 Button changed: bRef=0, Joy=3, Btn=31, Pressed
 1751501 [Buttons] 72=P3,31,CL1:R,0
 1751579 Button changed: bRef=0, Joy=3, Btn=31, Released
 1751673 WRITElua 3340,   4 bytes: 00 00 00 80                                      ....
 1751751 WRITElua 3340,   4 bytes: 00 00 00 00                                      ....
 1753857 Button changed: bRef=0, Joy=3, Btn=31, Pressed
 1753857 [Buttons] 72=P3,31,CL1:R,0
 1753888 Button changed: bRef=0, Joy=3, Btn=31, Released
 1754028 WRITElua 3340,   4 bytes: 00 00 00 80                                      ....
 1754059 WRITElua 3340,   4 bytes: 00 00 00 00                                      ....
 1756399 Button changed: bRef=0, Joy=3, Btn=30, Pressed
 1756415 [Buttons] 71=P3,30,CL1:R,0
 1756446 Button changed: bRef=0, Joy=3, Btn=30, Released
 1756618 WRITElua 3340,   4 bytes: 00 00 00 40                                      ...@
 1756649 WRITElua 3340,   4 bytes: 00 00 00 00                                      ....
 1758193 Button changed: bRef=0, Joy=3, Btn=30, Pressed
 1758193 [Buttons] 71=P3,30,CL1:R,0
 1758225 Button changed: bRef=0, Joy=3, Btn=30, Released
 1758365 WRITElua 3340,   4 bytes: 00 00 00 40                                      ...@
 1758427 WRITElua 3340,   4 bytes: 00 00 00 00                                      ....
 1765666 Button changed: bRef=0, Joy=2, Btn=2, Released
 1765666 [Buttons] 74=U2,2,CL2:K,0
 1766118 LUA: "HidDemo.lua": killed

I also setup the logging entry you suggested in IPCReady.lua (these are lines 52, 53, and 54 of that file.

if (Buttons ~= 0) or (PrevButtons ~= 0) then
  ipc.log("Datalength=" .. n .. " Buttons=" .. Buttons .. " PrevButtons=" PrevButtons)
end

For those same 4 encoder clicks the log is returning an error related to line 53 (the ipc.log line) as follows:

 ********* LUA: "ipcReady" Log [from FSUIPC version 4.734] *********
  1751501 System time = 05/10/2011 23:42:38, Simulator time = 23:37:13 (03:37Z)
  1751501 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
  1751501 *** LUA Error: ... (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua:53: ')' expected near 'PrevButtons'
  1751501 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
  1751501 System time = 05/10/2011 23:42:38, Simulator time = 23:37:13 (03:37Z)
********* LUA execution terminated: Log Closed *********

********* LUA: "ipcReady" Log [from FSUIPC version 4.734] *********
  1753857 System time = 05/10/2011 23:42:41, Simulator time = 23:37:16 (03:37Z)
  1753857 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
  1753857 *** LUA Error: ... (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua:53: ')' expected near 'PrevButtons'
  1753857 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
  1753857 System time = 05/10/2011 23:42:41, Simulator time = 23:37:16 (03:37Z)
********* LUA execution terminated: Log Closed *********

********* LUA: "ipcReady" Log [from FSUIPC version 4.734] *********
  1756415 System time = 05/10/2011 23:42:43, Simulator time = 23:37:18 (03:37Z)
  1756415 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
  1756415 *** LUA Error: ... (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua:53: ')' expected near 'PrevButtons'
  1756415 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
  1756415 System time = 05/10/2011 23:42:43, Simulator time = 23:37:18 (03:37Z)
********* LUA execution terminated: Log Closed *********

********* LUA: "ipcReady" Log [from FSUIPC version 4.734] *********
  1758193 System time = 05/10/2011 23:42:45, Simulator time = 23:37:20 (03:37Z)
  1758193 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
  1758193 *** LUA Error: ... (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua:53: ')' expected near 'PrevButtons'
  1758193 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
  1758193 System time = 05/10/2011 23:42:45, Simulator time = 23:37:20 (03:37Z)
********* LUA execution terminated: Log Closed *********

Share this post


Link to post
Share on other sites

I setup the HidDemo.lua on a spare toggle switch on my instrument panel. I started the hiddemo, turned my encoder 2 clicks ccw and 2 clicks cw and stopped the hiddemo.

The HidDemo.log shows this:

Okay. Tha's fine. The correct bits are changing. Didn't need the FSUIPC log.

I also setup the logging entry you suggested in IPCReady.lua (these are lines 52, 53, and 54 of that file.

...

For those same 4 encoder clicks the log is returning an error related to line 53 (the ipc.log line) as follows:

Yes, sorry, there's a typo -- I omitted the .. before the last value. The line should be:

  ipc.log("Datalength=" .. n .. " Buttons=" .. Buttons .. " PrevButtons=" .. PrevButtons)

Pete

Share this post


Link to post
Share on other sites

Pete,

I may have a bad diode in my wiring. After I changed the logging code I was getting some strange results that pointed back to an electrical issue so I went back to retest all the wiring. I'm using diodes on my bodnar board as suggested on leo's web site, but I'm starting to notice some intermittent results on a couple inputs. I'm going to go back and retest the diodes and replace anything questionable and double check the wiring and pick up after that. May be past the weekend though as I'll be out of town for a couple days. I'll post again when I have that done and can retest.

Thanks!

Tom G.

Share this post


Link to post
Share on other sites

I may have a bad diode in my wiring. After I changed the logging code I was getting some strange results that pointed back to an electrical issue so I went back to retest all the wiring. I'm using diodes on my bodnar board as suggested on leo's web site, but I'm starting to notice some intermittent results on a couple inputs. I'm going to go back and retest the diodes and replace anything questionable and double check the wiring and pick up after that. May be past the weekend though as I'll be out of town for a couple days. I'll post again when I have that done and can retest.

Okay.

Hopefully we can resolve it before next Friday (14th) as I'm then away till the 25th.

Regards

Pete

Share this post


Link to post
Share on other sites

Okay.

Hopefully we can resolve it before next Friday (14th) as I'm then away till the 25th.

Regards

Pete

Pete,

Making one last attempt before leaving town. Might be in trouble with the wife for not helping to pack, but the encoder problem is bugging me more than she'll be scolding me so . . . icon_mrgreen.gif

I cleared all the connections from my bodnar board and have just the one encoder hooked up with a new (and tested) diode. That should eliminate wiring questions. and to prove to myself that the encoder was being read I did the following:

  • I checked it against the stock calibration/test window in FSX and can see the correct button pulses on 31 and 32 (Joy 3.30 and 3.31) in the test window
  • I temporarily configured Joy 3.30 and 3.31 in the FSUIPC config to do other FSX functions and they were able to trigger those functions. Then pointed them back at LuaIPCReady
  • I turned on the FSUIPC log and can see both buttons come up with the corresponding rotation, but as seen below it's executing the Lua script is being killed.
  • "LUA: "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua": killed"
  • And with the logging lines in the script it returned the same four log entries for each click:

********* LUA: "ipcReady" Log [from FSUIPC version 4.734] *********
    79233 System time = 06/10/2011 20:42:33, Simulator time = 20:42:04 (00:42Z)
    79233 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
    80481 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
    80481 System time = 06/10/2011 20:42:34, Simulator time = 20:42:05 (00:42Z)
********* LUA execution terminated: Log Closed *********

And the HidDemo log shows this now:

********* LUA: "HidDemo" Log [from FSUIPC version 4.734] *********
    68469 System time = 06/10/2011 20:42:22, Simulator time = 20:41:53 (00:41Z)
    68469 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\HidDemo.lua"
    68578 LUA: Device has 1 x Hat axis, Max= 7
    68656 LUA: Hat = 15 0 0 0
    93585 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\HidDemo.lua"
    93585 System time = 06/10/2011 20:42:47, Simulator time = 20:42:18 (00:42Z)
********* LUA execution terminated: Log Closed *********

Unfortunately no movement on the heading bug, but that seems to be in line with the log entries above if I'm understanding it all correctly.

That's about all I can sneak in tonight. I'll be sure to check for any replies over the weekend, and I'll be back at the test bench on Tuesday evening.

Thanks for all your help, and have a great weekend!

Tom G.

Share this post


Link to post
Share on other sites
  • [*]I turned on the FSUIPC log and can see both buttons come up with the corresponding rotation, but as seen below it's executing the Lua script is being killed.[*] "LUA: "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua": killed"[*]And with the logging lines in the script it returned the same four log entries for each click:
********* LUA: "ipcReady" Log [from FSUIPC version 4.734] *********[/list]     79233 System time = 06/10/2011 20:42:33, Simulator time = 20:42:04 (00:42Z)
    79233 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
    80481 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua"
    80481 System time = 06/10/2011 20:42:34, Simulator time = 20:42:05 (00:42Z)
********* LUA execution terminated: Log Closed *********

You have some confusion here. The log does not show the "Killed" line, only that it ended.

The ipcReady Lua will only be "killed" if you are killing it by executing it again, or by assigning "LuaKill" to it. Maybe you've assigned ipcReady to something?

Without knowing what you are doing I can't help I'm afraid. You seem to have got yourself confused along the way. Every time you post less works and other things happen for no reason, or at least no reason you've described. I think you must be doing things you aren't telling me about.

And the HidDemo log shows this now:

********* LUA: "HidDemo" Log [from FSUIPC version 4.734] *********
    68469 System time = 06/10/2011 20:42:22, Simulator time = 20:41:53 (00:41Z)
    68469 LUA: beginning "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\HidDemo.lua"
    68578 LUA: Device has 1 x Hat axis, Max= 7
    68656 LUA: Hat = 15 0 0 0
    93585 LUA: ended "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\HidDemo.lua"
    93585 System time = 06/10/2011 20:42:47, Simulator time = 20:42:18 (00:42Z)
********* LUA execution terminated: Log Closed *********

So you never used any of the buttons whilst the HidDemo was running. Or none are working. without change the HidDeno would still show your butons, so evidently you've changed something.

Regards

Pete

Share this post


Link to post
Share on other sites

Pete,

I really appreciate your time on this, and I'm trying to post all the information I can here. I'm wracking my brain trying to figure out what key trouble shooting element I'm missing that I could add to what I've posted.

Diode info came from Leo's site here where he states that diodes should be used if 3 or more switches may be left in an on condition rather than just pulsing. I have some switches that will so I installed the diodes.

Here's some of the info from that page:

full 6x6 matrix
  • connects to six ROWS and six COLUMNS pins on the controller...
  • ..with diodes if there will be 3 or more contacts activated simultaneously, e.g. if you use ON/OFF switches
  • ..no diodes if buttons used only momentarily like most joysticks
  • First 32 buttons are standard buttons
  • Last 4 contacts make up 8-direction point-of-view hat (coolie) switch
  • Literally any diodes can be used - 1N4148 or 1N4004 are good ones

6x6.png
What is puzzling me is that it's only the lua scripts that don't seem to see the buttons consistently???.
  1. I can see the encoder buttons pulsing in the FSX calibration utility and trigger functions with the encoder from the native FSX control settings. I set the encoder buttons to pan views left and right to check this and it works.
  2. I can see the encoder buttons come up on the FSUIPC Options Button tab and trigger FSUIPC functions with the encoder. I used the encoder to rotate the heading bug using fast dec and fast inc and it works
  3. When I point the encoder back to the lua script it's triggering the script. But the script doesn't seem to be seeing the buttons. At least I believe that's what the logs are telling me.

  • The FSUIPC log shows the button events are launching the script but the script is getting killed
    86518 Button changed: bRef=0, Joy=3, Btn=30, Pressed
    86518 [Buttons] 71=P3,30,CL1:R,0
    86971 LUA: "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua": killed
    86971 Button changed: bRef=0, Joy=3, Btn=30, Released
    88063 Button changed: bRef=0, Joy=3, Btn=31, Pressed
    88063 [Buttons] 72=P3,31,CL1:R,0
    88515 LUA: "C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X\Modules\ipcReady.lua": killed
    88515 Button changed: bRef=0, Joy=3, Btn=31, Released


But, when I look at the HIDDemo or IPCReady log as you saw in my post above they aren't seeing the buttons ???
This is my first venture into encoder use, so maybe I'm missing something there...

  1. Based on the encoder spec sheet and what I read on Leo's site I have the correct pins connected to the correct inputs as if it where switch 31 and 32 in the diagram above.
  2. The A and B pins of the encoder are connected to the column 1 and 2 in the diagram above
  3. The common pin is connected to Row 6. I tested that with and without the diode
  4. I used his encoder flash utility to to set pair 31/32 as an encoder input at 1:1 and left the pulse width at the default of 48ms

Questions I have that I'll attempt to answer when I get back home:

  1. Could reversing the encoder connections row vs. column make any difference?
  2. Is the 48ms pulse width an issue? Should it be longer or shorter?
  3. If I remove all the code from the current IPCReady script and come up with some simple script that does a single and observable rudimenentary function does it show in the log and can I see the action in FSX?
  4. What might be preventing the button inputs that FSX and FDUIPC be can see from getting through to the lua script ???

Pete, any further observations or ideas would be greatly appreciated!!!

Share this post


Link to post
Share on other sites

What is puzzling me is that it's only the lua scripts that don't seem to see the buttons consistently???.

But the HidDemo one did, and I assume you've not messed with that? If that can't see them then no other Lua HID program will. HIDDemo works on everything I've ever tried it on.

So what have you changed?

Additionally the Lua program you are trying to get working was half working at one time and somehow without change stopped altogether and now gets itself "killed" in some undetermined manner.

None of these changes can happen by themselves, and i can't see what you are doing from here.

When I point the encoder back to the lua script it's triggering the script.

Now here's a problem. I don't understand at all what you are saying you are doing here. How exactly are you "pointing" the encoder this way?

By naming the script "ipcReady" you are asking FSUIPC to run it automatically when FS is ready. From what you posted earlier I see the script is designed to sit in a loop, in the backround, just watching for the buttons. If you have it triggered by a button instead it will be re-loaded, re-compiled and re-executed each time that button is seen. The previous running copy, waiting for a button, will be killed. I've no idea why you are trying to do it this way now, and if you are you need a completely different Lua program.

So, at some time, you changed your whole method of doing things for some reason, and i now don't understand what you are up to. I think you'll need to go through it, step by step, and tell me EXACTLY what you are doing now and what you have changed since it was all nearly working and all I asked for what an extra logging line (which I got wrong on the first stab and corrected for you).

If you want to use the Lua script I provided originally to someone else for the purpose of detecting fast and slow turning rotaries, then you really must use it in the way suggested for it. It works for all the other users I know using it. Why or how you are getting into a complete mess with it is bewildering me. Each time you post things are worse and less explainable!

Pete

Share this post


Link to post
Share on other sites

Now here's a problem. I don't understand at all what you are saying you are doing here. How exactly are you "pointing" the encoder this way?

Sorry for any confusion, by that I meant buttons 3.30 and 3.31 are defined in the FSUIPC config as follows:

71=P3,30,CL1:R,0
72=P3,31,CL1:R,0

Should I be removing those lines? I thought that was what triggered the lua script, but now reading that it runs in a continuous loop in the background I'm questioning that.

So, at some time, you changed your whole method of doing things for some reason, and i now don't understand what you are up to. I think you'll need to go through it, step by step, and tell me EXACTLY what you are doing now and what you have changed since it was all nearly working . . .

In the process of trouble shooting I may have made an inadvertent change, or done something that I'm not recalling, but nothing intentional. When I get home I will be restarting from scratch and re-doing everything, to include reloading the original script , and subsequent logging modification. I'll document step by step and if I'm not able to resolve it I'll post all the steps I took and all the logs to be sure I'm not leaving anything unaccounted for.

If you want to use the Lua script I provided originally to someone else for the purpose of detecting fast and slow turning rotaries, then you really must use it in the way suggested for it. It works for all the other users I know using it. Why or how you are getting into a complete mess with it is bewildering me. Each time you post things are worse and less explainable!

Pete your patients and assistance have been above and beyond the call of duty!!!

As for my efforts, while I've been away from it for a few years (the curse of being pulled into management) I'm a degree'd EE with experience in design, prototyping, fabrication, and trouble shooting. This encoder project has left me feeling a bit inadequate. I feel about as clueless as I was back in my first freshman year lab back in the 80's...

Again, thanks for your help on this!!! I'll be back at it with a fresh start when I get home on Tuesday.

Share this post


Link to post
Share on other sites

Sorry for any confusion, by that I meant buttons 3.30 and 3.31 are defined in the FSUIPC config as follows:

71=P3,30,CL1:R,0
72=P3,31,CL1:R,0

Without the whole INI file those mean little to me -- they just say to run whatever Lua program is number 1 in the Lua files list in the INI. If that is "ipcReady" then you should most certainly NOT be doing that!

Should I be removing those lines? I thought that was what triggered the lua script, but now reading that it runs in a continuous loop in the background I'm questioning that.

Yes. Remove them! Is this something you've changed at some stage AFTER you came here with your questions, after the earlier logs with things half done okay?

ipcReady is always run automatically. Please see the short Lua introductory document included with your FSUIPC Installation.

Please, can I ask: where are you getting your instructions from for all this? When you started out I assumed you knew something about what you were doing, what with the debug logs and so on. But if you were already then starting off the ipcReady with Debug, then the clash with the already-running ipcReady would have certainly affected the results!

Regards

Pete

Share this post


Link to post
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

×

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.