Show Posts
Pages: [1] 2 3
1  Forum 2005-2010 (read only) / Troubleshooting / Re: Export button resets PC on: March 17, 2008, 02:02:10 pm
i know my computer often freezes or reboots when loading to the arduino and it has to do with the computer having flakey usb. it will do the same thing reading memory cards, or uploading to my ipod. maybe you could try a pci usb card.
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: starting with spi questions about code on: March 12, 2008, 11:39:35 am
i fixed my erratic arduino behavior with a 100uf bypass cap after the arduino, i just looked at the demo board and it has 4 extra 10uf caps on each of the different vcc segments, the datasheet showed these as optional and didnt even list values so ill give that a shot first.

im not sure if its a noise or peak power problem the 100uf is solving, technically the speaker should not be doing more than 670mW according to the spec sheet so its probably noise.
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: starting with spi questions about code on: March 12, 2008, 12:40:34 am
regarding how to read status registers on the chipcorder, and im assuming other spi devices....

alright i think i have an idea of how it works miso goes in SPDR after each SPDR load so you put a byte into spdr and it outputs a byte into spdr from the spi device now... lets say the spi device puts 3 bytes into spdr for a command spdr only appears to hold a single byte, so how do we read all 3 bytes? the spi commands im noticing have 0x00 bytes beyond the command byte the number of these 0x00 bytes seem to conform to how many miso bytes the command returns so at first glance the extra 0x00 for each command seem like nonsense because they are null values however what it does is give you seperate spi_transfer calls, each returning a byte so while RD_STATUS is 0x05,0x00,0x00 its 3 different spi_transfers, and 3 different MISO states so you read each miso value after each spi transfer, then you can put them together to get the full miso stream so for my chip corder, when i send a play command, then continue checking the 3rd returned byte of the rd_status spi command while the chip is playing, the 3rd bit of the 3rd byte (last 0x00 transfer of RD_STATUS) will be 1, it will go to 0 when the chip is done (actually it will go from 00100000 to 10000000 as the first bit is the ready flag .. what you should be looking for anyways).

two things don't help figuring this out, serial.print's deletion of leading zeros, and serial.prints erratic behaviour while the circuit is playing the speaker (need to track this down) i assume its either power draw or noise. bitwise math is what youll need to do to check status ... for instance you dont want to start another spi command until the play command has completed which you don't know unless you check the regsiter... so you have to keep cycling through RD_STATUS spi commands until the 3rd byte is what you want.
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: starting with spi questions about code on: March 11, 2008, 08:48:55 pm
oddly enough the code does work once i changed the spi pins to the correct ones.

also the PU command needed to be put in setup for the loop to work. once i get everything working ill be sure to post a howto.

thanks all

to put multiple spi devices on the same bus wouldn't they need to all use the same SPCR settings?
5  Forum 2005-2010 (read only) / Syntax & Programs / starting with spi questions about code on: March 11, 2008, 01:09:18 am
im trying to interface a winbond chipcorder isd1700 via spi, i have it working with standalone buttons right now so i know it works, i have the spi lines hooked to the arduino, and this is sorta what i have so far.

can i use the opcodes like i am? do i need to do anything special for the hex codes, should i convert them to decimal? any hints on something im doing blatantly wrong?

i couldn't find a spi speed in the manual so i assumed the lowest

the datasheet specified
PU then CLR_INT then PLAY as a sample execution sequence
each of these command bytes is to be followed by a 0x00 value

the code doesn't work as is, but i don't exactly expect it to either. looking for some advice so i can work on it some more tommorrow thanks!

if your a masochist, here is the datasheet
http://www.techs-store.com/support/manual/isd1700/isd1700_eman.pdf
most of the spi stuff starts on page 31

Code:
#define DATAOUT     4   //mosi
#define DATAIN      5   //miso
#define SPICLOCK    6   //sck
#define SLAVESELECT 7   //ss

//opcodes
#define PU          0x01
#define STOP        0x02
#define RESET       0x03
#define CLR_INT     0x04
#define RD_STATUS   0x05
#define RD_PLAY_PTR 0x06
#define PD          0x07
#define RD_REC_PTR  0x08
#define DEVID       0x09
#define PLAY        0x40
#define REC         0x41
#define ERASE       0x42
#define G_ERASE     0x43
#define RD_APC      0x44
#define WR_APC1     0x45
#define WR_APC2     0x65
#define WR_NVCFG    0x46
#define LD_NVCFG    0x47
#define FWD         0x48
#define CHK_MEM     0x49
#define EXTCLK      0x4A
#define SET_PLAY    0x49
#define SET_REC     0x81
#define SET_ERASE   0x82

void setup() {

  byte clr;
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(SLAVESELECT,OUTPUT);
  digitalWrite(SLAVESELECT,HIGH); //disable device  
  SPCR = B01111111; //data lsb, clock high when idle, samples on falling
  clr=SPSR;
  clr=SPDR;
  delay(10);
  
}

void loop() {
  
  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(PU); // power up
  spi_transfer(0x00); // data byte
  digitalWrite(SLAVESELECT,HIGH);
  delay(100);
  
  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(CLR_INT); // clear interupt and eom bit
  spi_transfer(0x00); // data byte
  digitalWrite(SLAVESELECT,HIGH);
  delay(100);

  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(PLAY); // play
  spi_transfer(0x00); // data byte
  digitalWrite(SLAVESELECT,HIGH);
  delay(100);

  delay(10000);
  
}

char spi_transfer(volatile char data)
{
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait for the end of the transmission
  {
  };
  return SPDR;                    // return the received byte
}
6  Forum 2005-2010 (read only) / Syntax & Programs / Re: ideas for loading pcm data to flash? on: February 29, 2008, 01:41:53 pm
nono, i should have specified. i will be using a seperate flash chip like:

http://www.futurlec.com/Mini_FLASH.shtml

but i may have to store the start and end locations of each seperate pcm on the arduino so it knows where each section is on the external flash chip. if i used fixed duration chunks i can just keep the locations in code, but if i don't i would have to store the locations on the arduino board itself, or first few bytes of external flash data.
7  Forum 2005-2010 (read only) / Syntax & Programs / ideas for loading pcm data to flash? on: February 29, 2008, 01:18:20 pm
ive got a project lined up where part of it will involve loading pcm audio data from the computer to a flash chip connected to an arduino.

I would like to say, be able to upload 5 different pcm files onto the flash. then layer have the arduino play each pcm through a simple r2r dac.

my thoughts so far for proof of concept:

segment the flash into 5 known size chunks, hardcode the page value into the arduino
write a small processing app that you can specify a number from 1-5 and a txt file containing the pcm data.
the arduino will have a jumper, if the jumper is in program mode, it will wait for serial data.

the processing app writes an ID char to serial 1-5 to tell the arduino which chunk it is.
the processing app then streams the pcm data to the arduino which writes it to flash.

....

to later build on this, im assuming i could use the built in flash/eeprom memory and have the processing app write all 5 at the same time, updating the arduino flash/eeprom memory with the new page value (would have to update the entire flash at the same time doing this as opposed to being able to rewrite any chunk, but you could upload different length pcm samples.



any ideas?
8  Forum 2005-2010 (read only) / Interfacing / Re: code: interfacing a chipcorder isd1760 on: April 30, 2008, 01:05:11 pm
some errata:

the set_play above has the wrong value defined

it should be 0x80 not 0x49

corrected code:
Code:
#define SET_PLAY    0x80

also one user reported the isd worked with with the decimilia but not the older arduino. thanks eggplant.

also a brain fart on the last example it should be end>>8 and not start>>8

corrected code:
Code:
 spi_transfer(end&255); // data byte stop
  spi_transfer(end>>8); // data byte last 3 bits
9  Forum 2005-2010 (read only) / Interfacing / Re: code: interfacing a chipcorder isd1760 on: March 14, 2008, 12:11:11 am
some info regarding direct memory access:

many of the commands let you specify a range in memory to start and stop at. to automate playback ... recording etc...

my chip is the 60second version, the max memory location you can specify is 0x1EF or 495

each locaton is 10 bits long.

if you wanted to play from:
001 00100001 - 289
to
001 01000111 - 327

this chip will never use the first 2 bits, but the 240 second version will, its max value is
111 10001111 - 1935

the second byte you send is actually the first 3 bits of the number, the chipcorder is just lsb so its a little odd.
this spi command will do that (binary for readability

Code:
 digitalWrite(SLAVESELECT,LOW);
  spi_transfer(SET_PLAY); // clear interupt and eom bit
  spi_transfer(0x00); // data byte
  
  spi_transfer(B00100001); // data byte start
  spi_transfer(B00000001); // data byte last 3 bits
  spi_transfer(B01000111); // data byte stop
  spi_transfer(B00000001); // data byte last 3 bits
  spi_transfer(0x00); // data byte blank
  digitalWrite(SLAVESELECT,HIGH);

now how about a better way to do this?

Code:
 int start = 289;
  int end   = 327;
  
  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(SET_PLAY); // clear interupt and eom bit
  spi_transfer(0); // data byte
  
  spi_transfer(start%256); // data byte start
  spi_transfer((int)start/256); // data byte last 3 bits
  spi_transfer(end%256); // data byte stop
  spi_transfer((int)end/256); // data byte last 3 bits
  spi_transfer(0); // data byte blank
  digitalWrite(SLAVESELECT,HIGH);  

you could use also (read should probably) use bitmask also say
start&255  then start>>8

Code:
 digitalWrite(SLAVESELECT,LOW);
  spi_transfer(SET_PLAY); // clear interupt and eom bit
  spi_transfer(0); // data byte
  
  spi_transfer(start&255); // data byte start
  spi_transfer(start>>8); // data byte last 3 bits
  spi_transfer(end&255); // data byte stop
  spi_transfer(start>>8); // data byte last 3 bits
  spi_transfer(0); // data byte blank
  digitalWrite(SLAVESELECT,HIGH);  
10  Forum 2005-2010 (read only) / Interfacing / Re: code: interfacing a chipcorder isd1760 on: March 12, 2008, 09:00:40 pm
Code:
//define pins
#define DATAOUT     11   //mosi
#define DATAIN      12   //miso
#define SPICLOCK    13   //sck
#define SLAVESELECT 10   //ss

//opcodes
#define PU          0x01
#define STOP        0x02
#define RESET       0x03
#define CLR_INT     0x04
#define RD_STATUS   0x05
#define RD_PLAY_PTR 0x06
#define PD          0x07
#define RD_REC_PTR  0x08
#define DEVID       0x09
#define PLAY        0x40
#define REC         0x41
#define ERASE       0x42
#define G_ERASE     0x43
#define RD_APC      0x44
#define WR_APC1     0x45
#define WR_APC2     0x65
#define WR_NVCFG    0x46
#define LD_NVCFG    0x47
#define FWD         0x48
#define CHK_MEM     0x49
#define EXTCLK      0x4A
#define SET_PLAY    0x49
#define SET_REC     0x81
#define SET_ERASE   0x82

void setup() {

  byte clr;
  pinMode(DATAOUT, OUTPUT);
  pinMode(DATAIN, INPUT);
  pinMode(SPICLOCK,OUTPUT);
  pinMode(SLAVESELECT,OUTPUT);
  digitalWrite(SLAVESELECT,HIGH); //disable device  
  SPCR = B01111111; //data lsb, clock high when idle, samples on falling
  clr=SPSR;
  clr=SPDR;
  delay(10);

  //start serial
  //Serial.begin(57600);
  
  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(PU); // power up
  spi_transfer(0x00); // data byte
  digitalWrite(SLAVESELECT,HIGH);
  delay(100);  

  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(CLR_INT); // clear interupt and eom bit
  spi_transfer(0x00); // data byte
  digitalWrite(SLAVESELECT,HIGH);
  delay(100);

}

void loop() {

  
  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(PLAY); // clear interupt and eom bit
  spi_transfer(0x00); // data byte
  digitalWrite(SLAVESELECT,HIGH);
  
  ready_wait();
  
  digitalWrite(SLAVESELECT,LOW);
  spi_transfer(FWD); // clear interupt and eom bit
  spi_transfer(0x00); // data byte
  digitalWrite(SLAVESELECT,HIGH);
  
}

void ready_wait(){

  byte byte1;
  byte byte2;
  byte byte3;

  while(byte3<<7 != 128){
  
    digitalWrite(SLAVESELECT,LOW);
    byte1 = spi_transfer(RD_STATUS); // clear interupt and eom bit
    byte2 = spi_transfer(0x00); // data byte
    byte3 = spi_transfer(0x00); // data byte
    digitalWrite(SLAVESELECT,HIGH);

  }
  
  delay(100);
  
}

char spi_transfer(volatile char data)
{
  SPDR = data;                    // Start the transmission
  while (!(SPSR & (1<<SPIF)))     // Wait for the end of the transmission
  {
  };
  return SPDR;                    // return the received byte
}
11  Forum 2005-2010 (read only) / Interfacing / code: interfacing a chipcorder isd1760 on: March 12, 2008, 09:00:24 pm
this is a work in progress but im happy enough with the following example and should prove a good starting point for anyone using the chip. it is a recording chip with mic amp and speaker output as well as pushbutton controls. this example does the following:

powers up the 1700
plays from the current pointer on the chip memory
waits until the sample is done
forwards to next recording

loops

all of the opcodes are defined, but you will need to look up the datasheet to see how many and what type of data bytes you need to send after it.

also to check if the message is done, i am checking the first bit of the 3rd miso byte, which is the second status register on the chip.

for hooking up the chip i used the manual in the design guide for pushbutton control, then added the spi. it should be noted that the caps marked with a * on the vcc lines next to the .1uf caps, should be 10uf, you can see what i mean by downloading the evaluation board datasheet you can find it here:

http://www.winbond-usa.com/en/content/view/45/140/#ISDCOB17XXX

with a microphone and speaker attached i have 12 caps, 4 10uf, 2 4.7uf, 6 .1uf which seems like alot lol.
12  Forum 2005-2010 (read only) / Interfacing / Re: rgb led 196x32 matrix on: March 23, 2008, 03:59:27 am
something very similar you may look into are gambling machines.

often they can have decent sized arrays of smd rgb led's
here is something i came across
http://tinyurl.com/2x7u7y

as for do these things really cost thousands, i think the answer is yes .. easily.
commercial electronics in general are very pricey especially things that aren't mass produced. you would be amazed how much things can cost.

in the above gambling machine example, this is an array that is much smaller than what you are proposing and the seller states that the panel itself cost thousands of dollars originally.

this is interesting:
http://www.ledtronics.com/ds/rgb1004/
13  Forum 2005-2010 (read only) / Interfacing / Re: rgb led 196x32 matrix on: March 17, 2008, 01:49:35 pm
a very ambitious project

since you can always buy hardware after the fact, might i suggest not quite investing in the led's right away until you figure out all the hardware?

you may also need to look at using multiple microcontrollers and segmenting the display in order to get reasonable refresh rates my guess is that chaining this many drivers together will not yield satisfactory results. you will probably want segments controlled by microcontrollers that at as frame buffers, and microcontrollers dedicated to feeding display information to those frame buffers. you may also find out that the arduino isn't the best platform for this project. you also need to look at total power usage for the led's which will be quite high.

what do you want to do with the display? that might provide some more opportunity for feedback. do you also have a budget for this project? i would expect it to run easily into the thousands of dollars range.

it's doable though it will just take alot of planning, calculations and cold hard cash smiley-grin do you live near any universities? speaking with seasoned faculty on the subject will answer many questions as well.
14  Forum 2005-2010 (read only) / Development / Re: Library for TLC5940 16-channel PWM chip on: December 11, 2008, 02:18:14 am
wanted to give a big thank you for the library, i look forward to using it soon.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: replacing resonator with crystal? on: March 03, 2008, 03:10:14 pm
they are more accurate, which is why im considering trying the crystal route and see if it clears it up. that makes sense why they use resonators though.

looks like (1) 16mhz crystal and (2) 22pf caps to ground is all i need.
Pages: [1] 2 3