DCAudioDIY.com

DC Area Audio DIYer's Community
It is currently April 27th, 2024, 6:03 pm

All times are UTC - 5 hours [ DST ]




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: LDR Selector
PostPosted: February 25th, 2024, 2:05 pm 
Offline

Joined: March 5th, 2013, 9:35 am
Posts: 261
Location: Highland, MD
If this is too long, skip down to the sixth paragraph if you are interested in using rotary encoders in any projects.

I became interested in a diyAudio thread from 2015 where Vincent77 built an “Arduino-based Light-Dependent-Resistor (LDR) volume and source selection controller” (http://www.diyaudio.com/forums/analog-l ... oller.html.) Vincent77 provides his guidelines at the start of his article. I thought that his approach was interesting and was something that I could approach and that it would keep me off the streets for a while. As usual, it has taken me a few years to really get started (I've been off the street a lot!) When an LDR (photoresistor) is packaged with an LED, they are called optical isolators and other names.

Arduinos are microcontrollers that are easy to program if you have some “C” experience. A microcontroller is a minicomputer with a small amount of memory, few IO ports, and a few specialized tasks. A microprocessor is a powerful CPU with minimal memory, few IO ports, and complex tasks. So, this makes implementing a volume control interesting because Arduinos in general do not have built-in DACs for output, but DACs can be added to the circuit. What Arduinos do have are output pins that can make digital Pulse-Width-Modulation (PWM) signals with varying duty cycles that provide DC levels once the PWM signals are passed through a low-pass filter. Many drones have used the PWM signals from Arduinos to fly around.

Knowing this, I followed Vincent77’s approach of using PWM signals to control the LDRs. What I call the LDR Selector does not require matched LDRs to work: instead, the Arduino runs a calibration routine to find the LED drives needed to provide each volume step of a pair of series and shunt LDRs while providing a fixed input impedance in a user-selectable range of 10KΩ to 50KΩ. This is preceded by a group of relays providing up to six input channels and is followed with a pair of relays providing two output channels. All of this is under control of a Liquid Crystal Display (LCD) and rotary encoder or an IR remote control. We all have rotary encoders as volume and option selectors in cars and other products.

After all this introduction, I want to make the group aware of a neat IC. As you know, switch debouncing is something we don’t notice as humans because controlled things like lights don’t let us recognize the effects of bounce. Once we connect switches to a micro that looks at events a million times a second, then switch bouncing can drive that micro crazy with instabilities. This has happened to me with the rotary encoder input. I went down rabbit holes trying hardware, software, and combined methods of dealing with switch debouncing and I found that they didn’t work.

If you are using switches and especially rotary quadrature encoders with micros, then you need to know about LogiSwitch. This company makes a small assortment of debounce ICs that simplify switch and encoder integration at a cost under $4 each: maybe a little costly but after having caps and resistors and multiple instruction cycles wasted and still not finding a solution, these ICs are a godsend. I just finished breadboarding an LS-30 with an encoder and Arduino UNO board, and the results are immediate: suddenly everything works cleanly and precisely! I bought the through-hole package because I’m old school and would rather not make a PC board just to try out a circuit. That and I have big fingers.

An aside about my approach to using a microcontroller in this approach: in Arduino Land they have many models, and Vincent77 chose the Arduino Nano because it will plug into a PCB with two rows of pins like an IC. However, it doesn’t have as many features as other models, like the Arduino ATMega2560 that I chose to try. The “Mega” has more memory, more I/O ports, and more 16-bit timer-counters than the Nano, which largely has 8-bit timers. Using 16-bit timers, the Mega can produce higher-resolution PWM signals than the Nano, which I hope will prevent cross coupling with the audio signals passing through. More memory means that I don’t have to do as much code optimization to get the program (called a ‘sketch’ in Arduino Land) to fit into memory already smaller than a microprocessor. The problem with a Mega is finding data that describes locations of the seven pin headers with 78 pins on my PCB that the Mega will plug into. My first PCBs will arrive next week so I can see how well my layout is, along with building circuits without much breadboarding.

This will be interesting!


Attachments:
File comment: Here is the datasheet for the rotary-encoder debouncer.
LS30-Rotary-Encoder-IC-Datasheet.pdf [399.32 KiB]
Downloaded 35 times

_________________
- Guy
Top
 Profile  
 
 Post subject: Re: LDR Selector
PostPosted: February 25th, 2024, 9:07 pm 
Offline

Joined: April 22nd, 2013, 12:58 pm
Posts: 286
Nice post, guy. Very informative for those who are going down that road.
Way, way back in the dark ages, we sued to implement debounce algorithms in Programmable Logic Controllers (PLCs) for industrial control applications. I'm sure someone at Allen-Bradley spent a few months writing and testing that code. Emphasis on testing......


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 190 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group