Jump to content
The simFlight Network Forums

Fess_ter

new Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Fess_ter

  • Rank
    Newbie

Profile Information

  • Gender
    Male
  • Location
    Evansville, IN
  1. P3Dv4.4 FSUIPC Registered 5.15 I'm building an Arduino based console with Trim wheels, elevator, rudder and aileron. The wheels are on encoders that dial the trims. For rudder trim left and right, I use controls 66278 and 66279. I have a push button on the encoder that I use to center the rudder trim using (Rudder Trim Set) control 66732 with a parameter of 0. ipc.control(66732,0) will only work once. After centering once, if you dial the trim left or right and then try to center again, the ipc.control(66732,0) will have no effect. All of the "Trim Set" controls (Elevator, Aileron and Rudder) will not respond if the value of the parameter is equal to the last parameter sent. I have found a work around by sending ipc.control(66732,1) followed by ipc.control(66732,0). Cheers
  2. Brilliant! And Thanks. I'll try it tonight. ~Fess
  3. I will post the Log as soon as I can, but it won't be until around Wed the 21st, 2300Z . Here is the script. There is a lot of stuff in there. ~Fess port_file = "RADIO_port.txt" feet_per_meter = 3.28083989501312 speed = 115200 handshake = 0 serial_wait = 20 --------------------------------------- ------------------------------------------------------------------------ --- Looks for a file with stored COM Port to auto connect to Arduino. -- --- If no File, then create a file and ask for the COM Port. Also, -- --- if COM Port doesn't connect then ask for COM Port. -- ------------------------------------------------------------------------ file = io.open(port_file, "r") if file == nil then port_number = "10" file = io.open(port_file, "w") io.output(file) io.write(port_number) io.close(file) Arduino_Com_Port = com.open("COM"..port_numberandshake) else port_number = file:read (2) --ipc.display(port_number) io.close(file) Arduino_Com_Port = com.open("COM"..port_numberandshake) end if Arduino_Com_Port ~= 0 then ipc.display("Arduino Com Port "..port_number.." Open",5) else ipc.display("Could not open ARDUINO Com Port") ipc.sleep(2000) port_number = ipc.ask('\n'..'\n'..'\n'..'\n'..'\n'..'\n'..'\n'..'\nio.open(port_file, "w") io.output(file) io.write(port_number) io.close(file) Arduino_Com_Port = com.open("COM"..port_numberandshake) if Arduino_Com_Port == 0 then ipc.display("Could not open ARDUINO Com Port",5) ipc.exit() else ipc.display("Arduino Com Port "..port_number.." Open",5) end end ------------------------------------------------------------------- ------------------------------------------------------------------- function Arduino_Data(Arduino_Com_Port, datastring, length) --ipc.display("Function called",2) --ipc.display(datastring) --- L CRS ------------------------------------- if (string.find(datastring, "A56")) then --L CRS UP for i in string.gfind(datastring, "A56") do ipc.control(65663,0) end end if (string.find(datastring, "A55")) then --L CRS DOWN for i in string.gfind(datastring, "A55") do ipc.control(65662,0) end end ---------------------------------------------------------- --- IAS/mach ------------------------------------- if (string.find(datastring, "B15")) then --IAS/mach UP ipc.control(65896,0) end if (string.find(datastring, "B16")) then --IAS/mach DOWN ipc.control(65897,0) end ---------------------------------------------------------- --- HDG ------------------------------------- if (string.find(datastring, "A57")) then --HDG UP for i in string.gfind(datastring, "A57") do ipc.control(65879,0) end end if (string.find(datastring, "A58")) then --HDG DOWN for i in string.gfind(datastring, "A58") do ipc.control(65880,0) end end ---------------------------------------------------------- --- ALTITUDE ------------------------------------- if (string.find(datastring, "B11")) then --ALT UP ipc.control(65892,0) end if (string.find(datastring, "B12")) then --ALT DOWN ipc.control(65893,0) end ---------------------------------------------------------- --- VERTICLE SPEED ------------------------------------- if (string.find(datastring, "B13")) then --V/SPEED UP ipc.control(65894,0) end if (string.find(datastring, "B14")) then --V/SPEED DOWN ipc.control(65895,0) end ---- Transponder ------------------------------------- if (string.find(datastring, "A34")) then ipc.control(65651,0) end if (string.find(datastring, "A35")) then ipc.control(65652,0) end if (string.find(datastring, "A36")) then ipc.control(65653,0) end if (string.find(datastring, "A37")) then ipc.control(65654,0) end if (string.find(datastring, "A38")) then ipc.control(66455,0) end if (string.find(datastring, "A39")) then ipc.control(66456,0) end if (string.find(datastring, "A40")) then ipc.control(66457,0) end if (string.find(datastring, "A41")) then ipc.control(66458,0) end ---- COM1 ------------------------------------- if (string.find(datastring, "A02")) then ipc.control(65637,0) end if (string.find(datastring, "A01")) then ipc.control(65636,0) end if (string.find(datastring, "A04")) then ipc.control(65639,0) end if (string.find(datastring, "A03")) then ipc.control(65638,0) end ---- NAV1 ------------------------------------- if (string.find(datastring, "A14")) then ipc.control(65641,0) end if (string.find(datastring, "A13")) then ipc.control(65640,0) end if (string.find(datastring, "A16")) then ipc.control(65643,0) end if (string.find(datastring, "A15")) then ipc.control(65642,0) end ---- COM2 ------------------------------------- if (string.find(datastring, "A08")) then ipc.control(66437,0) end if (string.find(datastring, "A07")) then ipc.control(66436,0) end if (string.find(datastring, "A10")) then ipc.control(66440,0) end if (string.find(datastring, "A09")) then ipc.control(66438,0) end ---- NAV2 ------------------------------------- if (string.find(datastring, "A20")) then ipc.control(65645,0) end if (string.find(datastring, "A19")) then ipc.control(65644,0) end if (string.find(datastring, "A22")) then ipc.control(65647,0) end if (string.find(datastring, "A21")) then ipc.control(65646,0) end ---- ADF 1 ------------------------------------- if (string.find(datastring, "A25")) then ipc.control(65648,0) end if (string.find(datastring, "A29")) then ipc.control(65666,0) end if (string.find(datastring, "A26")) then ipc.control(65649,0) end if (string.find(datastring, "A30")) then ipc.control(65667,0) end if (string.find(datastring, "A27")) then ipc.control(65650,0) end if (string.find(datastring, "A31")) then ipc.control(65668,0) end if (string.find(datastring, "A28")) then ipc.control(66454,0) end if (string.find(datastring, "A32")) then ipc.control(66453,0) end ---- Freq Swap ------------------------------------- if (string.find(datastring, "A06")) then --com1 ipc.control(66372,0) end if (string.find(datastring, "A12")) then --com2 ipc.control(66444,0) end if (string.find(datastring, "A18")) then --nav1 ipc.control(66448,0) end if (string.find(datastring, "A24")) then --nav2 ipc.control(66452,0) end --ipc.sleep(serial_wait) end -- function end -------------------------------------------------------- --- Displays ------------------------------------------- -------------------------------------------------------- function call_crs_l (offset, value) if (string.len(value) == 2) then value = "0"..value end if (string.len(value) == 1) then value = "00"..value end com.write (Arduino_Com_Port, "=e"..value) end ------------------------- function call_crs_r (offset, value) if (string.len(value) == 2) then value = "0"..value end if (string.len(value) == 1) then value = "00"..value end com.write (Arduino_Com_Port, "=e"..value) end ------------------------- function call_iasmach (offset, value) --ipc.display(value) if (string.len(value) == 2) then value = "0"..value end if (string.len(value) == 1) then value = "00"..value end com.write (Arduino_Com_Port, "=f"..value) end ------------------------- function call_heading (offset, value) value = (value/65536)*360 value = tonumber(string.format("%.0f", value)) --ipc.display(value) --hdg = value if (string.len(value) == 2) then value = "0"..value end if (string.len(value) == 1) then value = "00"..value end com.write (Arduino_Com_Port, "=d"..value) end ------------------------- function call_altitude (offset, value) value = (value/65536)*feet_per_meter --ipc.display(value) value = tonumber(string.format("%.0f", value)) --ipc.display(value) if (string.len(value) == 4) then value = "0"..value end if (string.len(value) == 3) then value = "00"..value end com.write (Arduino_Com_Port, "=b"..value) end ------------------------- function call_vertical (offset, value) if (value > 9900) then value = 65536 - value if (string.len(value) == 3 ) then value = "-0"..value elseif (string.len(value) == 4 ) then value = "-"..value end else if (string.len(value) == 3 and value > 0) then value = "+0"..value elseif (string.len(value) == 4 and value > 0) then value = "+"..value end end if (value == 0) then value = "+0000" end --ipc.display(value) com.write (Arduino_Com_Port, "=c"..value) end ----------------------------------------------- function call_com1_main (offset, value) value = string.format("%04x", value) value = "1"..value:sub(1,2).."."..value:sub(3,4) --ipc.display(value) com.write (Arduino_Com_Port, "=A"..value) end function call_com1_stdby (offset, value) value = string.format("%04x", value) value = "1"..value:sub(1,2).."."..value:sub(3,4) --ipc.display("Com1 Stdby called",2) com.write (Arduino_Com_Port, "=B"..value) end function call_nav1_main (offset, value) value = string.format("%04x", value) value = "1"..value:sub(1,2).."."..value:sub(3,4) --ipc.display(value) com.write (Arduino_Com_Port, "=E"..value) end function call_nav1_stdby (offset, value) value = string.format("%04x", value) value = "1"..value:sub(1,2).."."..value:sub(3,4) --ipc.display(value) com.write (Arduino_Com_Port, "=F"..value) end function call_com2_main (offset, value) value = string.format("%04x", value) value = "1"..value:sub(1,2).."."..value:sub(3,4) --ipc.display(value) com.write (Arduino_Com_Port, "=C"..value) end function call_com2_stdby (offset, value) value = string.format("%04x", value) value = "1"..value:sub(1,2).."."..value:sub(3,4) --ipc.display(value) com.write (Arduino_Com_Port, "=D"..value) end function call_nav2_main (offset, value) value = string.format("%04x", value) value = "1"..value:sub(1,2).."."..value:sub(3,4) --ipc.display(value) com.write (Arduino_Com_Port, "=G"..value) end function call_nav2_stdby (offset, value) value = string.format("%04x", value) value = "1"..value:sub(1,2).."."..value:sub(3,4) --ipc.display(value) com.write (Arduino_Com_Port, "=H"..value) end function call_xpndr (offset, value) value = string.format("%04x", value) --ipc.display(value) com.write (Arduino_Com_Port, "=J"..value) end function call_dme1 (offset, value) value = string.format("%04d", value) value = value:sub(1,3).."."..value:sub(4,4) --ipc.display(value) com.write (Arduino_Com_Port, "=K"..value) end function call_dme2 (offset, value) value = string.format("%04d", value) --ipc.display(value) com.write (Arduino_Com_Port, "=L"..value) end function call_adf1 (offset, value) value = string.format("%04x", value) value_ext = ipc.readUW(0x0356) value_ext = string.format("%04x", value_ext) value = value_ext:sub(2,2)..value:sub(2,4).."."..value_ext:sub(4,4) --ipc.display(value) com.write (Arduino_Com_Port, "=I"..value) end function call_adf1_ext (offset, value_ext) value = ipc.readUW(0x034C) value = string.format("%04x", value) value_ext = string.format("%04x", value_ext) value = value_ext:sub(2,2)..value:sub(2,4).."."..value_ext:sub(4,4) --ipc.display(value) com.write (Arduino_Com_Port, "=I"..value) end ----------------------------------------------------- --- EVENTS ------------------------------------------ ----------------------------------------------------- event.com(Arduino_Com_Port, 50,1, "Arduino_Data") event.offset (0x0c5e, "UW", "call_crs_l") -- autopilot crs left side event.offset (0x0C4E, "UW", "call_crs_r") -- autopilot crs right side event.offset (0x07E2, "UW", "call_iasmach") -- autopilot IAS/mach event.offset (0x07CC, "UW", "call_heading") -- autopilot heading event.offset (0x07D4, "UD", "call_altitude") -- autopilot altitude event.offset (0x07F2, "UW", "call_vertical") -- autopilot vertical speed --------- event.offset (0x034e, "UW", "call_com1_main") -- com one main event.offset (0x311a, "UW", "call_com1_stdby") -- com one standby event.offset (0x0350, "UW", "call_nav1_main") -- nav one main event.offset (0x311e, "UW", "call_nav1_stdby") -- nav 1 standby event.offset (0x3118, "UW", "call_com2_main") -- com two event.offset (0x311c, "UW", "call_com2_stdby") -- com two standby event.offset (0x0352, "UW", "call_nav2_main") -- nav two main event.offset (0x3120, "UW", "call_nav2_stdby") -- nav two standby event.offset (0x0354, "UW", "call_xpndr") -- transponder event.offset (0x0300, "UW", "call_dme1") -- VOR1 DME distance event.offset (0x0306, "UW", "call_dme2") -- VOR2 DME distance event.offset (0x034c, "UW", "call_adf1") -- ADF one frequency main event.offset (0x0356, "UW", "call_adf1_ext") -- ADF one frequency main --event.offset (0x02D4, "UW", "call_radio") -- ADF two main --event.offset (0x0304, "UW", "call_radio_DME") -- VOR1 DME time --event.offset (0x030a, "UW", "call_radio_DME") -- VOR2 DME time ---------
  4. Pete, Background: I have a home built Radio based on Arduino that uses a LUA script thru FSUIPC. The LUA script worked fine with P3Dv3 FSUIPC4. The LUA script sends and receives data to the Arduino based Radio. My Problem: "event.com" will not call its function when the script is used with P3Dv4 FSUIPC5v102. The "event.offset" and "event.timer" function calls seem to work fine. For those may be experiencing the same issue: I was able to make the script functional by using "event.timer" as a work around. I renamed the previous function block that I used for "event.com". I have "event.timer" call it every 50ms and do a "com.read" at the top of the function to check for incoming data from the Arduino. ~Fess
×

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.