# Come on in!

Welcome to Unitronics' Support Forum!
You are welcome to browse as our guest--or sign up to join the discussion.  If you are new to Unitronics' award-winning All-in-One PLC + HMI programmable controllers and software, we invite you to visit our website.

• ### Member Statistics

5,289
Total Members
501
Most Online

Joined

• 2
• 1
• 1
• 3
• 2

• ### Posts

• Fantastic.  That is very helpful.  I can appreciate 'almost never'. That being said, my program has evolved over time, 2 different system integrators, and now me.  There are real numbers used in several places...generally related to drives and encoder outputs, speed, etc.  Is this the 'right' time to use real numbers, or just another way to handle those things?   I'm actually just converting from displacement/position to volume.  Little bit easier, but I will keep this in the back of my mind.
• Almost never. Multiply by 100 or 1000 (or whatever precision you need) in your linearization function block and then keep track of the location of the decimal point through any subsequent calculations. The HMI display function for integers has a handy virtual decimal point that you can use for display. I spend most of my time with VisiLogic rather than UniLogic, but my recollection is that the 16-bit integer registers are signed (VisiLogic has both signed and unsigned 32-bit registers, and only signed 16-bit registers - I think UniLogic is the same). Just use negative numbers as you normally would. Just be careful about register overflow and divide by zero. It seems I'm always dealing with converting flow rates to volume (most of the time) and volume measurements to flow rate (less often). Either many system designers don't understand that they need to use the proper sensor for the job at hand or they just go with whatever is cheaper at the moment (sometimes you need both flow and volume so conversion is necessary regardless). Converting between those two domains is very cumbersome and elegant solutions are rare. For converting flow to volume, you need to integrate. I just time slice the flow (usually in 100ms increments) and sum (there is some additional math involved to get the units correct). For the reverse, you just have to measure the volume as often as you can, calculate the time interval and filter as heavily as needed to get something approximately matching reality. If there's a better way, I sure would like to hear it.
• Good morning and happy Friday to all! I am still learning the ropes of PLCs ladder logic, etc and I am hoping to get some suggestions.  I am from the world of traditional code-writing and microcontrollers, so the handling of arrays and datatypes within ladder logic has been a bit of a learning curve.  Here's my situation: I am using a 4-20ma signal from a laser to measure the level of a material within a tank.  The tank has a rotating arm which periodically passes through the laser beam.  To filter this out, I am taking a measurement every .1 seconds and writing it to the 0th element of an array (after shuffling the rest of the values).  I am taking the minimum element of that array as the true level at that moment (arm in front of the beam will only make the measurement appear higher, never lower). I am taking the 'true level'/minimum measurements and writing them to another 10 element array every 0.1s, same scheme, shuffling, etc.  I have a third 10 element array in order to do calculations on the rate of change from the 0th element to the 1st, 2nd, 3rd, 4th, etc.  Essentially I am working to get the volumetric flow out of this tank....   The issue I'm having is that I am getting only whole numbers, and non-negative numbers.  The order of magnitude and precision should be X.XX.  I am only getting the integer portion, unsurprisingly. I used a formula function block and did my calculations in there.  Very handy.  Avoided me having to add another function block to divide by 0.1, 0.2, 0.3, 0.4 etc.  (Also, that was giving me datatype errors using the MULT function block).   I realize I've given a lot of details and not asked any questions directly, so here goes: 1.  When is the 'right' time to use real numbers? 2.  Given I only need 3 significant digits of precision, should I multiply my values by 100 or 1000 and format it on the HMI to show the decimal place? 3.  If I want to know both positive and negative values, should I use multiply by 100 or 1000 AND choose 32768/2 as the zero point?  As in, shift the values, so that below 16384 represents a negative volumetric flow? 4.  Are there better ways to handle arrays than creating multiple arrays just to store 9 elements, then move them back to the original array, or copying a whole array just to run numeric operations?  For example, is there a clever/elegant way to calculate the volumetric flow from the 0th element to the 1st, 2nd, 3rd, so on...getting 9 values and averaging, sorting, etc. to get a less noisy signal?     Kindest regards!
• In rung 9 try calling connect function over a transition contact. Also looks like you are connecting to 2 slaves simultaneously over the same socket, I think this won't work, you need to connect to first slave, run Modbus commands, disconnect, connect to second one, run Modbus for second one. Or use two sockets. Tell us how it goes.
• I did quick fiddle with the data in Excel.  It looks like an offset of -45 counts and then a linear scaling error of -2.4% over the range of the input. Fluke(ma) Actual Count Expected Count Count Diff. Data without offset Percentage Error 4.000 -45 0 -45 0   6.000 954 1024 -70 -25 -2.44% 8.000 1954 2048 -94 -49 -2.39% 12.000 3953 4096 -143 -98 -2.39% 14.000 4957 5119 -162 -117 -2.29% 16.000 5951 6143 -192 -147 -2.39% 18.000 6951 7167 -216 -171 -2.39% 20.000 7949 8191 -242 -197 -2.41%     I would not expect this as normal behaviour.  The spec sheet gives accuracy of 0.4%.   However, apart from the offset and scaling errors, the data looks quite clean.  Usually a bad input won't even perform this well. Were you able to test with the field wiring completely disconnected from the analogue module (that includes the commons as well as the signal lines)? I notice you are a few versions behind on UniLogic, the current version is 1.28.34.  I doubt the issue is version related, but I would suggest upgrading at some point.  I'd be pushing into a more thorough diagnosis of the hardware and field wiring first. Hope this helps,

×