Jump to content

Flex727

MVP 2023
  • Posts

    3,276
  • Joined

  • Last visited

  • Days Won

    239

Posts posted by Flex727

  1. If both the analog input and the analog output are 4-20mA and have the same bit resolution (check datasheets for the I/O modules), then simply perform a "Store" function from the integer assigned to the input to the integer assigned to the output. If there are any differences between the input and output (type of input or output, bit resolution, etc) then perform a Linearization function between the two.

  2. 7 hours ago, Isakovic said:

    Now I have a question here which method is best practice. In documentation for VisiLogic it is suggested to reduce the number of transition contacts, so I personally use one timer like Flex posted but with normal contact wherever it is needed in program. Is this still an issue in UniLogic or we can simply use frequency bit with transition contact?

    I think the only reason for this warning is that there are only a limited number of transition contacts available. This is, of course, due to the extra memory requirement for a transition contact (the PLC must "remember" the previous state) and that set aside memory is finite. As it is, there is enough memory for at least a couple hundred transition contacts (maybe 256? I don't remember) so the programmer would rarely run out (though I have in the past). If there is another reason to reduce transition contacts, I certainly would like to know.

    In the example I provided above with the self-resetting timer, I would prefer to use a positive transition contact even though a direct contact would only be on for a single scan anyway. This is because it is more clear to another programmer, or myself at a later date, exactly what the logic is doing.

  3. Not sure exactly what you mean by "pulsing". Do you want the bit on for one scan or for one second? If one scan then use a Positive Transition contact of either the one sec System Frequency bit, or use a self-resetting TON timer for frequencies other than 1 sec.

    Here is an example of a self-resetting timer. Place anything you want to have happen on the single scan to the right of the positive transition contact in rung 2.

    image.png.df3c56df71f22beecc5a8052768f5897.png

    34 minutes ago, Zwall said:

    I tried to use the timer TP but it seems like it makes a 1 second pulsation and a pulsation every 1 second.

    This makes no sense to me, but if you want a pulse of one second duration, then you activate the TP timer with a transition contact and the Timer Out will be on for the preset time each time it is activated.

    If you want a one second pulse every 3 seconds, then combine the two techniques above.

  4. Two things:

    In ladder rung 2 you are trying to activate a timer coil with SB 2. That won't work. A Delay Timer (TD) requires power flow to keep it activated for the full 2 seconds.

    Further, you are attempting to place two separate logic threads into a single ladder rung. Don't do that.

    You also need your timer to be self-resetting, or it will only activate once. I would also place a contact in front so you can turn your reading on and off. Your code for rung 2 should look something like this:

    image.png.d284ee34cdaeecbdbfa176a1b9f49b6d.png

    Turn on MB 0 (or MB of your choice) to start reading every 2 seconds. Turn off MB 0 to stop. You can leave off MB 0 if you wish - it's not absolutely necessary, but gives you some added control.

  5. Okay, I see another issue. You are reading 65 registers. When you place those registers into MI 1, you need to also have a vector of 65 registers (The values will go into MI 1 - MI 65). You seem to somehow be assuming all 65 registers will be stored in a single MI. You have other values that are stepping on that vector (such as MI 4 - Status Messages). And you are storing MI 3 into MI 10, which is also part of the vector you are reading from the weigher. One other thing, it appears you SET MB 3 to perform your MODBUS read. That's good, but you need to RESET it at the end of the MODBUS read function, otherwise you are trying to read on every scan and that won't work.

  6. Let me repeat:

    1 hour ago, Flex727 said:

    Have you reviewed the example programs that came with your VisiLogic installation?

    They can be found at Help / Examples, then drill down to Projects / Communication, then look at the examples for MODBUS. They will be for PLCs other than your V1210, but the ladder logic is identical. You probably want your PLC to be the MODBUS Master, so look at those examples.

  7. 2 hours ago, Patrick said:

    Does the PLC load power-up operand values before / during / after SB 2 cycle?

    It shouldn't matter. Assuming the battery is good, the values in the operands are retained and do not need to be restored during power-up for the value to be available to the name block. You don't really show how you are combining the strings for the name block, but be careful about the NULL value at the end. I've been bitten by that before.

    26 minutes ago, Cam said:

    If your getting the Name and IP from data tables I'm not sure this will happen during the power up cycle.

    Did I miss something? I don't see where the OP mentions any interaction with the Data Tables.

  8. 16 minutes ago, Patrick said:

    MB0 is set by SB2 in the first rung and resets after all start up rungs have completed.  Everything works except the PLC Name. 

    Not sure why you aren't using SB 2 here, but I agree it's not the source of your problem. What I see is that the numbers entered into the MI 230 vector don't look like valid ASCII characters (I haven't checked, so I'm not certain). Remember that each MI contains 2 characters so figuring out the value to assign to the MI is not that straightforward.

  9. I assumed @muckingfuddle wanted an actual average, not a moving average.

    For a 100 point moving average you could use MIs and indirect addressing. For 1000 points, you probably need to use a Data Table, as Joe suggests above, but for 10,000 points or more you're probably out of luck.

    At one time I came up with a routine for an approximation of a moving average for any number of points that I've never used, because I don't trust it, but I'm interested in finding out if it might be useful. Simply subtract the average from the sum and add the most recent data point then divide by the number of points to obtain the new average, and repeat. Only 4 registers needed - the most recent data point, the sum, the number of points total, and the average. I've simulated it in an Excel spreadsheet and it appears to follow an actual moving average very closely, but I'm worried that there is a flaw that I'm not seeing that might crop up under unusual circumstances. I think I need a mathematician.

×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.