I can film a video, if you like![]()
I can film a video, if you like![]()
You could, if you want to, or just post the code (not just the snippet above) for the 16F870 and two or three sequences of the result you're getting.
/Henrik.
On each cycle run, it returns different results. With 12F683, results are fixed, does not changing, no matter how many times loop is run.Code:include "modedefs.bas" DEFINE OSC 4 DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 4 DEFINE LCD_RSREG PORTB DEFINE LCD_RSBIT 0 DEFINE LCD_EREG PORTB DEFINE LCD_EBIT 1 DEFINE LCD_BITS 4 DEFINE LCD_LINES 2 DEFINE LCD_COMMANDUS 1500 DEFINE LCD_DATAUS 44 ADCON1=%00000110 'CONFIGURE PORT A AS DIGITAL PIRVELI VAR BYTE 'CHARTVISAS BEEPEBIS RAODENOBA MEORE VAR BYTE 'CHARTVISAS LEDEBIS CIMCIMIS RAODENOBA MESAME VAR BYTE 'meore etapisatvis shemtxveviti ricxvi MEOTXE VAR BYTE 'MESAME ETAPIS SHEMTXVEVITI RICXVI DROEBITI VAR WORD 'DROEBITI SHEMTXVEVITIS GENERACIISATVIS DROEBITI2 VAR WORD DROEBITI3 VAR WORD MTVLELI VAR WORD 'VARIABLE FOR COUNTER bvar1 var byte bvar2 var byte ROM1 VAR BYTE ROM2 VAR BYTE ROM3 VAR BYTE ROM4 VAR BYTE 'PRAVI VAR GPIO.0 'DEFINITIONS TAVKA: DROEBITI2=0 DROEBITI3=0 DROEBITI=0 READ 1,ROM1 READ 2,ROM2 READ 3,ROM3 READ 4,ROM4 GENERATE: 'CVLADEBIS GENERACIA RANDOM DROEBITI PIRVELI=(DROEBITI//6)+1 RANDOM DROEBITI MEORE=(DROEBITI//6)+1 RANDOM DROEBITI MESAME=(DROEBITI//6)+1 RANDOM DROEBITI MEOTXE=(DROEBITI//6)+1 lcdout $fe,$c0,"1=",#pirveli, " 2=",#meore, " " pause 50 goto generate end
I may be misunderstnading but previously you said that you needed some random numbers on power up. Now you're running the routine in a loop (at least that's how I understand it) - that's not the same thing. Each time thru the loop the seed will be what the last RANDOM statement generated. But when you start from scratch (ie power up) the seed will always be 0. As long as the seed is the same (ie 0 at power up) you'll get the same results - and I'll stick to that for a little while longer ;-)
Run this on a 16F870 and on a 12F683Cycle the power and run it again. Does it really give you A) Random numbers on the 16F870 but not on the 12F683 and/or B) Different results on 16F870 compared to the 12F683?Code:GENERATE: 'CVLADEBIS GENERACIA RANDOM DROEBITI PIRVELI=(DROEBITI//6)+1 RANDOM DROEBITI MEORE=(DROEBITI//6)+1 RANDOM DROEBITI MESAME=(DROEBITI//6)+1 RANDOM DROEBITI MEOTXE=(DROEBITI//6)+1 lcdout $fe,$c0,"1=",#pirveli, " 2=",#meore, " " pause 50 end
/Henrik.
Tested the above code. On power up, it gives 3 and 6 on 16f870 and 2 and 4 on 12f683, same results on each power up.
however, if I place it in the loop, results on 16f870 are changing, while on 12f683 they remain 2 and 4.
Hi,
OK, the fact that you don't get the exact same sequence from the two devices could possibly (I don't know) come from the different instruction width (12 vs 14 bits) between the two. But why the 12F683 doesn't continue the sequence when the routine is looped is beyond me.
/Henrik.
Bookmarks