7/13/2009 5:53 PM  
Posts: 7 Rating: (0) 
Hello, First of all, I'm a rookie with LOGO! :) Actually I didn't aquired one yet, I'm evaluating to option to do so but I need to find out if it is possible to do this with the LOGO!.  Get from a analog pH sensor the value (Possible)  Set the value of K (constant) via the arrow keys (Possible)  Apply the following formula and triger a solanoid valve if required CO2 = 3 x [K] x 10^(7pH) Can the algorithm be calculated inside LOGO! and trigger a output (solanoid valve) based on the result ? Thanks experts ! :) 
Last edited by: jbrazio at: 7/13/2009 7:18 PMChanged the topic title in order to be more descriptive. 

7/13/2009 6:22 PM  
Posts: 173 Rating: (92) 
Isn't there enough CO2 around already!! OK, here goes my first impression 1) There has been a very good posting here in the forum recently about connecting pH sensors and how to scale thier analog values to display them as 'realworld' values. 2) The sensor must be able to give its range of values via a 0..10 V or 0/4..20 mA signal that the LOGO! can read in. 3) Easiest is a 0..10V signal, 'cos 2 of the LOGO!'s (LOGO! 24 and LOGO! 12/24RC) can have up to 4 of thier digital inputs used for analog signal input > therefore you do not have to buy an extra expansion module. For 0..20 mA or 4..20 mA signals form a pH sensor, you will have to get an extra analog input module (2 channel) called a LOGO!AM2 4) Setting a constant value 'K' is possible via the cursor buttons but is a bit cumbersome. There are several pieces of code how top do this on the forum. I would rather recomend doing it via the external text display with the 'F' keys  much easier. 5) If you are just getting started, then a great opportunity is to get the LOGO! TD News Box. This great starter pack will have a LOGO! 12/24RCo (without its own onboard display), the external Text Display (LOGO! TD) and interface cable, as well as the programming software (LOGO! Soft Comfort V6.1) and the USB programming cable PLUS a great screwdriver to wire up all those terminals!, Oh, AND a manual, AND a Computer Based Training DVD to teach you how to get started and all the basics, AND ..... 6) In a really neat storage box (great for fishing reels after you have taken the LOGO! stuff out!) 7) Then you have all the hardware and manuals you need, oh, and you have friends on this forum who will do almost anything to help you write your code, debug it etc, if you show that you are willing to have a go at it yourself! 8) NOW THE HARD PART  the maths! The LOGO! has some great little simple maths capabilities and the new 0BA6 verison of the LOGO! has a maths calculation blcok that can add, multiply, divide, subtract. but only in the range 32768 to +32767. Anything outside of this range (and divide by zero) gets trapped by a Maths Error Check block  you will find out about this soon enough. 9) the most difficult thing you are trying to do is the 'raising to the power' of a exponent that is in itself variable (if I understand the '7  pH value' part correctly). 10) With the various function blocks, you can reference one value to another part of another block, so it MIGHT just be possible to do the following a) get teh pH value from the sensor and scale it correctly so that you get the value that you need between 0 & 7 I assume b) subtract this value from 7 c) use the result as the exponent on 10 d) multiply by the constant value (stored as a type of 'setpoint') Now comes the biggest problem  LOGO! cannot do floating point mathematics, the maths block only works with integrers between the range already mentioned, and there will be no fractions or decimal parts after the comma. One way to get around this is to multiply everything up by 10 or 100 or 1000, and then using the placement of the comma in the display to show a correct value. If you can tell us what raneg of vlaues you are expecting to input for K, what values you are expecting for pH and what the resulting range of CO2 values you are expecting will be, then mayben we can find a way through this! It is a great challenge and it would be even more great if you could use a LOGO! at the end of it! Give us some answers and we will give it a try! Aaaaarrggh ("Have a nice day!") 
7/13/2009 7:18 PM  
Posts: 7 Rating: (0) 
Thanks for the great answer ! In order to clarify things, in a planted tank.. CO2 is never enough ! ;P The 'K' constant is a water parameter called 'kH', the amount (ppm) of CO2 in water depends of the value of kH and pH. Assuming:  kH is a integer value, starting on 0 and ending on 20  pH is a decimal value, variation between 6.0 and 7.6 The max amount of CO2 that can come out of the equation is with ph = 6,0 and kH = 20, then CO2 = 600,000. Some other examples: pH = 6,1 and kH = 20 then CO2 = 476,597 pH = 7,1 and kH = 20 then CO2 = 47,660 ph = 7,6 and kH = 20 then CO2 = 15,071 A "real world" example would be pH = 7,0 and kH = 4 then CO2 = 12,000. From my understading, in order not to have the AM2 module, the pH probe should do the analog variation in volts and not in Amperes, is this correct ? Thanks ! 
7/14/2009 5:37 PM  
Posts: 173 Rating: (92) 
Hi jbrazio! Use up that nasty CO2 in your tank! 1) Selection of sensor 2) The actual voltage value goes into the LOGO! and it is internally represented as a value between 0..1000. So 0 V would be an internal integer value of 0, 10 V would be an internal integer value of 1000. 3) All of the function blocks in the LOGO! Soft Comfort programming 'language' that manipulate analog inpuit values, give you the chance to 'scale' this 0..1000 value into the realworld value that you are actually working with. There is a very knowledgeable participant in the forum called 'Betel' who has shared a nice EXCEL spreadsheet for calculating the 'gain' and 'offset' values to do the required scaling  whether you need to use only 1 analog block or a couple in series, you will get the 'realworld' value you require (with a small amount of deviation) (see the following link) 4) The typical values that you show could be the result of the calculation might be a problem. The LOGO! Maths Block can only work with integer values up to +32767. Your first example shows a value of 600 (six hundred). 5) the lowest value you show is 12, but it looks like the 3 decimal places after the comma are also important. It is possible to 'shift' all values up by multiplying them by 10 or 100 and then displaying them correctly by placing the comma where it is needed. 6) Then your example results could at best be displayed as 
7/15/2009 7:09 AM  
Posts: 153 Rating: (15) 
Hi,
No,you cannot. Because LOGO! is impossible to exponentiate (7pH). 
7/15/2009 2:01 PM  
Posts: 173 Rating: (92) 
Getting too complex for me! Yup, Audrey [Str] is correct, the LOGO! cannot handle the exponent part 10^(7pH). I thought that if K was kept as integer values between 0 to 20 and if the pH sensor values only had 1 decimal place and a range from 6 to 7.6, then the evaluation of (7pH) would only have 17 answers from (76)=1 to (77.6)= 0.6. The values of these 17 exponents could be stored in 5 multiplexers (MUX's), 'scaled up' by a factor of 10, so that 10^0.9 = 7.94328 could be 'stored' as 79 and so on for the other 16 values. Depending on the answer of the (700[pHx10]) subtraction (also factored up into integers), Analog Threshold triggers could be used to digitally select the En, S0 & S1 lines of these 5 MUX's, with the resulting value referenced back to a Maths block, where it would be multiplied with 3xK and the answer shown with 1 decimal place. All of this COULD work (see attached attempt), but the answers would be VERY approximate and you would not get the 3 decimal places of accuracy that your second clarification seemed to indicate. Required LOGO! pH=6.1, K=20: (476,597) 474,0 pH=7.1, K=20: (47,660)48,0 pH=7.6, K=20: (15,071) 12,0 pH=7,0, K=4: (12,000) 12,0 If you want to do it right, then an S7200: 224XP AC/DC/RLY, programmed with STEP 7 Micro/Win v4 SP6, together with an external text display TD200 will do the job nicely and accurately. Just a bit more pricey and complex to explain how to do it in this forum  check out the S7200 forum Sorry for getting your hopes up! Aaaaarrggh Attachment10_Exponentv3.zip (355 Downloads) 
This contribution was helpful to2 thankful Users 
7/16/2009 9:35 AM  
Joined: 1/5/2007 Last visit: 1/10/2021 Posts: 1685 Rating: (564)

Hello jbrazio, hello LOGO!Barbarian, I have a diverging opinion concerning a possible solution of your setting of a task with a LOGO!0BA6 which I want to represent next time. I think that the difference between the mathematical exact calculation of the value for CO2 and the calculation with a LOGO!circuit can be done better as with the version from LOGO!Barbarian.... 
==> Meine TAGListen: "deut." 

7/16/2009 10:32 AM  
Posts: 173 Rating: (92) 
Hey Betel! COOL! I was hoping that an EXPERT would join in! I would love to see your elegant solution, rather than my feeble attempt at bashing out a rough answer! I would love to see this solution for some complex maths done on a LOGO! and not having to go to a more expensive and more complex controller! Waiting in anticipation ! Aaaaarrggh ("Have a nice day!") 
7/16/2009 1:05 PM  
Posts: 7 Rating: (0) 
Thanks to all the replies, currently I've created a purchase order to for a 0BA6.. I should receive it on the following weeks. The idea is to have the LOGO! Logic module screen to display the CO2 and pH value, the pH value should come from a analog probe connected to one of the four analog inputs of the logic module. The value of CO2 should be calculated by the previous equation, with the option for the user to use the arrow keys on the logic module to set the kH parameter. From a relevance stand point, if the decimal values of the CO2 have to be discarded, that’s not a big issue. On the other hand, for pH display it’s important to have them, because a pH of 7.6 is very different of 7.2. 
7/16/2009 4:22 PM  
Joined: 1/5/2007 Last visit: 1/10/2021 Posts: 1685 Rating: (564)

Hi jbrazio, ...no problem...please send the data sheet (or identical infos) of the used sensor to scale the analoge input... Best regards Betel 
==> Meine TAGListen: "deut." 

7/17/2009 2:34 AM  
Posts: 7 Rating: (0) 
Hello, Thanks to all for the interest. Here goes the datasheet of a pH sensor that it's avaliable on my local electronic store. I can't really tell if the output is in V or A.. :/ Attachment201005_data_en.pdf (167 Downloads) 
7/17/2009 2:10 PM  
Joined: 1/5/2007 Last visit: 1/10/2021 Posts: 1685 Rating: (564)

Hi jbrazio, AttachmentJUMO_pH_en_Infos.zip (133 Downloads) 
==> Meine TAGListen: "deut." 

7/17/2009 2:45 PM  
Joined: 1/5/2007 Last visit: 1/10/2021 Posts: 1685 Rating: (564)

Hello jbrazio, hello LOGO!Barbarian, I have a diverging opinion concerning a possible solution of your setting of a task with a LOGO!0BA6 which I want to represent in the following one shortly. Notes on calculations with optimization of the LOGO!: The most important facts and restrictions concerning the LOGO! Programming already informed you of LOGO!Barbarian. to a) for the application here: to b) for the application here: Through some tricky modifications to allow the calculation and display resolution still significantly improve ( "DEMO_CO2_calculation__Math_equations_with_LOGO_V2 (0BA6). Lsc"). For this purpose the "table values with greater number of digits" are preset (see Note below). Ultimately, it is now one text box of three possible text message texts selected (because, unfortunately, can the number of decimal places not by reference to program define) and then display the best possible resolution automatically adjusted. The so achieved calculation is much better than for the solution version of LOGO! Barbarian and the version in "DEMO_CO2_calculation__Math_equations_with_LOGO_V1 (0BA6). Lsc" (compare the EXCEL Table2)! A disadvantage is simply that the further processing of the combined output value (in block B029 "CO2_mod) in the context of circuit (of course only if requested or required) differrenziert be! However, in this case also reached the precision of calculation block B026 "CO2_x" with one decimal place for all values suffice! b) divisions should be (only) in the last block ( = final calculation result) done. The EXCEL file demonstrated in "Table2" and "Table3" these concepts and their impact on the respective calculation results with a LOGO! module. The processed data also show how EXCELfiles the action in a LOGO! program can be exercised ... To the version "DEMO_CO2_calculation__Math_equations_with_LOGO_V2 (0BA6). Lsc": Even the (previous) multiplying the values "10 ** (7pH)" by a factor of 3 (the original equation) and a factor of 10 (for display one digit after decimal point) and the definition of these values, "30 * 10 ** (7pH)" as the table output values for the function f (pH) leads to improved calculation results .... Another "advancement" of the multiplier 100 for the requested additional 2 decimal places after decimal point, in conjunction with a "switching" or "recalculation with this factor" during the subsequent multiplication with the variable value of kH then leads to a mathematic correct calculation of 1 or 2 decimal places after decimal point as rounded values for CO2. Only the 3rd position after the decimal point indicates partial small deviations from rounding errors! In this case the predetermined table values for f (pH) (Parameters of the multiplexers) are no longer multiplied with 1000, but each with individual factors multiplied by the maximum large values (only slightly smaller than a maximum of 32767). In calculating the final values for CO2 (separated by number of decimal places) must then also these individual factors are taken into account. They are (must be) also in a table multiplexers available. Look at the comments in EXELTable3  At this time i have not programed a version V3 to work with this last concept! Please look and test the attached files as help to understand the concept to optimize this (or other) calculation(s) with a LOGO! module... Best regards Perhaps helpful links: AttachmentDEMO_CO2_calculation__Math_equations_with_LOGO (0BA6).zip (365 Downloads) 
==> Meine TAGListen: "deut." 

This contribution was helpful to2 thankful Users 
7/17/2009 3:35 PM  
Posts: 173 Rating: (92) 
WOW! WOW! WOW! WOW! I am totally amazed by this solution! It is absolutely elegant and compact and above all, easy to understand. You are the KING of the LOGO! Forum! Thank you so much for increasing our awareness of all the possibilities with this little controller. Ich werde völlig von dieser Lösung erstaunt! Es ist absolut elegant und kompakt und vor allem, leicht zu verstehen. Sie sind der König des LOGO! Forum! Danke Ihnen so viel für das Steigern unseres Bewusstseins von all den Möglichkeiten mit diesem kleiner Steurung. LOGO!Barbarian (lying on the floor making odd gurgling noises!) 
7/17/2009 7:05 PM  
Posts: 7 Rating: (0) 
Thanks very much for such a solution, not even in 10 years I would be able to accomplish that ! I’m amazed and feeling like a completely lost newb ! :) Regarding the pH sensor I’ve posted the datasheet before, after calling the manufacturer by phone they gave me the following ranges: pH: 0 to 12 Output: 400mV 12000mV How to scale the AI1 for such values ? Thanks ! 
7/18/2009 10:14 AM  
Joined: 1/5/2007 Last visit: 1/10/2021 Posts: 1685 Rating: (564)

Hi jbrazio, with my helpful link "Scalingof signals with analog blocks" you can find an EXCELtool from me to calculate the parameters of LOGO! analog amplifivers in an easy way.... Look at the attachment here to see witch inputs solve your question: 0 pH: 400 mv = 0,4 V puts the value 40 into LOGO!analog input block 12pH: 12000 mv =12,0 V puts the value12000 into LOGO!analog input block OK, i remember LOGO! analog inputs are onlo 0 to 10 V means 1000 as the value into LOGO!analog input block, but for the calculation of the needed block parameters this values are possible (and easy) to use. You must save, that the analog input signal is every time maximal 10,00 V !!! OUTPUT wanted in 0,0 pHto 12,0 pH means 0 to 120 LOGO! units The result is, that you must only change the parameters of the block B001 to GAIN = 0,1 and OFFSET = 4. Of cause, if you connect the signal to I7 (= AL1). AND see for big values of pH there is a smal difference between LOGO! amplifier output (pH = 11[,]6) and the correct value (pH = 12[,]0) OK with some blocks more you can solve this effect: Replace
To do this, you need 2 amplifiver in series (because GAIN is > 10,00). Use for the first amplifier GAIN = 10,00 and OFFSET = 0 Use for the second amplifier GAIN = 1,04 and OFFSET = 414 Now add a block analog math to divide the value from the second amplifier output with 100 to get the needed resolution of pH and use the output pin of that block in the same way as before B001 !!! Remember that the LOGO! program from me display in the range from 0 pH to 10 pH withthe correct value, but the value for CO2 is only corect in the range pH = 6,0 to 7,6 !!!You can add 1 or 2 blocks threshold trigger to test this condition and display 1 or 2 different alarms... Best regards Betel _______________________________________________ Perhaps helpful links: AttachmentCalculation_of_GAIN_and_OFFSET_for_analoge_amplifier (LOGO) pH.zip (89 Downloads) 

==> Meine TAGListen: "deut." 

8/1/2009 9:03 PM  
Posts: 7 Rating: (0) 
Hello Betel, Now the CO2 output part, you say that the value is only correct between 6 and 7.6 pH, is this a limitation of the program that can be overridden ? Meaning that the CO2 display would be correctly displayed for a wider range like between 5 and 9 pH ? Thanks for the time you waste(d) with me. :) 
8/2/2009 9:40 PM  
Joined: 1/5/2007 Last visit: 1/10/2021 Posts: 1685 Rating: (564)

hi jbrazio, here my answers to you:
The infos inside the handbook and under http://support.automation.siemens.com/WW/view/en/17967360contains the following facts: a) Analoge input range 0 to 10,00 V (gives integer values 0 to 1000 to a LOGO! circuit b) input volgage over 10,00 V gives every time the value 1000 to the LOGO! circuit c) input voltage of 12 V DC are no problem d) because the input pins for analoge voltage at the LOGO! basic modules are also digital input pins with maximum voltage values of 24 V DC, i think that the maxumum analoge input value should be 24 V too (of cause only with 0 to 10 V as measure range !!!)
Yes, that is correct...without changes of the circuit  only changes of values of the (or some) multiplexers are necessary  you can add two values/points more: pH 6,0 to 7,6 >> 5,8 to 7,6 or 5,9 to 7,7 or 6,0 to 7,8 (values calculated with the given EXCELsheed. OR with changes of the circuit  add more blocks anlog multiplexer and threshold trigger  and with additional calculation points with the EXCELsheed you can use a bigger pH range to calculate CO2. Look at the modified EXCELfile for the needed values to set the block parameters... Best regards Betel _______________________________________________ Perhaps helpful links: AttachmentDEMO_CO2_calculation__Math_equations_with_LOGO_pH5to9 (0BA6).zip (65 Downloads) 
==> Meine TAGListen: "deut." 

This contribution was helpful to1 thankful Users 
8/4/2009 12:36 PM  
Posts: 7 Rating: (0) 
Hello Betel, I think I've made the correct modifications to the circuit, could you please check ? I'm still missing the extra trigers to be able to display a wider CO2 value correctly. What I'm not understading yet is how to work with the excel gain calculator.. and how do inline amplifiers work.. :/ For instance, the Ai maximum value shouldn't be the 10V that LOGO can handle ? On the example you gave you're using the 0,412V range for Ai, the pH output should be 0 to 120 LOGO units, because gain is <10 then only one amp is needed with offset=4 and gain=0,10. But when I increase the Ax max from 120 to 12000 the GAIN is > than 10, so two amps are needed. The first one GAIN=10 and the second one GAIN=1,04. BUT the calculator gives GAIN=10,35.. does this mean that en serializing amps, the gain value of the second one is always 1 + TOTAL_GAIN  10 ? But despite the fact that the pH probe works on 0,4 to 12V. I would like to restrict the min and max pH display between 5 and 9.. how to find the correct values for the two amps ? Last question, is for any special reason that blocks 12 and 10 have the sensor type setup ? The other blocks like 04 and 06 do not have that. Best regards, JB. AttachmentDEMO_CO2_calculation__Math_equations_with_LOGO_V2_pH_5_to_9 (0BA6).zip (87 Downloads) 
8/8/2009 6:17 PM  
Joined: 1/5/2007 Last visit: 1/10/2021 Posts: 1685 Rating: (564)

Hi jbrazio, your circuit is ok  look my modification to display the correct pH range for CO2calculation... The EXCELsheed calculate a linear translation from a input range to an output range. The basis are two datapoints at the linear kurve. Because the input and outputrange of the block "amplifier" is from 32768 to 32767 the calculation is possible for this range  the range of analog input pins is only 0 to 1000!!! If the calculation results a value GAIN bigger as 10,00 we need more than one blocks amplifier (0BA5) or, if we have a LOGO!0BA6, one block "analog Math" is also possible... a) If we use two (or more) blocks amplifier at one signal line, we must calculate now the parameters GAIN and OFFSET for all this amplifiers. Set all parameters OFFSET = 0, only OFFSET of the last amplifiermust set by the calculated EXCELvalue (if bigger than +/ 10000 we need more blocks amplifier to add the complet value). The parameters GAIN of all amplifiers we calculated Gain(EXCEL) = GAIN_1 * GAIN_2 .... with the best fitting!!! b) If we use a block analog math, it is possible the real value GAIN(EXCEL) to translate as two integer values n and z with "n / z": V1 = Bxxx V2 = n V3 = z V4 = OFFSET (excel) ...((V1 * V2) / V3) +/ V4 10,35...n = 1035 and z = 100 B010 and B012 sensor type:Sorry, i only have made no change of the default values! REMEMBER that this settings in the window have only the effect to set the parameters GAIN and OFFSET for some given sensor types in an easy way  i used this never  i only set the parameters Gain and OFFSET by myself... Best regards Betel _______________________________________________ Perhaps helpful links: AttachmentDEMO_CO2_calculation__Math_equations_with_LOGO_V2b_pH_5_to_9 (0BA6).zip (87 Downloads) 
==> Meine TAGListen: "deut." 

4/23/2012 5:57 PM  
Joined: 1/5/2007 Last visit: 1/10/2021 Posts: 1685 Rating: (564)

Hello, with the LOGO! series 0BA6 and 0BA7 it is possible now to calculate lineare functions (with block amplifiver) and polynoms as funtion of an analog value Ax (wilock Math. function). It is helpful to use MSEXEL to calculate the coefficients of a polynome with order 1 (linear) or up to 4 or 5. This coefficients are the basic to define the Parameters for a LOGO! circuit witch then can calculate a polynom (most as approximation for the real data). Here is the link to that tool: EXCEL tool polynom regression for linear and nonlinear calculations The calculations i have done here to solve the question aremuch easier with this tool... Best regards Betel 
==> Meine TAGListen: "deut." 

Follow us on