# program help

Discussion in 'Programmer's Corner' started by shivalitambe, Sep 12, 2014.

1. ### shivalitambe Thread Starter New Member

Jul 3, 2014
8
0
hi,
i want to write a program to set voltage o/p at 210 v.
this voltage regulation i have to done using no. of resistor and transistor ckt, concept behind is that if o/p voltage is 230v then controller will compare it with set value 210. and operate 1st transistor to select first resistor. thn again controller will compare o/p across that resistor with se value if its not same then it will operate next transistor as switch to select next resistor of diff value and process goes on till it get nearest value.

pl help me to write program for above logic.

2. ### MrChips Moderator

Oct 2, 2009
12,624
3,451
You appear to be confused.

What you describe is a well known search algorithm called successive approximation.

If you want to generate a given voltage you use a digital-to-analog converter, (DAC). This does not require voltage measurement and feedback. As an example, suppose you have an 8-bit DAC that outputs a voltage from 0 to 255V.

The least significant bit controls a voltage source of 1V.
The next bit controls a voltage source of 2V.
The next bit controls a voltage source of 4V, etc.
:
:
The most significant bit controls a voltage source of 128V.

When you sum the outputs of all eight voltage sources you are able to produce any output from 0 to 255V in steps of 1V.

The successive approximation algorithm is used in the reverse scenario when you wish to determine the binary equivalent of an unknown voltage source, that is, when you want to create an analog-to-digital converter, ADC.

On the other hand, if you are attempting to create a servo-feedback control system whereby the output voltage is being loaded down and you need to drive the output back up to a regulated voltage, then you need to google PID controller.

Last edited: Sep 12, 2014
3. ### ErnieM AAC Fanatic!

Apr 24, 2011
7,435
1,625
No one can really help you write the code for an unknown controller driving a sketchy description of a circuit.

If you post a real then real help may You need not show every part but you do need to do better than a "resistor and transistor ckt."