8 Replies Latest reply on Jan 5, 2012 3:51 AM by user_1377889

    PSoC 3 Pseudo Random Sequence (PRC) Problem

    user_95319268

       Hello,

         

      i'am using the prs 2.0 component in one of my projects to generate step by step pseudo random values. 

         

       

         

      The component is configured as 32bit Resolution (32, 30, 26, 25) with seed value 0xFFFFFFFF in single cycle and single step API mode.

         

      Initialization is done trough:

         
       PRS_1_Start();
         

      An following lines of code are step by step iterated:

         
       uint32 binprc = PRS_1_Read();  SendBuffer[3] = (uint8)(binprc & 0x000000FF);  SendBuffer[2] = (uint8)((binprc>>8) & 0x000000FF);  SendBuffer[1] = (uint8)((binprc>>16) & 0x000000FF);  SendBuffer[0] = (uint8)((binprc>>24) & 0x000000FF);   USBUART_1_Write(SendBuffer, 4);  PRS_1_Step();
         

       

         

      So I get the binary values from the shift register sent through usb. The values are then displayed in binary coding (each line a step of 4 bytes, left MSB):

         

       

         
       #0: 11111111111111111111111111111111   #1: 10111001111111111111111111111111   #2: 00110101111111111111111111111111   #3: 01101011111111111111111111111110   #4: 11010111111111111111111111111100   #5: 11101001111111111111111111111001   #6: 10010101111111111111111111110011   #7: 01101101111111111111111111100111   #8: 11011011111111111111111111001110   #9: 11110001111111111111111110011101  #10: 10100101111111111111111100111011  #11: 00001101111111111111111001110111  #12: 00011011111111111111110011101110  #13: 00110111111111111111100111011100  #14: 01101111111111111111001110111000  #15: 11011111111111111110011101110000  #16: 11111001111111111100111011100001  #17: 10110101111111111001110111000011  #18: 00101101111111100011101110000111  #19: 01011011111111000111011100001110  #20: 10110111111110011110111000011100
         

      ...

         

      For my understanding it looks like that with each step one bit comes shifted in from the lsb side. But what are the 5..7 Bits in the MSB part?? Pseudo random values should be equal from one to the next step up to the shiftet in new bit?

         

       

         

      Can anybody help me :)

         

      Bye

         

      Franz

        • 1. Re: PSoC 3 Pseudo Random Sequence (PRC) Problem
          user_1377889

          Hi Franz,

             

          it is always easier for us to have a look at the complete project (or a working example).

             

          Would you mind to

             

          1st Clean project

             

          2nd Archive (minimal and compressed)

             

          3rd upload here

             

           

             

          I'll have a look at it.

             

          Bob

          • 2. Re: PSoC 3 Pseudo Random Sequence (PRC) Problem
            user_1377889

            and

               

            the watched behaveour (shifting in bits from MSB into LSB) is part of the defined algorithm to generate those Pseudo-Randomnumber-Sequence.

               

            That implies:

               

            The numbers are not random-numbers

               

            The sequence of the numbers fulfills a math test for a random-number sequence.

               

             

               

            When displayed as binary values, the shifts become obvious, but when displayed as decimals, the "pseudo" gets a bit hidden.

               

            So my question is: What do you want to do with that Sequence of numbers?

               

            Or do you just need a (some) Random-number(s)?

               

            Bob

            • 3. Re: PSoC 3 Pseudo Random Sequence (PRC) Problem
              user_95319268

               Ok it seems to missunderstood...

                 

               

                 

              The shifted in bit from the right side (lsb side) is the correct behaviour (typical LFSR). My Problem is the 5..7Bits on the left side (msb side) that doesn't shift correctly. I do not know where they come from.

                 

               

                 

              I expect:

                 

              #0: 11111111

                 

              #1: 1111111n

                 

              #2: 111111nn

                 

              #3: 11111nnn

                 

              #3: 1111nnnn

                 

              ...and so on with "n" is one pseudo random shifted in new bit each time. Ane each time a MSB bit is shifted out on the MSB side.

                 

               

                 

              I need this for decoding a fetched sequence. Maybe I can pack a stripped version of the project and upload it here.

                 

               

                 

              Thanks for your help.

              • 4. Re: PSoC 3 Pseudo Random Sequence (PRC) Problem
                user_95319268

                 Or with the example above:

                   

                 

                   
                #0: 11111111111111111111111111111111  #1: 11111111111111111111111111111111  #2: 11111111111111111111111111111111  #3: 11111111111111111111111111111110  #4: 11111111111111111111111111111100  #5: 11111111111111111111111111111001  #6: 11111111111111111111111111110011  #7: 11111111111111111111111111100111  #8: 11111111111111111111111111001110  #9: 11111111111111111111111110011101  #10: 11111111111111111111111100111011  #11: 11111111111111111111111001110111  #12: 11111111111111111111110011101110  #13: 11111111111111111111100111011100  #14: 11111111111111111111001110111000  #15: 11111111111111111110011101110000  #16: 11111111111111111100111011100001  #17: 11111111111111111001110111000011  #18: 11111111111111100011101110000111  #19: 11111111111111000111011100001110  #20: 11111111111110011110111000011100   I hope will help. Thanks.  
                • 5. Re: PSoC 3 Pseudo Random Sequence (PRC) Problem
                  user_95319268

                   okay again :-)

                     

                   

                     

                   

                     

                  #0: 11111111111111111111111111111111

                     

                   #1: 11111111111111111111111111111111

                     

                   #2: 11111111111111111111111111111111

                     

                   #3: 11111111111111111111111111111110

                     

                   #4: 11111111111111111111111111111100

                     

                   #5: 11111111111111111111111111111001

                     

                   #6: 11111111111111111111111111110011

                     

                   #7: 11111111111111111111111111100111

                     

                   #8: 11111111111111111111111111001110

                     

                   #9: 11111111111111111111111110011101

                     

                  #10: 11111111111111111111111100111011

                     

                  #11: 11111111111111111111111001110111

                     

                  #12: 11111111111111111111110011101110

                     

                  #13: 11111111111111111111100111011100

                     

                  #14: 11111111111111111111001110111000

                     

                  #15: 11111111111111111110011101110000

                     

                  #16: 11111111111111111100111011100001

                     

                  #17: 11111111111111111001110111000011

                     

                  #18: 11111111111111100011101110000111

                     

                  #19: 11111111111111000111011100001110

                     

                  #20: 11111111111110011110111000011100

                  • 6. Re: PSoC 3 Pseudo Random Sequence (PRC) Problem
                    user_1377889

                    The algorithm for generating pseudo-random numbers is not only shifting in of the msb into the lsb. The parameter named "Polynome" gives the bit-positions which are to be XORed with theit previous positions. Not all polynomes guarantee to deliver a sequence of optimal length (2^bitnumber) but the default polynom is.

                       

                    When you look at the polynome for your 32-bit PSR, you see that it just uses a few upper-bits where you observe the sudden bit-changes in your output.

                       

                    The seed - value gives the opportunity to have 2^bits -1 different sequences (start pooints of the sequence) only the seed-value of zero (0) will not generate a sequence.

                    • 7. Re: PSoC 3 Pseudo Random Sequence (PRC) Problem
                      user_95319268

                       Yes a noticed yesterday, that the implemented LFSR algorithm is the galois one and not fibbonnaci, that I expect.

                         

                      I solved it this way, that I fetch the bitstream output in another ordinary shift register and so get my random values as calculated in my simulations.

                         

                       

                         

                      Thank you for your help!

                         

                      Franz

                      • 8. Re: PSoC 3 Pseudo Random Sequence (PRC) Problem
                        user_1377889

                        You'e welcome

                           

                        Bob