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.

New Here? Please read this important info!!!


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

Reply
 
Thread Tools Display Modes
Old May 22nd, 2023, 07:12 PM   #1
Avatar_41
Member
Turkey

Avatar_41 is offline
 
Join Date: Aug 2019
Location: Istanbul
Posts: 85
STL bit and byte numbers

Hello everyone, friends. I need help with something. I want to read and change Bit and Byte numbers via HMI. I found a code snippet for this as below. I tried, it works, but I don't know how to transfer the values ​​like "I 10.7" that I marked in red here to another address and read and change it. I need your support on this.
Attached Images
File Type: jpg IMG_20230523_020421.jpg (136.5 KB, 33 views)
File Type: jpg 1.JPG (110.3 KB, 26 views)
File Type: jpg 1_1.JPG (34.4 KB, 15 views)
Attached Files
File Type: pdf 1_FC1.pdf (4.0 KB, 23 views)
  Reply With Quote
Old May 23rd, 2023, 02:39 AM   #2
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 6,537
When you say you tried it, it works, what do you mean by that as your code is not writing the output_bit?
__________________
S7-300 to 1500 conversions done - email (minus the spam) to spams7conversions@hotmail.com
  Reply With Quote
Old May 23rd, 2023, 02:54 AM   #3
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Fields of corn
Posts: 2,451
There's a document from Siemens laying out how the pointer is formed, and the memory area it points to is a number in the address formed. I reckon it's the 810000000 number that commands this. search the help for pointer and it's likely there the explanation.
  Reply With Quote
Old May 23rd, 2023, 02:59 AM   #4
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Fields of corn
Posts: 2,451
Also, STL is on its way out, I'd instead look at pointing to an IO buffer instead.
  Reply With Quote
Old May 23rd, 2023, 08:21 PM   #5
Avatar_41
Member
Turkey

Avatar_41 is offline
 
Join Date: Aug 2019
Location: Istanbul
Posts: 85
I may not have explained exactly what I want to do. Translation problems may occur. Bit and Byte numbers appear in LAR1, for example I 10.7. I want to transfer the 10.7 value here to a DataBlock address and change it whenever I want via the HMI. However, I don't know how to pass this value to DataBlock and I need help with this.

Quote:
Originally Posted by L D[AR2,P#0.0] View Post
When you say you tried it, it works, what do you mean by that as your code is not writing the output_bit?
  Reply With Quote
Old May 24th, 2023, 01:49 AM   #6
cardosocea
Member
United Kingdom

cardosocea is offline
 
Join Date: Nov 2016
Location: Fields of corn
Posts: 2,451
I understood what you wanted to do perfectly. You'd want a box to write the byte number and another box to write the bit number. and then return the value at that memory position.



And the way to do this is via addressing with a pointer.



Check here:



https://www.fleaplc.it/index.php/tut...nput-parameter


Search the help for:



Format of the Parameter Type Pointer
  Reply With Quote
Old May 24th, 2023, 02:01 AM   #7
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 6,537
Your example code already does what you want. Change the values in DB10 via the HMI to address a different byte/bit.
Attached Images
File Type: jpg bitbyte.jpg (44.3 KB, 90 views)
__________________
S7-300 to 1500 conversions done - email (minus the spam) to spams7conversions@hotmail.com
  Reply With Quote
Old May 24th, 2023, 07:23 PM   #8
Avatar_41
Member
Turkey

Avatar_41 is offline
 
Join Date: Aug 2019
Location: Istanbul
Posts: 85
Here's the problem, I'm writing as 11.7 on the HMI, but I can't see this value as 11.7. However, if in the Watt table; If I choose Out Variable display format as Pointer, I can read it, but if I set the data type as Pointer in FC1, Out Variable turns red, so it goes into error. I couldn't understand how I could solve this.
Quote:
Originally Posted by L D[AR2,P#0.0] View Post
Your example code already does what you want. Change the values in DB10 via the HMI to address a different byte/bit.
  Reply With Quote
Old May 25th, 2023, 02:52 AM   #9
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 6,537
Here's your code with byte number=11 and bit number=7, I can see I11.7 in the FC.


You need to post some screen shots to explain what you are looking at.
Attached Images
File Type: jpg bitbyte1.jpg (210.1 KB, 72 views)
__________________
S7-300 to 1500 conversions done - email (minus the spam) to spams7conversions@hotmail.com
  Reply With Quote
Old May 25th, 2023, 03:35 AM   #10
Manglemender
Member
United Kingdom

Manglemender is offline
 
Join Date: Jul 2007
Location: Lancashire
Posts: 1,272
Quote:
Originally Posted by Avatar_41 View Post
Here's the problem, I'm writing as 11.7 on the HMI, but I can't see this value as 11.7. However, if in the Watt table; If I choose Out Variable display format as Pointer, I can read it, but if I set the data type as Pointer in FC1, Out Variable turns red, so it goes into error. I couldn't understand how I could solve this.
There are two different types of pointer in S7. What you are creating is a byte pointer which is 4 bytes (DWORD). The other type of pointer is an ANY POINTER which is 10 bytes and has a complex structure.
  Reply With Quote
Old May 26th, 2023, 08:05 PM   #11
Avatar_41
Member
Turkey

Avatar_41 is offline
 
Join Date: Aug 2019
Location: Istanbul
Posts: 85
When I select Any as the data type of Output, it goes into error.
any_data_type_030331.JPG

Quote:
Originally Posted by Manglemender View Post
There are two different types of pointer in S7. What you are creating is a byte pointer which is 4 bytes (DWORD). The other type of pointer is an ANY POINTER which is 10 bytes and has a complex structure.
  Reply With Quote
Old May 26th, 2023, 08:12 PM   #12
Avatar_41
Member
Turkey

Avatar_41 is offline
 
Join Date: Aug 2019
Location: Istanbul
Posts: 85
I'm sorry to bother you all the time, but I think I'm doing something wrong. When I change the values via hmi, for example, when I type 0.0, the decimal value changes to -2130706432. When you do 0.1, it changes to -2130706431. Do I need to divide this number by another number to get ("I0.0")? Or do I need to do something else?
ss_030754.JPG

Quote:
Originally Posted by L D[AR2,P#0.0] View Post
Here's your code with byte number=11 and bit number=7, I can see I11.7 in the FC.


You need to post some screen shots to explain what you are looking at.
  Reply With Quote
Old May 27th, 2023, 02:34 AM   #13
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 6,537
You are doing nothing wrong. What is the purpose of writing the area pointer to the OUTPUT?
__________________
S7-300 to 1500 conversions done - email (minus the spam) to spams7conversions@hotmail.com
  Reply With Quote
Old May 27th, 2023, 02:47 AM   #14
Manglemender
Member
United Kingdom

Manglemender is offline
 
Join Date: Jul 2007
Location: Lancashire
Posts: 1,272
Also, the two AND statements prior to the Transfer instruction have no effect on the Transfer so they serve no purpose. What was the intent for those instructions?
  Reply With Quote
Old May 28th, 2023, 12:07 PM   #15
Avatar_41
Member
Turkey

Avatar_41 is offline
 
Join Date: Aug 2019
Location: Istanbul
Posts: 85
What I don't understand is: Why can't I see these 0.0 or 0.1 values, so what can I do to see 0.0 instead of -2130706432?

Quote:
Originally Posted by L D[AR2,P#0.0] View Post
You are doing nothing wrong. What is the purpose of writing the area pointer to the OUTPUT?
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum


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
Loading .Pre in an array of timers? dginbuffalo LIVE PLC Questions And Answers 24 March 11th, 2016 06:44 PM
S7 STL Dword to Byte rikcando LIVE PLC Questions And Answers 5 May 21st, 2012 05:06 PM
bit from byte IEC61131-3 hapetter LIVE PLC Questions And Answers 2 March 4th, 2011 06:25 AM
Dectect morethan 1 bit set in a byte. Darbs003 LIVE PLC Questions And Answers 20 August 12th, 2010 10:18 AM
Siemens Addressing Fun james-0000 LIVE PLC Questions And Answers 4 August 9th, 2008 12:58 AM


All times are GMT -4. The time now is 09:56 PM.


.