
Elementary Math Fractions, Percentages, Word Problems, Equations, Inequations, Factorization, Expansion 
 LinkBack  Thread Tools  Display Modes 
January 29th, 2018, 02:49 AM  #1 
Member Joined: Jan 2016 From: Uk Posts: 93 Thanks: 2  Simplifying an equation
Hi, I am not much of a mathematician or computer programmer, but I'm trying to include an equation into a program. Here is the equation: What happens is the program READs 12x Temperature/Pressure addresses, to give T1T3 and P1P9 (Shown in the equation as dig_X) I want to READ these values first then add them into the program while simplifying it. Any help would be much appreciated. cheers, Camerart. 
January 29th, 2018, 03:11 AM  #2  
Senior Member Joined: Feb 2016 From: Australia Posts: 1,769 Thanks: 626 Math Focus: Yet to find out.  Quote:
 
January 29th, 2018, 03:31 AM  #3 
Senior Member Joined: Apr 2014 From: Glasgow Posts: 2,142 Thanks: 726 Math Focus: Physics, mathematical modelling, numerical and computational solutions 
It looks like a C program. I would copy and paste the code into a new file and the wrap those two different pieces of functionality into two separate methods. For example, you could do something like: Code: double GetTemperatureAsDouble() { <code here for the Page 45 method> } char* GetTemperatureAsString() { <code here for the page 46 method> } Once you've got the methods available for use, you can put them in a program like this: Code: int main { double mytemp; char* tempString; myTemp = GetTemperatureAsDouble(); tempString = GetTemperatureAsString(); return 0; } 
January 29th, 2018, 03:36 AM  #4 
Member Joined: Jan 2016 From: Uk Posts: 93 Thanks: 2 
Hi J, It is hard to read, and I'm trying to reduce it so it is simpler. NOTE: DOUBLE is a double precision floating point number ~ 16 digits precision. Take this line: var1 = (((double) adc_t) / 16384.0 –((double) dig_t1) / 1024.0) * ((double) dig_t2) ; I have READ and calculated all of the 'dig_xx' elements from the module, so I think it could be shortened to something like this: var1 = (((double) adc_t) / 16384.0 –((27100) / 1024.0) * ((double) 25631) var1 = (((adc_t) / 16384.0 –(26.46484375 * ( 25631) var1 = (((adc_t) / 16384.0 –678,320.41015625 I'm sure there are a few mistakes already, and I have no confidence to try. Are you able to read Python, as I have a similar equation? c. 
January 29th, 2018, 04:40 AM  #5  
Member Joined: Jan 2016 From: Uk Posts: 93 Thanks: 2  Quote:
I am not using C, but Oshonsoft BASIC, which has all sorts of gotchas. This is not really a computing question, but a mathematical one. I am trying to 'simplify down' the equation mathematically, them write it and test it as i go along. C.  
January 29th, 2018, 05:03 AM  #6  
Senior Member Joined: Apr 2014 From: Glasgow Posts: 2,142 Thanks: 726 Math Focus: Physics, mathematical modelling, numerical and computational solutions 
Okay, I understand. No wonder you're having trouble then... the quality of code is awful (very 1980s!) and the comments refer to the pages of a book or article, so do you have the book/article it is referring to? Quote:
I don't know anything about ADCs, but, after a quick Google search (see for example Calculate temperature from ADC value of MCP9701A sensor  Microchip), it seems as if the equation is a conversion that relates an ADC voltage value (as outputted from an ADC connected to a temperature sensor) to the temperature being sensed. The equation is probably something like $\displaystyle T = A (V  B)$ where T is temperature (in Celsius), V is ADC voltage (in Volts) and A and B are coefficients that dictate the calibration of the sensor and ADC component. A is a "temperature coefficient" and B is an "offset" . If you have $\displaystyle T = V / 16384.0 – 678320$ Then you have $\displaystyle A = \frac{1}{16384} = 0.000061$ and $\displaystyle B = 678320 * 16384 = 1.11 \times 10^{10}$ Those values don't seem like sensible values for a calibration scheme though for an ADC...  
January 29th, 2018, 05:25 AM  #7  
Member Joined: Jan 2016 From: Uk Posts: 93 Thanks: 2  Quote:
Here's a similar Python program: The addresses may be different, I haven't check them fully, till you like the look of it. Notes are marked ################ All between @@@@@@@@@@@@@@ has been READ and calculated seprately, so fixed. C.  

Tags 
equation, simplifying 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Assistance with simplifying an equation  chopnhack  Algebra  3  February 22nd, 2017 07:28 PM 
Simplifying an equation  bobred  Algebra  2  February 2nd, 2015 07:35 AM 
Simplifying this equation  Kinh  Algebra  5  March 13th, 2014 11:00 PM 
Simplifying equation  bytelogik  Algebra  3  June 17th, 2012 06:01 PM 
Simplifying an equation  jakeward123  Algebra  4  May 11th, 2012 12:37 PM 