Show Posts
Pages: [1] 2 3 ... 8
1  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: July 29, 2013, 09:08:22 am
I modified the library to increase and decrease the volume, and it works great. I added three new functions to the library. Hope these help.

Thanks. Didn't help unfortunately--I still get very choppy volume when trying to modify the volume. Here's scope trace of what's supposed to be a constant 440 Hz tone, after a call to volume(3):



Turns out that it only happens with 32 Kb/s ADPCM files (created by the UsbRecorder v1.3 tool). Setting the volume with 24 Kb/s or lower sampling rate files works fine, even though 32 KB/s file play fine at full volume. Weird. Anyway, the solution is to use 24 Kb/s max.
2  Using Arduino / Audio / Re: loop single sound on the WTV020-SD-16P on: July 27, 2013, 07:24:23 pm
I've been playing around with one of these devices too (WTV020-SD-mini) and find it requires a bit of reverse engineering to figure out how it works. It doesn't pay to follow the data sheets out there too closely. As you've noted, the "BUSY" signal appears to be active high rather than low as the data sheet would seem to imply. Also, it's not really a BUSY signal but rather just a bit that says when the device is out of "standby" (low-power drain) mode. When a file is played, the BUSY line stays high for about one second after the play stops:



The top trace is the voltage on one of the speaker pins, the bottom trace is BUSY. The time scale is 1 second per division. The line actually goes low when the device switches to standby. BTW, it draws about 2 ma in standby as opposed to maybe 100 ma average when playing a loud sound.

So when trying to loop a sound using BUSY as a trigger there will be at least a one second gap in between plays. But there's another quirk--if you try to send another play command immediately after BUSY going low, it will be ignored. I find by trial and error that you need to delay about 10 ms after BUSY goes low to successfully wake the chip up again with a play command.

So to summarize, to loop a sound:

-- send play command
-- wait for BUSY to go low
-- wait 10 ms
-- send play command, etc.

Joe
3  Using Arduino / Audio / Re: Arduino library for WTV020-SD-16P audio module on: July 23, 2013, 07:55:42 am
Has anyone been able to get the volume command working properly with this device? According to the spec, commands 0xfff0 through 0xfff7 should set one of eight volume levels, but only mute (0xfff0) and full volume (0xfff7) work properly. Intermediate values cause the audio to become very choppy, randomly changing volume, like maybe the ADPCM can't sync up? This happens with this library (if I change, say, VOLUME_MIN from 0xfff0 to 0xfff3 and call mute()) as well as an interrupt-based one I'm working on.

I'm using 32Kb/s ADPCM files from the UsbRecorder utility.

Joe
4  Using Arduino / General Electronics / Re: External power supply is drained when using USB on: July 22, 2013, 02:05:25 pm
Hard to say, but when the Arduino is powered by USB, there are actually two connections between the circuits, your "GND-GND" connection and also a connection through the electrical outlet ground wires, so there's a ground loop. With the "GND-GND" connection open, I wonder what you'd get if you measured the voltage between the power supply ground to the "earth" ground, also between the USB ground and earth ground.
5  Using Arduino / General Electronics / Re: A cautionary tale with cheap ebay Voltage Regulators. on: July 22, 2013, 05:09:42 am
I bought a lot of 10 of the ebay LM2596 boards for about $15 shipped.

http://www.ebay.com/itm/10pcs-LM2596S-power-module-DC-DC-Buck-Converter-Step-Down-Module-/400358408922

After some testing, I suspect that the LM2596S chip on these boards is counterfeit. The LM2596 spec sheet says that the switching frequency is 150 KHz, but these measure more like 50 KHz. The output ripple is supposed to be under 30 mV, but I see 200 mV with a 5V/300ma load. Also, if I set it for 5V at no load, I measure 4.75V at 1.6A load, more droop than expected.

Last year I bought a very similar-looking device from ebay for $6, only slight differences in the layout, matching this item:

http://www.ebay.com/itm/DC-DC-Buck-Converter-Module-LM2596-Breadboard-Power-Module-1-23V-35V/321158804705

That device shows a 150 KHz switching frequency as expected and much lower output ripple.
6  Using Arduino / Motors, Mechanics, and Power / Re: DC 5V 28YBJ-48 Stepper Motor Question on: July 10, 2013, 10:01:29 am
I've been experimenting with the 28BYJ-48 5V stepper to see what kind of application it might fit into--other than operating air conditioner louvers!

The torque is not very large. In a rough measurement I get about 250 g-cm. That's using an Arduino Uno to drive it, powered by USB, with the ULN2003 driver board that comes with the motor. The spec sheet says >300 g-cm, so it's in the ballpark.

The torque is unsurprisingly strongly dependent on the supply voltage to the driver board. With USB providing power, I see on a scope that the voltage drops from 5.0V to about 4.2V when the coils are energized, so it probably loses a little there. I tried driving it with 6.0V from another supply and the torque about doubled, to ~500 g-cm, but at 6V the motor gets pretty hot after about a minute or so, so that's probably not recommended, unless the use is very intermittent.

It's probably best to connect a separate regulated power supply to the driver board rather than using the Arduino-regulated +5V or USB.
7  Using Arduino / Motors, Mechanics, and Power / Re: Arduino Fio + xbee + Stepper Motor on: July 10, 2013, 06:03:30 am
I think it could work, as 3.3V is enough to turn the ULN2003 drivers "on," although you would still need a separate 5V supply to connect to the driver board to power the motor.
8  Using Arduino / Motors, Mechanics, and Power / Re: DC 5V 28YBJ-48 Stepper Motor Question on: July 10, 2013, 05:53:05 am
If you want fine positioning they're pretty good (about 4000 half-steps per revolution, so < 0.1 degree), although there are a few degrees of play (backlash) on the shaft, so some accommodation would be needed to address that. The spec sheet gives a max 1000pps at no load, so that amounts to about 15rpm max.
9  Using Arduino / Programming Questions / Re: Fastest way to do sin(), cos() atan2() on: October 12, 2011, 01:59:37 pm
@jmknapp

your table is of type uint16 and you use only halve its range (0..65535) so there is a few bits precision to be won?

check - http://arduino.cc/forum/index.php/topic,69723.0.html -

< 50 usec per call
- handles values outside 0..360
- tablesize: 182 bytes (uses interpolation)

Hi Rob,

I don't think going to 65535 would give even one more bit of precision--the error comes mostly from the table size of 1024, so that for example the step from sintab[0] to sintab[1] is 50, and 50/32768 = 0.00152. If the table went to 65535, the step between sintab[0] and sintab[1] would just go to 101 and give almost the same ratio.

You mention sin() taking 120 usec--what board is that with? I get 255 usec with a 16 MHz Diecimila, or at least I did some time back when I looked at it.

joe
10  Using Arduino / Programming Questions / Re: Fastest way to do sin(), cos() atan2() on: October 12, 2011, 07:37:22 am
Floating point divisions are more expensive, around 34 usec, but I don't think you have to use them. I.e., to convert from degrees to radians instead of 2*pi*d/360., just use 0.0174533*d.

So I gather since you want a speedup of a factor of three, you're looking for a total time of less than about 100 usec for the sin() call? It's an interesting exercise that might come in handy for my purposes too, so I gave it a whack. Here's some code that does a sin() function using table lookup in progmem:

Code:
#include <avr/pgmspace.h>
#define N 5000   // number of calls to make during test
#define NS 1024   // number of entries in sin table
#define MAXI 32768  // max integer value in table
#define I2F (1./MAXI) // conversion from integer to float

int i ;
long startTime, endTime ;
float dt ;
float d = 0.0 ;  // argument to sin function, degrees
float s ;  // result of sin function

// sin table
// values for first quadrant, other quadrants calculated by symmetry
PROGMEM prog_uint16_t sintab[NS] = {
0,
50,100,150,201,251,
301,351,402,452,502,
552,603,653,703,753,
804,854,904,954,1005,
1055,1105,1155,1206,1256,
1306,1356,1407,1457,1507,
1557,1607,1658,1708,1758,
1808,1858,1909,1959,2009,
2059,2109,2159,2210,2260,
2310,2360,2410,2460,2510,
2560,2611,2661,2711,2761,
2811,2861,2911,2961,3011,
3061,3111,3161,3211,3261,
3311,3361,3411,3461,3511,
3561,3611,3661,3711,3761,
3811,3861,3911,3961,4011,
4061,4110,4160,4210,4260,
4310,4360,4409,4459,4509,
4559,4609,4658,4708,4758,
4808,4857,4907,4957,5006,
5056,5106,5155,5205,5255,
5304,5354,5403,5453,5503,
5552,5602,5651,5701,5750,
5800,5849,5898,5948,5997,
6047,6096,6146,6195,6244,
6294,6343,6392,6442,6491,
6540,6589,6639,6688,6737,
6786,6835,6884,6934,6983,
7032,7081,7130,7179,7228,
7277,7326,7375,7424,7473,
7522,7571,7620,7669,7717,
7766,7815,7864,7913,7961,
8010,8059,8108,8156,8205,
8254,8302,8351,8400,8448,
8497,8545,8594,8642,8691,
8739,8788,8836,8884,8933,
8981,9029,9078,9126,9174,
9223,9271,9319,9367,9415,
9463,9512,9560,9608,9656,
9704,9752,9800,9848,9896,
9944,9991,10039,10087,10135,
10183,10230,10278,10326,10374,
10421,10469,10517,10564,10612,
10659,10707,10754,10802,10849,
10897,10944,10991,11039,11086,
11133,11181,11228,11275,11322,
11369,11416,11464,11511,11558,
11605,11652,11699,11746,11793,
11839,11886,11933,11980,12027,
12073,12120,12167,12213,12260,
12307,12353,12400,12446,12493,
12539,12586,12632,12678,12725,
12771,12817,12864,12910,12956,
13002,13048,13094,13140,13186,
13232,13278,13324,13370,13416,
13462,13508,13554,13599,13645,
13691,13736,13782,13828,13873,
13919,13964,14010,14055,14100,
14146,14191,14236,14282,14327,
14372,14417,14462,14507,14552,
14598,14642,14687,14732,14777,
14822,14867,14912,14956,15001,
15046,15090,15135,15180,15224,
15269,15313,15357,15402,15446,
15491,15535,15579,15623,15667,
15712,15756,15800,15844,15888,
15932,15976,16019,16063,16107,
16151,16195,16238,16282,16325,
16369,16413,16456,16499,16543,
16586,16630,16673,16716,16759,
16802,16846,16889,16932,16975,
17018,17061,17104,17146,17189,
17232,17275,17317,17360,17403,
17445,17488,17530,17573,17615,
17658,17700,17742,17784,17827,
17869,17911,17953,17995,18037,
18079,18121,18163,18204,18246,
18288,18330,18371,18413,18454,
18496,18537,18579,18620,18662,
18703,18744,18785,18826,18868,
18909,18950,18991,19032,19073,
19113,19154,19195,19236,19276,
19317,19358,19398,19439,19479,
19519,19560,19600,19640,19681,
19721,19761,19801,19841,19881,
19921,19961,20001,20040,20080,
20120,20159,20199,20239,20278,
20318,20357,20396,20436,20475,
20514,20553,20592,20631,20671,
20709,20748,20787,20826,20865,
20904,20942,20981,21020,21058,
21097,21135,21173,21212,21250,
21288,21326,21365,21403,21441,
21479,21517,21555,21592,21630,
21668,21706,21743,21781,21818,
21856,21893,21931,21968,22005,
22042,22080,22117,22154,22191,
22228,22265,22301,22338,22375,
22412,22448,22485,22521,22558,
22594,22631,22667,22703,22740,
22776,22812,22848,22884,22920,
22956,22992,23027,23063,23099,
23134,23170,23205,23241,23276,
23312,23347,23382,23417,23453,
23488,23523,23558,23593,23627,
23662,23697,23732,23766,23801,
23835,23870,23904,23939,23973,
24007,24041,24075,24109,24144,
24177,24211,24245,24279,24313,
24346,24380,24414,24447,24480,
24514,24547,24580,24614,24647,
24680,24713,24746,24779,24812,
24845,24877,24910,24943,24975,
25008,25040,25073,25105,25137,
25169,25201,25234,25266,25298,
25330,25361,25393,25425,25457,
25488,25520,25551,25583,25614,
25645,25677,25708,25739,25770,
25801,25832,25863,25894,25925,
25955,25986,26016,26047,26077,
26108,26138,26169,26199,26229,
26259,26289,26319,26349,26379,
26409,26438,26468,26498,26527,
26557,26586,26615,26645,26674,
26703,26732,26761,26790,26819,
26848,26877,26905,26934,26963,
26991,27020,27048,27076,27105,
27133,27161,27189,27217,27245,
27273,27301,27329,27356,27384,
27411,27439,27466,27494,27521,
27548,27576,27603,27630,27657,
27684,27711,27737,27764,27791,
27817,27844,27870,27897,27923,
27949,27976,28002,28028,28054,
28080,28106,28131,28157,28183,
28208,28234,28259,28285,28310,
28335,28361,28386,28411,28436,
28461,28486,28511,28535,28560,
28585,28609,28634,28658,28682,
28707,28731,28755,28779,28803,
28827,28851,28875,28898,28922,
28946,28969,28993,29016,29039,
29062,29086,29109,29132,29155,
29178,29201,29223,29246,29269,
29291,29314,29336,29359,29381,
29403,29425,29447,29469,29491,
29513,29535,29557,29578,29600,
29621,29643,29664,29686,29707,
29728,29749,29770,29791,29812,
29833,29854,29874,29895,29915,
29936,29956,29977,29997,30017,
30037,30057,30077,30097,30117,
30137,30156,30176,30196,30215,
30235,30254,30273,30292,30312,
30331,30350,30368,30387,30406,
30425,30443,30462,30480,30499,
30517,30535,30554,30572,30590,
30608,30626,30644,30661,30679,
30697,30714,30732,30749,30766,
30784,30801,30818,30835,30852,
30869,30886,30902,30919,30936,
30952,30969,30985,31001,31018,
31034,31050,31066,31082,31098,
31114,31129,31145,31161,31176,
31192,31207,31222,31237,31253,
31268,31283,31298,31312,31327,
31342,31357,31371,31386,31400,
31414,31429,31443,31457,31471,
31485,31499,31513,31526,31540,
31554,31567,31581,31594,31607,
31620,31634,31647,31660,31673,
31685,31698,31711,31723,31736,
31749,31761,31773,31785,31798,
31810,31822,31834,31846,31857,
31869,31881,31892,31904,31915,
31927,31938,31949,31960,31971,
31982,31993,32004,32015,32025,
32036,32047,32057,32067,32078,
32088,32098,32108,32118,32128,
32138,32148,32157,32167,32176,
32186,32195,32205,32214,32223,
32232,32241,32250,32259,32268,
32276,32285,32294,32302,32311,
32319,32327,32335,32343,32351,
32359,32367,32375,32383,32390,
32398,32405,32413,32420,32427,
32435,32442,32449,32456,32463,
32469,32476,32483,32489,32496,
32502,32509,32515,32521,32527,
32533,32539,32545,32551,32557,
32562,32568,32573,32579,32584,
32589,32595,32600,32605,32610,
32615,32619,32624,32629,32633,
32638,32642,32647,32651,32655,
32659,32663,32667,32671,32675,
32679,32682,32686,32689,32693,
32696,32700,32703,32706,32709,
32712,32715,32718,32720,32723,
32726,32728,32730,32733,32735,
32737,32739,32741,32743,32745,
32747,32749,32750,32752,32754,
32755,32756,32758,32759,32760,
32761,32762,32763,32764,32764,
32765,32766,32766,32767,32767,
32767,32767,32767
} ;

float romsin(float x) {
int ix ;   // index into sin table
int is ;   // value read from sin table
int q ;    // quadrant number 0,1,2,3
        int j ;

x *= 1./360. ;

x -= (int)x ;

if (x < 0)
x += 1.0 ;   // x is now between 0 and 1, representing 0 to 360 degrees

        q = x * 4 ;   // get quadrant number

        ix = (int)(x*4*NS) % NS ;  // get index into table

switch(q) {
case 0:   // 0-90
is = pgm_read_word_near(sintab + ix);
break ;
case 1:   // 90-180
ix = NS - ix - 1 ;  // reflect
is = pgm_read_word_near(sintab + ix); ;
break ;
case 2:   // 180-270
is = -pgm_read_word_near(sintab + ix); ;  // negate
break ;
case 3:   // 270-360
ix = NS - ix - 1;   // reflect
is = -pgm_read_word_near(sintab + ix); ;   // negate
break ;
}

        return((float)is*I2F) ;
}

void setup() {
  Serial.begin(9600) ;
  Serial.println("Sin in ROM test....") ;
}

void loop() {
  startTime=millis() ;
  for (i = 0 ; i < N ; i++)
    s = romsin(d) ;
  endTime=millis() ;
  dt = 1000.*(float)(endTime - startTime)/N ;  // time per call in usec
  
  Serial.print("sin(") ;
  Serial.print(d) ;
  Serial.print(")=") ;
  Serial.print(s) ;
  Serial.print(", ") ;
  Serial.print((int)dt) ;
  Serial.println(" usec/call") ;
  
  d += 1.0 ;
}

The results are around 80 usec per call. The error is at most 0.0016, near 0 and 180 degrees. That could be improved with a bigger table if necessary, and/or using interpolation although in the latter case there would be a time hit.

I'm not sure why people warn against the slowness of progmem access. From what I can see, a read takes less than a microsecond, so that's no worry in this context.

cos(), atan2() etc. are left as an exercise for the reader!

Joe
11  Using Arduino / Programming Questions / Re: Fastest way to do sin(), cos() atan2() on: October 11, 2011, 07:49:41 pm
FYI, I measured the speed of a sin() call on a 16 MHz Diecimila and got 255 usec. A floating point multiply clocked in at 9 usec.

Joe
12  Using Arduino / Project Guidance / Re: Weather radar on: October 05, 2011, 06:54:54 pm
I've been playing with that sensor. It works well out to about 50 feet with something like a 120 degree beam pattern in azimuth, 60 degrees in elevation. Not so great for weather systems!

Within that beam pattern it'll tell you the speed of objects, but not the range. Doppler radars with range capabilities are "pulsed," where a pulse is sent out and the phase of the received pulse is measured to get the range per the speed of light. This sensor doesn't have this capability. You can operate it in what the data sheet calls "pulsed" mode, but that just allows you to save on power consumption and doesn't involve any capability to measure the phase of the returned pulses. It's pretty much a black box. You apply power and ground and you get an IF signal out, containing the difference (doppler) frequencies, conveniently located in the audio range. E.g., a 100 mph object produces a ~3100 Hz signal. The most basic mode is "continuous wave" mode where the transmit antenna (consisting of two small patches on the pcb) continuously emits the x-band signal, and the receive antenna (similarly two patches on the pcb) continuously receives the reflected signal. As I say, the pulsed mode allows you to reduce the duty cycle to conserve power, although the unit isn't too power hungry--30 ma @ 5V.

Joe
13  Using Arduino / Project Guidance / Re: ADC problem on: October 05, 2011, 08:08:04 am
The output resistance of your current source is RV1 which is 1K max. So it seems that U2 is really just an inverting voltage amplifier with gain 430/RV1.

That's a valid way of looking at the circuit. Combining "Vout = Vcell * 430/RV1" with "Vcell = Icell * RV1", we get "Vout = Icell * 430". Whis is exactly what @secretagent wants.

True, which is why I deleted my post just before you replied.  smiley
14  Using Arduino / Project Guidance / Re: XBee chip anitinna on: September 27, 2011, 07:53:12 pm
Check out Digi's paper:

XBee & XBee‐PRO OEM RF Module Antenna Considerations
http://ftp1.digi.com/support/images/XST-AN019a_XBeeAntennas.pdf

Summarizing, they compare both the 1mW XBee and 60 mW XBee-Pro, each with a chip or whip antenna.



Quote
The radiation pattern for the whip antenna is similar to that of a dipole. That is to say, it
is shaped like a donut.  Thus, the performance of a module using a whip antenna, is
relatively insensitive to its orientation in the plane that is perpendicular to the whip
antenna.  On the other hand, the radiation pattern of the chip antenna is not as uniform
as that of the whip antenna.  Therefore, certain orientations will achieve better
performance than others.  As our evaluation was performed, the orientation was
selected to achieve the best performance. ...

After reviewing Table 1, we can make several important observations.
• The whip antenna has a range advantage over the chip antenna, but only outdoors.
• The XBee-PRO can achieve more range than the XBee.
• The XBee-PRO and XBee both achieve more range outdoors than they do indoors.

The whip antenna on the XBee module affords additional range in outdoor applications.
However, it also occupies more space.  If more range is required, and space is a
constraint, then the XBee-PRO with a chip antenna may be more appropriate.  On the
other hand, if more range is a requirement and cost, not space, is the constraint, then
the XBee with a whip antenna may be the best choice. 
It should also be clear that the XBee-PRO can achieve superior range when compared to
the XBee.  Thus, if the application requires more range than the XBee can provide, then
the XBee-PRO with a whip or a chip antenna could be used.  Again, the chip antenna is
best for tight spaces, while the whip antenna achieves more range. 
15  Using Arduino / Project Guidance / Re: Prototype working, what's next? (For production/distribution) on: September 27, 2011, 10:16:12 am
For enclosures, I've been thinking about using local laser-cutting facilities. Laser cutters can easily cut acrylic for pots, switches, displays, etc. There's a local hackerspace of sorts here for small-scale work, as well as several other options in town for larger runs. Of course, that means putting it together yourself, so maybe that's not a good solution for you.

There's a guy at the hackerspace (http://columbusideafoundry.com) who laser-cuts recycled wooden cigar boxes for electronic enclosures.

Joe
Pages: [1] 2 3 ... 8