1 2 Previous Next 16 Replies Latest reply on Oct 25, 2019 3:37 AM by LePo_1062026

    How to use internal logic circuit

    suto_2664507

      If you can see SCH, you can understand, but it is an AND circuit of SW and DOWN OR circuit and HOS_SW. Theoretically, if the output of the OR circuit is active Low or when HOS_SW is active Low, the external output LED04 becomes active Low. An externally pulled-up LED is mounted. Will the external LED04 be lit in this circuit? The external output pin is Bidirectional and is active Low in the open-drain circuit.

        • 1. Re: How to use internal logic circuit
          JoMe_264151

          Can you please post your complete project so that we all can have a look at all of your settings. To do so, use

          Creator->File->Create Workspace Bundle (minimal)

          and attach the resulting file.

           

          Bob

          • 2. Re: How to use internal logic circuit
            suto_2664507

            Hi Bob

             

            thank you for the advice!

            Attach the compressed file.

             

            Best Regards,

            Tossiy

            • 3. Re: How to use internal logic circuit
              JoMe_264151

              LED should light continuously except when SW DOWN and HOS WS are presses simultaneously within a 1/00 s window (which I think might be a bit small) and be dark for 1/100s which you may not see.

               

              Bob

              1 of 1 people found this helpful
              • 4. Re: How to use internal logic circuit
                LePo_1062026

                Tossiy,

                 

                I agree with Bob.  The LED04 should be continuously ON ... EXCEPT when ( SW || DOWN) && HOS_SW is true.  When true, the LED04 will turn off for 1/100 s (=0.01 s).  The human eye can detect a pulse of 1/60 s or longer.  Therefore the 1/100s pulse may be too short.

                 

                What is your intended logic for this LED04?

                 

                Len

                1 of 1 people found this helpful
                • 5. Re: How to use internal logic circuit
                  suto_2664507

                  Thank you, Bob.

                  I was relieved that your confirmation was obtained.

                   

                  Xperia™から送信

                   

                  JoMe_264151さんは書きました

                   

                  >JoMe_264151  replied to the discussion

                  >"How to use internal logic circuit"

                  >To view the discussion, visit: https://community.cypress.com/message/211264?et=watches.email.thread#211264

                  >

                  • 6. Re: How to use internal logic circuit
                    suto_2664507

                    Hi Len

                     

                    I'm a beginner programmer and I'm currently studying C language.

                    So, I designed it with hardware, but the specification is that LED04 should be light for 0.5 seconds when SW and DOWN are pressed at the same time and only HOS_SW is pressed.

                     

                    Best Regards,

                    Tossiy

                     

                     

                    Xperia™から送信

                     

                    LePo_1062026さんは書きました

                     

                    >LePo_1062026  replied to the discussion

                    >"How to use internal logic circuit"

                    >To view the discussion, visit: https://community.cypress.com/message/211282?et=watches.email.thread#211282

                    >

                    • 7. Re: How to use internal logic circuit
                      LePo_1062026

                      Tossiy,LED04_timer_cnt

                       

                      This logic can be implemented in HW or SW.  Your choice.  That's why I personally love the PSoC because I can design circuits in HW to minimize SW and achieve very high performance.

                       

                      Let me see if I understand your logic definition for LED04.  I will write what I think the logic you want in C code.  Please correct me if I'm not correct.

                      for(;;)     // forever loop

                           bool LED04_active;

                           uint16_t LED04_timer_cnt = 0;

                       

                           if(  (SW && DOWN) || HOS_SW )          // if BOTH SW 'and' DOWN switches pressed 'or' HOS_SW pressed

                           {

                                LED04_active = true;         // the LED is active

                                LED04_timer_cnt = 500;   // Start the 0.5 second timer.  count in 1ms intervals

                           }

                      ...

                           // If using SW, place code here to count down LED04_timer_cnt once every 1ms.

                      ...

                           if( LED04_timer_cnt == 0)

                           {

                                LED04_active = false;

                           }

                           LED04_Write(LED04_active);

                      }

                       

                      // You can use the systick feature on the PSoC to get 1ms clock ticks if you wanted.  Otherwise you can use a HW timer.

                      // If you use the debounce components without a HW timer (using a 2Hz clock), then your timing resolution is 0.5s +/- 0.5s

                       

                      If you chose to perform the logic listed above in HW, you can minimize the code above significantly.

                       

                      Len

                      1 of 1 people found this helpful
                      • 8. Re: How to use internal logic circuit
                        suto_2664507

                        Hi Len Thank you for the program source code I received from you. Currently, I'm studying the program that I received from you. By the way, if you use this logic circuit without passing DEBOUNCER, how about? If I change to this circuit, the LED04 only lights up while the Switch is pressed. Today we have the PSoC5LP-097 kit, so let's experiment with it. Best Rrgards, Tossiy

                        • 9. Re: How to use internal logic circuit
                          LePo_1062026

                          Tossiy,

                           

                          Attached is a modified version of your TopDesign with a PulseConverter component.  It converts the shorter switch edge pulses (10ms) to 500ms for the LED04 if the logic is correct.  The logic used: (  (SW && DOWN) || HOS_SW ) .  If this is not the correct switch logic, change the logic gates after the debouncers.

                           

                          Len

                          1 of 1 people found this helpful
                          • 10. Re: How to use internal logic circuit
                            suto_2664507

                            Hi Len

                             

                            Thank you so much for taking a moment of your precious time for me.

                            I didn’t know that.

                            You made a 0.5 second pulse length using a pulse converter.

                            I was able to understand that it can be configured by hardware without relying on software.

                            It will be a good study for me.

                            Thank you.

                            Best Regards,

                             

                            Tossiy

                            • 11. Re: How to use internal logic circuit
                              suto_2664507

                              Hi Len I have a question regarding the sch file that you've e-mailed me Oct.9. 1.Is it okay if I don't write c-source program by changed sch-file? 2.After I build this program, the LED04 lights keep on. I don't know why. Please tell me how to solve it. Tossiy

                              • 12. Re: How to use internal logic circuit
                                LePo_1062026

                                Tossiy,

                                 

                                I'm not sure how to answer your question.   Are you using my project I attached in this discussion?  If not, send me what you have that is causing the LED04 to stay on.

                                 

                                Len

                                • 13. Re: How to use internal logic circuit
                                  suto_2664507

                                  Hi Len

                                   

                                  The attached file(sch) is the one I received from you last time.

                                  When the power is turned on, the LED lights up suddenly.

                                   

                                  The specification is as follows.

                                  1.When DOWN and SW are pressed simultaneously, the LED04 turns on.

                                  2.When I press only HOS_SW, LED04 lights up.

                                  The lighting time is 0.5 seconds.

                                   

                                  Logic is immutable, even if I change.

                                  Do I need to add a program?

                                   

                                   

                                  Best Regards,

                                  Tossiy

                                  • 14. Re: How to use internal logic circuit
                                    LePo_1062026

                                    suto,

                                     

                                    I believe I solved the issue.  The logic I presented was correct but the clock generation for both the Clock_2Hz and Clock_100Hz is at fault.

                                     

                                    Here is a pic of the Clock tab of the DWR.  You can see that both the 2Hz and 100Hz was assigned to the same clock of 915.527 Hz!!!  This is because the input clock is the MASTER_CLK = 60MHz.  The maximum division for the clock source is 65536.

                                    I reassigned the clock source to be the ILO.

                                    This as least addressed the generated clock for 2Hz and 100Hz to be closer to the intended frequency.

                                     

                                    Additionally, I miscalculated that the PulseConvert component only worked on rising edges.  Therefore I needed to change the for the input and output to the component.  (See the new logic below)

                                    Here is a scope plot of the 'fixed' logic.  You can see that the LED04 (D3) pulse is a active low signal of a 453.3ms width when one of the switches (HOS_SW) in this case is active low.  You requested 500ms, however the accuracy of the ILO oscillator is +100% -50%.  Not very accurate.  If needed, you can use the MASTER_CLK as the source but with a Frequency Divider component.  This allows the IMO accuracy (0.25% in your design) to be used.  The downsides are it takes more UDB resources to create two Frequency Divider components and the human eye will not really notice the difference of improved accuracy.

                                     

                                    Len

                                    1 2 Previous Next