This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

comp or lpcomp for 2 analog inputs with different v-- (ref)

i am working with nrf52832

i need to check 2 analog inputs and set my own v- (ref) 

i can have value read every few seconds so no fast readings needs to be done 

if i understand correctly i better use lpcomp if no fast readings is needed?

also,  is it possible, and if there are some code examples, to be reading 2 analog inputs with 2 different v-- (references) (one for each input pin) ?

best regards

Ziv

Parents
  • Hello, 

    if i understand correctly i better use lpcomp if no fast readings is needed?

    Yes, Lpcomp is good for low-power readings of pin state changes. Have you seen the documentation for the LPCOMP peripheral, and the lpcomp example in the SDK?

    also,  is it possible, and if there are some code examples, to be reading 2 analog inputs with 2 different v-- (references) (one for each input pin) ?

    We have no examples demonstrating this directly, but you may modify the lpcomp example to use the external references on pins AIN0 and AIN1.
    Since the LPCOMP is only made to monitor one pin at the time, you will have to switch between the two pins and their references, to check the levels.

    Have you considered using the SAADC with differential ended input instead of the LPCOMP?
    Depending on your application, this might be both easier to implement and more precise.

    Best regards,
    Karl

  • thanks Karl

    since i can comp (or lpcomp) only one input pin each time and to switch between them i have to go through the handler and CPU anyway the COMP option in my case doesn't really helps

    i have started working on configuring and reading the 3 inputs pin with saadc driver, it is also not so easy, for example it is not possible to do OVERSAMPLING with multiple pins (aka SCAN MODE) (i did made a small change to the NRFX_SAADC.C file to achieve just that) but actually it is still not so clear to me how to manage the 3 inputs if i want to read each one of the in a different timing and is less CPU intervention as possible (i saw the saadc example with the timer and ppi but i am not sure how to manage that with 3 inputs, i have tried to look for a way to change the configured pin with in the saadc event handler but it fail) 

    if the saadc is kind of a new topic it is possible to close this post (i am not sure how to do that)

    best regards

    Ziv

  • Hello Ziv,

    I understand. I saw your other ticket, and your workaround for using oversampling with scan mode - in order to get the correct results then you should also make sure that burst is enabled on every channel.
    As for how to manage the three inputs in the least CPU intensive way, I would have to suggest setting up three timers and connecting them to the sample task through PPI. I have not tried this myself, but I recall reading that you may have multiple events connected to the same task just fine - you could try this and see if it fits your requirements.
    In this case, you would need to discard the measurements on the channels you are not interested in at that particular time - since the SAADC in scan mode will sample every enabled channel each time.

    ziv123 said:
    if the saadc is kind of a new topic it is possible to close this post (i am not sure how to do that)

    Yes, you are right. I will close the ticket, no worries.
    Please do not hesitate to open a new ticket if you should encounter any other issues or questions in the future.

    Good luck with you development!

    Best regards,
    Karl

  • thanks

    i will check , i have been looking through the saadc driver and HAL API, i didn't find the way to configur some of the pins to HIGH or LOW values to use the event type:

    NRF_SAADC_EVENT_CH1_LIMITH 

    NRF_SAADC_EVENT_CH1_LIMITL

    if i am to use one saadc periferial with 3 channels (for 3 input pins), i wish to use 2 of them as high/low interrupts for the analog input and one that reads the values.. can you help with giving me direction or a close example?

    also, if i use the 'app_timer' , does it changes the way i work with the ppi in the "least CPU intensive wat" asspect ?

    best regards

    Ziv

Reply
  • thanks

    i will check , i have been looking through the saadc driver and HAL API, i didn't find the way to configur some of the pins to HIGH or LOW values to use the event type:

    NRF_SAADC_EVENT_CH1_LIMITH 

    NRF_SAADC_EVENT_CH1_LIMITL

    if i am to use one saadc periferial with 3 channels (for 3 input pins), i wish to use 2 of them as high/low interrupts for the analog input and one that reads the values.. can you help with giving me direction or a close example?

    also, if i use the 'app_timer' , does it changes the way i work with the ppi in the "least CPU intensive wat" asspect ?

    best regards

    Ziv

Children
No Data
Related