How to raise an interrupt from existing ADC

Discussion related to "under the hood" OpenMV topics.
User avatar
Raj
Posts: 21
Joined: Wed Jun 05, 2019 2:14 am

How to raise an interrupt from existing ADC

Postby Raj » Wed Jun 05, 2019 2:59 am

God Bless you guys for the wonderful endeavor you are living up to.

Novice, please ...

This is my code:
---------------------------------------------------------------------------------------
....
adc = pyb.ADC(pyb.Pin('P6'))
adcread=0
....
#while (True):
adcread=adc.read()
if (adcread>250):
clock.tick()
img = sensor.snapshot()
....
# Do machine vision algorithms on the image here
....
print(clock.fps())
----------------------------------------------------------------------------------------

I need the Cam to consume as less power as possible until 'adcread' is greater than 250.
Once 'adcread' becomes greater than 250, the while loop should work and, thereafter, when 'adcread' falls below the value of 250, the Cam should go back to low power mode.

I understand that interrupts can be of use here. But how to raise an interrupt from ADC which continuously raises and falls?

Or, is there any completely different approach to this, please?
User avatar
Raj
Posts: 21
Joined: Wed Jun 05, 2019 2:14 am

Re: How to raise an interrupt from existing ADC

Postby Raj » Wed Jun 05, 2019 6:28 am

BTW .. I'm on H7, please.
User avatar
iabdalkader
Posts: 1141
Joined: Sun May 24, 2015 3:53 pm

Re: How to raise an interrupt from existing ADC

Postby iabdalkader » Wed Jun 05, 2019 10:44 am

Raj wrote:
Wed Jun 05, 2019 2:59 am
I understand that interrupts can be of use here. But how to raise an interrupt from ADC which continuously raises and falls?
I don't think you can do that, there's no sleep/wake on ADC at least not that I know of. Alternatively you could just put the cam in low power, wake up, check adc and back to low power etc...

while (true):
check_adc()
if (adc < 250):
sleep
else:
do something else.

See the low power examples in Examples->19-Low-Power
User avatar
Raj
Posts: 21
Joined: Wed Jun 05, 2019 2:14 am

Re: How to raise an interrupt from existing ADC

Postby Raj » Wed Jun 05, 2019 1:09 pm

Thank you very much for the quick response.
:D

Return to “Technical Discussion”

Who is online

Users browsing this forum: MSN [Bot] and 4 guests