12/2/2014 2:54 PM | |
Posts: 20 Rating: (2) |
Ok, thank you huggy_d1. I'll give it a try this way! |
12/2/2014 4:09 PM | |
Joined: 1/5/2011 Last visit: 4/22/2024 Posts: 815 Rating: (121) |
Dear VDWJAN, Huggy's suggestions are good as always, but let me add another,it might be less time consuming. You could convert the input bools to a byte (for example;by the use of the AT statement), then convert that byte to a real (Byte to Dint to Real), and use the unscale function (located under the "conversion operations" folder of your basic instructions) to rescale 0.0-255.0 (Real)to 0-27648 (Dint). I've attached some screenshots that show my suggested approach. Let me know if this was of any use. Kind regards, Jens AttachmentBitsToInt.pdf (133 Downloads) |
Keep it simple and on-topic. |
|
This contribution was helpful to1 thankful Users |
12/2/2014 5:04 PM | |
Posts: 5225 Rating: (1185) |
Hi there. I wanted to jump in here to make hnoury mentions of our two heroes: huggy_d1 and Jens_app You guys both have nice solutions. One should note that the solution by huggy_d1 increases a fixed increment for each input switched ON. It gets the job done quickly with rough jumps (probably what is required). Jens_app, you have done a brilliant job in documenting a procedure in converting the digital inputs to a number and mathematically scaling to an analog value. Every newby should give your work a read. In all fairness.. this is probably going over the top for what was asked. But then.. I like the scenic route too. Thank you guys! w |
This contribution was helpful to3 thankful Users |
12/2/2014 5:15 PM | |
Joined: 7/7/2010 Last visit: 4/26/2024 Posts: 14639 Rating: (2349)
|
Thanks to w.b. and j_a for the kind words. My suggestion was more of a concept that a polished result like offered by j_a. The +=4 was a placeholder meant to indicate the increment could be linear, or could be binary encoded like Jens_app's solution, like bit 0 =4 + 0 x 2^0, bit 1 = 4 + 1 x 2^1, bit 2 = 4 + 1 x 2^2, bit 3 = 4 + 1 * 2^3, ... bit 8 = 4 + 2^7, and then run that through the scale/unscale. It could also be from a table of known values, like from a vendor that has something like: 4 mA = 0 kPa 8 mA = 100 kPa 11.5 mA = 200 kPa 17 mA = 300 kPa or other such similar oddities where there were 8 specific points to consider and this would allow for a simple and repeatable calibration or process setup. |
science guy |
|
This contribution was helpful to1 thankful Users |
12/4/2014 7:55 PM | |
Posts: 5225 Rating: (1185) |
Hi. Try this [LINK]. Use the formulas.. V = I x R.....EQ1 P = V x I ....EQ2 Then combining EQ1 and EQ2 to get the formula: P = (I x R) x I = I2 x R.... EQ3 Now let us assume you get standard 0.25W resistor.. 0.25 = (0.020)2 x R >>> R = 625ohm So.. if you select a resistor smaller than 625ohm you will not burn out the resistor. Now using EQ1 we can calculate that V = 12.5V. We need to keep in mind that the voltage will have a ceiling.. 10V - which is less than 12.5V. In EQ1 it calculates as R = 500ohm. Finally... R = 320ohm, 0.25W will work for you to measure 0 to 6.4V. Does this work for you? w |
Follow us on