Teensy interfacing with AD7124

Hello Everyone, i am new with teensy and beginner with arduino, currently i am working on teensy4.1 and EVAL-AD7124-8SDZ, the board has SPI pins as test points / solder points, and i am trying to establish a connection with this pin. the board already has a power supply of 7-9v, and i am powering my teensy through usb. my aim is to connect a MQ-8 sensor on the 24 bit ADC, but before that i am trying to slowly achieve the basic SPI setup. The following are the pin connections

TSCLK - PIN 13 of teensy
TCS - PIN 10 of teensy
TDIN -PIN 11 of teensy
TDOUT - PIN12 of teensy

AVDD - VCC of MQ8
AVSS - GND of MQ8
AIN2 - A0 of MQ8

i connected the teensy GND to the GND of ADC board.

For the first instance i have code to just read the ID register 0x05, which has a value 0x17 but i do not receive this value. this means i have not established a SPI connection successfully. i am trying to troubleshoot this but if you find any mistakes in the code or approach please correct me. thank you i will have the code and important links below.



https://mm.digikey.com/Volume0/opasdata/d220001/medias/docus/1234/AD7124-8SDZ_EVB_UG.pdf
 

Attachments

  • ADC7124_teensy_SPI.ino
    1.8 KB · Views: 24
Last edited:
Be aware that the pins on the T4.1 are not 5V tolerant. If you connect an external device that shares pins with the Teensy, that device must not drive those pins to a voltage greater than 3.3V or damage may result. It looks like your device operates it's I/O pins at 5V. You'll need some kind of level conversion to avoid damaging your Teensy.

Mark J Culross
KD5RXT
 
Be aware that the pins on the T4.1 are not 5V tolerant. If you connect an external device that shares pins with the Teensy, that device must not drive those pins to a voltage greater than 3.3V or damage may result. It looks like your device operates it's I/O pins at 5V. You'll need some kind of level conversion to avoid damaging your Teensy.

Mark J Culross
KD5RXT
Thanks Mark for your advice. My device is having 3.3v and it is compatible with teensy. So that is no problem.
 
The AD7124 is a rather complex 24-bit ADC, so you've got a learning curve ahead of you. The link below is to a library on github that supports this device. Instead of trying to write your own driver, you should install this library and run its example programs. Those should work right out of the box, and you'll be able to use one of those working examples as the starting point for your own sketch that does what you want to do with the ADC.

https://github.com/NHBSystems/NHB_AD7124

You probably should also download and review the datasheet for the AD7124, so you have some idea of what the library is doing.

https://www.analog.com/media/en/technical-documentation/data-sheets/ad7124-8.pdf
 
Don't use SPI.beginTransaction() alone in setup(). Just delete that part. You only should use SPI.beginTransaction() when you actually communicate with SPI. Always call SPI.endTransaction() when you're done. Your sendData() function does that properly.

For the first instance i have code to just read the ID register 0x05, which has a value 0x17 but i do not receive this value. this means i have not established a SPI connection successfully.

I'm confused. Your program doesn't seem to read anything. It just transmits 2 bytes (address and value) but doesn't do anything with the returned data from SPI.transfer().
 
The AD7124 is a rather complex 24-bit ADC, so you've got a learning curve ahead of you. The link below is to a library on github that supports this device. Instead of trying to write your own driver, you should install this library and run its example programs. Those should work right out of the box, and you'll be able to use one of those working examples as the starting point for your own sketch that does what you want to do with the ADC.

https://github.com/NHBSystems/NHB_AD7124

You probably should also download and review the datasheet for the AD7124, so you have some idea of what the library is doing.

https://www.analog.com/media/en/technical-documentation/data-sheets/ad7124-8.pdf
Hey joe,

Thanks for your advice, i also think it would be lil easier and better to use directly the library and explore with some examples. Thanks.
 
Don't use SPI.beginTransaction() alone in setup(). Just delete that part. You only should use SPI.beginTransaction() when you actually communicate with SPI. Always call SPI.endTransaction() when you're done. Your sendData() function does that properly.



I'm confused. Your program doesn't seem to read anything. It just transmits 2 bytes (address and value) but doesn't do anything with the returned data from SPI.transfer().
Hey Paul,
i get your point, i will implement this and try again. Regarding the 2 btyes i just wanted to read ID register and check with the datasheet if the values match or not. Thanks
 
Back
Top