Announcements

Equip yourself to optimize PSoc4 MCUs for Evs at the EV Webinar. Click here to register.

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

PSoC™ 4 Forum Discussions

MikeAustin
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

OK, this is what I'm trying to do...

I have a sporadic analog signal that I want to capture the peak value of.  I have no way of knowing when this signal will occur, and its duration will be something in the order of 20usec - 1msec, and I want to try to capture the peak value.  Or, at the very least, be able to determine if the peak was within Range 1, Range 2 or Range 3.

My initial idea was to use a SAR ADC component and set up the lower and upper trigger levels for 3 different channels to give me the three ranges (Range 1 < Range 2 < Range 3).  I could then simply set interrupt priorities accordingly, and get a rough peak detect result that way.  However, it doesn't look like you can set the upper and lower trigger levels for individual channels; it appears this is a "set to the same for all channels" option only.

My next thought was to use 3 x SAR ADC components, and have the same input into each one, and simply set the trigger levels on each SAR ADC component to match the range levels I wanted.  However, there is a limit of only one SAR ADC component, so I can't use that option either.

I'm trying to achieve my end goal without making any modifications to my existing hardware, so whilst I can see there is a way to achieve my end goal in hardware (for example having three different comparators that I use the outputs of to trigger an interrupt), this is not a path I want to go down unless it proves impossible to achieve in software.

Anyone been confronted with this issue before, and if so, how did you solve it?

Cheers,

Mike

0 Likes
1 Solution
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hello Mike,

I am not sure about the nature of the signals you are handling. If all of them are reaching the peak value at the same time, you can use the ADC to trigger the range interrupt. Inside the ADC ISR, you can continue taking the sample values for the duration you have mentioned and check for the peak value. The count value returned by the ADC for each channel can be checked, and inside the firmware you can make sure that the current sample value is greater than the previous  sample value. Even if the three signals are independent and reach the peak value at different instances of time, same method can be extended. Only thing to take care will be how to handle peak value from the previous sample. This will be purely software based solution (as you may require) but it can be CPU intensive too.

Best Regards,
VRS

View solution in original post

1 Reply
Vasanth
Moderator
Moderator
Moderator
250 sign-ins 500 solutions authored First question asked

Hello Mike,

I am not sure about the nature of the signals you are handling. If all of them are reaching the peak value at the same time, you can use the ADC to trigger the range interrupt. Inside the ADC ISR, you can continue taking the sample values for the duration you have mentioned and check for the peak value. The count value returned by the ADC for each channel can be checked, and inside the firmware you can make sure that the current sample value is greater than the previous  sample value. Even if the three signals are independent and reach the peak value at different instances of time, same method can be extended. Only thing to take care will be how to handle peak value from the previous sample. This will be purely software based solution (as you may require) but it can be CPU intensive too.

Best Regards,
VRS