Show Posts
Pages: 1 ... 64 65 [66] 67 68 ... 105
976  Using Arduino / Programming Questions / Re: the function call just partly work on: October 13, 2012, 01:38:12 pm
This is wrong:
Code:
  if (sample < sinewave_length&&PressStatus=1) {
It would be best to parenthesize the two separate conditions but the real problem is that '=' is assignment, not comparison.
Use this:
Code:
  if ((sample < sinewave_length) && (PressStatus == 1)) {

Pete
977  Using Arduino / Programming Questions / Re: Fast Fourier Transform in realtime on: October 13, 2012, 10:45:27 am
I posted some results of playing around with FFT here: http://arduino.cc/forum/index.php/topic,96562.0.html

But there is an implementation of the Fast Hartley Transform here: http://wiki.openmusiclabs.com/wiki/ArduinoFHT
The FHT is faster than FFT.

Pete
978  Using Arduino / Programming Questions / Re: Excel on: October 10, 2012, 11:09:10 am
I've used the Arduino to generate CSV files on a uSD card. Double-left-clicking on the filename immediately opens the file in Excel with each Comma Separated Value entered in a new field. As far as I can remember, I haven't done any special setup in Excel to make it do that. This is with Excel 2010 on WIn7Pro.

Pete
979  Using Arduino / Programming Questions / Re: Concatenate int to make a file name on: October 10, 2012, 11:02:01 am
Code:
snprintf(nombrearchivo,13,"%02d%02d20%02d.csv", dayOfMonth, month, year);
That filename structure will not sort well when you have a lot of files. I'd suggest that you use YYYYMMDD instead so that the files will be sorted into natural order when you view them in Windows Explorer or use 'ls' or whatever on Linux.
Code:
snprintf(nombrearchivo,13,"20%02d%02d%02d.csv",year,month, dayOfMonth);

Pete
980  Using Arduino / Programming Questions / Re: Programming parabolic function on: October 05, 2012, 10:19:07 am
A little bit of algebra changes that to
Code:
RTCvar = (120.*seconds - seconds*seconds)/36.;

Pete
981  Using Arduino / Programming Questions / Re: sketch formula line on: September 28, 2012, 11:38:01 am
The formula is slightly wrong. It should be:
Code:
position = pinval_1 | (pinval_2 << 1) | (pinval_3 << 2) | (pinval_4 << 3);

Pete
982  Using Arduino / Project Guidance / Re: *Total noob working on school project*- How to know what I need? on: September 26, 2012, 11:03:11 am
How big is the can? Why are you using an Arduino anway?

Pete
983  Using Arduino / Programming Questions / Re: Problem with DS1307 and DS18B20 on: September 22, 2012, 04:03:03 pm
Quote
it shows a size of 27,180 bytes
That's the amount of flash ram that's used. The IDE does not show you how much SRAM you are using.
You are using the String library and, as I mentioned, the SD library requires quite a bit of SRAM so you will almost certainly be running into problems caused by exceeding the SRAM limit which on a 328-based Arduino is only 2kB.
You should get rid of the String library and handle the character strings yourself.

Pete
984  Using Arduino / Programming Questions / Re: Problem with DS1307 and DS18B20 on: September 22, 2012, 11:00:39 am
The symptoms you describe suggest that you are exceeding the available SRAM.The SD library uses a fair bit of SRAM on its own. If you have a lot of strings or, worse yet, you are using the String library, you'll easily exceed SRAM.

Pete
985  Using Arduino / Networking, Protocols, and Devices / Re: Does RF transmitter transmit all the time? on: September 20, 2012, 06:04:55 pm
The ebay page says the transmitter does "Modulation mode: ASK /OOK".
In order to do OOK there would have to be a way of keying the transmitter on and off - n'est-ce pas?
However, the "documentation" is sparse at best, so that might be wrong.

Pete
986  Using Arduino / Programming Questions / Re: bitwise shift operators, where does the bit go? on: September 19, 2012, 01:52:34 pm
You can do inline assembler stuff but the closest I have got to it is to use
Code:
    asm volatile("nop\n"::);
to give me a delay guaranteed to be greater than a few nanoseconds.

You may be focusing on the wrong thing to optimize though. If your "do blah" takes microseconds or even milliseconds to execute then agonizing over the few instructions required to shift and test a bit is a waste of time.

Pete
987  Using Arduino / Programming Questions / Re: bitwise shift operators, where does the bit go? on: September 19, 2012, 12:52:10 pm
Quote
How are either of those examples any different in efficiency than the first example I gave?
They have two great advantages over your example.
(a) you can't access the overflow bit from C even if you use a left shift.
(b) they work.


Quote
In assembler you to a test under mask and then branch on a condition
If you are so desperate for speed you will have to use assembler, one way or another.

Pete
988  Using Arduino / Programming Questions / Re: bitwise shift operators, where does the bit go? on: September 19, 2012, 12:23:25 pm
Code:
for(byte i=0;i<8;i++)
{   data >>=1;
   if(overflow) {
       do blah;
   }
}
A right shift cannot create an overflow condition. All you need to do is test the low order bit and shift the data *afterwards*.
Code:
for(byte i=0;i<8;i++)
{
   if(data & 1) {
       do blah;
   }
  data >>= 1;
}

If you need to test the high order bit first this code will work:
Code:
for(byte i=0;i<8;i++)
{
   if(data & 0x80) {
       do blah;
   }
  data <<= 1;
}
If data is a signed byte you can use (data < 0) instead of (data & 0x80).

Pete
989  Using Arduino / Programming Questions / Re: CRC8 calc on: September 19, 2012, 12:12:47 pm
The OneWire library here http://www.pjrc.com/teensy/td_libs_OneWire.html has a CRC8 function in it. It uses a different polynomial but you could use that function as a starting point.

Pete
990  Using Arduino / Audio / Re: Renaming an Arduino midi device.... on: September 18, 2012, 11:50:37 am
I think this is a common problem in Windows when you have multiple identical MIDI devices (e.g. 2 or 3 identical keyboards). Windows distinguishes them by just adding a number and as you have discovered it doesn't always assign the same number to the same device. The only sure way I can think of to get around it would be if you have the ability to change the actual device name within the MIDI device. i.e. if you can get at the device software and change "Moco for Lufa" to "Moco for Lufa A" in one of them and "Moco for Lufa B" in the next etc.
A less certain way would be to always power each device up in the same order and power them down in the reverse order but Windows will probably find a way to screw that up too.

Pete
Pages: 1 ... 64 65 [66] 67 68 ... 105