Show Posts
Pages: 1 2 [3]
31  Forum 2005-2010 (read only) / Interfacing / Re: supply current: has arduino fryed my qprox sen on: January 30, 2007, 09:39:09 pm
P.S.

here's my updated code.

Code:
/* QT300 interface
 * ------------------
 * Jon Drews, 30 Jan, 2007.
 * mistersquiggle at hot mail
 * ------------------
 *
 *  notes:
 *  burst length timing shows normal/expected results.  but 16bit data returned is almost static.
 *  tried several values of Cs capacitor.  this changes the data returned, but it is still static.  hmmmm.
 *
 */

int DRDY = 2;               // 'data ready' pin set to pin 2 on arduino
int SDI = 3;                // data input pin set to pin 3 on arduino
int SCK = 4;                // clock output pin set to pin 4 on arduino
int REQ = 5;                // 'request data' output pin set to pin 5 on arduino
byte qtbytea = 0;           // stores the first byte of data returned from QT300
byte qtbyteb = 0;           // stores the second byte of data returned from QT300
int i = 0;
int bl = 0;                 // used to count the time of the acquisition burst

void setup() {
  pinMode(DRDY, INPUT);
  pinMode(SDI, INPUT);
  pinMode(SCK, OUTPUT);
  pinMode(REQ, OUTPUT);
  digitalWrite(REQ, HIGH);    // set data request pin HIGH
  digitalWrite(SCK, LOW);     // set clock pin LOW
  Serial.begin(115200);       // set baud rate for arduino-->pc communication
  delay(1000);                // weird.  things only seem to work if i allow a 1sec pause here...
  Serial.println("ready...");
  while(Serial.available() == -1){
    // wait for any key to be pressed
  }
}

void loop(){
  qtbytea = 0;                // reset data variables
  qtbyteb = 0;
  bl = 0;                     // reset burst length var.
  digitalWrite(REQ, LOW);     // request data from QT300 by grounding the REQ line
  delayMicroseconds(80);      // minimum REQ pulse is 30us
  digitalWrite(REQ, HIGH);
  while(digitalRead(DRDY) == HIGH){
    bl++;                     // time the length of the acquisition burst.
  }
  for (i = 0; i < 8; i++) {   // loop for transfering the first byte of data from QT300 to arduino
    delayMicroseconds(20);    // minimum delay 12us
    digitalWrite(SCK, HIGH);  // trigger the clock pin high
    delayMicroseconds(20);    // minimum delay 13us
    if (digitalRead(SDI))
      qtbytea |= (1 << i);    //set individual bit in qtbytea variable using shift left
    digitalWrite(SCK, LOW);   //return clock pin low
  }
  i = 0;
  for (i = 0; i < 8; i++) {   // loop for transfering the second byte of data from QT300 to arduino
    delayMicroseconds(20);
    digitalWrite(SCK, HIGH);
    delayMicroseconds(20);
    if (digitalRead(SDI))
      qtbyteb |= (1 << i);
    digitalWrite(SCK, LOW);
  }
  Serial.print(qtbytea, BIN);  // print the first byte in binary format
  Serial.print("-");
  Serial.print(qtbyteb, BIN);  // print the second byte in binary format
  Serial.print(" BL: ");
  Serial.println(bl, DEC);     // print the length of the acquisition burst.  then do a line break.
  delay(100);                  // wait a bit to avoid flooding the serial port with data
}
32  Forum 2005-2010 (read only) / Interfacing / Re: supply current: has arduino fryed my qprox sen on: January 30, 2007, 09:16:11 pm
thanks for the help daniel!

here's an update: i changed the program to pause for 1 second before initially requesting data from the QT300, and voila!  it's working.... well, at least something is.  the weird thing is that the 16bit data returned from the QT300 is pretty much constant, no matter how near or far my hand is from the antenna.  but i set a line in the program to time the length of the QT300's acquisition burst (ie, the time between when arduino grounds the REQ line, and when the QT300 says it's ready by grounding the DRDY line).  despite the same data value being returned, the acquisition time changes just as you would expect it to - when my hand is near to or touching the antenna, it drops right down.  when i move my hand away, the burst time increases again.

strange.

so, if anyone has experience using a QT300 and might know what the problem is here, i'd love to hear your thoughts.  it's a bit beyond me!

if you want to see the raw data from 3 different test runs with different Cs (sampling capacitor) values - i poseted them on the QProx website forum - follow the link: http://www.qprox.com/forum/read.php?f=1&i=4748&t=4748.
i forgot to mention in my post there that the data is taken over a period of about 5 seconds, with me moving my hand from about 10cm away from the antenna to a point where it almost touches.  sampling rate is about 8 samples per second.

jon.
33  Forum 2005-2010 (read only) / Interfacing / supply current: has arduino fryed my qprox sensor? on: January 25, 2007, 07:41:20 am
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...)
Code:
/* 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.
34  Forum 2005-2010 (read only) / Interfacing / Re: measuring direction and angle of elevation on: July 05, 2007, 03:10:52 am
hehe!  that's priceless...
35  Forum 2005-2010 (read only) / Interfacing / Re: measuring direction and angle of elevation on: June 29, 2007, 07:45:04 pm
thanks zitron... that's really useful!

have you or anyone else used the MicroMag 3-axis magnetometer? here's a link to a writeup at sparkfun electronics, which has a link to the datasheet:
http://www.sparkfun.com/commerce/product_info.php?products_id=244
it certainly sounds like it's just what the doctor ordered, but like i said, i didn't even know wat i was looking for before you told me what it was actually called...

in any case, $60ish for a sensor is getting expensive, but i don't mind spending that much or more if it will do the job well.  it's not going to be the biggest outlay of the project.

i'm a little bit worried about indoor electromagnetic interference - might that be an issue with this sensor?  i plan on doing initial testing outdoors in the park opposite my house, but i would eventually like the system to work in practically any environment.  and i'm also going to need some form of wireless communication from the user back to a remote computer...

maybe a combination of magnetometer and some other system might be sensible...
36  Forum 2005-2010 (read only) / Interfacing / measuring direction and angle of elevation on: June 28, 2007, 08:51:27 pm
hi boys and gals,

i'm starting a fairly ambitious project that is going to involve gathering accurate realtime info about a person's movement within a defined space - possibly quite a large area, in- or outdoors.  in particular, i want to monitor the movements of their head (they will be wearing some kind of helmet, headband etc that contains appropriate sensors).

i need to know:
a) which direction they are looking in, to the nearest 10 degrees or better.  this can be relative to any point - magnetic north or some kind of internationally recognised standard would be useful, but anything fixed on land will do otherwise.  a radio point source? a wi-fi router?  something that won't be confused by objects (buildings etc) in the way.

b) what the angle of elevation (up or down) of their head is.   again, to the nearest 10 degrees or better.  they will be walking around, so i don't want their body movements to compromise this sensor's readings.

in addition to being quite accurate, i need both sets of data to be rapidly updated - at least 10 times per second, but preferably much faster.

i'm posting this here in the hope that someone could give me some suggestions as to what sensors i could use (in conjunction with arduino) to achieve these two goals.  sorry if this has been discussed in other forum topics, but i don't exactly know what to look for yet.

the one that i'm most unsure of is the direction (azimuth) sensor.  perhaps someone who knows a bit about astronomy might be able to help...?

love, jon.
37  Forum 2005-2010 (read only) / Interfacing / Re: Density/Specific Gravity sensing on: July 05, 2007, 03:04:26 am
Quote
Hmm... I'm curious, how does the capacitance sensor measure density? Would it work in the air?

a) they measure the total capacitance of all material in proximity to the sensor electrode.  this material's capacitance is determined by its dielectric constant multiplied by how much of it there is.  since wort is heavier at the start of fermentation than it is at the end, i'd guess that its dielectric constant changes too.  that's why i suggested a capacitnce sensor.

b) yep, they will work through air quite well, although quantum for some reason stress that that isn't their designed function.  i've used them to build a theremin, to quite good effect.  it's worth bearing in mind that the design of the sensor electrode ("antenna") has a large bearing on the performance of the system.  in the case of my theremin, i had to use a system of antennas (actually a slightly modded TV rabbit-ear setup) to increase the sensing distance to beyond about 300mm.  obviously, this won't be an issue for the wort density sensor.

s: you might need to be careful about bubbles sticking to the electrode...?  also, keep in mind that the the qt300 isn't good for single-shot measurements - the first few values returned are always inaccurate.  the trick is to request about 100 readings in rapid succession, and use the average (or sum) of the last 20 or so as your data.
38  Forum 2005-2010 (read only) / Interfacing / Re: Density/Specific Gravity sensing on: July 02, 2007, 08:49:59 am
you could try using a capacitance sensor to measure the density of the wort.  i've used a qprox qt300 capacitance-to-digital sensor with arduino for a completely different purpose, but humidity and density sensing is apparently what they are designed for - they're used quite widely in manufacturing industry...  and it's pretty easy to get the qt300 to talk to arduino.  it returns arbitrary 16-bit readings, so you will have to calibrate it initially by using the usual hydrometer (sp?) method, but provided you feed it a nice smooth power supply (pref batteries) the readings stay pretty rock solid.

actually, even if you don't calibrate your SG readings against the sensor, you could just get arduino to log the sensor readings every few hours or so and let you know when they become stable at the end of fermentation.  if you really want to know your alcohol content you could just do the initial and final SG readings manually.

i live in melbourne, australia, and ordered a few qprox chips from farnell in sydney (only cost about A$9 or US$7 each i think). outside oz i think they are widely available - spark fun should have them.

here's a datasheet for the qt300:
http://www.qprox.com/downloads/datasheets/qt300_102.pdf

if you do decide to use a capacitance sensor, i'd be interested to hear how you go.

happy brewing!
jon.
39  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Theremin on: February 06, 2007, 04:02:28 am
well, for anyone interested... i've had some initial success with this project - in that i've somehow managed to get a QT300 capacitance-to-digital sensor talking to arduino in a vaguely meaningful manner.  yay!  you can see some of the progress and read about what needs to be done next on this thread (titled "supply current..."):
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1169728880

hopefully you might also be able to emulate what i've done, if you're interested, but otherwise i'll do my best to write up the proceedure as a tutorial soonish...
i'll start a new thread once i'm back from a (potentially very fun and messy) beach roadtrip and have had time to get round to investigating ways to make the setup behave more like a theremin should behave.  at the moment it's actually quite bad, but i've got a few ideas on how to improve it.  if you do too, i'd love to hear about it!

love, jon.
40  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Theremin on: January 23, 2007, 01:05:47 am
well, i've been too scared of frying my arduino to have a go doing something like that schematic.  BUT!  i have some digital capacitance sensors on order, so once they arrive i'll make a prototype and keep you posted.  if they EVER arrive goddammit!
i'm not getting my hopes up, though.  the qprox folks seem to think that capacitance-in-air applications, like a theremin, really aren't what the QT range are made for.  they only ever seem to talk about touch control buttons and fluid levels, yadayada. but we shall see...
41  Forum 2005-2010 (read only) / Interfacing / Re: Arduino Theremin on: January 19, 2007, 01:41:48 am
thanks daniel.  i've actually decided to give the Qprox QT300 chip a go, since it basically does what i'm trying to achieve in my attempted schematic:  ie, charging and discharging a cap really quickly, and turning the results into 16-bit data for processing.  and if that fails, yep - i'll try the f to v converter.  i've been hesitant to try them in the past because i thought they'd be too sluggish in response time, but maybe if i run the oscillator at a relatively high frequency...?  anyway, i'll post the results as soon as qt300's arrive and i can get something happening.  oh and thanks for the theremin world link - i've been using the site for a while now and think it's a really good resource!

jon.
42  Forum 2005-2010 (read only) / Interfacing / Arduino Theremin on: January 16, 2007, 05:22:28 am
hi all.

my first arduino project!  i've been fiddling around trying to make a theremin, but my electronics knowledge is sooo bad...  perhaps i could use arduino instead?

anyhoo, before i go and short circuit the thing in a fit of blissful electronic ignorance, i thought i'd best get a few opinions.

what if we use one of the analog outputs to charge up a capacitor - then, when it's charged, switch off the output and let the cap discharge through an analog input.  when the cap has fully discharged and the input goes low, measure how many microseconds have elapsed since the program started, feed that number into a tone generator function, then repeat.

my preliminary schematic:

[or goto http://www.jonandaviva.googlepages.com/theremin_schematic.jpg]

a change in antenna capacitance will alter the cycle time marginally, and this difference can be amplified before the result goes to the tone generator.

do you think i need the diodes?  did i even show them pointing the right way??  what about a resistor - some kind of load to work against??  hmmm.  what's stopping all the charge from just going from A0 (out) to A1 (in) rather than charging the cap?  maybe put a resistor at A1 instead of a diode?

aaargh!

here's the programming concept:

1. set A0 high for x microseconds (long enough to charge the cap).
2. once A0 is low, wait for A1 to go low (while the cap discharges through it)
3. once A1 is low, measure the elapsed time in u-secs (MILLIS command? ideas?) from the beginning of step 1.
4. process the u-secs value mathematically to detemine pitch (larger value = hand closer to antenna = higher pitch)
5. execute a module to play resulting pitch through another analog output with speaker attached.
6. while the pitch generator module is in operation, loop back to step 1.

sorry for posting such a sketchy concept, but i need all the help i can get.  hope to hear your ideas!

jon.
43  Forum 2005-2010 (read only) / Interfacing / Re: Conecting Antenas to Arduino (simplified There on: January 27, 2007, 12:38:34 am
an antenna is basically a capacitor.  theremins operate by responding to changes in the antenna's capacitance, which occur when objects (like your hand) move closer to, or further away from it.

if you want to use arduino to make an antenna-based controller or theremin, you need to figure out a way in which it can 'read' the capacitance of the antenna.  converting the antenna capacitance to a variable resistance value (in other words, turning it into a potentiometer) may require some complex, or at least unnecessary, circuitry.  i've been experimenting with quantum's QT300 capacitance-to-digital sensor, which dierctly measures the capacitance of an object connected to it, then returns a 16-bit digital value relating to the measurement.  there may be other ways to measure capacitance - perhaps you could try using arduino to directly measure the antenna capacitance somehow?

let me know if you have any luck!

jon
44  Forum 2005-2010 (read only) / Exhibition / Re: Arduino and VMUSIC2 on: August 21, 2007, 01:33:54 am
star indeed... well done!

i'd love to hear how you go with 2-way communication.  keep us posted!

jon
45  Forum 2005-2010 (read only) / Frequently-Asked Questions / Instruction set? Difference between Wired/Arduino on: September 19, 2005, 11:45:42 pm
Hi,

I posted a second ago about a workshop in London.  Until then, I'm keen to try and teach myself.  Has an instruction set manual/guide been created to help people wishing to learn just the basics?  I can program in basic (PICs normally) and lingo, but have not yet picked up proce55ing.

Also, what is the difference between arduino and wired? It looks like arduino might be better for teaching novices / students.   True?

Many thanks in advance, looks like a useful piece of kit, am looking forward to getting to grips with it.

cheers

jon
Pages: 1 2 [3]