Jump to content
The simFlight Network Forums

Too many inputs at the same time, possible issue?


Recommended Posts

Hello Pete, now that the 747 is out I have finally started flying something with 4 engines again. This leads me to my question that maybe you can shed some light on, or a more desired method.

I have two Saitek USB Throttles, 6 axis', 1 Spoiler, 4 Throttle, 1 Flap. My question is in regards of button presses being sent to the sim. Right now Throttle Lever 1-4 when pulled into the reverse detent (Button) I have a custom command sent.

When In the detent each lever 1-4 sends "Decrease Engine" command to repeat when held. This part is fine and works no problem, but what happens next is my question.

When each button gets Released, I have custom .lua scripts in for each release on 1-4. Basically it will gradually add power (F3) to simulate a gradual reduction from full reverse to reverse idle and break the command instruction once the engine reaches IDLE. I think with 4 commands being sent virtually all at the same time some get missed, lag behind on another, or fail to remain in sync. 

Do you have any input on what to do here? I was thinking of making a custom profile for the specific aircraft and mapping it to one button instruction does it to all 4 engines at once but I would like to know if maybe there's a better way to do this?  

Any thoughts on this?

 

EDIT: I should mention on twin engine aircraft everything works fine. 

Link to comment
Share on other sites

20 minutes ago, AngeloCosma said:

When each button gets Released, I have custom .lua scripts in for each release on 1-4. Basically it will gradually add power (F3) to simulate a gradual reduction from full reverse to reverse idle and break the command instruction once the engine reaches IDLE. I think with 4 commands being sent virtually all at the same time some get missed, lag behind on another, or fail to remain in sync. 

Without seeing the Lua code itself I couldn't really comment.

The state of all buttons on a single device is sent in one USB message, as are the axis positions. Things like axis positions are rarely if ever missed -- depending on the FSUIPC polling rate (adjustable), and so buttons certainly won't be unless they are so transient they are only pressed for less than one scan interval -- maybe 1/20th to 1/50th of a second (I don't recall the default rate offhand). However, you are talking about the buttons being held on for reverse, then released, so transience is certainly not applicable. Once off they are off, and if previously noted as on the change will most certainly be noticed.

Are there are 4 separate Lua scripts, one for each? Are they loaded each time, or are you using the event system to trigger on the button event? There are many ways of doing things. I would need to know more about what you are doing.

Pete

 

Link to comment
Share on other sites

@Pete Dowson Thank you for the reply. Yes it is one .lua per engine.

Here is the .lua for engine 1, they are all the same except the obvois changes in the offset number for the respective engines.

" while true do throttle1 = ipc.readSW(0x088c) if throttle1 >= 0 then break --exit when no more reverse end ipc.control(65964) --65964 = throttle1 incr. Use 65965 for smaller increment ipc.sleep(500) -- "

The are triggered by FSUIPC as "Send action when button released" Tick box is checked and in the drop down list is select "Idle(x).lua where X is the engine number 1-4. 

Link to comment
Share on other sites

I have to format that properly to understand it:

while true do
   throttle1 = ipc.readSW(0x088c)
   if throttle1 >= 0 then
        break --exit when no more reverse
   end
   ipc.control(65964) -- 65964 = throttle1 incr. Use 65965 for smaller increment
   ipc.sleep(500) 
end

I added an "end" at the end because you appear to have missed it out, hopefully only on the copy you made here.

Sleeping for a whole half second seems rather extreme. How did you arrive at such a long gap?  Just the time you want between throttle decrements? You could of course simply add a small number to offset 088C instead each time, or, probably more reliably for some add-on aircraft, use the Throttle1_set control instead with an increasing negative parameter.

Most of all I think it would be better to have your Luas pre-loaded, via an [Auto] section (maybe profile specific), and use an event to trigger it instead.  The event.button function with a "downup" parameter set to 2 (for release) is made for the job. Then don't assign anything to the button release parts in FSUIPC assignments.

Pete

 

Link to comment
Share on other sites

4 minutes ago, Pete Dowson said:

I have to format that properly to understand it:


while true do
   throttle1 = ipc.readSW(0x088c)
   if throttle1 >= 0 then
        break --exit when no more reverse
   end
   ipc.control(65964) -- 65964 = throttle1 incr. Use 65965 for smaller increment
   ipc.sleep(500) 
end

I added an "end" at the end because you appear to have missed it out, hopefully only on the copy you made here.

Sleeping for a whole half second seems rather extreme. How did you arrive at such a long gap?  Just the time you want between throttle decrements? You could of course simply add a small number to offset 088C instead each time, or, probably more reliably for some add-on aircraft, use the Throttle1_set control instead with an increasing negative parameter.

Most of all I think it would be better to have your Luas pre-loaded, via an [Auto] section (maybe profile specific), and use an event to trigger it instead.  The event.button function with a "downup" parameter set to 2 (for release) is made for the job. Then don't assign anything to the button release parts in FSUIPC assignments.

Pete

 

I am very novice in regards to creating these lua's, another forum member helped and came up with those values. 

I understood your reply up to "DownUp" parameter set to 2. If you don't mind and because my knowledge is so limited but I am trying, would you mind showing me what the modified more correct .lua would look like. Just for one and I can go ahead and transpose it to each remaining engine. 

I agree the half second seems long and at times the engines idle too slowly so I will shorten that value down some, but this brings another point. Sometimes the engines take 4-5 seconds (estimate to idle) and other times (same plane) it seems the value gets ignored and idles much quicker. Any ideas as to why on that? Most likely due to my poor lua assigning. 

Link to comment
Share on other sites

function ThrottleToIdle()
	while true do
	  throttle1 = ipc.readSW(0x088c)
      if throttle1 >= 0 then
          break --exit when no more reverse
      end
      ipc.control(65964) -- 65964 = throttle1 incr. Use 65965 for smaller increment
      ipc.sleep(500) 
   end
end

event.button(joystick nmuber or letter, button number , 2, "ThrottleToIdle")
Link to comment
Share on other sites

The above is the quick and dirty way. Really you could also use a timer event instead of the loop and sleep, but try the above. Remember to put the joystick and button details in the event.button line, instead of the text I've put there, and think about a shorter time than 500.

There are lots of examples of Lua plug-ins provided in the FSUIPC Documents folder, and more in the User Contributions subforum above. It is easy enough to get a better feel for doing these things.

Pete

 

 

Link to comment
Share on other sites

Looking at my .luas now, and I see that I edited the sleep to 300. So I will try what you posted above with that. 

Now why do I have to put the Joy ID and button in the lua, wont that get assigned when I map it in FSUIPC under control sent when released or is the EVENT a new way of handling this now?

" Most of all I think it would be better to have your Luas pre-loaded, via an [Auto] section (maybe profile specific), and use an event to trigger it instead.  The event.button function with a "downup" parameter set to 2 (for release) is made for the job. Then don't assign anything to the button release parts in FSUIPC assignments. "

Will have to re read this a few times with FSUIPC in front of me to make full sense of it. 

Link to comment
Share on other sites

23 minutes ago, AngeloCosma said:

Now why do I have to put the Joy ID and button in the lua, wont that get assigned when I map it in FSUIPC under control sent when released or is the EVENT a new way of handling this now?

You evidently missed the bit at the end, even though you quited it again:

"don't assign anything to the button release parts in FSUIPC assignments."

The Luas will need to be pre-loaded as I said. They'll just be sitting there waiting.

Pete

 

 

Link to comment
Share on other sites

Just now, Pete Dowson said:

You evidently missed the bit at the end, even though you quited it again:

"don't assign anything to the button release parts in FSUIPC assignments."

The Luas will need to be pre-loaded as I said. They'll just be sitting there waiting.

Pete

 

 

Yes I edited my original reply with your post indicating what I misread. 

function ThrottleToIdle()

In the () will the engine number go there correct? Simple 1-4, or Throttle1set or, etc. 

event.button(joystick nmuber or letter, button number , 2, "ThrottleToIdle")

I can get the joy and button ID when I press it in FSUIPC correct? the "ThrottleToIdle") (Should it only contain the 1 parenthesis, or is one missing. "ThrottletoIdle1") should it look like that when finished?

Link to comment
Share on other sites

18 minutes ago, AngeloCosma said:

In the () will the engine number go there correct? Simple 1-4, or Throttle1set or, etc. 

No.  As clearly documented in the Lua library document (in your FSUIPC documents folder), the parameters, which are supplied by the Event function (which knows nothing about engines) is

(joy, button, downup)

In other words, the same joystick and button numbers you entered into the Event, and a value saying whether the button was down, or up. Since you have no use for any of those in the code in the function there's no real point declaring them.

18 minutes ago, AngeloCosma said:

I can get the joy and button ID when I press it in FSUIPC correct?

Of course. In the assignment!!!

18 minutes ago, AngeloCosma said:

the "ThrottleToIdle") (Should it only contain the 1 parenthesis, or is one missing. "ThrottletoIdle1") should it look like that when finished?

I see both ( and ) for the Event function. Where on Earth are you looking?

I suggest you look at examples. I'm not here to re-document everything that is already perfectly adequately described and documented. You need to think about helping yourself.

Pete

 

Link to comment
Share on other sites

Read page 22 on the Lua Library pdf and that gave me some insight. 

This is what I have now, does it look right?

function ThrottleToIdle()
while true do 
    throttle3 = ipc.readSW(0x09BC) 
    if throttle3 >= 0 then   
        break --exit when no more reverse 
    end 
    ipc.control(65974)--65974 = throttle3 incr. Use 65965 for smaller increment 
    ipc.sleep(300) -- adjust for speed of increase. 10mSecs = 100 per second
     end
end

event.button(0, 8 , 2, "ThrottleToIdle")

Link to comment
Share on other sites

16 minutes ago, AngeloCosma said:

This is what I have now, does it look right?

Well it looks okay -- throttle 3 (0x9BC)?  But then so do mine till I run them and get an error reported! That's always the best way to test with scripting. After all it's so easy to change them and try again.

Errors, if any, will be reported in the FSUIPC4.LOG file -- unless you enable the option for a separate Lua log.

Pete

 

Link to comment
Share on other sites

2 hours ago, AngeloCosma said:

Pete, another user and I have been at it for hours to no avail, either we are overthinking it or missing something. 

Any help? Take a look here to see what's been done if you are curious what we tried.

http://www.avsim.com/topic/503344-any-advanced-fsuipc-users-here-lua-event/

Pete,

To hopefully save you some time, I think the problem was my error (I was 'helping' Angelo).   For some reason (age problem, maybe?  :sad: ) I forgot to put Lua in front of the Lua script names in the [Auto] section of the FSUIPC.ini file like:

 [Auto]

1=Lua Throttle_Idle_1

2=Lua Throttle_Idle_2

3=Lua Throttle_Idle_3

4=Lua Throttle_Idle_4

As a result, the event.button command did nothing. Until Angelo can give this fix a try, it likely is not worth your time to look further into this.

Al

Link to comment
Share on other sites

3 hours ago, ark1320 said:

I forgot to put Lua in front of the Lua script names in the [Auto] section of the FSUIPC.ini file like:

Yes. The [Auto] facility lists Macros or Plug-ins which should be executed. It can include macros setting switches and so on, to help set up a cockpit perhaps, or for many other things.  Loading of plug-ins is only one of its functions and it needs to be told explicitly.

Pete

 

Link to comment
Share on other sites

3 hours ago, Pete Dowson said:

Yes. The [Auto] facility lists Macros or Plug-ins which should be executed. It can include macros setting switches and so on, to help set up a cockpit perhaps, or for many other things.  Loading of plug-ins is only one of its functions and it needs to be told explicitly.

Pete

 

Why is it then when I assigned new lua we worked on last night to "Control to send when button released" just as a way to force it to see if it would work, it still did nothing? Or is it simply not going to work in the type of application trigger?

Link to comment
Share on other sites

33 minutes ago, AngeloCosma said:

Why is it then when I assigned new lua we worked on last night to "Control to send when button released" just as a way to force it to see if it would work, it still did nothing? Or is it simply not going to work in the type of application trigger?

Oh dear. Do NOT trigger it at all! It needs to be pre-loaded and actually running! It will get the button release by itself when it happens!

If you want to start it for testing changes without reloading FS to make the [Auto] trigger, just assign "Lua <name>" to a spare keypress combination. When you make a change and replace the file(s), reload them by using the same keypress again. Check the FSUIPC log for any error reports.

Pete

 

  • Upvote 1
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.