0414 Wee Neal Posted July 17, 2016 Share Posted July 17, 2016 Hi I have connected a Potentiometer to my VHF FM panel, which is set up: a. Arduino Nano - Based on IRQ Serial sketch b. Max 7219 module connected to a 6 digit 7 segment display c. I have connected the Max7219 modue and the 4 rotary encoders to a Nano which has a RS485 module connected but not coded as yet. d. I have connected 1x 3 pos switch for Squelch e. I have connected 1 x Pot for the volume, connected to the A0 pin. The Pot does not seem to operate the vol control effectively. The problem I have is that the Pot is sending a steady stream of readings and only stops when I turn it fully to the left when the reading is then 0. I have made an assumption that this is due to fluctuating readings from the Pot itself. I have coded a 'smoothing' element to my sketch to try and stop this happening: #define DCSBIOS_IRQ_SERIAL #include "DcsBios.h" /*/ Define the number of samples to keep track of. The higher the number, // the more the readings will be smoothed, but the slower the output will // respond to the input. Using a constant rather than a normal variable lets // use this value to determine the size of the readings array. */ const int numReadings = 700; int readings[numReadings]; // the readings from the analog input int readIndex = 0; // the index of the current reading int total = 0; // the running total int average = 0; // the average int inputPin = A0; /* paste code snippets from the reference documentation here */ DcsBios::Potentiometer vhffmVol("VHFFM_VOL", A0); void setup() { DcsBios::setup(); // initialize serial communication with computer: /* Serial.begin(9600); */ // initialize all the readings to 0: for (int thisReading = 0; thisReading < numReadings; thisReading++) { readings[thisReading] = 0; } } void loop() { DcsBios::loop(); // subtract the last reading: total = total - readings[readIndex]; // read from the sensor: readings[readIndex] = analogRead(inputPin); // add the reading to the total: total = total + readings[readIndex]; // advance to the next position in the array: readIndex = readIndex + 1; // if we're at the end of the array... if (readIndex >= numReadings) { // ...wrap around to the beginning: readIndex = 0; } // calculate the average: average = total / numReadings; // send it to the computer as ASCII digits /* Serial.println(average); delay(1); // delay in between reads for stability*/ } This has slowed the data being received but in no way stopped it. I have a few questions: 1. I have tried 2 other pots and they have the same effect - Is his normal? 2. Am I using the wrong pots - 10k rated? 3. Help! Many thanks in advance. Neal Desktop PC: Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels. Link to comment Share on other sites More sharing options...
Deezle Posted July 18, 2016 Share Posted July 18, 2016 Normal, pots are noisy. Add more filtering. I played a bit with DCS-bios and found a good filtering code (may be the same one you have), I had to increase the value significantly to stop a constant stream of data, didn't seem to negatively effect operation though. Increase that 700 number until it stops. Intel 9600K@4.9GHz, Asus Z390, 32GB DDR4, EVGA RTX 3070, Custom Water Cooling, 970 EVO 1TB NVMe 34" UltraWide 3440x1440 Curved Monitor, 21" Touch Screen MFD monitor, TIR5 My Pit Build, VKB Gunfighter Pro w/WH Grip, TMWH Throttle, MFG Crosswinds W/Combat Pedals, Cougar MFDs, Custom A-10C panels, Custom Helo Collective, SimShaker with Transducer Link to comment Share on other sites More sharing options...
0414 Wee Neal Posted July 18, 2016 Author Share Posted July 18, 2016 Hi Thanks for the reply, I will try that. Neal Desktop PC: Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels. Link to comment Share on other sites More sharing options...
Warhog Posted July 18, 2016 Share Posted July 18, 2016 Hi Neal I have had all sorts of grief with pots regardless of using smoothing code for them. I decidided quite some time ago that they just arn't worth the trouble. So now I use rotary encoders and that solved the noise issue for me. Granted they act differently than pots but from my perspective they don't take anything away from the experience whatsoever. Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals Link to comment Share on other sites More sharing options...
0414 Wee Neal Posted July 18, 2016 Author Share Posted July 18, 2016 Hi John excellent idea, certainly makes life easier. I have also noted that DCS Bios already has these set up in the reference documentation; happy days. Thanks for the reply. Neal Desktop PC: Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels. Link to comment Share on other sites More sharing options...
0414 Wee Neal Posted July 18, 2016 Author Share Posted July 18, 2016 Hi John on another note, what Servos are you using for flap, oxygen etc? Neal Desktop PC: Intel i7 14700K, MSI Z790 MAG Tomahawk MOBO, 64Gb RAM , GPU Nvidia RTX 3080ti Windows 11, VPC joystick, Crosswind rudder peddles, HP Reverb G2, VPC Collective, DOF Reality H2, Gametrix seat, WinWing panels. Link to comment Share on other sites More sharing options...
Warhog Posted July 18, 2016 Share Posted July 18, 2016 Hi Neal I use those Tower Pro SG90 cheapy servo's. They are small and inexpensive. They work ok although they are a little noisy. For the flaps gauge and oxygen gauge they are perfect. Regards John W aka WarHog. My Cockpit Build Pictures... My Arduino Sketches ... https://drive.google.com/drive/folders/1-Dc0Wd9C5l3uY-cPj1iQD3iAEHY6EuHg?usp=sharing WIN 10 Pro, i8-8700k @ 5.0ghz, ASUS Maximus x Code, 16GB Corsair Dominator Platinum Ram, AIO Water Cooler, M.2 512GB NVMe, 500gb SSD, EVGA GTX 1080 ti (11gb), Sony 65” 4K Display VPC MongoosT-50, TM Warthog Throttle, TRK IR 5.0, Slaw Viper Pedals Link to comment Share on other sites More sharing options...
StiC Posted July 19, 2016 Share Posted July 19, 2016 I have had all sorts of grief with pots regardless of using smoothing code for them. Sorry about hijacking this thread. I'm wondering if it might be possible to put the analogue inputs to better use with voltage dividers. I'm thinking it might be way to replace multi position switches and avoid using up digital inputs. I can follow all the user documentation, but the developer stuff is over my head. Link to comment Share on other sites More sharing options...
Recommended Posts