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 (354 Downloads) 
This contribution was helpful to2 thankful Users 
7/16/2009 9:35 AM  
Joined: 1/5/2007 Last visit: 9/3/2020 Posts: 1673 Rating: (561)

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: 9/3/2020 Posts: 1673 Rating: (561)

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." 

Follow us on