1 2 3 Previous Next 64 Replies Latest reply on Aug 29, 2014 6:38 AM by ki.leung

    PSoC1 LCD

    chris.devitt

       I have loaded the PWM PRS example and added an LCD to display the CompareValue as a percentage as well as show the CompareValue as a bar graph. The 0 bargraph appears to be all partially on without the hexbyte displayed.

         

      Archive attached

         

      Any suggestions?

         

      Chris 

        • 1. Re: PSoC1 LCD
          ki.leung

          In your while loop, you just update the PWM and not writing anything to the LCD.

          • 2. Re: PSoC1 LCD
            chris.devitt

             I get the same result if the LCD script is put inside the loop

               

            Chris

            • 3. Re: PSoC1 LCD
              chris.devitt

               OK, the solution is to put the LCD code between the loops. Although I would have thought that the LCD would have been updated inside the loop after the input register was read.

                 

              Is there a command to write decimal numbers to the LCD?

                 

              Chris

              • 4. Re: PSoC1 LCD
                ki.leung

                If you don't put it inside the loop it would never shown.

                   

                Here is my approach for this project. Do one thing a time

                   

                1. Print a message such as hello world to the LCD

                   

                2. Use a delay loop to print a message with a counter which increase every 1 second..

                   

                3. Add the counter to count the number of keypress and shown on the LCD

                   

                4. Add another button so can do up and down counts and shown on the LCD

                   

                5. Change the step size of every increment or decement and print it on the LCD

                   

                6. Add printing of the bar

                   

                7. Add setting of the PWM

                • 5. Re: PSoC1 LCD
                  ki.leung

                  You should try example project, there is one about writing a ADC value on the LCD and other one is about using the PWM.

                  • 6. Re: PSoC1 LCD
                    user_1377889

                    Converting ints to decimal strings use atoi()

                       

                    Decimals and float conversion best with sprintf().

                       

                    C-manual I like most is here: publications.gbdirect.co.uk/c_book/, look under Libraries, formatted I/O

                       

                     

                       

                    Bob

                    • 7. Re: PSoC1 LCD
                      user_1377889

                      (&§%E$)! NOT  atoi() but  itoa()!

                         

                      As a matter of fact it seems as if I cannot tell the right hand side from the left hand side, but mixing itoa and atoi is new for me!

                         

                       

                         

                      Bob

                      • 8. Re: PSoC1 LCD
                        chris.devitt

                         Thanks for your comments HL.

                           

                        Bob, sounds like a plan. I'll give it a whirl!

                           

                        Thanks mate

                           

                        Chris D.

                        • 9. Re: PSoC1 LCD
                          chris.devitt

                           More on the LCD. I still cannot display decimal numbers on the LCD. The only way is to print a hex byte with either two or four characters and this converts decimal numbers to hex bytes and displays the hex byte.

                             

                          Secondly is there any way to speed up the LCD processing. With LCD outputs included in a while loop the updated data from PTR0DR takes forever to process even though CPU clock is set to sysclock/1 on a 24MHz system. If I take out the LCD code then the update from PRT0DR is blindingly fast. I am using the 3210 eval kit.

                             

                          Chris D.

                          • 10. Re: PSoC1 LCD
                            user_1377889

                            The LCD is a rather slow device with delay loops (needed!) in the range of some ms. So it will be difficult to speed that up.

                               

                            I do not understand what you mean with "update PRT0DR", can you please post your complete project, so that we all can have a look at all of your settings? To do so, use
                            Designer->File->Archive Project
                            and attach the resulting file (do NOT use chrome, that still may not work).

                               

                             

                               

                            Bob
                             

                            • 11. Re: PSoC1 LCD
                              ki.leung

                              The charater LCD you are using is very slow, you cannot expect it as fast as you computer monitor. It is much much slower.  

                                 

                              The reponse time of the LCD display (optical) is in the range of 100-300ms. So basically it is no use t undate it more than 10 times a second (unless you want to create grey scale this way).

                              • 12. Re: PSoC1 LCD
                                chris.devitt

                                 I suspect I will need to send the CompareValue data from inside the loop to a register and then have the LCD read the register every 500mS? with a routine outside the loop.

                                   

                                Chris

                                • 13. Re: PSoC1 LCD
                                  user_1377889

                                  Your LCD only needs to get initialized only once, same with the bargraph. Best would be to put all the hardware (and software) initialization stuff into a separate routine that is called from main() in the very beginning. Also, when needed, enable interrupts there.

                                     

                                  Constructs in C-language as

                                     

                                  Variable = Variable +1; is better written as Variable++;

                                     

                                  and

                                     

                                  Variable = Variable + n; written as Variable += n;

                                     

                                  This will allow the compiler to generate denser code..

                                     

                                  Under Help->Documentation->Compiler and Programming Documents->C Language Compiler User Guide You will find an explanation on how to use the itoa() macro which will convert integers to ascii.

                                     

                                   

                                     

                                  Bob

                                  • 14. Re: PSoC1 LCD
                                    user_1377889

                                    Som additional thoughts:

                                       

                                    Working with a pseudo random number generator is usually done in the following order:

                                       

                                    Start the hardware, write the polynom.

                                       

                                    Seed the PRS.

                                       

                                    Retrieve several numbers from generator where usually the number is smaller than the period of the PRS.

                                       

                                     

                                       

                                    A PRS does not give you a random number, it delivers a random progession of numbers. When you are looking at getting something random you ought to google for "true random number" or ask Mrs. W. Pedia for it.

                                       

                                     

                                       

                                    Bob

                                    1 2 3 Previous Next