Kiiza

ANALOG INPUTS AND OUTPUTS

27 posts in this topic

Hello guys,

I am happy to be on this forum.

I am just starting up with OMRON PLCs. I have been programming SIEMENS PLCs for the last three years.

I am quite comfortable with the boolean logic. However, I am struggling with the analogs. I'm looking for an instruction that will help me bring in and scale analog inputs and I am wondering if I'll need to unscale the analog outputs as I send them out. I have tried the SCL instruction but it does not seem to do for me what I need. i need to get a signal wired to the input card and convert it to a maningful value. Plus, advice about how to address analog inputs and outputs would be very helpful to me.

Thank you very much, I appreciate.

Edited by Kiiza

Share this post


Link to post
Share on other sites

Well, this does not say which PLC you are using, but here is a function block that I wrote for scaling a while back:

 

Provide more info on which PLC and which analog modules you are using and we can help further.

1 person likes this

Share this post


Link to post
Share on other sites

Hello Michael,

thanks for the reply

Well, I am using C1JM CPU13.

Share this post


Link to post
Share on other sites

I actually downloaded your function block already.

I still don't understand properly the input Max_Analog_in_INT. Is it really necessary? And what exactly does it mean? and there is the integer data type; because the analog inputs are integers --correct me if I am wrong. The value range in that case is  -32768 to 32767 . How does your FB account for those ranges? Because your FB seems to scale the input from 0 to Max_Analog_in_INT.

Thank you.

Edited by Kiiza

Share this post


Link to post
Share on other sites

Some analog inputs have a range of 0-4000, some have a range of 0-8000, some have a range of 0 to 30000.  The max value is the max of the analog input range (4000, 8000 or 30000).  It is just used to calculate the scaling equation (y=mx+b).

Share this post


Link to post
Share on other sites

Hello Michael,

As I mentioned earlier, I have only worked with SIEMENS PLCs and for them the range is always  -32768 to 32767   0r 0 to 32767 depending on whether the signal is unipolar or bipolar. I am only using the simulator within CX-One; I don't have a PLC with me. I am wondering; do the different analog input cards come with particular specifications for the  Max_Analog_in_INT ?

Thank you, i appreciate.

Share this post


Link to post
Share on other sites
Just now, Kiiza said:

I am wondering; do the different analog input cards come with particular specifications for the  Max_Analog_in_INT ?

Yes, per my question earlier, what analog module are you using?  (there are several that can be used with the CJ1M)

Share this post


Link to post
Share on other sites

OK, I get it.

In that case; does it matter if I am using 4-20mA or 0-20mA? 

Share this post


Link to post
Share on other sites

Well, you may have to check the module.  I am not sure that all of our modules support 0-20mA.  If it does, then the input will be able to be configured as either 0-20mA or as 4-20mA.  Your module will have a resolution value, like 4000 or 8000 or something.   The 0-20 or 4-20 will then be represented by 0-3999 or 0-7999 (depending upon the resolution).

Share this post


Link to post
Share on other sites

Now I wanna ask about the analog outputs. I am imagining I have to unscale them in some way inorder to convert operator values or automatically generated values from for instance a PID into a format understandable by the PLC. Do you have any suggestions as to how I can go about this?

Thank you.

Share this post


Link to post
Share on other sites

The raw data will still be available after the scaling function block.  It scales the raw value and puts it into a different memory address.  Just use the raw value address if you need it "unscaled".

 

Share this post


Link to post
Share on other sites

I am not so sure I understand that.

I am referring to analog outputs form the PLC this time. For instance if I am sending a 0-50Hz frequency setpoint to a VFD. On the HMI the operator enters a value between 0 and 50Hz. How do I unscale te operator value to a form that the PLC will understand (I imagine that will be in integer format).

Kind Regards.

Share this post


Link to post
Share on other sites

You can write your own FB or ladder that is less flexible.  For instance, if you figure out that your analog speed output (0-4000) range = 0 to 2000 rpm (for example), you could just take the operator entry as a real number and multiply it by a real value of 20.0 and then convert the answer to an integer. 

Share this post


Link to post
Share on other sites

I was trying to understand if the analog input cards also have a set maximum (for instance 0-8000). I think I get it that they do have. I f am scaling a 0-1460 rpm output for instance, my zero_point would be 0; Max_Point be 8000; the  Max_Analog_in_INT  be 1460. And then I would take the integer value out of the analog output card (that's when I utilise your Function block). That's what I make of it, please correct me if I'm wrong.

The other intriguing question is; Does OMRON have standard function blocks for scaling inputs and unscaling outputs in CX-Programmer?

Thank you.

Share this post


Link to post
Share on other sites

Not quite, it would be like this:

P9gf0T9qccXXwAAAABJRU5ErkJggg==

The function block is really using a min and a max analog input.  The MIN is not an input to the block and is set to 0.  The max would be 8000.  the zero point and the Max point are what you want the analog range (0-8000) in this case to be scaled to.  So, if you had 0 - 4000 analog in put and you had a pressure input that ranged from 50 to 750 psi, you would put 4000 as your Max_Analog_in_INT value, 50 as your Zero_Point and 750 as your Max_Point and then your input that can range from 0-4000 would be scaled from 0-750.

Note that when I have an input of 4000 (as shown in picture), which would be 12mA if using a 4-20mA signal, then the value that it is converted to is 730 (4000/ 8000  = 1/2 and 1/2 of 1460 is 730).  Note that it converted it to three different formats (Real, INT and BCD).

1 person likes this

Share this post


Link to post
Share on other sites

I generally do not bother scaling outputs. Just do my maths. So, for example, if the analogue output is 0-4000, the drive is set up with the 4-20ma input is 0-100hz, the operator punches in 30hz on the touch screen - 1 hz = a count of 40 x 30 = 1200. I just then write 1200 to the analogue output - generally do not waste my time scaling if I do not have to.

I do often scale inputs though - different matter.

I would suggest you use 4-20ma rather than 0-20ma - that way you can detect a loss of signal.

Share this post


Link to post
Share on other sites

Thank you very much guys. Your advice has been so helpful.

Share this post


Link to post
Share on other sites

I am now onto PID control. I have seen the two PID control instructions; PID and PIDAT. However, my challenge with them is: How do I actually set the values for the different parameters? Because the interface of the instruction only shows three parameters yet there's much more to the PID than those three. I read the manual for the PID instructions and it talks about other parameters such as C, C+1, C+2,.... My question is; how do I access and get to set these parameters?

Thank you.

Share this post


Link to post
Share on other sites

For example, if you assign D100 as your First Parameter Word for C, then C+1 will be D101, C+2 will be D102, and so on. Use MOV instructions to populate these memory locations. Pay attention to the required data types and input them correctly.  

Share this post


Link to post
Share on other sites

Thanks, I was wondering how I was supposed to do that.

The next question now is; There are bunches of bits from words that are used in islolation for instance Bits 04 to 15 of C+5 are supposed to be for 2-PID parameter (a). There are other separate bunches of bits. How do I manage to write to only that stream of bits and not the rest of the bits within that word?

If anyone has an example of a project where they have used this, it would be of very great help.

And the additional question is; do I always have to move the data as word? Because I realize sometimes I need to write floating point values and those would typically need 32-bit address areas, I don't know how that affects the C, C+1, C+2,... addressing order.

Thank you.

Edited by Kiiza

Share this post


Link to post
Share on other sites
16 hours ago, Kiiza said:

The next question now is; There are bunches of bits from words that are used in islolation for instance Bits 04 to 15 of C+5 are supposed to be for 2-PID parameter (a). There are other separate bunches of bits. How do I manage to write to only that stream of bits and not the rest of the bits within that word?

Take a look at the MOVD instruction.

16 hours ago, Kiiza said:

 

And the additional question is; do I always have to move the data as word? Because I realize sometimes I need to write floating point values and those would typically need 32-bit address areas, I don't know how that affects the C, C+1, C+2,... addressing order.

Take a look at the PID Parameter Settings table in the programming manual. There is a description for each parameter. It appears that most are in Integer format. REAL will not be allowed. You'll have to do conversions. Also pay attention to the resolution for each parameter. For example, the Proportional Band is in units of 0.1%, so if you MOV &0015 into C+1 this will be 1.5%.

17 hours ago, Kiiza said:

If anyone has an example of a project where they have used this, it would be of very great help.

Sorry, I do not. This has been discussed on these forums. I did a brief search but came up empty. The search function on this site could use some help.

Share this post


Link to post
Share on other sites

That's a little bit crazy. Because when conversions are done from real to integer then you are either truncating or rounding off which obviously affects the accuracy.

Share this post


Link to post
Share on other sites
1 hour ago, Kiiza said:

That's a little bit crazy. Because when conversions are done from real to integer then you are either truncating or rounding off which obviously affects the accuracy.

Yes, this is true.  However, if you do all of your math using real numbers and then as the last step convert it to an integer, you will be as accurate as an integer format will let you be (within 1).  If you were to do all the math using integers, then you can introduce much greater error.  Here is an example where I divide 9 by 5 and then multiply by 4.  Using all integers, I get an answer of 4.  Using reals and then converting to an integer, I get 7, which is much more closer to the correct answer of 7.2.

wejfWcKghN9QAAAAABJRU5ErkJggg==

 

Share this post


Link to post
Share on other sites

I see, I'll do whatever calculations I need to do before the conversions.

Could you be having an example of a project where you've used the PID instruction? It would be of great service to me.

Thank you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now