7/3/2012 9:58 AM | |
Joined: 10/7/2005 Last visit: 11/13/2024 Posts: 3027 Rating: (1057)
|
Hello Sasongko it's actually quite simple, but you need to appreciate the structure of the S5 Analogue input value (see also attached pic and grab also a copy of the S5-90U/S5-95U Programmable Controller System Manual which contains your AI card). The mostsignificant bit (bit 15) is the sign bit. The least three significant bits (bit 0, 1 and 2) contain overflow and error bits. Your Block is a simple analogue input "scaling" FB which actually doesn't do all that much useful stuff, but here's a commented version of it anyhow: : DO DB 161 // open DB161 : : L PW 154 // load raw AI value : T FW 200// and store in FW200 : : A F 200.7 // If raw AI value is negative(Sign bit = 1) : = F 255.0 // memorise this : : AN F200.7 // If raw AI is positive(Sign bit = 0) : JC M001 // --> Jump : L FW 200 // Else: (raw AI value is negative) : CSW // do two's complement (= make negative value positive) : T FW 200 // and store it back in FW200
: SRW 3 // get rid of overflow, error and unused bits 0-2 : FDG // convert to floating point value : L KG +1000000+01 // load 1.0 : XG // multiply raw AI with 1.0 : L KG +5000000+00 // load 0.5 : +G // add 0.5 to above result : GFD // convert to Double Integer : T DW 70 // storevalue in DW70 (of DB161) |
Cheers |
|
This contribution was helpful to2 thankful Users |
7/3/2012 11:17 AM | |
Posts: 87 Rating: (0) |
Dear Fritz, I am sorry for my foolish. Is FW 200 = FB 200 + FB 199 ? Many thanks |
7/3/2012 12:11 PM | |
Joined: 7/18/2011 Last visit: 10/14/2024 Posts: 521 Rating: (91) |
Hi Sasongko, FW200 = FY200 + FY201 or in German mnenotics MW200 = MB200 + MB201 Kind regards, BV |
Follow us on