Analog Sensor
응답
19. 2. 15 오후 9:32

 

Hi all

I want to use a TMP 36 temperature sensor, and read the values ​​that that sensor is generating, I read the Extension Bus Guide and I can not understand. Does anyone have a code on how to read analog values ​​with that sensor?

Thank you

 

0 (0 투표)
RE: Analog Sensor
응답
19. 2. 18 오전 8:26 as a reply to Andres Rivera.

Hello Andres,

I had a short look to the datasheet of the TMP36 sensor. It seems you first need a little electronic to adapt the voltage level. The sensor needs a supply voltage between 2.7 and 5.5 V. So you can use the 3.3V power supply pin of the extension bus. Please notice the normal GPIO pins are only endure a maximum voltage of 2.5 V. So you first have to calculate a voltage divider to adapt your measuring voltage to a range bewteen 0 and 2.5 V.

After that you can use one of the two available ADC channel of the extension board. The ADC pins are located at PD5 and PD6. To use the ADC controller i recommend the em_adc.h interface. You can find the interface in the following path:

YourProject/SDK/xdk110/Libraries/EMlib/3rd-party/EMLib/emlib/inc/em_adc.h

The next step depends on your requirements for the measuremt. If you want to sample data really quick and accurate, i recommend the usage of a timer and the PRS bus system.

So i you have any further questions don't hesitate to ask. If you  go more in detail about your requirements and use case i am sure we will find the best solution for you.

Best regards,

Christian

 

0 (0 투표)
RE: Analog Sensor
응답
19. 2. 18 오후 2:25 as a reply to Christian Köhler.

 

Hello Christian

The first thing I want to do is read the values ​​of any analog sensor, whether the temperature, or a photoresistor, or any analog sensor that exists, wanted to start with the TMP36 to make tests, then the second thing I wanted to do is that those I can see them on the web.

Best regards,

Andrés

0 (0 투표)
RE: Analog Sensor
응답
19. 2. 19 오전 7:51 as a reply to Andres Rivera.
Finally you wanna have something like that ?
+1 (1 투표)
RE: Analog Sensor
응답
19. 2. 19 오전 8:01 as a reply to Andres Rivera.

Hello Andres,

there are two possible ways to get and process data from the ADC. The first way is with a ISR. This is a nice solution because every time you have new data available the ISR function is automatically executed. The second way is with the DMA bus. You can store the new ADC data directly into the RAM storage without any CPU workload. You can decide which solution you implement recording to your use case and the related sampling rates.

1. Solution ISR

To implement the first solution you can use three modules from the EMlib library. The ADC, PRS and TIMER modules. You can configure the ADC with the interface em_adc.h. After that you can "connect" the ADC and TIMER via the PRS bus. You can configure the TIMER to count up and get an overflow after a defined value of time. This overflow event will trigger the ADC via PRS bus to start a conversion. You have to implement the ISR in your main code. The TIMER and PRS function are described in the em_prs.h and em_timer.h interfaces. The ISR for the ADC looks like:

void ADC0_IRQHandler(void)

2. Solution DMA

The second solution is based on the first solution. But insteed of implementing the ISR in your main code you have a look in the em_dma.h interface. Then you can configure the DMA to read out the new data directly from the ADC and store them into RAM storage. Please be aware of the fact that you have to modify the SDK to use the DMA bus. You have to add the dmactrl.h interface to your emlib directory in the "inc" folder. You can find the missing file on the internet.

I hope this was helpfull.

Best regards,

Christian

 

0 (0 투표)
RE: Analog Sensor
응답
19. 2. 19 오후 2:20 as a reply to Christian Köhler.

Hello Achim


Yes, exactly, read the value of the sensor through the internet, that I can monitor the sensor from my home or office, and the sensor and the XDK that are in the factory.

0 (0 투표)
RE: Analog Sensor
응답
19. 2. 19 오후 2:23 as a reply to Andres Rivera.

Hello Chistian

Will they have an example code? I am new in this and I could not understand almost anything.

 

0 (0 투표)
RE: Analog Sensor
응답
19. 2. 20 오후 1:30 as a reply to Andres Rivera.
We have that also already done in combination with the BOSCH Neexed PPM and BOSCH ThingBook.

Greetings Achim
+1 (1 투표)
RE: Analog Sensor
응답
19. 2. 20 오후 4:17 as a reply to Achim Kern.


Hello Achim

Do you have a code where you can read the values ​​of the analog sensors?

Do you have images showing how to connect the sensor to the XDK gateway?

0 (0 투표)