![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]()
|
New Here? Please read this important info!!!
![]() |
#16 | |
Lifetime Supporting Member
|
Quote:
![]() Bubba.
__________________
“Now will come the nay-sayers with all the reasons why you shouldn't do this. Some of them are teachers, and some of us are doers. Besides, you have got to let the smoke out of this equipment every now and then, or it starts to clog up the chimney.” ~Lancie1 |
|
![]() |
![]() |
#17 |
Member
![]() ![]() Join Date: Dec 2007
Location: Los Alamos
Posts: 337
|
Why locking? For completeness, I'd like to see a translation of that into Rockwell Structured Text
|
![]() |
![]() |
#18 |
Lifetime Supporting Member
![]() ![]() Join Date: Jun 2012
Location: Australia
Posts: 3,013
|
|
![]() |
![]() |
#19 | |
Member
|
Quote:
Code:
(* RNG calculates random numbers from 0 to 1. RNG requires two in_out variables to maintain state. *) FUNCTION RNG : REAL VAR_IN_OUT m_z : DWORD; m_w : DWORD; END_VAR VAR u: DINT; END_VAR m_z:=DINT_TO_DWORD(36969*DWORD_TO_DINT(m_z AND 16#FFFF)+DWORD_TO_DINT(SHR(m_z,16))); m_w:=DINT_TO_DWORD(18000*DWORD_TO_DINT(m_w AND 16#FFFF)+DWORD_TO_DINT(SHR(m_w,16))); u := DWORD_TO_DINT( SHL(m_z,16))+DWORD_TO_DINT(m_w); RNG :=DINT_TO_REAL(u+1)*2.328306435454494E-10+0.5; END_FUNCTION // http://www.codeproject.com/KB/recipes/SimpleRNG.aspx It would be better if m_z and m_z were part of a function block.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon |
|
![]() |
![]() |
#20 | |
Lifetime Supporting Member + Moderator
|
Quote:
Yes there are some that should not be reopened but this was not one also in a day or two they will be out of sight and out of mind. If its spam it gets deleted by the mods and as long as no one replies to the thread it goes back in the file and back to the date it was last replied too.
__________________
www.PLCCable.com PLC Communication Cables, PLC Trainers, Fluke Meters, MicroLogix, ControlLogix, Siemens, Allen Bradley and more... all your automation needs... ((NEW)) After Market 1784-U2DHP Allen Bradley USB to DH+ and Gateways |
|
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
S7 Random Number Generator | RRobbins | LIVE PLC Questions And Answers | 14 | July 8th, 2016 08:36 AM |
Usless but maybe fun excercise | ndzied1 | LIVE PLC Questions And Answers | 6 | May 15th, 2006 07:28 AM |
PLC 5/04 random number generator | seat14 | LIVE PLC Questions And Answers | 2 | December 11th, 2005 12:29 AM |
Random number | Shahed | LIVE PLC Questions And Answers | 4 | December 3rd, 2005 04:25 AM |
Random number generator for PLC5 | Contr_Conn | LIVE PLC Questions And Answers | 11 | September 8th, 2004 02:57 AM |