Jump to content
The simFlight Network Forums
Sign in to follow this  

Programming Efficiency (VB.NET)

Recommended Posts

Hi Pete,

In mean time we've managed to get most things working. However we have a few questions. We are experiencing delays of +- 3 sec on the commands given, probabely due to unefficient programming.

Do you have any FSUIPC related tips concerning a more efficient programming? (Note that there is also code included for the acquisition of voltages).

Second question: We are getting the voltage values in double format, this means a lot of numbers behind the floating point, however, flightsim requires a Short as input, this means we are loosing all numbers behind the floating point. Currently we devide the voltage input by the max voltage input (so this means max = 1) and * 16348. Is there a more interesting way to cope with this problem?


Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick

'Engine 1 Throttle Lever

Dim reader1 As AnalogMultiChannelReader

Dim myTask1 As New Task

myTask1.AIChannels.CreateVoltageChannel("dev1/ai0", "", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts)


reader1 = New AnalogMultiChannelReader(myTask1.Stream)

Dim datainput1 As Double(,)

datainput1 = reader1.ReadMultiSample(-1)

Dim voltage1 As Double = datainput1(0, 0)

lblVoltageENG1.Text = voltage1

Dim dwOffset1 As Integer

Dim Wel1 As Short = ((voltage1 / 8.73) * 16384)

Dim ThrottleToken1 As Integer

Dim Result1 As Integer

dwOffset1 = &H88C

FSUIPC_Write(dwOffset1, Wel1, ThrottleToken1, Result1)


'Engine 2 Throttle Lever

Dim reader2 As AnalogMultiChannelReader

Dim myTask2 As New Task

myTask2.AIChannels.CreateVoltageChannel("dev1/ai1", "", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts)


reader2 = New AnalogMultiChannelReader(myTask2.Stream)

Dim datainput2 As Double(,)

datainput2 = reader2.ReadMultiSample(-1)

Dim voltage2 As Double = datainput2(0, 0)

lblVoltageENG2.Text = voltage2

Dim dwOffset2 As Integer

Dim Wel2 As Short = ((voltage2 / 8.73) * 16384)

Dim ThrottleToken2 As Integer

Dim Result2 As Integer

dwOffset2 = &H924

FSUIPC_Write(dwOffset2, Wel2, ThrottleToken2, Result2)


'Engine 3 Throttle Lever

Dim reader3 As AnalogMultiChannelReader

Dim myTask3 As New Task

myTask3.AIChannels.CreateVoltageChannel("dev1/ai2", "", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts)


reader3 = New AnalogMultiChannelReader(myTask3.Stream)

Dim datainput3 As Double(,)

datainput3 = reader3.ReadMultiSample(-1)

Dim voltage3 As Double = datainput3(0, 0)

lblVoltageENG3.Text = voltage3

Dim dwOffset3 As Integer

Dim Wel3 As Short = ((voltage3 / 8.73) * 16384)

Dim ThrottleToken3 As Integer

Dim Result3 As Integer

dwOffset3 = &H9BC

FSUIPC_Write(dwOffset3, Wel3, ThrottleToken3, Result3


'Elevator Position Control

Dim reader4 As AnalogMultiChannelReader

Dim myTask4 As New Task

myTask4.AIChannels.CreateVoltageChannel("dev1/ai3", "", AITerminalConfiguration.Rse, -10, 10, AIVoltageUnits.Volts)


reader4 = New AnalogMultiChannelReader(myTask4.Stream)

Dim datainput4 As Double(,)

datainput4 = reader4.ReadMultiSample(-1)

Dim voltage4 As Double = datainput4(0, 0)

lblVoltageElevator.Text = voltage4

Dim dwOffset4 As Integer

Dim Wel4 As Short = (((voltage4 - (9 / 2)) / (9 / 2)) * 16384)

Dim ThrottleToken4 As Integer

Dim Result4 As Integer

dwOffset4 = &HBB2

FSUIPC_Write(dwOffset4, Wel4, ThrottleToken4, Result4)






End Sub

FSUIPC_Close() is called in form_closed


All comments on the programming are more than welcome to impove the loading time.

Share this post

Link to post
Share on other sites
Hi Pete,

In mean time we've managed to get most things working. ...

Why have you posted the exact same message twice? Is this related to your quadruple Process calls, three or which are for nothing? ;-)


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

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