You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old June 25th, 2012, 11:18 AM   #1
Miuko
Member
Slovakia

Miuko is offline
 
Join Date: Jun 2012
Location: Bratislava
Posts: 6
Step 7 - analog to real value problem

I am try to do this task:
write FC1 that would read from analog input (analog input = tw). The output of the FC1 will be downloaded/read/recorded in the format REAL. The output should be normed in the interval himin and himax that is connected with the input values of the model with analog inputs.
FC1 will have 3 inputs read from analog entry,himin, himax.

In the picture you can see my FC1. It is called from OB1.
http://imageshack.us/photo/my-images...nshot260d.jpg/

My problem is that from what I have tested, it is working very strangely - I get weird numbers.
examples-
tw=2
himin= changed automatically to 512!
himax=100
output= 1120407388




Do you see what can be the problem?

Thank you for any help!

Miro
  Reply With Quote
Old June 25th, 2012, 12:48 PM   #2
oldnerd
Member
United States

oldnerd is offline
 
Join Date: Mar 2011
Location: Al
Posts: 38
Not 100% sure but sounds like the scale is way off.
__________________
"Keep it simple."
  Reply With Quote
Old June 25th, 2012, 01:11 PM   #3
juanmdx
Member
Mexico

juanmdx is offline
 
Join Date: May 2007
Location: SLP
Posts: 268
I guess you should do something like this:
t1 := WORD_TO_INT(tw);
t2 := INT_TO_REAL(t1);
t3 := t1/27468; //here you have the value in a 0 to 100 scale
t4 := 100/himax; //get the convertion factor for your scale
t5 := t3/t4 + himin //now youo have it int a himin to himax scale


Hope this can help you, I don't know why your min and max values are changing (you said they are readed from an input), so maybe that's messing your program also.
  Reply With Quote
Old June 25th, 2012, 01:34 PM   #4
L D[AR2,P#0.0]
Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 4,893
Quote:
Originally Posted by Miuko View Post
In the picture you can see my FC1. It is called from OB1.
http://imageshack.us/photo/my-images...nshot260d.jpg/
Copy/paste the text from the SCL editor into your post - it is really quite tedious having to enter code from a screen shot. E.g.

Code:
FUNCTION fc111:VOID
VAR_INPUT
    himin:INT;
    himax:INT;
    tw:WORD;
END_VAR
VAR_OUTPUT
    ti5:REAL;
END_VAR
VAR_TEMP
    ti:INT;
    ti2:REAL;
    ti3:REAL;
    ti4:REAL;
END_VAR

BEGIN
ti:=WORD_TO_INT(tw);
ti2:=INT_TO_REAL(ti);
ti3:=ti2/27648;
ti4:=ti3*(himax-himin);
ti5:=ti4 + himin;
end_function
You also need to post the call in OB1 - without that we are blind. At a guess though, you are using M flags as the parameters to the FC and you have chosen MW's and MD that overlap.

Last edited by L D[AR2,P#0.0]; June 25th, 2012 at 02:01 PM.
  Reply With Quote
Old June 25th, 2012, 02:05 PM   #5
L D[AR2,P#0.0]
Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 4,893
When you are monitoring code, you can chose the format for the display. You are showing the result in decimal format. Right click on the variable and select floating point (or automatic)
Attached Images
File Type: jpg fpf.JPG (44.7 KB, 35 views)
  Reply With Quote
Old June 25th, 2012, 02:35 PM   #6
Miuko
Member
Slovakia

Miuko is offline
 
Join Date: Jun 2012
Location: Bratislava
Posts: 6
OK sorry next time I will do it.
Yes that was one of the problems. The other was that I used close Bytes (now I am reading that you found out also this! ), so it was manipulating himin when I changed himax - for each it is needed 2 bytes and I used PEW256 and PEW257 so it was overriding!
Thank you very much for support!
Quote:
Originally Posted by L D[AR2,P#0.0] View Post
Copy/paste the text from the SCL editor into your post - it is really quite tedious having to enter code from a screen shot. E.g.

Code:
FUNCTION fc111:VOID
VAR_INPUT
    himin:INT;
    himax:INT;
    tw:WORD;
END_VAR
VAR_OUTPUT
    ti5:REAL;
END_VAR
VAR_TEMP
    ti:INT;
    ti2:REAL;
    ti3:REAL;
    ti4:REAL;
END_VAR

BEGIN
ti:=WORD_TO_INT(tw);
ti2:=INT_TO_REAL(ti);
ti3:=ti2/27648;
ti4:=ti3*(himax-himin);
ti5:=ti4 + himin;
end_function
You also need to post the call in OB1 - without that we are blind. At a guess though, you are using M flags as the parameters to the FC and you have chosen MW's and MD that overlap.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
ABB Active analog problem Aburke LIVE PLC Questions And Answers 8 May 15th, 2012 07:11 PM
Omron Analog input problem abot LIVE PLC Questions And Answers 4 April 16th, 2012 04:05 PM
Analog card F408AD from automation direct....problem trubleshtr LIVE PLC Questions And Answers 1 September 1st, 2009 12:10 PM
Step 7 Real to DINT Ranjith LIVE PLC Questions And Answers 4 June 15th, 2007 04:32 AM
Urgend Step 7 programming problem Combo LIVE PLC Questions And Answers 8 August 24th, 2003 11:23 PM


All times are GMT -5. The time now is 07:33 PM.


.