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 July 23rd, 2020, 10:44 AM   #16
Phrog30
Member
United States

Phrog30 is offline
 
Join Date: Dec 2006
Location: Montgomery, Alabama
Posts: 657
Quote:
Originally Posted by Peter Nachtwey View Post
1. A little late to the party
2. For a PLC5??
  Reply With Quote
Old July 23rd, 2020, 11:04 AM   #17
Firejo
Member
United States

Firejo is offline
 
Firejo's Avatar
 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 1,428
Technically there is no such thing as a true random number generator in a computer. There is always a pattern although sometimes the pattern is so long it appears that it is random. Having said that someone discovered using a Lavalamps as an analog input creates a true random number generator.
https://en.wikipedia.org/wiki/Lavarand
__________________
Go Hawks!!!
  Reply With Quote
Old July 23rd, 2020, 11:13 AM   #18
Peter Nachtwey
Member
United States

Peter Nachtwey is online now
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,185
Quote:
Originally Posted by Firejo View Post
Technically there is no such thing as a true random number generator in a computer. There is always a pattern although sometimes the pattern is so long it appears that it is random. Having said that someone discovered using a Lavalamps as an analog input creates a true random number generator.
https://en.wikipedia.org/wiki/Lavarand
Be practical. Although any pattern will eventually be repeated there are some that won't happen in a life time or while the earth still exists.
A lava lamp with an analog output? Give me a break. The AtoD converter has only some many bits of output. I you count sequences of analog output then there is still a limitation as the analog values will not change instantly.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old July 23rd, 2020, 11:19 AM   #19
Peter Nachtwey
Member
United States

Peter Nachtwey is online now
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,185
Quote:
Originally Posted by Phrog30 View Post
1. A little late to the party
2. For a PLC5??
Doesn't a PLC5 have a bit shift block where many bits can be shifted at once? ANDing with 65535 simply means separating a 32 bit value into two 16 bit ones and treating them like an unsigned number.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old July 23rd, 2020, 12:17 PM   #20
Firejo
Member
United States

Firejo is offline
 
Firejo's Avatar
 
Join Date: Jun 2008
Location: Redmond, WA
Posts: 1,428
Quote:
Originally Posted by Peter Nachtwey View Post
Be practical. Although any pattern will eventually be repeated there are some that won't happen in a life time or while the earth still exists.
A lava lamp with an analog output? Give me a break. The AtoD converter has only some many bits of output. I you count sequences of analog output then there is still a limitation as the analog values will not change instantly.
Peter I'm wondering what it's like to be a so superior to everyone else. Yet again you took what was one persons input into an interesting topic and turn it into a personal attack. I could care less what you think about my thoughts on any topic and I think you taking it to a personal level speaks volumes to the kind of person you are.
__________________
Go Hawks!!!
  Reply With Quote
Old July 23rd, 2020, 12:22 PM   #21
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 1,236
Quote:
Originally Posted by firejo View Post
...

dnftt!
  Reply With Quote
Old July 23rd, 2020, 12:46 PM   #22
kwade
Member
United States

kwade is offline
 
Join Date: May 2013
Location: sc
Posts: 355
Quote:
Originally Posted by Firejo View Post
Peter I'm wondering what it's like to be a so superior to everyone else. Yet again you took what was one persons input into an interesting topic and turn it into a personal attack. I could care less what you think about my thoughts on any topic and I think you taking it to a personal level speaks volumes to the kind of person you are.

he he

he probably unknowingly made use of it today

https://blog.cloudflare.com/randomne...in-production/
  Reply With Quote
Old July 23rd, 2020, 02:25 PM   #23
I_Automation
Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 154
One counter per digit needed
RES counter if /DN
Each counter triggered by a different TON timer, each with own short .PRE

Use counter .ACC as pointer to integer file of digits 0-9 in various orders, set counter .PRE to last integer used

CPT
(N99:[C5:1.ACC] * 1000) + (N99:[C5:2.ACC] * 100) + (N99:[C5:3.ACC] * 10) + (N99:[C5:4.ACC])


- OR -

Do a masked move of Watchdog scan time or Time Base (S:3 or S:4) and use those digits as pointers to the N99 file.

Last edited by I_Automation; July 23rd, 2020 at 02:34 PM.
  Reply With Quote
Old July 25th, 2020, 05:04 AM   #24
I_Automation
Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 154
Quote:
Originally Posted by didioloa View Post
Guys, do you have any strategies that you use?

My casino strategy that never fails:

Leave your money in your pocket, and don't take credit cards to a casino ever.
  Reply With Quote
Old July 25th, 2020, 07:45 AM   #25
I_Automation
Member
United States

I_Automation is offline
 
I_Automation's Avatar
 
Join Date: Jun 2020
Location: Detroit, Michigan USA
Posts: 154
Hmmm,
Must be against the forum policy to promote a casino..........
  Reply With Quote
Old July 25th, 2020, 12:49 PM   #26
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 1,236
I heard a scheme to have $1,000,000 owning racehorses: you start with $2,000,000, ...
  Reply With Quote
Old July 25th, 2020, 10:02 PM   #27
Phrog30
Member
United States

Phrog30 is offline
 
Join Date: Dec 2006
Location: Montgomery, Alabama
Posts: 657
Quote:
Originally Posted by Peter Nachtwey View Post
Doesn't a PLC5 have a bit shift block where many bits can be shifted at once? ANDing with 65535 simply means separating a 32 bit value into two 16 bit ones and treating them like an unsigned number.
Yes, I was merely stating your linked C# example isn't a direct drop in. Probably better to reference PLC code, not C# code. But, that's just me.
  Reply With Quote
Old July 25th, 2020, 11:11 PM   #28
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 1,236
Quote:
Originally Posted by Peter Nachtwey View Post
Doesn't a PLC5 have a bit shift block where many bits can be shifted at once? ANDing with 65535 simply means separating a 32 bit value into two 16 bit ones and treating them like an unsigned number.

No, not like C/C++ has the >> operator.

The PLC-5 Bit Shift instructions (e.g. here) shift by one bit position at a time, so to get the equivalent of C/C++ [>>16], i.e. shift right by 16 in PLC-5, it may be easier to
  1. AND with -65536,
  2. DIVide by 65536,
  3. AND with 65535,
in that order.
  Reply With Quote
Old July 25th, 2020, 11:11 PM   #29
Peter Nachtwey
Member
United States

Peter Nachtwey is online now
 
Peter Nachtwey's Avatar
 
Join Date: Apr 2002
Location: Vancouver, WA, US
Posts: 7,185
Quote:
Originally Posted by Phrog30 View Post
Yes, I was merely stating your linked C# example isn't a direct drop in.
It is the algorithm that is important. Some assembly may be required.



Quote:

Probably better to reference PLC code, not C# code. But, that's just me.
Do an internet search for "random number generator PLC5". All you get it this thread. There aren't any PLC5 random number generator examples.



I don't have a PLC5 and have only programmed one once in a galaxy far far away.


The key is the algorithm. There are a few good algorithms. Many were generated by George Marsaglia

https://en.wikipedia.org/wiki/George_Marsaglia

I use the algorithm I posted a link to. However, that may not have been the easiest to implement on a PLC5. I would consider the XorShift section of this


https://en.wikipedia.org/wiki/Linear...shift_register
Since I think it could be implemented with a BSL or BSR instruction and some XOR blocks.


Can you handle a BSL or BSR blocks and some XOR blocks?


Now can someone implement a 16 bit and 32 bit LFSR on a AB PLC?It should be easy for LD [] to do it on a S7.
The problem will be solved.


I can think of only one potential problem. The generated numbers will appear random but the sequence of numbers will always be the same. This may be good or bad depending on needs.


Some people of thin skin.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon
  Reply With Quote
Old July 25th, 2020, 11:31 PM   #30
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 1,236
Quote:
Originally Posted by Peter Nachtwey View Post
It is the algorithm that is important. Some assembly may be required.

Of course.


Quote:
Originally Posted by Peter Nachtwey View Post

I can think of only one potential problem. The generated numbers will appear random but the sequence of numbers will always be the same. This may be good or bad depending on needs.

It depends on the seed; the PLC-5 has six status words in its clock (year, month, ..., second); the low 5 to 6 bits of each of (day of month, hour of day, minute of hour, second of minute) would combine into a reasonable one-time, 20-bit+ seed that would generate one of a million different pieces of the sequence each time.


Also, if someone has chosen a PLC do so summat random, then it is unlikely to be important that the quality of the RNG is not at a crytographically-secure level; if it's important e.g. a casino, then they have enough money and don't have to fiddle around with underpowered toys.
  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
S7 Random Number Generator RRobbins LIVE PLC Questions And Answers 14 July 8th, 2016 08:36 AM
Allen Bradley 1761-NET-ENI Jezz LIVE PLC Questions And Answers 11 August 17th, 2007 08:56 PM
S7-416-2 DP Fault - SFB20 sparky64 LIVE PLC Questions And Answers 8 July 30th, 2004 03:48 AM
Philosophical Illusion? Terry Woods LIVE PLC Questions And Answers 71 June 28th, 2004 08:41 AM
"Random" number generation ajbachhuber LIVE PLC Questions And Answers 9 September 10th, 2003 09:41 PM


All times are GMT -4. The time now is 07:19 PM.


.