Show Posts
Pages: 1 [2] 3
16  Forum 2005-2010 (read only) / Syntax & Programs / some syntax not in arduino refernce guide? on: January 19, 2007, 09:07:35 pm
i was looking through the tutorial on interfacing arduino with a QT401 sensor.  there are some commands and syntaxes that i totally don't understand and can't seem to find in the reference guide.  is anyone able to explain to me what they mean?

the complete segment of code that i'm quoting from is included below if you want to see the context...

ok, first up:
Code:
byte qt401_transfer(byte data_out)
what does the bit in brackets refer to?  i thought variable declaration just took the format type variableToDefine = value; - the example above looks to me like some kind of nested declaration or a function call...

second question:
Code:
while(0 < i) {

    mask = 0x01 << --i
hmmmm... i'm really stumped on this one.  what do "<<" and "--" mean?

third question:
Code:
if(data_out & mask){
i couldn't find any reference to "&" as a logical operator in the reference guide...  how does it work?

number four:
Code:
data_in |= mask
is this just an error and meant to be "!=" (ie, not equal to)...?

lastly, number five:
Code:
return data_in;
i can't find any reference to "return" as a command.... smiley-sad


well, sorry these are probably such basic questions.  but this bit of code looks like something that will be useful for a project i'm starting, so i'd love to actually be able to understand it properly...

is there a more extensive arduino 0007 reference guide somewhere?

thanks to anyone who can help me out!

jon.




(here's the snippet of code i'm referencing)
Code:
//
//  exchange a byte with the sensor
//

byte qt401_transfer(byte data_out)
{
  byte i = 8;

  byte mask = 0;
  byte data_in = 0;

  digitalWrite(qt401_ss,LOW); // select slave by lowering ss pin
  delayMicroseconds(75); //wait for 75 microseconds

  while(0 < i) {

    mask = 0x01 << --i; // generate bitmask for the appropriate bit MSB first

    // set out byte
    if(data_out & mask){ // choose bit

      digitalWrite(qt401_do,HIGH); // send 1

    }
    else{

      digitalWrite(qt401_do,LOW); // send 0

    }

    // lower clock pin, this tells the sensor to read the bit we just put out
    digitalWrite(qt401_clk,LOW); // tick

    // give the sensor time to read the data

    delayMicroseconds(75);

    // bring clock back up

    digitalWrite(qt401_clk,HIGH); // tock

    // give the sensor some time to think

    delayMicroseconds(20);

    // now read a bit coming from the sensor
    if(digitalRead(qt401_di)){

      data_in |= mask;

    }

    //  give the sensor some time to think

      delayMicroseconds(20);

  }

  delayMicroseconds(75); //  give the sensor some time to think
  digitalWrite(qt401_ss,HIGH); // do acquisition burst

  return data_in;
}
17  Forum 2005-2010 (read only) / Syntax & Programs / bit to byte conversion 101 on: January 19, 2007, 08:27:53 pm
well, i'm pretty new to programming, so sorry if this seems really basic to some of you...

i want to receive 2 bytes of data from an external chip (Qprox QT300) in single bit pulses, then assemble the received bits into bytes, then send these 2 bytes on to the PC via the usb cable.

the method of getting the individual bits is quite straightforward:
1. set a clock pin output HIGH, the wait a few microseconds.
2. receive a HIGH or LOW bit on a digital pin, and store the value in a variable.
3. set the clock pin output LOW and wait a few microseconds.
4. repeat 16 times (with a short pause in between bytes).

so: now you have 16 zeros or ones, which you might store in an array, or as 16 individual integers, etc.
but how do you assemble them into 2 seperate bytes?
it seems really clumsy to write a function which steps through each bit in turn an adds them up according to the bit order value (ie 1,1,1,1,1,1,1,1 = 1+2+4+8+16+32+64+128 = 255).

is there an easier or at least more elegant way??  like, if they were stored in an array, is there some function that i'm unaware of that automatically sums the array as a byte value?

thanks,

jon.
18  Forum 2005-2010 (read only) / Troubleshooting / Re: sabotaged arduino not transmitting!! on: February 27, 2007, 03:54:08 am
hmmmm... well, assuming nothing vital is burned out, is there any explanation for the LED flashing every 10secs?  

could the ATmega8 have perhaps been somehow reconfigured by having arduino's pins 2 and 5 set to +5v without being switched on... and if so is there a way to restore settings?
19  Forum 2005-2010 (read only) / Troubleshooting / sabotaged arduino not transmitting!! on: February 25, 2007, 09:02:19 pm
horror! some idiot connected the power supply to an external sensor that i had hooked up to arduino over a SPI, without powering up arduino first... and left it for hours.  the sensor had it's own voltage regulated (LM7805) battery supply independent of arduino's supply.

i arrived to find arduino's power light and tx/rx lights flickering spasmodically...

so i disconnected everything, plugged in USB, hit reset, and uploaded "serial_read_advanced" from the examples to test things.  the tx/rx lights flashed in a very normal looking way while it was uploading, and i got the standard "AVR ATmega8 found, firmware version 1.18" message.

when i open the serial monitor and send data to arduino, the rx light confirms it's receiving something, but nothing else happens - no transmitting.  when i type 'H', the led doesn't light up.  i added a line to Serial.print("hello") whenever data is recieved, but... nothing!!  not even a flashing tx light.

the only thing that happens is that the pin13 LED flashes every 10 seconds (a kind of flickery looking flash, too...), but this seems to stop after two minutes or so.

aaaaaargh!!!!

anyone have any idea what the problem might be??  please tell me that the power from the sensor hasn't fried some critical part of arduino...  this is how i had the sensor connected to arduino - the battery on the right is the one that got connected, while arduino had no power:



well, hope someone can help!!!

jon.
20  Forum 2005-2010 (read only) / Interfacing / Re: Controlling an array of 16 speakers on: June 17, 2008, 10:05:56 pm
Quote
you COULD do the actually speaker processing on the Arduino itself.

that sounds a lot less painless.... any ideas how to go about doing that?  i have 2 arduinos - i could use one for controller processing, the other to drive the speaker matrix...?

otherwise, i think i might be able to get my hands on a 16-channel soundcard - which would be a lot more practical than 8 soundcards.  but really, my preference would be to have no computer at all so if anyone is able to suggest a way to do all the processing on arduino(s) i'd be uber grateful!
21  Forum 2005-2010 (read only) / Interfacing / Controlling an array of 16 speakers on: June 17, 2008, 09:05:17 pm
Hi all,

I'm working on sound design for a production in melbourne this august.  My idea is to place a grid array of, say, 16 small speakers (4x4) concealed within the audience and to create a 'field' of sound that can be moved dynamically around the grid.

At this stage, the only way I can think of doing this is by using a 16-channel midi-controlled mixer to route sound (either from a single source, or from 16 individual sources via a computer soundcard) to each of the 16 speakers.  I would make a 2-dimensional controller using arduino to interpolate the sound 'position' and set the volume of each channel on the mixer accordingly in realtime.

I just wanted to put the idea out on this forum to see if anyone had some any ideas about how this could be achieved, or any suggestions for a different equipment setup.  I'm not particularly well acquainted with pro audio gear, so the more low-tech the solution, the better!

Thanks,

Jon.
22  Forum 2005-2010 (read only) / Interfacing / Re: 16 electrodes with only one QT300 sensor on: October 04, 2007, 08:13:47 pm
thanks for the suggestion -  i've done some searching around and found this 16:1 analog cmos multiplexer from maxim:
http://datasheets.maxim-ic.com/en/ds/MAX396-MAX397.pdf

do you think this might be suitable?  it says it's suitable for routing audio signals, so i suppose it would also do for routing aquisition bursts from a capacitance sensor...? but i have no idea how these things work....
cheers,
jon
23  Forum 2005-2010 (read only) / Interfacing / 16 electrodes with only one QT300 sensor on: September 27, 2007, 11:07:53 pm
hi all...

i'm making a touch-sensitive surface: i want to use arduino + a qt300 chip to sense the capacitance on 16 different electrodes in sequence, using only the one qt300.  (for now i'd prefer to use the qt300 rather than a Qslide etc because it's simple and cheap and easy and flexible)

anyone got any ideas how to do this, using as few arduino pins as possible?  my thought is that i could use a 1:16 demux chip to route the acquisition bursts from the QT300 through each sense electrode in turn, but i've never used de/multiplexers before... would that work?

the eventual aim is to make a large touch-sensitive field using about 60-100 conductive traces etched onto PCB, or something.  hence trying to conserve arduino pins... space is also extremely limited, so as little QT300s as possible, too, hence some kind of 16:1 routing chip.  any suggestins more than welcome, as i don't really know what i'm doing... as usual.

love,
jon.
24  Forum 2005-2010 (read only) / Interfacing / Re: playing mp3s from a USB thumb drive on: August 21, 2007, 02:21:04 am
i meant jpeg.  video.  too many darn pegs these days....
25  Forum 2005-2010 (read only) / Interfacing / Re: playing mp3s from a USB thumb drive on: August 21, 2007, 01:38:25 am
looks great!

imagine if vinculum added mpeg decoding as well. you could build an iPod... smiley
26  Forum 2005-2010 (read only) / Interfacing / Re: playing mp3s from a USB thumb drive on: August 09, 2007, 10:42:45 pm
whoa.  thanks so much daniel.  i've been scouring the net looking for something like that for ages, not knowing what it was called...

it's still a bit pricey, but i guess compared to the cost of buying all the components and then going through the process of getting them all communicating.....

does anyone know any suppliers who still have the Vmusic1 in stock?
27  Forum 2005-2010 (read only) / Interfacing / playing mp3s from a USB thumb drive on: August 08, 2007, 12:52:40 am
so, here's a very vague idea for a project for general discussion:

these days everyone uses USB thumb drives.  i keep a modest mp3 collection on my 8gb stick.  wouldn't it be great to have a portable mp3 player that i could stick my USB drive into and play my mp3s wherever?  iPods are just too expensive for me.  and i like the convenience of not using usb cables.  i know there are usb stick-style mp3 players, but even they aren't worth the cost in my opinion - and when it comes to upgrading, you pay for their mp3 functionality all over again.  my 8GB usb drive cost me just $25 on ebay.

anyway, it seems to me that no-one makes such a device.  am i the only one who would like to see one?

does anyone think arduino would be up to the task?

it would mean getting arduino to communicate simultaneously with:
- a USB drive,
- an mp3 decoder chip, and
- a display of some sort so the user could navigate the file structure.
and possibly other components that i haven't thought of yet.

has anyone got suggestions for how to tackle this?  think it isn't possible? know any gadgets that do this already?
28  Forum 2005-2010 (read only) / Interfacing / copying arduino program to new microcontroller on: August 23, 2007, 07:38:16 pm
hi all.  i don't know what this process is called, so i'm sorry if there's another forum topic devoted to it...

i'm designing a small portable audio gadget, so i don't want to put the entire arduino board inside.  is there an easy method of cloning my arduino program onto another microcontroller (say another ATmega168), mapping the arduino pins to specific pins on the new chip?  i'm only using digital I/Os, no pwm or analog.

thanks.

jon.
29  Forum 2005-2010 (read only) / Interfacing / Re: supply current: has arduino fryed my qprox sen on: July 25, 2007, 01:16:22 am
hmmm, i'm not all that sure about 1-wire mode.  i'm using the chip as it comes out of the box: in 4-wire SPI slave mode.  to set it to 1-wire mode i think you need a special cloning adapter (QTM300CA) to change the relevant parameter.  from memory, i think it will cost more than an arduino...  here's the user's guide:

http://www.qprox.com/downloads/manuals/qtm300ca_102.pdf

but you'd better chack that it's what you need before forking out the cash.  also, if you just want to run several QT300s with one arduino, there's a section in the QT300 datasheet that explains how to use several chips over a single SPI interface.  i think you need 3 common wires, then one wire for each chip...?

j.
30  Forum 2005-2010 (read only) / Interfacing / Re: supply current: has arduino fryed my qprox sen on: February 06, 2007, 03:49:58 am
wheeee! i don't believe it, but i've just managed to get the whole thing working perfectly.  turns out, i was reading the bits returned from QT300 backwards, shifting left instead of right.  silly me.  but yes.  i shall post this as a tutorial in a week or so when i get back from travelling.

next up is improving the stability of the system - currently, using a 100nF sampling cap, the data returned ranges from about 2200 (far) to 800 (near), but has a noise level of about +/- 15 which is totally unuseable for precision control.  

some improvements i'm considering:

- isolating the QT300 from arduino, powering it on it's own battery supply to get rid of power rippling (i'm sure arduino's USB power output isn't crash hot in terms of ripple - can anyone verify this?)

- adding some shielding around the QT300 (could anyone suggest some good literature on how shielding works?  i know absolutely nothing, except that i should keep my ground traces away from the sensor electrode...)

- perhaps try using optocouplers or some other kind of circuit isolation (again, i know nothing.  do optocouplers work fast enough to allow microsecond-accurate transfer of data, or does anyone know of some other similar gadget that does?)

- trying to increase the sensitive distance of the antenna.  starting with researching antenna design - how shape, length, material, etc. affect the sensitivity characteristics.  i don't even know if the QT300 is capable of projecting the sensitivity field, or whatever you call it, through more than about 10cm of air.  i'm hoping i can overcome this somehow, because 10cm is pretty useless to a theremin player...

hmmmm.  so i've sill got quite a fair way to go on this one.  but at least the first big hurdle is pretty much sorted out.  any suggestions welcome!

jon.
Pages: 1 [2] 3