epokha Posted June 22, 2020 Posted June 22, 2020 Hi all, Sorry this must have a simple answer, but I sure can't find it. Using an Arduino Mini I've just set up my first panel, everything works fine except the warning LEDs. They are opposite of what is happening in the sim. So, when the light is on its off on the panel. Anyone have an idea of what is causing this? If I could reverse it in the sketch with some code everything would work as expected. LED is of this type: https://www.onpowbutton.com/download/2015020911103373499.pdf with 220ohm resister in series on 5V. Does the same thing for both Ka-50 and AV-8 Thanks for any help /* Tell DCS-BIOS to use a serial connection and use interrupt-driven communication. The main program will be interrupted to prioritize processing incoming data. This should work on any Arduino that has an ATMega328 controller (Uno, Pro Mini, many others). */ #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" /* paste code snippets from the reference documentation here */ DcsBios::PotentiometerEWMA<5, 128, 5> hmsBrightness("HMS_BRIGHTNESS", A0); DcsBios::PotentiometerEWMA<5, 128, 5> shkvalBrightness("SHKVAL_BRIGHTNESS", A1); DcsBios::PotentiometerEWMA<5, 128, 5> skhvalContrast("SKHVAL_CONTRAST", A2); DcsBios::PotentiometerEWMA<5, 128, 5> hudBrightness("HUD_BRIGHTNESS", A3); DcsBios::Switch2Pos weaponsMasterArm("WEAPONS_MASTER_ARM", 8); DcsBios::LED scMasterCautionLed(0x1814, 0x0800, 2); void setup() { DcsBios::setup(); } void loop() { DcsBios::loop(); } AMD 3600X- 32GB RAM - Gigabyte Geforce RTX 2080Ti - 512GB NVme Samsung 830 256Gb 840 256Gb SSD - Track IR 4.0 + TrackClip Pro - Thrustmaster HOTAS Warthog - WarBRD base mount and extention - Simped F16/USB (Stolen!) - Thrustmaster T-flight pedals (spew) DCS KA-50 Blackshark 1 & 2; DCS P-51 Mustang; DCS A-10C Warthog; DCS UH-1 Huey; DCS F-86F; DCS Mi-8MTV2; DCS Mig-21bis; DCS: AV-8b; DCS: Spitfire IX; DCS: NS430; DCS: Combined Arms; Lock On Flaming Cliffs 3; Rise of Flight; IL2:1946;
No1sonuk Posted June 22, 2020 Posted June 22, 2020 So your LED is connected to 5V through a resistor on one end, and the other to the arduino pin? If that's the case, you've wired it wrong. The wiring should be Arduino pin-resistor-LED- GND.
epokha Posted June 22, 2020 Author Posted June 22, 2020 So your LED is connected to 5V through a resistor on one end, and the other to the arduino pin? If that's the case, you've wired it wrong. The wiring should be Arduino pin-resistor-LED- GND. Sorry, you are right. I misspoke. It is wired pin-resistor-LED-GND AMD 3600X- 32GB RAM - Gigabyte Geforce RTX 2080Ti - 512GB NVme Samsung 830 256Gb 840 256Gb SSD - Track IR 4.0 + TrackClip Pro - Thrustmaster HOTAS Warthog - WarBRD base mount and extention - Simped F16/USB (Stolen!) - Thrustmaster T-flight pedals (spew) DCS KA-50 Blackshark 1 & 2; DCS P-51 Mustang; DCS A-10C Warthog; DCS UH-1 Huey; DCS F-86F; DCS Mi-8MTV2; DCS Mig-21bis; DCS: AV-8b; DCS: Spitfire IX; DCS: NS430; DCS: Combined Arms; Lock On Flaming Cliffs 3; Rise of Flight; IL2:1946;
No1sonuk Posted June 22, 2020 Posted June 22, 2020 Sorry, you are right. I misspoke. It is wired pin-resistor-LED-GND OK then. Wire it the way you said you had it. ;) If pin-resistor-LED-GND is "reversed", try 5V-resistor-LED-pin. :juggle:
epokha Posted June 22, 2020 Author Posted June 22, 2020 (edited) OK then. Wire it the way you said you had it. ;) If pin-resistor-LED-GND is "reversed", try 5V-resistor-LED-pin. :juggle: It does the same thing reversed. Not sure why I should try 5V-Resistor LED to pin Edited June 22, 2020 by epokha AMD 3600X- 32GB RAM - Gigabyte Geforce RTX 2080Ti - 512GB NVme Samsung 830 256Gb 840 256Gb SSD - Track IR 4.0 + TrackClip Pro - Thrustmaster HOTAS Warthog - WarBRD base mount and extention - Simped F16/USB (Stolen!) - Thrustmaster T-flight pedals (spew) DCS KA-50 Blackshark 1 & 2; DCS P-51 Mustang; DCS A-10C Warthog; DCS UH-1 Huey; DCS F-86F; DCS Mi-8MTV2; DCS Mig-21bis; DCS: AV-8b; DCS: Spitfire IX; DCS: NS430; DCS: Combined Arms; Lock On Flaming Cliffs 3; Rise of Flight; IL2:1946;
No1sonuk Posted June 22, 2020 Posted June 22, 2020 (edited) See attachment. If the LED is wired <5V-Resistor-LED-pin> the LED will turn on when the pin goes LOW. This is active low. If the LED is wired <pin-Resistor-LED-GND> the LED will turn on when the pin goes HIGH. This is active high (the way DCS-BIOS LEDs are normally wired). If the LED operation is the opposite of what you want, switch over the wiring. Edited June 22, 2020 by No1sonuk
epokha Posted June 22, 2020 Author Posted June 22, 2020 (edited) See attachment. If the LED is wired <5V-Resistor-LED-pin> the LED will turn on when the pin goes LOW. This is active low. If the LED is wired <pin-Resistor-LED-GND> the LED will turn on when the pin goes HIGH. This is active high (the way DCS-BIOS LEDs are normally wired). If the LED operation is the opposite of what you want, switch over the wiring. That makes sense. However, its doing exactly the same thing which ever way I arrange it! It's driving me up the wall. Is it something to do with the LED I'm using? Or the value of resister I'm using? It's a LAS1-AJ-22 https://www.onpowbutton.com/download/2015020911103373499.pdf Edited June 22, 2020 by epokha AMD 3600X- 32GB RAM - Gigabyte Geforce RTX 2080Ti - 512GB NVme Samsung 830 256Gb 840 256Gb SSD - Track IR 4.0 + TrackClip Pro - Thrustmaster HOTAS Warthog - WarBRD base mount and extention - Simped F16/USB (Stolen!) - Thrustmaster T-flight pedals (spew) DCS KA-50 Blackshark 1 & 2; DCS P-51 Mustang; DCS A-10C Warthog; DCS UH-1 Huey; DCS F-86F; DCS Mi-8MTV2; DCS Mig-21bis; DCS: AV-8b; DCS: Spitfire IX; DCS: NS430; DCS: Combined Arms; Lock On Flaming Cliffs 3; Rise of Flight; IL2:1946;
No1sonuk Posted June 22, 2020 Posted June 22, 2020 That makes sense. However, its doing exactly the same thing which ever way I arrange it! It's driving me up the wall. That's impossible if it's wired as in one of the cases of the image I posted. Are you sure the LED is the right way round? Note that the anode (+ side) is always connected to the resistor. The "bar" of the symbol is on the cathode side (-ve). As a test, change the code's LED pin assignment to 13 and look at the onboard LED. That's wired active high. If that's working the correct way round, your LED wiring is messed up somehow.
epokha Posted June 23, 2020 Author Posted June 23, 2020 That's impossible if it's wired as in one of the cases of the image I posted. Are you sure the LED is the right way round? Note that the anode (+ side) is always connected to the resistor. The "bar" of the symbol is on the cathode side (-ve). As a test, change the code's LED pin assignment to 13 and look at the onboard LED. That's wired active high. If that's working the correct way round, your LED wiring is messed up somehow. That was it. The resister was connected to the wrong polarity and as I switched it, I left it connected to the wrong polarity every time :music_whistling: Thanks for your help and patience! AMD 3600X- 32GB RAM - Gigabyte Geforce RTX 2080Ti - 512GB NVme Samsung 830 256Gb 840 256Gb SSD - Track IR 4.0 + TrackClip Pro - Thrustmaster HOTAS Warthog - WarBRD base mount and extention - Simped F16/USB (Stolen!) - Thrustmaster T-flight pedals (spew) DCS KA-50 Blackshark 1 & 2; DCS P-51 Mustang; DCS A-10C Warthog; DCS UH-1 Huey; DCS F-86F; DCS Mi-8MTV2; DCS Mig-21bis; DCS: AV-8b; DCS: Spitfire IX; DCS: NS430; DCS: Combined Arms; Lock On Flaming Cliffs 3; Rise of Flight; IL2:1946;
No1sonuk Posted June 23, 2020 Posted June 23, 2020 That was it. The resister was connected to the wrong polarity and as I switched it, I left it connected to the wrong polarity every time :music_whistling: Thanks for your help and patience! NP. I had a feeling you were switching the LED around. It's the only way you could get the same result. Does it work properly with the "active high" wiring now?
epokha Posted June 23, 2020 Author Posted June 23, 2020 NP. I had a feeling you were switching the LED around. It's the only way you could get the same result. Does it work properly with the "active high" wiring now? Yep, working as per your diagram. High active. AMD 3600X- 32GB RAM - Gigabyte Geforce RTX 2080Ti - 512GB NVme Samsung 830 256Gb 840 256Gb SSD - Track IR 4.0 + TrackClip Pro - Thrustmaster HOTAS Warthog - WarBRD base mount and extention - Simped F16/USB (Stolen!) - Thrustmaster T-flight pedals (spew) DCS KA-50 Blackshark 1 & 2; DCS P-51 Mustang; DCS A-10C Warthog; DCS UH-1 Huey; DCS F-86F; DCS Mi-8MTV2; DCS Mig-21bis; DCS: AV-8b; DCS: Spitfire IX; DCS: NS430; DCS: Combined Arms; Lock On Flaming Cliffs 3; Rise of Flight; IL2:1946;
Recommended Posts