Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - SRAND instruction, how to use it?

(you are viewing a thread; or go back to list of threads)

SRAND instruction, how to use it? (by MGP)
Is there someone who can give me more insight into the SRAND instruction based on a small example?

The example in the manual is not clear enough for me, you would do me a great favor with it.
Sun Mar 17 2019, 03:50:33
(no subject) (by Ziggy)
When the SRAND is presented with a TRUE condition it will read the value of seed variable and generate a pseudo random number output.
The mapping from seed variable to output variable is constant. For same seed You always get same response.

You can take response value and assign it to seed variable and depending on the length of the epoch the output will appear as a random number sequence ... until the epoch is finished and it repeats again.

Often used in spread spectrum communications as a spreading function.

Where it might be useful to You ... hmmm... don't know.
I have used it in the past in fact i wrote my own pseudo random function based on a sixteen bit polynomial.

The epoch is the length of the pseudo random sequence before the unique inpur response pairs start repeating.

Some solutions ( polynomials are sub optimal) produce same response for two different inputs as such they are as useful as an ashtray on a motorbike.

for more info ... google M sequence linear feedback shift registers

You might want to write a little routine ... a modem to send info to your PC... and a SRAND with output fed back to seed with a printout of seed output pairs.

Import text into a spread sheet and plot it for visual feel.
Sun Mar 17 2019, 21:02:59
(no subject) (by MGP)
Duhh.. after reading this 20 times I still dont understand what you are trying to say, I am more confused than before ;-)

I dont understand the relation between the 2 seed variables and the random function.
Mon Mar 18 2019, 11:45:40
(no subject) (by Ziggy)
My apologies...

random function is a function whihc takes an input number the seed.

It then uses the seed to calculate the random function value.

You can use the random function output to do what ever you need it for.

If you feed the the output of random function back into itself, it will calculate a new random value.

If you keep feeding the output back into the function You will keep on getting new random function values.
Eventually You willstart to see numbers You have already seen.
You will have reached the end of the "EPOCH" of the pseudo random generator.

How you use this is up to You.

May be You can use it as a source of noise say to inject a bit of noise into a mechanical system whihc needs a bit of noise to prevent it from sticking into one position... or may be some other application..The pseudo random generators are based on Maximum length polynomial expressions which if say 8th order will have 255 distint solutions.

Non maximum length 8th order polynomial will have fewer than 255 solutions.

Maximum length polynomials are used as spreading functions in spread spectrum communications. Where You use it is up to Your application, I used it to flash a light source whihc due to data randomness causes the eye blink response to be triggered.
Mon Mar 18 2019, 16:38:23
(no subject) (by MGP)
I was helping someone with an artistic project with random video images and used the RAND instruction for that and I wondered what that SRAND instruction meant.

I do not fully understand it yet but I will study your explanation carefully, anyway thank you for the explanation.
Mon Mar 18 2019, 17:12:42
(no subject) (by Ziggy)
the difference between RAND and SRAND in the context of above explanation is that RAND is identical to SRAND with new seed value permanently fed back from output of SRAND function permanently so that just like RAND the SRAND returns a new value everytime it is called .

With RAND you get a new value everytime You call it... same with SRAND when output fed back into input.
Mon Mar 18 2019, 19:24:20
(no subject) (by Ziggy)
If you plot out the SRAND seed versus output numbers then You could assign different passwords to operators so that the software expects a sign on number....whihc is the first seed value...
it then generates the new number from seed and the operator then has to know what that number is and punch it in for access to the equipment.

A kind of challenge and response system. Depending on the length of the epoch the number os pass codes could be largish.
By modifying the response from the first seed ( say adding a number to the response ) the next input would be somewhere else in the sequence providing additional security.
Mon Mar 18 2019, 20:47:38
(no subject) (by MGP)
Ziggy thank you very much, this is much better to understand what it does, this also allow me better to understand what the example in the manual is trying to explain.

If I have more time, I will try it out in practice.
Tue Mar 19 2019, 04:15:28
(no subject) (by MGP)
To all, I made a 6 channel 16bit random serial out, speed regulated with AD, generator on a 16F886 introsc 8Mhz, more than 6 channels = out of memory.


Attached you can find the 1-channel version (16F88) for learning purpose, if you want more channels then copy/paste the rungs and change the numbers.
It has a disable pin and a latch pin.

If you simulate it you must change the AD value >0
Tue Mar 19 2019, 05:03:03, download attachment random_16bit_serialout_speedcontrolled.ld
(no subject) (by MGP)
To Ihor, the last version of LDmicro is the best version I ever had, a pleasure to work with. Thx
Tue Mar 19 2019, 05:09:22
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):