Then the DOUT phase starts and lasts for 348 MCLKs (typical numbers), during which we can clock out the data. At the start of a new conversion cycle, the DRDY phase lasts for 36 MCLKs (modulator cycle periods), so each cyle, we can wait/delay for the DRDY phase to simply pass. So my method is to initially have the microcontroller reset the ADC, so that we have awareness/control of the timing from then on (also see Timing diagram below). The ADS1252 has DRDY (converted data ready indication) and DOUT (actual data output) both on the same pin, one followed by the other in a chronologically structured way, so I can use proper timing and interrupts to check when data is ready and when to get data. SCLK pin (for commands: Synchronization, Power-down, or RESET) This ADC only uses two pins to interface with the Arduino/microcontroller: My approach is partly based on TI Application Note for same ADC: to be safe, 30 usec, instead of 27 usec, which is wait for DRDY to pass and to reach start-point of DOUT into array, and print out only later at end. possible improvement: store all data from multiple cycles will these instructions eat into time significantly? and store read data into three bytes */ read in adc data (sending out don't care bytes) DRDY phase to pass, and thus for DOUT phase to begin go to drdy_wait routine, where we wait for so here, hold SCLK HIGH for 5 CONVCYCLEs = 1440 usec to reset ADC, we need SCLK HIGH for min of 4 CONVCYCLES can use hardware interrupt in future but now just poll "sort of" an interrupt to go to read_adc routine If (digitalRead(MISOPIN) = HIGH) read_adc() in the timing diagram, and just have to wait for release ADC from reset now we're at a known point CPHA = 0: data sampled on rising edge (LOW to HIGH) CPOL = 0: so that SCLK is normally LOW initialize SPI (with default settings, including. corresponding to SCK pin and DRDY/DOUT pin on ADC PinMode(SCLKPIN, OUTPUT) pinMode(MISOPIN, INPUT) Buy one of low jitter, such as Crystek's C33xx or S33xx (DIP). Or easiest, buy a clock oscillator (has 4 pins, one of which goes to the CLK pin of the ADC).Set up a timer for your chosen frequency on one of Arduino/Atmega's pins.I recommend using the option of Prescaler of 8, so the ADC gets 2MHz instead of 16MHz. Not very hard but you have to set some fuse bits You can search Google or this forum for help on this. As far as how to actually supply the clock (not a typical 2-pin crystal oscillator input), you have three options (thanks BenF for suggestions): And you can start reading data at 24 bit precision (kinda) from the serial terminal.įor the clock pin of this ADC, I used 2MHz if you use a different frequency, you have to change some timing variables in the code, as outlined in the "Full details" section. If you want to learn more details, for future use, about how exactly the interfacing (SPI) is working between the Arduino and the ADC, then read the "FULL DETAILS" section below (and consult the datasheet as well this one's pretty simple).īy the way, a very clear tutorial on SPI by Nick Gammon is here: īut if you want to just quickly use the ADC, I suggest you simply read the ADC clock source section below, then view the Pinout diagram below and plug the wires in as shown (be sure to add capacitors as appropriate too), and finally just use the code I pasted below. I've spent the last couple of weeks working on reading the datasheet and gaining some very useful knowledge while figuring out how to code this thing, along with some help from forum members here, so now, I decided to make a small tutorial with the basic pseudocode as well as actual code. It has a maximum of 24 bit digital readout precision, which is significantly better than Arduino's inbuilt 10-bit ADC, so if you need to make some precise readings, this is useful. The ADC I use is ADS1252 from Texas Instruments. I'm no expert yet, but since I've played around with this for some time, feel free to ask if you have any questions. Learning to use this ADC will also be a good beginner exercise in using Serial Peripheral Interface (SPI). Here is a tutorial/recommendation for those who need a high-precision analog to digital converter (ADC) that is easy to use (SPI but just 2 wires, and ADC itself has only 8 pins) and is fast (40,000 samples per second).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |