How to use internal logic circuit

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
suto_2664507
Level 4
Level 4
50 replies posted 25 replies posted 10 replies posted

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.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

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

Len
"Engineering is an Art. The Art of Compromise."

View solution in original post

16 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Bob

thank you for the advice!

Attach the compressed file.

Best Regards,

Tossiy

0 Likes

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

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

>

0 Likes

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

Len
"Engineering is an Art. The Art of Compromise."

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

>

0 Likes

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

Len
"Engineering is an Art. The Art of Compromise."

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

0 Likes
lock attach
Attachments are accessible only for community members.

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

Len
"Engineering is an Art. The Art of Compromise."

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

0 Likes

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

0 Likes

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

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
lock attach
Attachments are accessible only for community members.

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

0 Likes

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.

pastedImage_0.png

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)

pastedImage_0.png

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.

pastedImage_1.png

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes
lock attach
Attachments are accessible only for community members.

Hi Len

The photo to be attached is in the state of power ON.

The LED04 port is P15. 2.

The logic level remains at 0V.

What should I do?

0 Likes

suto,

Interesting.  You can see from my scope plot that LED04 is only driven low when a switch is pressed.  Note:  I had to change the assignment for LED04 from P15.2 to P3.5.  When it was on P15.2, I did get a stuck low condition.  I thought it was because on my 059-Kit I has a 32K XTAL soldered on to P15.2.  Maybe that's not it.

There are three other reasons I can think of that might be causing what you are seeing.

  1. Did you copy the new logic for the LED04 output I posted?  My previous logic assumed that the Pulse Converter worked on either edge.  That was wrong.  I only works on rising edge and therefore I had to invert the input and the output signal.
  2. Make sure that Clock_2Hz and Clock_100Hz are using ILO as the source clock.  Otherwise the clock frequencies using the MASTER_CLK will be the same.  (See post above).
  3. Reassign LED04 to P3.5 with the output as a STRONG.  Use a scope to determine the logic state and if the active low pulse is occurring as expected.  If the reassignment works, make the reassignment permanent. (Or find another Port pin that will work).

Len

PS:  Don't give up.  You're nearly there!

Len
"Engineering is an Art. The Art of Compromise."
0 Likes