Show Posts
Pages: 1 ... 30 31 [32] 33 34 ... 96
466  Using Arduino / Programming Questions / Re: SoftwareSerial and float numbers on: June 19, 2013, 11:18:23 am
Arghh. Wotinell was I thinking of? Oh yes. It's sprintf that doesn't do floats.
My bad.

Pete
467  Using Arduino / Programming Questions / Re: Some questions about the Goertzel algorithm and ADC conversions on: June 18, 2013, 09:24:31 pm
Code:
  byte jH = ADCH;
If ADCH returns a 10-bit result, you're going to have trouble cramming it into 8 bits.


Code:
mag=sqrt(pow(Q1,2)+pow(Q2,2)-Q1*Q2*coeff);
I don't trust pow(), I would write this as:
Code:
mag=sqrt(Q1*Q1+Q2*Q2-Q1*Q2*coeff);

Pete
468  Using Arduino / Project Guidance / Re: Help with multiple DS18S20 sensors and remote data-logging on: June 18, 2013, 09:01:23 pm
I agree that the worst part might be getting a 100m string of ds18s20 to work but I would have thought that a Mega would be massive overkill for just a string of DS18S20 plus perhaps a uSD/EEPROM and an RTC. Apart from power and ground, the string of DS18B20 will all be on one pin. The remaining pins will depend upon which type of devices are used but even if you use both SPI for a uSD (4 pins) and I2C (2pins) for an RTC. It could easily be done on a Nano with spare pins to use if light intensity and humidity sensors are added.



Pete
469  Using Arduino / Project Guidance / Re: Help with multiple DS18S20 sensors and remote data-logging on: June 18, 2013, 07:36:01 pm
What sort of facilities, if any, are at the remote site? Power? Phone?
Logging temperatures once an hour over a period of a few weeks is a miniscule amount of data. An EEPROM or a microSD card can easily handle that and if you use a uSD card it is easy to write the data into a CSV file which can be loaded into Excel.
One thing to ponder is whether you need to timestamp the logged data each hour which will require a real-time clock or a GPS.

Pete
470  Using Arduino / Programming Questions / Re: SoftwareSerial and float numbers on: June 18, 2013, 05:40:10 pm
As you have discovered, println does not work with float. You would have to convert it to a string yourself and then send that.

Pete
471  Using Arduino / LEDs and Multiplexing / Re: Some (two) useful formulas that I cannot find on the internet on: June 17, 2013, 10:18:07 am
If the number of columns in the array is N and you want the (i,j) element (counting them as you showed - not as in C) the order is:
Code:
(i-1)*N + j
which for (2,4) gives 9.


Pete
472  Using Arduino / Storage / Re: Finding available file name too slow with SD.exists() on: June 16, 2013, 08:03:33 pm
Yes. It just improves on a linear search through all possible filenames. I don't know anything about the internals of the SD directory structure :-)

Pete
473  Using Arduino / Programming Questions / Re: Problems getting the DS18B20 to work with code from Bildr.com on: June 16, 2013, 06:54:07 pm
The delay goes immediately after:
Code:
ds.write(0x44,1);

Pete
474  Using Arduino / Storage / Re: Finding available file name too slow with SD.exists() on: June 16, 2013, 06:15:05 pm
The search would be something like this. Assume that the function file_exists(int n,char *dirpath) checks whether the file name whose index is 'n' (e.g. IMGL0011.JPG when n=11) exists within the directory whose pathname is "dirpath" and returns non-zero if it does.
I'm also assuming that a directory will have no more than 100 files numbered from 0 to 99.
Code:
int find_file(char *dirpath)
{
  int lo,hi,mid;

  lo = 0;
  hi = 99;

  // Set up the initial conditions for the binary search that the first file (0) must exist
  // and the last one (99) must not
 
  // if index zero doesn't exist, it is the next file (or, at least, it indicates that
  // this directory is empty)
  if(!file_exists(lo,dirpath)) return(0);
  // if index 99 does exist then this directory is full, return an error/full indication
  if(file_exists(hi,dirpath))return(-1);

  do {
    mid = (hi-lo+1)/2;
    // If the mid-point file exists, change the lo pointer
    // otherwise change the hi pointer
    if(file_exists(mid,dirpath)) lo = mid;
    else hi = mid;
    // If hi and lo are just one apart, we've found the boundary between the two
    // and then next filename is hi
  } while(hi-lo > 1);
  return(hi);
}
If there are 1000 files per directory, just change "hi=99;" to "hi=999;". In that case, the number of tests will be a maximum of about 12 (including the two initial tests of 0 and 999).

Pete
475  Using Arduino / Storage / Re: Finding available file name too slow with SD.exists() on: June 16, 2013, 02:23:32 pm
Do a binary search of the name. If there can be up to 100 files per directory, a binary search would require at most 7 tests.

Pete
476  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 15, 2013, 01:29:26 pm
I have a vague memory of trying to figure out that library quite some time ago.
Instead of calling setA2Time in the library, try using the code in my previous message to set alarm2 to fire every minute.

Pete
477  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 15, 2013, 12:09:03 pm
Quote
is sda and scl 5 v tolerant?
The datasheet says absolute maximum on those two pins is 6V and maximum operating voltage on those is 5.5V so they should be OK with 5V.

Pete
478  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 15, 2013, 10:55:51 am
Once you have set the address register you can write a consecutive sequence of data. To set Alarm2 to fire every minute use this:
Code:
Wire.beginTransmission(0x68);
Wire.write(0x0b); //addr
Wire.write(0x80); //data to 0x0b
Wire.write(0x80); //data to 0x0c
Wire.write(0x80); //data to 0x0d
Wire.endTransmission();

BTW. The registers for the ISL12057 look very similar to the DS3234/DS3231 so code for those should work with minimal or no tweaking on ISL12057.

Pete
479  Using Arduino / Networking, Protocols, and Devices / Re: i2c rtc writing to addresses need help on: June 14, 2013, 09:36:54 pm
Code:
Wire.write(0x0B>>8);
This isn't right.
Code:
(0xB >> 8)
is zero. When writing an address to the chip you only write one byte (i.e. only 0x0B), not two. Follow that with whatever data is required.

Pete
480  Community / Bar Sport / Re: I got one... Are Geoligists dumb? on: June 12, 2013, 09:22:35 pm
Quote
no science degree requires an electronics course, except for physics
Electrical Engineering?

Pete
Pages: 1 ... 30 31 [32] 33 34 ... 96