Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Problem finding the equation

Status
Not open for further replies.

baileychic

Advanced Member level 3
Joined
Aug 2, 2017
Messages
728
Helped
56
Reputation
112
Reaction score
57
Trophy points
28
Activity points
7,033
I have problem finding the equation.

I am doing a project using PIC12F1840.

I am reading adc value and scaling it to 110 to 280 value.

110 and 280 are the lower and upper limits.

I have to convert 111 to 179 to 217 to 224 value but the condition is

for increase of 1 in input the output should increase by 1.

111 (input voltage) + 106 = 217
118 + 106 = 224

after this for

119 to 126 the output should again vary from 217 to 224.

This has to continue till 279 (input voltage).

For input voltage 111 to 179 then output value varies between 217 and 224 and cycles between these values for increase of every 7 value in input.
 

Hi,

I don´t understand the description.
A table or diagram could clarify.

Klaus
 

This is the data table.

input value has to be mapped to corresponding output values. I tried to get an equation using non-linear regression tool but it gave a value os 220.0.

Code:
111 = 217
117 = 224
118 = 217
124 = 224
125 = 217
131 = 224
132 = 217
138 = 224
139 = 217
145 = 224
146 = 217
152 = 224
153 = 217
159 = 224
160 = 217
166 = 224
167 = 217
173 = 224
174 = 217
186 = 224
187 = 217
193 = 224
194 = 217
200 = 224
201 = 217
207 = 224
208 = 217
214 = 224
215 = 217
221 = 224
222 = 217
228 = 224
229 = 217
235 = 224
236 = 217
242 = 224
243 = 217
249 = 224
250 = 217
256 = 224
257 = 217
263 = 224
264 = 217
270 = 224
271 = 217
277 = 224

I made this simple code which works.

Code:
if((input_voltage > 110) && (input_voltage < 280)) {
j = 0;
                      
do {
      output_voltage = input_voltage + 106 - (j * 7);
      j++;                          
} while(output_voltage > 224);
}
 
Last edited:

Are you sure those conversion figures are correct?
The left figure increases in a 1 then 6 progression and the right figure alternates between 217 and 224. That doesn't seem right for converting an ADC reading to anything meaningful.

Brian.
 

Yes, it is correct. I am reverse engineering a stabilizer for a client. The stabilizer has 4 Relays and lower cut off value is 110V and upper cut off value is 280V. The relays provide a output voltage of 203 to 253V for 111V to 279V input. The client needs the device to work as original product. The original product output voltage varies like that. Client mentioned that a fake output voltage of 217V to 224V has to be displayed as in the above table.
 

Try:
Code:
if((input_voltage + (input_voltage > 174) % 6 == 6) output_voltage = 217;
else output_voltage = 224;

I took 174V input as the point where modulus 6 results reverse, hence adding 1 to it.

Brian.
 

@betwixt

Your code only provides two values for output voltage i.e., 217V and 224V. Right ?

I need for 111V to 118V I should get 217V to 224V in step of 1.

I will try your code in debugger.
 

Apologies - but your table only shows two output voltages.
It may be easier to do the calculation on raw ADC readings where the resolution is higher.

Brian.
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top