Adaptateur d'encodeur sur carte IO

Cartes diverses / Add-On pour réalisation de cockpits / Interfaces variées

Re: Adaptateur d'encodeur sur carte IO

Messagede jacquesvde » Mar 20 Déc 2016 19:10

bravoaffiche
Jacques V cligneoeil
Avatar de l’utilisateur
jacquesvde
 
Messages: 1226
Inscription: 20/04/09
Localisation: Courcelles Belgique

Re: Adaptateur d'encodeur sur carte IO

Messagede JacquesZ » Mar 20 Déc 2016 20:29

PILRIDER a écrit:En fait, je suis obligé d'agrandir l'HSI car autrement les boutons seraient dans la lunette du tableau de bord.

JC


Ben si c'est QUE ça, je vais te faire une version SANS bezel ni bouton extérieur!
Je retrouve le code et je te fais passer ça.

Jacques
Dernière édition par JacquesZ le Mar 20 Déc 2016 20:50, édité 1 fois.
Ma chaîne YouTube Tutos sur l’A320 par un Pilote de Ligne: https://youtube.com/channel/UCljftuoKBcgeR-WBgYJpuoA
Avatar de l’utilisateur
JacquesZ
 
Messages: 2848
Inscription: 24/11/10

Re: Adaptateur d'encodeur sur carte IO

Messagede JacquesZ » Mar 20 Déc 2016 20:46

Et hop, version spéciale du HSI pour toi!

Image

Il suffit juste de remplacer le script logic.lua existant par celui-ci.
1-Aller dans l'onglet Create/Edit d'AM
2- Choisir le Generic Bendix/King KI525A HSI
3- Cliquer sur l'icône Script pour afficher le code de l'instrument
4- Copier et remplacer le code existant par le code ci-joint.

utilisation: il suffit juste de mettre "false" dans la section VARIABLES du script modifié pour ne pas afficher les bezels, vis, fond, etc...
display_frame=false -- displays the rectangular frame
display_screws=false -- displays the mounting screws
display_bezel=false -- displays the external bezel
display_dials=false -- displays the dials

Jacques

Code: Tout sélectionner
---------------------------------------------------------------
-- BENDIX/KING CROWN SILVER KING SERIE                       --
-- KI525A HSI (ELECTRICAL)                                   --
-- version 1.3   
-- (fixed loc Scale position at startup)       
-- (new variable to display or not the Bezel)             
-- J. ZAHAR 04/2016                                          --
-- based on original by MacnFly (Thanks Mac!)                --
-- Modeled using the user manual of the real instrument      --
-- includes failure flags when power OFF                     --
-- FSX and Xplane version 
---------------------------------------------------------------

---------------------------------------------------------------
-- DISPLAY VARIABLES SECTION                                 --
-- Set to True or False according to taste                   --
---------------------------------------------------------------
display_frame=false -- displays the rectangular frame
display_screws=false -- displays the mounting screws
display_bezel=false -- displays the external bezel
display_dials=false -- displays the dials
FSX_HSI_source=0 -- NAV source for the HSI (FSX only!)--> 0:NAV1, 1:NAV2, 2:GPS (no GS)
gyro_spinup_duration=15000 -- time (in msec) before elec gyro is at full speed when master switch has been switched ON (default 10-15  sec)
---------------------------------------------------------------
-- END OF DISPLAY VARIABLES SECTION                          --
-- DO NOT MODIFIY CODE PAST THIS POINT !!!                   --
---------------------------------------------------------------
-- Global variables
is_failed=false
gbl_cur_hdef=0
gbl_cur_vdef=119
gbl_cur_bearing=0
gbl_target_hdef=0
gbl_target_vdef=20
gbl_target_bearing=0
gbl_factor1= 0.25
gbl_factor2= 0.25
gbl_factor3= 0.3
-- DIAL FUNCTIONS --
function new_obs(obsset)

   if obsset == -1 then
   if FSX_HSI_source==0 then --NAV1
      xpl_command("sim/radios/obs1_down")
      fsx_event("VOR1_OBI_DEC")
      end
   if FSX_HSI_source==1 then -- NAV2
      xpl_command("sim/radios/obs2_down")
      fsx_event("VOR2_OBI_DEC")
      end
   if FSX_HSI_source==2 then -- GPS
      xpl_command("sim/radios/obs1_down")
      fsx_event("VOR1_OBI_DEC")
      end
   elseif obsset == 1 then
   if FSX_HSI_source==0 then
      xpl_command("sim/radios/obs1_up")
      fsx_event("VOR1_OBI_INC")
      end
   if FSX_HSI_source==1 then
      xpl_command("sim/radios/obs2_up")
      fsx_event("VOR2_OBI_INC")
      end
   if FSX_HSI_source==2 then
      xpl_command("sim/radios/obs1_up")
      fsx_event("VOR1_OBI_INC")
      end
   end
end

function new_heading(headingset)

   if headingset == -1 then
      xpl_command("sim/autopilot/heading_down")
      fsx_event("HEADING_BUG_DEC")
   elseif headingset == 1 then
      xpl_command("sim/autopilot/heading_up")
      fsx_event("HEADING_BUG_INC")
      end
   
end
-- GRAPHICS --
if display_frame==true then
   img_add_fullscreen("HSI_background frame.png")
end
img_add_fullscreen("HSI_background.png")
img_rose = img_add_fullscreen("HSI_compas rose.png")
img_bug = img_add_fullscreen("HSI_headingbug.png")
img_neddle = img_add_fullscreen("HSI_Needle arrow.png")
img_center_to = img_add_fullscreen("HSI_to flag.png")
img_center_from = img_add_fullscreen("HSI_from flag.png")
img_center = img_add_fullscreen("HSI_loc scale.png")
img_center_neddle = img_add_fullscreen("HSI_Needle center.png")
img_hdg_flag = img_add_fullscreen("HSI_flag HDG right.png")
img_nav_flag = img_add_fullscreen("HSI_flag NAV left.png")
img_add_fullscreen("HSI_inner bezel.png")
img_glideslope_markers = img_add_fullscreen("HSI_ILS bugs.png")--,0,-100,512,512)
img_add_fullscreen("HSI_inner bezel2.png")
if display_screws==true then
   img_add_fullscreen("HSI_Bezel ext.png")
end
   if display_screws==true then
   img_add_fullscreen("HSI_screws.png")
end
--img_add_fullscreen("HSIguidelines.png")--guidelines (used for debugging)
-- Default visibility --
visible(img_hdg_flag, false)
visible(img_nav_flag, false)

-- FUNCTIONS --
function removes_HDG_flag() -- removes NAV flag after gyro_spinup_duration
visible(img_hdg_flag, false)
end

function PT_hsi(heading,source,crs,nav1hdef,nav2hdef,gpshdef,nav1vdef,nav2vdef,
                gpsvdef,nav1display,nav2display, glideslopeflag, headingbug, nav1_fromto, nav2_fromto, gps_fromto, failed,has_power)
-- HDG flag
if (failed==1 or has_power==0) then --partial panel failure or master switch is off or main electrical bus is off
      visible(img_hdg_flag,true)-- show HDG flag immediately
      visible(img_nav_flag, true )
      is_failed=true --instrument is off
   else -- power is on
   if is_failed==true then -- gauge powering up? we start a timer to let the gyro spinning before removing the flag
      running=timer_running(gyro_startup_timer) -- if timer is already started do nothing
      if running==false then
         gyro_startup_timer=timer_start(gyro_spinup_duration,nil,removes_HDG_flag)--wait for gyro_spinup_duration before removing flag
      end
      is_failed=false
   end
    -- gbl_cur_bearing=gbl_target_bearing
end
if is_failed==true then --instrument is powered off
   nav1display=0
   nav2display=0
   nav1hdef=0
   nav1vdef=0
   nav1_fromto=0
   nav2hdef=0
   nav2vdef=0
   nav2_fromto=0
   gpshdef=0
   gpsvdef=0
   gps_fromto=0
   glideslopeflag=0
    gbl_target_bearing=gbl_cur_bearing
end--if is_failed
-- global variables setting before calling of timer_callback()
   gbl_target_bearing=-heading+crs
   gbl_target_bug=headingbug   
   -- Rotate compas card
   img_rotate(img_rose, -heading)
   -- Rotate heading bug
   img_rotate(img_bug, headingbug - heading)
   img_rotate(img_center, gbl_target_bearing)
   img_rotate(img_center_to, gbl_target_bearing)
   img_rotate(img_center_from, gbl_target_bearing)
   

if source == 0 then -- NAV1
   gbl_target_hdef=nav1hdef
   gbl_target_vdef=nav1vdef
end   

if source == 1 then -- NAV2
    gbl_target_hdef=nav2hdef
   gbl_target_vdef=nav2vdef
end
   
if source == 2 then -- GPS
    gbl_target_hdef=gpshdef
   gbl_target_vdef=gpsvdef
end
   -- flags to/from
   to = ((source == 0 and nav1_fromto == 1) or (source == 1 and nav2_fromto == 1) or (source == 2 and gps_fromto == 1))
   from = ((source == 0 and nav1_fromto == 2) or (source == 1 and nav2_fromto == 2) or (source == 2 and gps_fromto == 2))
   visible(img_center_to, (to == true and glideslopeflag==0))
   visible(img_center_from, (from == true and glideslopeflag==0))

   -- GS bugs
   if glideslopeflag == 1 then -- GS signal received
   --visible(img_glideslope_markers, true)
   --gbl_target_vdef=-2
   else
   --visible(img_glideslope_markers, false)
   gbl_target_vdef=-3.5 -- sends the bugs out of view
   end

-- NAV flag when no valid VOR or localizer
   visible(img_nav_flag, (source == 0 and nav1display == 0) or (source == 1 and nav2display == 0))
   

   
end

-- function to slowly move CDI center needle to current CDI deviation --
-- Thanks Ralph and Corjan for the trick!                             --
 function timer_callback()
    -- CDI needle
   img_rotate(img_neddle, gbl_cur_bearing)
    img_rotate(img_center_neddle, gbl_cur_bearing)
   -- Calculation of center CDI needle position in pixels according to current needle bearing (actually bearing=course-heading)
   navhdef = var_cap(gbl_cur_hdef, -4, 2.5) --horizontal deflection of CDI needle in ° (-2.5,2.5°)
    dh = navhdef  * math.cos((gbl_cur_bearing)*math.pi/180)* 41 -- 41 : distance in pixels between 2 dots
    dv = navhdef * math.sin((gbl_cur_bearing)*math.pi/180)* 41
     --Move center CDI needle
   move(img_center_neddle, dh, dv, nil, nil)
   --Move GS needle
   navvdef = var_cap(gbl_cur_vdef, -4, 4)--vertical deflection of GS bugs in °
   --dm = (navvdef * 41)-119 -- 40 : distance in pixels between 2 vertical dots
   dm = (navvdef * 41) -- 40 : distance in pixels between 2 vertical dots
    move(img_glideslope_markers, nil, dm , nil, nil)
   
    --Calculation of current CDI deflection in ° with respect to target deflection position
   -- currrent position is decreased/increased by "gbl_factor" every function call until reaching target position within 0.001 degrees
    raw_diff = (gbl_target_hdef - gbl_cur_hdef) -- compute the delta of position
    diff = fif(raw_diff,raw_diff,(raw_diff)*-1) -- chooses the sign of delta
    gbl_cur_hdef = fif(math.abs(diff) < 0.001, gbl_target_hdef, gbl_cur_hdef + (diff * gbl_factor1) )-- chooses the greatest value
     --Calculation of current GS deflection in ° with respect to target deflection position
   raw_diff = (gbl_target_vdef - gbl_cur_vdef)
    diff = fif(raw_diff,raw_diff, (raw_diff) * -1)
    gbl_cur_vdef = fif(math.abs(diff) < 0.001, gbl_target_vdef, gbl_cur_vdef + (diff * gbl_factor2) )
   -------------
   gbl_cur_bearing=gbl_target_bearing
   -- calculation for rotating needle (unused)
    -- raw_diff = (360 + gbl_target_heading - gbl_cur_heading) %360
    -- diff = fif(raw_diff < 180, raw_diff, (360 - raw_diff) * -1)
    -- gbl_cur_heading = fif(math.abs(diff) < 0.001, gbl_target_heading, gbl_cur_heading + (diff * gbl_factor3) )
 end

 -- function to adapt FSX parameters to Xplane function
function PT_hsi_FSX(heading, obs, vertical, horizontal, nav_fromto, has_glide,  headingbug,  partial_panel, master)
   if (master==false ) then
         has_bus_power=0
      else
         has_bus_power=1
      end
      if (partial_panel==1) then
         fail=1
      else
         fail=0
      end
      
   glideslope = fif(has_glide, 1, 0)   --from FSX boolean to integer (Xplane style)
   vertical = 2 / 119 * vertical -- GS range from -119 to + 119 in FSX
   horizontal = 2 / 127 * horizontal -- CDI range from -127 to + 127 in FSX

   PT_hsi(heading, 0, obs, horizontal, 0, 0, vertical, 0, 0, nav_fromto, 0, glideslope, headingbug, nav_fromto, 0, 0, fail,has_bus_power)
--function PT_hsi(heading,source,crs,nav1hdef,nav2hdef,gpshdef,nav1vdef,nav2vdef,gpsvdef,nav1display,nav2display, glideslopeflag, headingbug, nav1_fromto, nav2_fromto, gps_fromto, fail,has_bus_power)
end

-- DIAL ADD --
if display_dials==true then
   dial_OBS = dial_add("dialhsi.png", 18, 368, 85, 85, new_obs)
   dial_BUG = dial_add("headingbug.png", 409, 368, 85, 85, new_heading)

   dial_click_rotate(dial_OBS, 5)
   dial_click_rotate(dial_BUG, 5)
end
if FSX_HSI_source==0 then -- NAV1 (default)
fsx_variable_subscribe("HEADING INDICATOR", "Degrees",--"PLANE HEADING DEGREES GYRO", "Degrees",
                  "NAV OBS:1", "Degrees",
                  "NAV GSI:1", "Number",
                  "NAV CDI:1", "Number",                   
                  "NAV TOFROM:1", "Enum",    
                  "NAV HAS GLIDE SLOPE:1", "Bool",
                  "AUTOPILOT HEADING LOCK DIR", "Degrees",
                  "PARTIAL PANEL ELECTRICAL", "Enum",-- failure of electrical bus
                  "ELECTRICAL MASTER BATTERY","Bool",PT_hsi_FSX)-- master switch
end
if FSX_HSI_source==1 then -- NAV2
fsx_variable_subscribe("HEADING INDICATOR", "Degrees",--"PLANE HEADING DEGREES GYRO", "Degrees",
                  "NAV OBS:2", "Degrees",
                  "NAV GSI:2", "Number",
                  "NAV CDI:2", "Number",                   
                  "NAV TOFROM:2", "Enum",    
                  "NAV HAS GLIDE SLOPE:2", "Bool",
                  "AUTOPILOT HEADING LOCK DIR", "Degrees",
                  "PARTIAL PANEL ELECTRICAL", "Enum",-- failure of electrical bus
                  "ELECTRICAL MASTER BATTERY","Bool",PT_hsi_FSX)-- master switch
end
if FSX_HSI_source==2 then -- GPS
fsx_variable_subscribe("HEADING INDICATOR", "Degrees",--"PLANE HEADING DEGREES GYRO", "Degrees",
                  "NAV OBS:1", "Degrees",
                  "HSI GSI NEEDLE", "Number",
                  "HSI CDI NEEDLE", "Number",                   
                  "HSI TF FLAGS", "Enum",    
                  "HSI GSI NEEDLE VALID", "Bool",
                  "AUTOPILOT HEADING LOCK DIR", "Degrees",
                  "PARTIAL PANEL ELECTRICAL", "Enum",-- failure of electrical bus
                  "ELECTRICAL MASTER BATTERY","Bool",PT_hsi_FSX)-- master switch
end
xpl_dataref_subscribe("sim/cockpit2/gauges/indicators/heading_electric_deg_mag_pilot", "FLOAT",-- electrical, not vacuum
                 "sim/cockpit2/radios/actuators/HSI_source_select_pilot", "INT",
                 "sim/cockpit2/radios/actuators/hsi_obs_deg_mag_pilot", "FLOAT",
                 "sim/cockpit2/radios/indicators/nav1_hdef_dots_pilot", "FLOAT",
                 "sim/cockpit2/radios/indicators/nav2_hdef_dots_pilot", "FLOAT",
                 "sim/cockpit2/radios/indicators/gps_hdef_dots_pilot", "FLOAT",
                 "sim/cockpit2/radios/indicators/nav1_vdef_dots_pilot", "FLOAT",
                 "sim/cockpit2/radios/indicators/nav2_vdef_dots_pilot", "FLOAT",
                 "sim/cockpit2/radios/indicators/gps_vdef_dots_pilot", "FLOAT",
                 "sim/cockpit2/radios/indicators/nav1_display_horizontal", "INT",
                 "sim/cockpit2/radios/indicators/nav2_display_horizontal", "INT",
                 "sim/cockpit2/radios/indicators/hsi_display_horizontal_pilot", "INT",
                 "sim/cockpit2/autopilot/heading_dial_deg_mag_pilot", "FLOAT",
                 "sim/cockpit/radios/nav1_fromto", "INT",
                 "sim/cockpit/radios/nav2_fromto", "INT",
                 "sim/cockpit/radios/gps_fromto", "INT",
                 "sim/operations/failures/rel_esys","INT", -- failure of main bus
                 "sim/cockpit/electrical/battery_on", "INT", PT_hsi) -- master switch on
                
 -- Timers
 -- Thanks Ralph and Corjan !--
tmr_update = timer_start(0, 50,timer_callback)-- moves the CDI needle every 0.05 second   by calling the timer_callback() function
Ma chaîne YouTube Tutos sur l’A320 par un Pilote de Ligne: https://youtube.com/channel/UCljftuoKBcgeR-WBgYJpuoA
Avatar de l’utilisateur
JacquesZ
 
Messages: 2848
Inscription: 24/11/10

Adaptateur d'encodeur sur carte IO

Messagede JC67 » Mer 21 Déc 2016 15:17

Merci.
j'ai réalisé ta modification et ça fonctionne très bien.
J'adopte ton HSI.
JacquesZ a écrit:Et hop, version spéciale du HSI pour toi!
Windows 11 Professionnel
i9-12900KF
Asus ROG STRIX Z690-F GAMING WIFI
KF556C40-32 Bank 0 (32 Go)
NVIDIA RTX 4090
KINGSTON SNVS2000G SCSI (1,82 To)
Avatar de l’utilisateur
JC67
 
Messages: 130
Inscription: 16/03/14
Localisation: AY CHAMPAGNE

Re: Adaptateur d'encodeur sur carte IO

Messagede PapaLima » Lun 18 Déc 2017 01:13

Bonsoir JC67

Je me lance dans un MIP pour mon TwinOtter dans la même idée que toi : Ecran plat pour des gauges AirManager avec une façade et des bezels encodeurs plats. On ne change pas une équipe qui gagne, hein?

Ma question concerne le perçage des trous des gauges sur la façade. Tu as utilisé une scie cloche ? Il y en avait au bon diamètres (80mm et 40mm) ? Je compte faire un essai de placement des trous avec un CTP de 5mm avant de passer sur une façade ALU pour gagner en épaisseur.

Bons vols
Philippe
Avatar de l’utilisateur
PapaLima
 
Messages: 814
Inscription: 14/04/16
Localisation: LFPG

Adaptateur d'encodeur sur carte IO

Messagede JC67 » Jeu 21 Déc 2017 10:32

Bonjour,
Après de nombreux essais infructueux j'ai finalement opté pour la solution Schaeffer.
Tu peux y concevoir le MIP de ton choix.
https://www.schaeffer-ag.de/fr/designer_de_faces_avant/le_logiciel/
Pour les encadrements, je les ai fait réaliser par Fabien.
Idem pour les encodeurs.

Actuellement, j'ai remisé dans un coin cet ensemble car je m'oriente vers du multi-écrans tactiles.
La solutions multi-écrans tactiles permet d'avoir la possibilité de changer d'avion sans être restreint par les périphériques physiques.
C'est moins esthétique , mais plus économique et ça répond à mon souhait d'avoir un simu générique.

@+
JC
Windows 11 Professionnel
i9-12900KF
Asus ROG STRIX Z690-F GAMING WIFI
KF556C40-32 Bank 0 (32 Go)
NVIDIA RTX 4090
KINGSTON SNVS2000G SCSI (1,82 To)
Avatar de l’utilisateur
JC67
 
Messages: 130
Inscription: 16/03/14
Localisation: AY CHAMPAGNE

Re: Adaptateur d'encodeur sur carte IO

Messagede JacquesZ » Jeu 21 Déc 2017 14:06

Tu peux aussi prévoir des façades modulables en fonction de l’appareil Utilisé, ça peut rajouter au réalisme.

Jacques
Ma chaîne YouTube Tutos sur l’A320 par un Pilote de Ligne: https://youtube.com/channel/UCljftuoKBcgeR-WBgYJpuoA
Avatar de l’utilisateur
JacquesZ
 
Messages: 2848
Inscription: 24/11/10

Re: Adaptateur d'encodeur sur carte IO

Messagede PapaLima » Jeu 21 Déc 2017 14:21

Merci JC

J'ai suivi ton post concernant les encodeurs plats et les bezels, je passe aussi par Fab chouettedoights

Ton idée écran tactile pour du générique se comprend aussi.
Mais comme le souligne Jacques prévoir une façade par avion pour rajouter de la 3D serait un bon compromis.

Bonnes fêtes
Avatar de l’utilisateur
PapaLima
 
Messages: 814
Inscription: 14/04/16
Localisation: LFPG

Re: Adaptateur d'encodeur sur carte IO

Messagede PapaLima » Ven 22 Déc 2017 17:20

@JC,

Tiens une solution hybride publiée par Russ aujourd'hui : écran tactile avec AirManager relié avec une Arduino pour piloter un bouton physique qui permet de faire bouger tous les boutons virtuels.

On touche le bouton que l'on veut faire bouger à l'écran puis on tourne le bouton physique !

Air Manager Arduino All-In-One Knob

Pas bête pour un simu générique.
Avatar de l’utilisateur
PapaLima
 
Messages: 814
Inscription: 14/04/16
Localisation: LFPG

Adaptateur d'encodeur sur carte IO

Messagede JC67 » Sam 23 Déc 2017 18:34

En effet.
Russ Barlow est une grande source d'inspiration.
Je regarde toujours avec attention ses solutions qui sont pertinentes pour mon projet.
Joyeux Noël à tous.
@+
JC
Windows 11 Professionnel
i9-12900KF
Asus ROG STRIX Z690-F GAMING WIFI
KF556C40-32 Bank 0 (32 Go)
NVIDIA RTX 4090
KINGSTON SNVS2000G SCSI (1,82 To)
Avatar de l’utilisateur
JC67
 
Messages: 130
Inscription: 16/03/14
Localisation: AY CHAMPAGNE

PrécédenteSuivante

Retourner vers Vos circuits électroniques fait maisons et PIC





Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 3 invités