it's the $8.49 question, boys and gals.
so, my eventual aim is to make a digital theremin using the Qprox QT300 capacitance-to-digital sensor IC hooked up to arduino.
my QT300 sensors finally arrived, so i introduced one of them to arduino, uploaded some code which i calculated will let the two of them communicate according to the QT300 spec sheet, then i let them do their thing.
first run was perplexing. the 2-byte data acquisition from QT300 seemed to go ok, but all the 16bit values returned by arduino to the computer were constant, changing only every few seconds or so.
unplug. replug.
second run - the program didn't even make it past the bit where arduino requests data from the qt300 sensor. it sent the request, then just sat there waiting for QT300 to say it was ready... which it never did.
my latest hypothesis is that arduino puts out too much current through the digital pins for the QT300 to deal with. the QT300 spec sheet says that the max current is 1500 micro amps (uA), minimum 60. is it possible that this has been exceeded?? does anyone know where to get technical info about arduino's electrical specs? and if it has fryed the QT300 in this way, could anyone suggest, to a relative beginner, how to limit the current going through the sensor to a non-dangerous level (ie, below 1500uA)?
well, i should include as much info as i can. so, first up, here's the QT300 data sheet:
http://www.qprox.com/downloads/datasheets/qt300_102.pdf
secondly, this is my understanding of how arduino gets data from the QT300: (in SPI SLAVE MODE, which is the default mode of operation, unless i'm very mistaken...?) (see page 9 of the spec sheet)
basically, arduino requests data by grounding a "data request" pin ("REQ") for at least 30 microseconds. then, after a short delay, the QT300 grounds a "data ready" pin ("DRDY") to let arduino know that it has calculated the capacitance value of the theremin antenna, and is ready to send a 16-bit reading. the reading is sent in a series of 16 individual bits into the "SDI" pin on arduino, while arduino cloks out each seperate bit by setting a clock pin ("SCK") alternately high, then low, in 15-microsecond half-cycles.
make sense?
even if i alter the program to stop waiting interminably for the QT300 to say that it's ready to transmit data - that is, if i get it to sart clocking the QT300 regardless - the returned data is still always zero x 16.
next up, here's the code i wrote: (yep, feel free to use it if you're interested. let me know how you go...)
/* QT300 interface
* ------------------
* Jon Drews, 25 Jan, 2007.
* mistersquiggle at hot mail
* ------------------
*/
int DRDY = 2; // data ready pin
int SDI = 3; // data input pin
int SCK = 4; // clock output pin
int REQ = 5; // request data output pin
unsigned int qtbytes = 0; // stores the 16bits of data returned from QT300
int i = 0;
int x = 0;
void setup() {
pinMode(DRDY, INPUT);
pinMode(SDI, INPUT);
pinMode(SCK, OUTPUT);
pinMode(REQ, OUTPUT);
digitalWrite(REQ, HIGH);
digitalWrite(SCK, LOW);
Serial.begin(9600);
delay(1); // dunno if this is necessary...
Serial.println("ready...");
}
void loop(){
digitalWrite(REQ, LOW);
delayMicroseconds(35); // minimum REQ pulse is 30us
Serial.println("REQ sent");
digitalWrite(REQ, HIGH);
Serial.println("REQ floated high");
Serial.print("init SDI input val: ");
Serial.println(digitalRead(SDI));
Serial.println("waiting for data ready signal");
while(digitalRead(DRDY) == HIGH){
//wait for data ready signal (DRDY low) from QT300
}
for (i = 0; i < 16; i++) {
delayMicroseconds(15); //minimum delay 12us
digitalWrite(SCK, HIGH); //trigger the clock pin high
delayMicroseconds(15); //minimum delay 13us
x = digitalRead(SDI);
Serial.print(x, BIN);
Serial.print("-");
if (digitalRead(SDI))
qtbytes |= (1 << i); //set individual bit in qtbytes variable using shift left
digitalWrite(SCK, LOW); //return clock pin low
}
delay(500);
qtbytes = 0;
}
AND!
a photo of the schematic:
and the whole lot all wired up. yes, i assure you none of my uninsulated wires are touching. really...
sigh
well, any insightful suggestions very very welcome...
jon.