Comparator in PSoC 5LP

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

cross mob
Anonymous
Not applicable

Hi,

I'm a PSoC newbee and just tried out the WaveDAC8 example. I was able to connect the on-board switch via the input Pin P2.2 to the wave select input and the system outputs one of the 2 specified waveforms (sine or triangle) depending on whether the button is pressed or not.

Then I connected a comparator to the output of the DAC (positive input) and a 0.256V Vref at the negative input. The output of the comparator is connected via output pin P2.1 to the on-board blue LED.

Unfortunately the comparator output doesn't toggle at all, but stays low (LED off) although the DAC voltage definitely crosses the 0.256V threshold during each period.

At a DAC waveform output frequency of 1kHz the comparator should be fast enough.

When I use the inverted mode of the comparator, the output remains high (LED on), so at least the connection from the comparator output to the pin seems to work.

In the analog schematic I see that the DAC output signal goes via an OpAmp to the pin P0.0 and is then fed back to the positive input of the comparator.

So all seems OK, but still the comparator seems to be not working.

Does anyone have an idea what could be wrong?

Thanks,

Gerhard

1 Solution

You forgot to start the comparator:  Comp_1_Start();

View solution in original post

6 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Please post your code by clicking on File then Create_Workspace_bundle. So we can see your code and schematic.

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

Sorry, I didn't know how to best share my design. I attached the archive.

Thanks & regards, Gerhard

0 Likes

You forgot to start the comparator:  Comp_1_Start();

Anonymous
Not applicable

Thanks for this hint. I was not aware, that I have to start the analog components. I thought, these hardware components are just "on" when the system has powered up (just like a kind of analog FPGA).

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I have changed your program.  Your PRF (Pulse Recurrence Frequency)  was too high so your display always looked like the LED   was on. You forgot to start the Comparator in your code and I changed the port where you connected the voltage reference . You may want to look at this Precision Illumination Signal Modulation (PrISM) component it is made for this application.

Anonymous
Not applicable

Thanks a lot for your help. I observed the LED not only visually (I expected it to change brightess because of different on-time during the period - which it finally does - however only a bit...) but I checked it also with a scope, so the high frequency is not a problem. Anyway, after starting the comparator, the PSoC does what I would have expected.

0 Likes