This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC124s021: Example code C++ for ADC124s021

Part Number: ADC124S021
Other Parts Discussed in Thread: ADC128S052

Hello,

new to the forum and looking for some insight. I've recently added the adc124s021 ADC to a development board I'm working with and would like to some insight, direction on how to use the device. I've used ADC's on arduino's over I2C/SPI in the past, but Industrial IO is brand new to me. I've done a number of searches, and have come across different guidance, but none that seems relevant .

http://processors.wiki.ti.com/index.php/Linux_Core_ADC_Users_Guide

this one seemed the most helpful, but there were a number of functions such as enable, buffer, etc that are not present on my OS. Is there a guide sheet or sample code that someone can share that will give me any direction in writing software in C++?

Michael

  • Part Number: ADC124s021

    Tool/software: Linux

    Hello,

    So, Im working with a development board and have patched the ADC128s052 Device Driver with the patch that adds ADC124s021 support. Also updated the kernel with the ADC128 and have gotten the ADC to show up in the /dev/ directory as an iio device. I'm using /sys/bus/iio/devices/iio:deviceX to locate the resources for the ADC. 

     

    In the resource location I have the following listings.

     

    dev   in_voltage0_raw    in_voltage1_raw      in_voltage2_raw      in_voltage3_raw       in_voltage4_raw      in_voltage5_raw      in_voltage6_raw      in_voltage7_raw      in_voltage_scale      name      of_node      power      subsystem      uevent

     

    Here are my questions

     

    1) the 124s021 chip is a 4-channel chip, however I'm seeing 8-channels. My thoughts is that its based off of the 128 chip, which is 8-channels. In the documentation the input selection is based off of a 3 bit identifier, however bit 3 is a don't care. So I'm thinking that the channels are doubled, once for when bit 3 is zero and then again when bit 3 is one. Make sense?

    2) I'm doing a simple read using cmdline      cat /sys/bus/iio/devices/iio:deviceX/in_voltageX_raw      which is pumping out values. We have two wires connected to the board. Wire 1 connected to pin 1, input1, and wire 2, ground, has a resistor on it before both wires comet together. After they come together another wire is connected to both with another resistor. This way any current that is coming in is roughly split in half.

    Well when we touch a ground, which should report back a zero reading on the ADC, we actually get around 2313, sometimes 2056, and other times 1800. But never what we should get back. It seems like the input is just floating.

    so hooked it up to an oscilloscope and checked for the chip select signal. The SPI_CSIM_SS2 for that chip is being driven high at all times. However, when I make a request for a read, it drops low, which is what we want to see. As the ADC requires a low signal as an indicator for the CS read. So that appears to be working just fine.

    Anyone have any insight into what is going on.

  • Hi Michael,

    Welcome to our e2e Forum!

    Since your two posts today are basically related, I merged them together. We will get back to you in the next day or two with some recommendations.
  • That sound fair to me. Thank you for the support

    I did want to add an update. So I ended up changing my device tree file a little. Before the line compatible= had the adc128s052 label in there. I ended up changing it compatible="ti,adc124s021" so that it matches the correct chip. However, it is still showing up with all eight channels, rather than four. I thought that might have made a difference, but no change. Im now only seeing four channels. I'm not sure what changed, but I made some changes in the kernel configuration menu for another area I'm testing and when I recompiled the kernel and baked a new image I'm now seeing only four channels as I'm suppose to . 

    but all four channels are reporting the same value, and nothing changes with the value when I ground the wire or apply voltage to it.

  • Hi Michael,

    I'm happy to hear that you are making some progress! Can you provide some screen shots of the SPI lines between your processor and the ADC124S021?
  • Hi Michael,

    Have you resolved the issue?
  • We have not resolved this as of yet. We had another issue during development. I'm jumping back on the ADC monday of next week, at which time I'll hook it up to a scope and get some pictures of what is going on for you.

    Michael

  • Hi Michael,

    Do you have any updates for us?
  • Hi Michael,

    Do you have any updates for us?