Pages: 1 [2] 3   Go Down
Author Topic: interfacing a 12 Bit SPI ADC  (Read 10781 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  Thanks. It works great now.



Phil
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 11
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey, nice work on the code.  What is the name of the gyro that you are trying to interface with the arduino?  Could you include your code for the gyro as well?  I'm having trouble interfacing the MLX 90609 rate gyro through SPI.

Thanks!!
Logged

New Zealand
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
arduino: far too much like electrical engineering.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using the sparkfun analogue IMU, hence the ADC. The important thing with SPI is to read the datasheet carefully, nearly all SPI devices aren't 'standard'.
Logged


-- Alec

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello Halabut,
  
    I recently bought a Wiring Mini board and hooked up one of these mcp3208's to it .. using the same code you provided. It compiled with no errors and successfully uploaded to the wiring board. It doesn't seem to work though. All I see in the serial monitor of the Wiring IDE is either 0 or 4095 ... and the occasional random number every once in a while.

  I'm using the same pin #'s ... 10,11,12,13


  It works 100% on my arduino.


thanks,
Phil
Logged

New Zealand
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
arduino: far too much like electrical engineering.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't have any experience with wiring, but from the sounds of it this is a hardware problem. Check all your wires are in correctly and that the ADC has its ref voltage and power supplies connected and they're at the right levels. Other than that I can't think what it'd be.
Logged


-- Alec

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  Thank you. I checked it a few times over and then switched to a different set of pins with the same results. It is strange. Do you think it has something to do with timing? ... maybe the wiring board's timing is different from the Arduino.



Phil
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 572
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe the pin mapping is different between wiring an arduino. remember the pin #'s in the arduino world typically refer to the arduino board's pin numbers, not the microcontroller pin numbers.

Arduino was obviously inspired/based on/an offshoot of (not sure of the technical term, don't want to offend the tinket.it guys) the wiring board, so maybe the numbers match, I'm not sure.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  That's a good possibility, but I don't think I would have seen anything on the serial monitor.



Phil
Logged

New Zealand
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
arduino: far too much like electrical engineering.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Timing shouldn't be a problem, the code is all bit-banged. It's very timing insensitive, and doesn't rely on any chip-specific features.
Logged


-- Alec

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  I'm pretty sure it is a pin mapping problem. I just checked out the schematic at:

http://wiring.org.co/download/WiringMini.pdf

It looks like Port 3 is where I need to be wiring the ADC to ... I was originally trying to use Port 1 on the Wiring Mini

Wiring Mini Board pins        MCP3208 ADC Pins
 
           24             ----->   CS Chip Select Pin 10
           25             ----->   CLC Clock Pin 13
           26             ----->   Din MOSI Pin 11
           27             ----->   Dout MISO Pin 12


  Looks like this should work. I'm out on the road with my job right now. I should be able to check this on Monday.


Phil
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

   I've been messing around with it for the last couple hours on the correct pins ...  still the same results. I have no idea what may be the problem.



Phil
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  I'm back to just using this on Arduino.

I'm trying to use the AGND pin. I tried putting about 2V on it, but it just shunts down to millivolts ... since it is an analog ground. Is AGND really meant for setting a lower limit? The spec sheet doesn't really mention too much about it.

 

Phil
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

  I figured it out. I had to use a separate power source for the analog end of things. I connected the pot wiper (from analog source) to AGND pin.

In the end it brings the resolution down to only 11 bits instead of 12. I have my Vref set to 4.77V (from digital source) and AGND of 2.25V .... my ADC range is from 0 to 2047. Is there any way to make this range from 0 to 4095 ?


P.S.  I didn't connect the Analog ground to the digital ground.


Phil
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi halabut,
I am a newbie with arduino. I'm currently trying to implement ADC MCP3204. I tried to use your code and connect similarly but my adcvalue keeps reading either zero or 4095 (5V). I suspect it's the timing but the datasheet for both 3204 and 3208 have the exact same timing. Please help, thanks!
Logged

New Zealand
Offline Offline
Jr. Member
**
Karma: 1
Posts: 69
arduino: far too much like electrical engineering.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's strange, especially given that they're the same datasheet. Looking at the code it should work fine (for the first four channels only obviously)
All I can advise is checking your connections against the datasheet, the pins are in the same order (except dgnd on the left). Many of my frustrating 'broken' circuits have been me forgetting to connect ground, so check everything twice. Other than that it might (and this is unlikely) be a dud chip.

Alec
Logged


-- Alec

Pages: 1 [2] 3   Go Up
Jump to: