Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

generate random number in 16f628

Status
Not open for further replies.

johnson

New Member
dear all,

anyone knows how to "continuosly " generating a series of random number in 16f628, prefereble in using pic basic. I try using random command but it does not generate the random number.

thanks!


cheers,
 
I don't know how to write basic for pic, but i remembered that there is a algorithm to build random function as I studied on programming in high school.

The fact that random is not relly random, but it's made from an algorithm that choose one of upto 10^12 matrix elements in Pascal. And if you want, you can make it.

Perhaps you have to review how to generate random function in high level languages, and then do it in PICs. I'm in doubt that high level language for PIC can give random function. If you find out the ans, pls tell meeh. I also care bout it.
 
Try this, gets numbers from 1 to 255

Code:
     FOR R = 0 TO 10
	  X= RANDOM+X
	  NEXT R
	  RND=X/250
x is a DWORD
RND is BYTE long
I hope ist help.

Why is the random command not generating you random numbers ?
It is 16 bit long 1 - 65535, there is 65535 combination, I just tried,
for 5 min I have never got the same number !? [1sec/num]


STEVE
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top