I'll start with something not so complicated but I think useful.
Something I learned in my Electronic design course is that in some type of circuits, such as high order filters, we have to use component's values as precise as possible. Otherwise, the parameters of the circuit's response will not be optimal (not even close sometimes).
In most cases, we fix the value of the capacitors since their commercial values are not as varied as the resistors. The simplest way to solve the problem is to use potentiometers or other type of variable resistors; that's good if we are making tests in a protoboard, but if we want more like a permanent design (impressed circuit), fixed resistors are the way to go. And we also want to use these values to run our simulations.
From experience (mine and from my professors), it is better if we use at most two resistors to approximate the desired value in order to avoid huge differences due to the resistors' tolerance. Since it can be tedious to figure out by yourself which two resistors are best (with or without a calculator); I decided to write a C++ program to find these values.
The input of the program is the desired resistor value. The output shows which two commercial resistors can be used (in series and in parallel) to approximate the input as well as their percentage error. It also shows two results for each combination, the first approximate value is less than the desired one and the other greater. The reason for this is because according to your application you may want to choose one or the other. For example, when connecting a LED you'll probably use a resistor with a higher value in order to prevent damaging your component; and when using a transistor you may use a resistor value with a smaller value to make sure it is activated.
Here is a example of the output when the input is 4350:
Well. here is the ComputeResistance.cpp code, I did not finish simplifying it all, but I tried to comment the most important parts and functions. I also left as comments the print functions and variables I used to debug the program in case you want to do it too.
Comments, improvements and questions are welcome. I'll also put a table with the resistors' commercial values for you to consult it.
Resistors' Commercial Values


Nice!
ReplyDeleteYa me suscribĂ