OBT ~ Escadrille virtuelle
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.

OBT ~ Escadrille virtuelle


 
PortailAccueilRechercherDernières imagesS'enregistrerConnexion
Qui est en ligne ?
Il y a en tout 15 utilisateurs en ligne :: 0 Enregistré, 0 Invisible et 15 Invités

Aucun

Le record du nombre d'utilisateurs en ligne est de 293 le Jeu 7 Nov - 14:08
ECOLE DE CHASSE
TS3 OBT
Novembre 2024
LunMarMerJeuVenSamDim
    123
45678910
11121314151617
18192021222324
252627282930 
CalendrierCalendrier
-55%
Le deal à ne pas rater :
Friteuse sans huile – PHILIPS – Airfryer HD9200/90 Série 3000
49.99 € 109.99 €
Voir le deal

Répondre au sujet
 

 PANEL BF109

Aller en bas 
2 participants
AuteurMessage
LFDM-Carleo

LFDM-Carleo


Messages : 319
Date d'inscription : 08/06/2017
Age : 46
Localisation : Toulouse

PANEL BF109 Empty
MessageSujet: PANEL BF109   PANEL BF109 Icon_minitimeSam 14 Mar - 23:45

Description de la méthodologies pour creer un panel d'afficheur Segment7 avec DCS BIOS et une carte Arduino

Matériel et logiciel nécessaire
1 - un afficheur Segment7 Max7219
https://i.ytimg.com/vi/VgNIkGzxGAU/maxresdefault.jpg

Pourquoi mon afficheur Segment7 doit avoir une puce Max7219
Un afficheur segment7 est composer de LED, 7 exactement + 1 pour le point en bas a droite. Pour gérer 1 LED il faut 1 connexion pour le +5V, une pour le - masse et 1 pour le signal
Ce qui veut dire qu'il faut pour un afficheur, 24 connections ça fait beaucoup de fils surtout quand on veut par exemple afficher une altitude et qu'il va falloir au moins 5 afficheurs soit 120 connections.
Heureusement la puce Max7219 va gérer pour nous toutes ces connexions sur seulement 5 fils, mieux on peux empiler les afficheurs les uns derrières les autres, en série jusqu’à 8 afficheurs de 8 segment7 LED
un lien vers un tres article vous detayant le pourquoi du comment www.carnetdumaker.net/articles/utiliser-...rte-arduino-genuino/


2 - Une carte ARDUINO
Ma préférence va pour la Mega 2560 qui offre un grand nombre de connexion, mais le modèle UNO peut très bien faire l'affaire pour commencer
Je vous invites a acheter un modèle certifié et non pas une copie chinoise. Parce que c'est mieux de faire marcher une boite local et ensuite vous n'aurez pas de problème de compatibilité parce que vous aurez une puce authentique et pas une copie presque pareil, mais pas exactement
PANEL BF109 Arduino-mega-r3-atmega2560-assemble

Pour faire vos tests et essais de montage je vous invite a acheter ces 2 objets qui vous faciliterons la vie
www.elegoo.com/product/elegoo-120pcs-multicolored-dupont-wire/
www.elegoo.com/product/elegoo-3pcs-mb-10...otype-pcb-board-kit/

3 - Le Logiciel ARDUINO IDE
Téléchargeable a cette adresse www.arduino.cc/en/main/software
Laisser vous guider par l'installeur

4 -Les librairies ARDUINO LedControl
Téléchargeable depuis l'IDE ARDUINO
Menu Outils / Gerer Les Bibliotheques/ Taper LedControl dans la barre de recherche/et cliquer sur le bouton installer

Les afficheurs coutent environ 10euros plus ou moins
La carte arduino coute environ 30euros plus ou moins
Les câbles et tables de montage de test environ 40 euros plus ou moins
PANEL BF109 8
PANEL BF109 9
PANEL BF109 10
PANEL BF109 11


Et voici le code arduino a injecter

#define DCSBIOS_IRQ_SERIAL
#include
#include
#include




// Module connection pins (Digital Pins)

//pin 51 is connected to the DataIn
//pin 52 is connected to the CLK
//pin 53 is connected to LOAD / CS

//pin 39 is connected to the DataIn
//pin 40 is connected to the CLK
//pin 38 is connected to LOAD / CS

//pin 37 is connected to the DataIn
//pin 36 is connected to the CLK
//pin 35 is connected to LOAD / CS

//pin 34 is connected to the DataIn
//pin 33 is connected to the CLK
//pin 32 is connected to LOAD / CS

//pin 31 is connected to the DataIn
//pin 30 is connected to the CLK
//pin 29 is connected to LOAD / CS

LedControl lc1=LedControl(51,52,53,2); //This creates an instance of a single controller named "lc1" for the first 4 Segment7 display
LedControl lc2=LedControl(39,40,38,2); //This creates an instance of a single controller named "lc1" for the first 4 Segment7 display
LedControl lc3=LedControl(37,36,35,2); //This creates an instance of a single controller named "lc1" for the first 4 Segment7 display
LedControl lc4=LedControl(34,33,32,2); //This creates an instance of a single controller named "lc1" for the first 4 Segment7 display
LedControl lc5=LedControl(31,30,29,2); //This creates an instance of a single controller named "lc1" for the first 4 Segment7 display

// GENERAL REF NOTE BELOW



void onAltitudeValueChange(unsigned int newValuealt) {

newValuealt= (newValuealt*1.30067);


int altunit;
int altdeci;
int altcenti;
int altmilli;
int altdecmilli;

altunit=newValuealt%10;
newValuealt=newValuealt/10;
altdeci=newValuealt%10;
newValuealt=newValuealt/10;
altcenti=newValuealt%10;
newValuealt=newValuealt/10;
altmilli=newValuealt%10;
newValuealt=newValuealt/10;
altdecmilli=newValuealt;

lc1.setDigit(0,4,altdecmilli,false);
lc1.setDigit(0,3,altmilli,false);
lc1.setDigit(0,2,altcenti,false);
lc1.setDigit(0,1,altdeci,false);
lc1.setDigit(0,0,altunit,false);

}
DcsBios::IntegerBuffer altitudeValueBuffer(0x42a0, 0xffff, 0, onAltitudeValueChange);
/////////////////////////////////////////////////////////////////////////////////

void onCompassHeadingValueChange(unsigned int newValuehdg) {
int hdgunit;
int hdgdeci;
int hdgcenti;

hdgunit=newValuehdg%10;
newValuehdg=newValuehdg/10;
hdgdeci=newValuehdg%10;
newValuehdg=newValuehdg/10;
hdgcenti=newValuehdg;

lc2.setDigit(0,2,hdgcenti,false);
lc2.setDigit(0,1,hdgdeci,false);
lc2.setDigit(0,0,hdgunit,true);



}
DcsBios::IntegerBuffer compassHeadingValueBuffer(0x42a6, 0xffff, 0, onCompassHeadingValueChange);

/////////////////////////////////////////////////////////////////////////////////


void onAirspeedValueChange(unsigned int newValuevit) {

newValuevit=(newValuevit*1.3306451);
int vitunit;
int vitdeci;
int vitcenti;
int vitmilli;

vitunit=newValuevit%10;
newValuevit=newValuevit/10;
vitdeci=newValuevit%10;
newValuevit=newValuevit/10;
vitcenti=newValuevit%10;
newValuevit=newValuevit/10;
vitmilli=newValuevit;

lc3.setDigit(0,3,vitmilli,false);
lc3.setDigit(0,2,vitcenti,false);
lc3.setDigit(0,1,vitdeci,false);
lc3.setDigit(0,0,vitunit,false);

}
DcsBios::IntegerBuffer airspeedValueBuffer(0x429e, 0xffff, 0, onAirspeedValueChange);
/////////////////////////////////////////////////////////////////////////////////

void onCoolantTemperatureValueChange(unsigned int newValuetemp1) {
int temp1unit;
int temp1deci;
int temp1centi;
boolean negative;

if(newValuetemp1<0) { negative=true; newValuetemp1=newValuetemp1*-1; }

temp1unit=newValuetemp1%10;
newValuetemp1=newValuetemp1/10;
temp1deci=newValuetemp1%10;
newValuetemp1=newValuetemp1/10;
temp1centi=newValuetemp1;
if(negative) {lc2.setChar(0,3,'-',false);}else{lc2.setChar(0,3,' ',false); }

lc1.setDigit(1,0,temp1unit,false);
lc1.setDigit(1,1,temp1deci,false);
lc1.setDigit(1,2,temp1centi,false);
}
DcsBios::IntegerBuffer coolantTemperatureValueBuffer(0x429a, 0xffff, 0, onCoolantTemperatureValueChange);
/////////////////////////////////////////////////////////////////////////////////


void onOilTemperatureValueChange(unsigned int newValuetemp2) {
int temp2unit;
int temp2deci;
int temp2centi;
boolean negative;

if(newValuetemp2<0) { negative=true; newValuetemp2=newValuetemp2*-1; }

temp2unit=newValuetemp2%10;
newValuetemp2=newValuetemp2/10;
temp2deci=newValuetemp2%10;
newValuetemp2=newValuetemp2/10;
temp2centi=newValuetemp2;
if(negative) {lc2.setChar(0,7,'-',false);}else{lc2.setChar(0,7,' ',false); }

lc1.setDigit(1,4,temp2unit,false);
lc1.setDigit(1,5,temp2deci,false);
lc1.setDigit(1,6,temp2centi,false);
}
DcsBios::IntegerBuffer oilTemperatureValueBuffer(0x4298, 0xffff, 0, onOilTemperatureValueChange);

////////////////////////////////////////////////////////////////////////////
/*
void onVariometerneedleChange(unsigned int newValueVario) {

int variounit;
int variodeci;
int variocenti;
boolean negative;

if(newValueVario > -99 || newValueVario < 99)return;
if(newValueVario<0) {negative=true; newValueVario=newValueVario*-1; }
variounit=newValueVario%10;
newValueVario=newValueVario/10;
variodeci=newValueVario%10;
newValueVario=newValueVario/10;
variocenti=newValueVario;

if(negative) {lc2.setChar(1,3,'-',false);}else{lc2.setChar(1,3,' ',false);}

lc2.setDigit(1,0,variounit,false);
lc2.setDigit(1,1,variodeci,false);
lc2.setDigit(1,2,variocenti,false);
}
DcsBios::IntegerBuffer variometerneedleBuffer(0x4270, 0xffff, 0, onVariometerneedleChange);*/
/////////////////////////////////////////////////////////////////////////////////

void onFuelLevelValueChange(unsigned int newValueFuel) {
if (newValueFuel<100) {
lc2.setChar(1,3,'F',false);
lc2.setRow(1,2,0x1c);
lc2.setChar(1,1,'E',false);
lc2.setChar(1,0,'L',false);
}else{
lc2.setChar(1,3,' ',false);
lc2.setChar(1,2,' ',false);
lc2.setChar(1,1,' ',false);
lc2.setChar(1,0,' ',false);

}
int fuelunit;
int fueldeci;
int fuelcenti;
int fuelmilli;

fuelunit=newValueFuel%10;
newValueFuel=newValueFuel/10;
fueldeci=newValueFuel%10;
newValueFuel=newValueFuel/10;
fuelcenti=newValueFuel%10;
newValueFuel=newValueFuel/10;
fuelmilli=newValueFuel;

lc2.setDigit(1,4,fuelunit,false);
lc2.setDigit(1,5,fueldeci,false);
lc2.setDigit(1,6,fuelcenti,false);
lc2.setDigit(1,7,fuelmilli,false);
}
DcsBios::IntegerBuffer fuelLevelValueBuffer(0x4292, 0xffff, 0, onFuelLevelValueChange);

/////////////////////////////////////////////////////////////////////////////////

void onRadioModeChange(unsigned int Radio) {

lc4.setDigit(0,7,Radio,false);

}
DcsBios::IntegerBuffer radioModeBuffer(0x420e, 0x1800, 11, onRadioModeChange);
/////////////////////////////////////////////////////////////////////////////////
void onTachometerValueChange(unsigned int RPMValue) {
int RPMunit;
int RPMdeci;
int RPMcenti;
int RPMmilli;

RPMunit=RPMValue%10;
RPMValue=RPMValue/10;
RPMdeci=RPMValue%10;
RPMValue=RPMValue/10;
RPMcenti=RPMValue%10;
RPMValue=RPMValue/10;
RPMmilli=RPMValue;

lc3.setDigit(1,4,RPMunit,false);
lc3.setDigit(1,5,RPMdeci,false);
lc3.setDigit(1,6,RPMcenti,false);
lc3.setDigit(1,7,RPMmilli,false);
}
DcsBios::IntegerBuffer tachometerValueBuffer(0x42a2, 0xffff, 0, onTachometerValueChange);
/////////////////////////////////////////////////////////////////////////////////
void onManifoldPressureValueChange(unsigned int ManifoldValue) {
if (ManifoldValue > 10 || ManifoldValue < 57) {ManifoldValue=ManifoldValue/2.95768;} else {ManifoldValue=ManifoldValue/4.0555555;}

int Maniunit;
int Manideci;

Maniunit=ManifoldValue%10;
ManifoldValue=ManifoldValue/10;
Manideci=ManifoldValue;

lc3.setDigit(1,0,Maniunit,false);
lc3.setDigit(1,1,Manideci,true);
}
DcsBios::IntegerBuffer manifoldPressureValueBuffer(0x428c, 0xffff, 0, onManifoldPressureValueChange);
/////////////////////////////////////////////////////////////////////////////////

void onFtZfSwitchChange(unsigned int newValue) {
}
DcsBios::IntegerBuffer ftZfSwitchBuffer(0x420e, 0x2000, 13, onFtZfSwitchChange);
/////////////////////////////////////////////////////////////////////////////////
void onMg1310ShellCounterChange(unsigned int LeftShell) {
LeftShell=LeftShell/128.01;

int LeftShellunit;
int LeftShelldeci;
int LeftShellmilli;

LeftShellunit=LeftShell%10;
LeftShell=LeftShell/10;
LeftShelldeci=LeftShell%10;
LeftShell=LeftShell/10;
LeftShellmilli=LeftShell;

lc4.setDigit(1,0,LeftShellunit,false);
lc4.setDigit(1,1,LeftShelldeci,false);
lc4.setDigit(1,2,LeftShellmilli,false);
}
DcsBios::IntegerBuffer mg1310ShellCounterBuffer(0x4272, 0xffff, 0, onMg1310ShellCounterChange);

/////////////////////////////////////////////////////////////////////////////////
/*
void onMg1311ShellCounterChange(unsigned int RightShell) {
RightShell=RightShell/217.75;

int RightShellunit;
int RightShelldeci;
int RightShellmilli;

RightShellunit=RightShell%10;
RightShell=RightShell/10;
RightShelldeci=RightShell%10;
RightShell=RightShell/10;
RightShellmilli=RightShell;

lc4.setDigit(1,4,RightShellunit,false);
lc4.setDigit(1,5,RightShelldeci,false);
lc4.setDigit(1,6,RightShellmilli,false);
}
DcsBios::IntegerBuffer mg1311ShellCounterBuffer(0x4274, 0xffff, 0, onMg1311ShellCounterChange);
*/
/////////////////////////////////////////////////////////////////////////////////

//Loading LED on event

DcsBios::LED lgDown(0x4204, 0x0800, 2);//Green Led for landing gear down
DcsBios::LED lgUp(0x4204, 0x0400, 3);//Red Led for landing gear up
DcsBios::LED batOnOff(0x4200, 0x1000, 4);//Battery ON/OFF
DcsBios::LED genOnOff(0x4200, 0x0001, 5);//Generator ON/OF
DcsBios::LED fuelOnOff(0x4202, 0x0004, 6);//Fuel Pump ON/OFF
DcsBios::LED ignOnOff(0x4200, 0x0400, 7);//Starting System ON/OFF
DcsBios::LED pitHeatOnOff(0x4200, 0x0004, Cool;// Pitot ON/OFF
DcsBios::LED radioOnOff(0x4200, 0x4000, 9);//Radio ON/OFF
DcsBios::LED wngDrpOnOff(0x4200, 0x0100, 10);//Wing Drop ON/OFF
DcsBios::LED navLightsOnOff(0x4200, 0x0010, 11);//Navligths ON/OFF
DcsBios::LED trgSafety(0x4202, 0x0010, 12);//Trigger safety cover ON/OFF

void onFuelReserveLampChange(unsigned int newValue) {

}
DcsBios::IntegerBuffer fuelReserveLampBuffer(0x428a, 0xffff, 0, onFuelReserveLampChange);
/////////////////////////////////////////////////////////////////////////////////


void setup() {
DcsBios::setup();

// TEST LED SYSYTEM
digitalWrite(2, HIGH);
delay(300);
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
delay(300);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
delay(300);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(300);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
delay(300);
digitalWrite(6, LOW);
digitalWrite(7, HIGH);
delay(300);
digitalWrite(7, LOW);
digitalWrite(8, HIGH);
delay(300);
digitalWrite(8, LOW);
digitalWrite(9, HIGH);
delay(300);
digitalWrite(9, LOW);
digitalWrite(10, HIGH);
delay(300);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
delay(300);
digitalWrite(11, LOW);
digitalWrite(12, HIGH);
delay(300);
digitalWrite(12, LOW);
// MAX7219 INITIALISATION
//This initializes the MAX7219 and gets it ready for use:
//FIRST - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc1.shutdown(0,false); //turn on the display
lc1.setIntensity(0,2);//set the brightness
lc1.clearDisplay(0); //clear the display
lc1.setChar(0,7,'H',false);
lc1.setChar(0,6,'e',false);
lc1.setChar(0,5,'l',false);
lc1.setChar(0,4,'l',false);
lc1.setChar(0,3,'o',false);
lc1.setChar(0,2,'1',true);
delay(300);
lc1.clearDisplay(0); //clear the display

//SECOND - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc1.shutdown(1,false); //turn on the display
lc1.setIntensity(1,2);//set the brightness
lc1.clearDisplay(1); //clear the display
lc1.setChar(1,7,'H',false);
lc1.setChar(1,6,'e',false);
lc1.setChar(1,5,'l',false);
lc1.setChar(1,4,'l',false);
lc1.setChar(1,3,'o',false);
lc1.setChar(1,2,'2',true);
delay(300);
lc1.clearDisplay(1); //clear the display

//THIRD - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc2.shutdown(0,false); //turn on the display
lc2.setIntensity(0,2);//set the brightness
lc2.clearDisplay(0); //clear the display
lc2.setChar(0,7,'H',false);
lc2.setChar(0,6,'e',false);
lc2.setChar(0,5,'l',false);
lc2.setChar(0,4,'l',false);
lc2.setChar(0,3,'o',false);
lc2.setChar(0,2,'3',true);
delay(300);
lc2.clearDisplay(0); //clear the display

//FOURTH - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc2.shutdown(1,false); //turn on the display
lc2.setIntensity(1,2);//set the brightness
lc2.clearDisplay(1); //clear the display
lc2.setChar(1,7,'H',false);
lc2.setChar(1,6,'e',false);
lc2.setChar(1,5,'l',false);
lc2.setChar(1,4,'l',false);
lc2.setChar(1,3,'o',false);
lc2.setChar(1,2,'4',true);
delay(300);
lc2.clearDisplay(1); //clear the display

//FIFTH - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc3.shutdown(0,false); //turn on the display
lc3.setIntensity(0,Cool;//set the brightness
lc3.clearDisplay(0); //clear the display
lc3.setChar(0,7,'H',false);
lc3.setChar(0,6,'e',false);
lc3.setChar(0,5,'l',false);
lc3.setChar(0,4,'l',false);
lc3.setChar(0,3,'o',false);
lc3.setChar(0,2,'5',true);
delay(300);
lc3.clearDisplay(0); //clear the display

//SIXTH - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc3.shutdown(1,false); //turn on the display
lc3.setIntensity(1,Cool;//set the brightness
lc3.clearDisplay(1); //clear the display
lc3.setChar(1,7,'H',false);
lc3.setChar(1,6,'e',false);
lc3.setChar(1,5,'l',false);
lc3.setChar(1,4,'l',false);
lc3.setChar(1,3,'o',false);
lc3.setChar(1,2,'6',true);
delay(300);
lc3.clearDisplay(1); //clear the display

//SEVENTH0 - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc4.shutdown(0,false); //turn on the display
lc4.setIntensity(0,Cool;//set the brightness
lc4.clearDisplay(0); //clear the display
lc4.setChar(0,7,'H',false);
lc4.setChar(0,6,'e',false);
lc4.setChar(0,5,'l',false);
lc4.setChar(0,4,'l',false);
lc4.setChar(0,3,'o',false);
lc4.setChar(0,2,'7',true);
delay(300);
lc4.clearDisplay(0); //clear the display

//HEIGHT - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc4.shutdown(1,false); //turn on the display
lc4.setIntensity(1,Cool;//set the brightness
lc4.clearDisplay(1); //clear the display
lc4.setChar(1,7,'H',false);
lc4.setChar(1,6,'e',false);
lc4.setChar(1,5,'l',false);
lc4.setChar(1,4,'l',false);
lc4.setChar(1,3,'o',false);
lc4.setChar(1,2,'8',true);
delay(300);
lc4.clearDisplay(1); //clear the display


//NINEGHT - 8 DIGIT 7 SEGMENT DISPLAY - MAX7219 INITIALISATION
lc5.shutdown(0,false); //turn on the display
lc5.setIntensity(0,Cool;//set the brightness
lc5.clearDisplay(0); //clear the display
lc5.setChar(0,7,'H',false);
lc5.setChar(0,6,'e',false);
lc5.setChar(0,5,'l',false);
lc5.setChar(0,4,'l',false);
lc5.setChar(0,3,'o',false);
lc5.setChar(0,2,'9',true);
delay(300);
lc5.clearDisplay(0); //clear the display


}

void loop() {
DcsBios::loop();


}


Revenir en haut Aller en bas
http://www.arkenstones.fr
OBT~Acro

OBT~Acro


Messages : 1655
Date d'inscription : 20/06/2008
Age : 52
Localisation : Sancerre, centre du monde

PANEL BF109 Empty
MessageSujet: Re: PANEL BF109   PANEL BF109 Icon_minitimeDim 15 Mar - 1:03

....certes, cela va sans dire...
Et au final c'est pour faire quoi ?
Revenir en haut Aller en bas
LFDM-Carleo

LFDM-Carleo


Messages : 319
Date d'inscription : 08/06/2017
Age : 46
Localisation : Toulouse

PANEL BF109 Empty
MessageSujet: Re: PANEL BF109   PANEL BF109 Icon_minitimeDim 15 Mar - 9:57

altimetre compas IAS temperature fuel munition radio etc tout ca sur un affichage numérique
au lieu d'avoir des indicateur a aiguille j ai un affichage numerique
ca marchera pour tout les avions
Revenir en haut Aller en bas
http://www.arkenstones.fr
Contenu sponsorisé





PANEL BF109 Empty
MessageSujet: Re: PANEL BF109   PANEL BF109 Icon_minitime

Revenir en haut Aller en bas
 
PANEL BF109
Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous pouvez répondre aux sujets dans ce forum
OBT ~ Escadrille virtuelle :: Forum Simulateurs Warbirds :: DCS - Warbirds-
Répondre au sujetSauter vers: