Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 10th April 2004, 05:08 PM   (permalink)
Default generate random number in 16f628

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,
johnson is offline  
Old 10th April 2004, 09:34 PM   (permalink)
Default

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.
falleafd is offline  
Old 10th April 2004, 09:52 PM   (permalink)
Default

might be of interest
http://www.phanderson.com/PIC/16C84/random.html

Just google it... comes up with lots of hits
Exo is offline  
Old 11th April 2004, 05:43 AM   (permalink)
Default

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
csaba911 is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 06:34 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker