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: 11/29/2024 Posts: 815 Rating: (123) |
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 (159 Downloads) |
Keep it simple and on-topic. |
|
This contribution was helpful to1 thankful Users |
12/2/2014 5:04 PM | |
Posts: 5225 Rating: (1198) |
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: 1/23/2025 Posts: 15549 Rating: (2467)
|
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 |
Follow us on