Show Posts
Pages: [1] 2 3 4
1  Forum 2005-2010 (read only) / Troubleshooting / Re: trouble uploading to lilypad on: October 27, 2008, 02:08:39 pm
Yup, just had to hold reset exactly from when I start the upload until the Tx light on the breakout board starts flashing.  Thanks for the tip.
2  Forum 2005-2010 (read only) / Troubleshooting / trouble uploading to lilypad on: October 26, 2008, 05:52:27 pm
Hi,
 
After a while using the diecimila, I have recently purchased a lilypad in an attempt to make a halloween costume.  However, I'm having trouble uploading to it.  I'm using the mini-usb breakout board from sparkfun without alligator clips or anything and I'm pretty sure it is connected the correct way, as the built-in led on the board blinks when it's plugged in and the Tx led on the breakout board blinks when I attempt to upload.  However, it gives me an error message, "avrdude: stk500_recv(): programmer is not responding."  I'm connected using serial port /dev/tty.usbserial-A80081IW and have selected the lilypad board.  What am I doing wrong?

Thanks,
Zach
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: truncated ints and conversion to chars on: September 11, 2010, 08:24:43 pm
Very well explained.  Thanks!
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: truncated ints and conversion to chars on: September 11, 2010, 04:28:14 pm
But given:

unsigned char foo[3];

and

char *bar = &foo[0];

doesn't

foo == bar

for all intents and purposes or am I getting it completely wrong here?
5  Forum 2005-2010 (read only) / Syntax & Programs / Re: truncated ints and conversion to chars on: September 11, 2010, 03:07:09 pm
I have to be honest, I thought an unsigned char and a byte were the same thing.  What is the distinction?

6  Forum 2005-2010 (read only) / Syntax & Programs / Re: truncated ints and conversion to chars on: September 11, 2010, 12:34:02 pm
I have 10 analog sensors being read in from one Arduino and transmitted over WiFi via UDP to another Arduino which uses the values to PWM dc motors.  For various compatibility issues with other systems receiving the data, I would prefer to transmit the values as an array of chars or unsigned chars rather than as ints.

What I can't figure out is how to read the ints into the array, when they will take up 2 index places each and, similarly, how to parse them out into an array of ints.  Whatever method I use, it needs to be able to be read into uip_appdata using the memcpy function in order to work with the WiShield library.  The problem with itoa was that it would halt the program whenever I sent a number around 1023.  This was likely due to my implementation and I am now scaling the value to 255, but I still prefer sprintf for it's robustness and the fact that I understand better how it works.  
7  Forum 2005-2010 (read only) / Syntax & Programs / Re: truncated ints and conversion to chars on: September 10, 2010, 12:48:56 pm
Cool, thanks.  Just wasn't sure it was linear.  
8  Forum 2005-2010 (read only) / Syntax & Programs / Re: truncated ints and conversion to chars on: September 10, 2010, 12:42:11 pm
You mean the max analog value for 5v is 1023, while for 3.5v it's smaller?  What is it?

Also, still looking for an answer to my second question, although realize it's more complicated.  
9  Forum 2005-2010 (read only) / Syntax & Programs / truncated ints and conversion to chars on: September 10, 2010, 11:32:48 am
I have two issues for which I'm not sure the solutions.  First, the following code seems to be truncating my ints so I get a max value of somewhere around 180, rather than 255.  Any idea what I'm doing wrong here?  Ignore the variable uip_appdata- this is part of the WiShield library (ugh), references to the rest of which have been omitted for simplicity.

Code:
int sensors[10] = {0,0,0,0,0,0,0,0,0,0};
int motors[10] = {0,0,0,0,0,0,0,0,0,0};

void setup()
{
   Serial.begin(57600);
}

void loop()
{  
   for(int i = 0; i < 10; i++){
     sensors[i] = map(analogRead(i), 0, 1023, 0, 255);
   }
}

extern "C"
{
   static void send_data(void)
   {
     memcpy(uip_appdata, &sensors, sizeof(sensors));
     memcpy(&motors, uip_appdata, sizeof(sensors));
     for(int i = 0; i < 10; i++){
       Serial.println(motors[i]);
     }
   }
}

Second, trying the same thing with either chars or unsigned chars is giving me all zeros upon conversion back to ints.  I think the root of both these issues is that integers take up two bytes and I'm losing the second one, but it seems I should be able to fit an integer into one unsigned char, no?  

I'm also wondering if there's a more robust C function to convert chars to ints than atoi.  I much prefer sprintf to itoa, as I have had problems with the latter handling larger integers (not longs, just something in the range of 1023).  

Code:
unsigned char sensors[10] = {0,0,0,0,0,0,0,0,0,0};
unsigned char motorsTemp[10] = {0,0,0,0,0,0,0,0,0,0};
int motors[10] = {0,0,0,0,0,0,0,0,0,0};

void setup()
{
   Serial.begin(57600);
}

void loop()
{  
   for(int i = 0; i < 10; i++){
     sensors[i] = byte(map(analogRead(i), 0, 1023, 0, 255));
   }
}

extern "C"
{
   static void send_data(void)
   {
     memcpy(uip_appdata, sensors, sizeof(sensors));
     memcpy(motorsTemp, uip_appdata, sizeof(sensors));
     for(int i = 0; i < 10; i++){
       motors[i] = atoi((const char*)motorsTemp[i]);      
       Serial.println(motors[i]);
     }
   }
}

OR

Code:
int sensors[10] = {0,0,0,0,0,0,0,0,0,0};
int motors[10] = {0,0,0,0,0,0,0,0,0,0};

void setup()
{
   Serial.begin(57600);
}

void loop()
{  
   for(int i = 0; i < 10; i++){
     sensors[i] = map(analogRead(i), 0, 1023, 0, 255);
   }
}

extern "C"
{
   static void send_data(void)
   {
     char str[20];
     sprintf(str, "%i", sensors);
     memcpy(uip_appdata, str, strlen(str));
     memcpy(str, uip_appdata, strlen(str));
     for(int i = 0; i < strlen(str); i++){
       motors[i] = atoi((const char*)str[i]);      
       Serial.println(motors[i]);
     }
   }
}

Thanks!

-Zach
10  Forum 2005-2010 (read only) / Syntax & Programs / Re: sampling analog signals on: November 19, 2009, 05:55:07 pm
Another question: is the AD5206 digital pot pretty much interchangable with analog pots or would that leave me back where I started?
11  Forum 2005-2010 (read only) / Syntax & Programs / Re: sampling analog signals on: November 19, 2009, 05:44:12 pm
I just figured multiplying by HIGH would scale the value of the pot to the Arduino's output voltage, but I was likely incorrect.  

I realize I should have done much more research on general Arduino audio stuff before posting here.  Apologies all around.

However, in everything I've read today, I did not see one option described: what if I were to replace the pots on the 4017 with photoresistors and use an optical gate with LEDs dimmed by pwm, controlled by pots going into Arduino's analog in?  I think this may be the winner...
12  Forum 2005-2010 (read only) / Syntax & Programs / Re: sampling analog signals on: November 19, 2009, 10:27:20 am
I was just using analogWrite out one of the pwm pins, as in the code example in my first post in this thread.  

I'm going to have to read through the article about filters and possibly experiment with a dac chip.  Can you direct me to any tutorials on this kind of thing (replicating or sampling a pot) specifically for Arduino?    
13  Forum 2005-2010 (read only) / Syntax & Programs / Re: sampling analog signals on: November 19, 2009, 09:39:08 am
Grumpy Mike, can you possibly elaborate on the last point?  Are you saying I have to use an external dac to send values back to the analog circuit after digital processing?  Where would I find such a dac?  I had no trouble just passing the mixing bus straight through the Arduino to the preamp.  
14  Forum 2005-2010 (read only) / Syntax & Programs / Re: sampling analog signals on: November 18, 2009, 10:29:28 am
I think I get what you're driving at Mitch, but it doesn't seem a good solution for analog signals as I'm interested in sampling their full timbre with the attack and delay.  It seems like this would basically make them sound much more "digital," no?

Another solution would be instead of sampling the signal out of the 4017, to simply store the value of the pots connected to each pin as a scalar (i.e. only storing it when it changes).  Unfortunately, I have had trouble with even this.  I can't even correctly route the pot through the Arduino and back to the VCO without processing it at all!  Any example code of this would be greatly appreciated.  

Thanks,
Zach
15  Forum 2005-2010 (read only) / Syntax & Programs / Re: sampling analog signals on: November 17, 2009, 05:35:31 pm
I would still like to find an algorithm to store this on the chip, as the cost of the Wave shield would exceed everything else in this sequencer I'm building.  

Surely there must be simple audio compression algorithms like this?
Pages: [1] 2 3 4