Show Posts
Pages: 1 ... 63 64 [65] 66 67 ... 109
961  Using Arduino / Storage / Re: 1284p and SD datalogging on: August 05, 2012, 06:59:11 pm
SD.h is based on an very old version of SdFat.  I wrote SdFat but no longer support the version used as the base for SD.h.

You might want to try the latest version of SdFat.  Except for Software SPI, it uses the pin definitions in the Arduino hardware/variants folders so no edits should be needed for hardware SPI.

You probably won't use Software SPI.  For the 1284P, Software SPI uses the Sanguino pin map.

SdFat is here http://code.google.com/p/sdfatlib/downloads/list.
962  Development / Other Software Development / Re: New fast digital I/O and Software SPI libraries on: August 05, 2012, 06:43:18 pm
I don't like macro implementations and macros are not needed to use to use digitalWrite() or another function when the pin number is not a constant.

I produce an error when pin number is not a constant because most professional embedded programming standards consider having a function change execution speed by a factor of 30  when an argument is a constant to be poor practice.

You could do this to have a fast/slow digital write:
Code:
static inline __attribute__((always_inline))
void fastSlowWrite(uint8_t pin, bool value) {
  if (__builtin_constant_p(pin)) {
    fastBitWriteSafe(pinMap[pin].port, pinMap[pin].bit, value);
  } else {
    digitalWrite(pin, value);
  }
}

This compiles as 692 bytes and write is fast.
Code:
#include <DigitalPin.h>
const uint8_t PIN = 13;
void setup() {
  pinMode(PIN, OUTPUT);
  fastSlowWrite(PIN, 1);
}
void loop() {}
This compiles as 872 bytes and write is slow.
Code:
#include <DigitalPin.h>
uint8_t var = 13;
void setup() {
  pinMode(var, OUTPUT);
  fastSlowWrite(var, 1);
}
void loop() {}

I made DigitalPin a wrapper since it insures the static and class functions behave the same.  I almost used separate implementations since the template insures the pin number is a constant an much of the static function stuff is not needed.
963  Using Arduino / Storage / Re: Arduino Mega 2560 W5100 Ethernet Shield and SdFat library on: August 05, 2012, 10:13:58 am
Pulling pin 10 high is worth a try since SdFat does not set pin 10 high on the Mega. 

SdFat pulls pin 10 high on 328 boards to avoid problems but it can't do that on the Mega since SS is not pin 10 on the Mega.

It could be that the W5100 overpowers one SD on the SPI bus but not the other SD.

It's a problem with the cards SPI controller if you still get this.
Quote
SD errorCode: 0XA
SD errorData: 0X9
964  Development / Other Software Development / New fast digital I/O and Software SPI libraries on: August 05, 2012, 07:18:50 am
I posted new fast I/O libraries as DigitalPinBeta20120804.zip http://code.google.com/p/beta-lib/downloads/list.

The libraries support standard 168/328 Arduino, Mega, Leonardo, Teensy, Teensy++, and Sanguino.

The DigitalPin class provides very fast inline functions. DigitalPin is a template class and pin numbers must be specified at compile time. 

For 328 pins and low address Mega pins read(), toggle(), and write() execute in two cycles or 125 ns for a 16 MHz CPU.  This is about thirty times faster than digitalWrite() which executes in about 4 usec.

The main member functions for the DigitalPin class are:
Code:
void config (bool mode, bool level);
void high ();
void low ();
void mode (bool pinMode);
bool read ();
void toggle ();
void write (bool value);

The library also contains these static inline functions similar to digitalRead()/digitalWrite().  Pin number must be a constant.
Code:
static bool fastDigitalRead (uint8_t pin);
static void fastDigitalToggle (uint8_t pin);
static void fastDigitalWrite (uint8_t pin, bool level);
static void fastPinConfig (uint8_t pin, bool mode, bool level);
static void fastPinMode (uint8_t pin, bool mode);

There is also a Software SPI class that runs at about 2 MHz.  It is a template class with compile time pin numbers and SPI mode.  Modes 0 - 3 are supported MSB first.  LSB first would be easy to implement.

The member functions are:
Code:
void begin ();
uint8_t receive ();
void send (uint8_t data);
uint8_t transfer (uint8_t txData);

There is also a class, DigitalIO, with run-time pin numbers.  It is much slower than the  above DigitalPin class but is 3 - 4 times faster than the Arduino digitalRead()/digitalWrite() functions.
965  Development / Suggestions for the Arduino Project / Re: How about adding digitalToggle(pin)? on: August 04, 2012, 04:25:45 pm
I posted a new version of fast I/O libraries with toggle() as DigitalPinBeta20120804.zip http://code.google.com/p/beta-lib/downloads/list.

The libraries support standard 168/328 Arduino, Mega, Leonardo, Teensy, Teensy++, and Sanguino.

The DigitalPin class provides very fast inline functions. DigitalPin is a template class and pin numbers must be specified at compile time. 

For 328 pins and low address Mega pins read(), toggle(), and write() execute in two cycles or 125 ns for a 16 MHz CPU.

The main member functions for the DigitalPin class are:
Code:
void config (bool mode, bool level);
void high ();
void low ();
void mode (bool pinMode);
bool read ();
void toggle ();
void write (bool value);

The library also contains these static inline functions similar to digitalRead()/digitalWrite().  Pin number must be a constant.
Code:
static bool fastDigitalRead (uint8_t pin);
static void fastDigitalToggle (uint8_t pin);
static void fastDigitalWrite (uint8_t pin, bool level);
static void fastPinConfig (uint8_t pin, bool mode, bool level);
static void fastPinMode (uint8_t pin, bool mode);

There is also a Software SPI class that runs at about 2 MHz.  It is also a template class with compile time pin numbers and SPI mode.  Modes 0 - 3 are supported MSB first.  LSB first would be easy to implement.

The member functions are:
Code:
void begin ();
uint8_t receive ();
void send (uint8_t data);
uint8_t transfer (uint8_t txData);
966  Development / Other Hardware Development / Re: Pitolino - a small data logging gadget on: August 04, 2012, 02:56:50 pm
florinc,

I just posted a new version of the fast I/O libraries as DigitalPinBeta20120804.zip  http://code.google.com/p/beta-lib/downloads/list.

Standard 168/328, Mega, Teensy, Leonardo, Teensy++, and Sanguino are supported.
967  Using Arduino / Storage / Re: Arduino Mega 2560 W5100 Ethernet Shield and SdFat library on: August 04, 2012, 02:51:57 pm
I don't think a MMCmicro card will fit a microSD socket.

I looked at the status and the the reason ACMD41 failed is "com CRC error".  This should never happen since CRC is disabled by default for SPI access.

I have seen a similar problem with one card, an Eye-Fi card.

The latest SdFat supports CRC but it slows access.

Try editing SdFatConfig.h and make this change
Code:
#define USE_SD_CRC 2
968  Using Arduino / Storage / Re: Arduino Mega 2560 W5100 Ethernet Shield and SdFat library on: August 04, 2012, 01:10:09 pm
The error occurs in the card identification part of initialization.  The command that fails is called ACMD41. 

Any chance you are using a MMC card?

This command ACMD41 is not supported by MMC cards and the SdFat and SD.h libraries do not support MMC cards.
969  Topics / Science and Measurement / Re: ADC accuracy on: August 04, 2012, 10:34:03 am
I didn't do the Open Music Labs work, I just used it to estimate the accuracy of a fast data logger.

I wrote a program that logs 100 ksps to an SD http://arduino.cc/forum/index.php/topic,113879.0.html.

I plan to post the logger soon, after completing work on another Arduino library for fast digital I/O and general software SPI.
970  Using Arduino / Storage / Re: Code from SD card? on: August 04, 2012, 10:15:53 am
There has been interest in a SD bootloader but little has been done.  westfw started a topic and I wrote a very small program to read from an SD.  The SD read part takes about 1200 bytes so a 2 KB loader would be possible.

Here is the topic with my code http://arduino.cc/forum/index.php/topic,89478.msg674246.html#msg674246.  The code is attached to this post (you need to be logged in to see the atachment).

Too bad westfw didn't pursue it.  He is an expert on bootloaders.
971  Development / Other Hardware Development / Re: Pitolino - a small data logging gadget on: August 04, 2012, 09:56:27 am
I don't think the labels on the board matter too much, Teensy is easy to use with port-bit labels.

Pin Numbers are a pain but they permeate Arduino software so you do need a mapping.  It would be nice if you didn't add another variant.

Are you using the mapping with D31 = A7 = PA0 or the one with D31 = A7 = PA7?

It would be helpful if the variants for 1284P had names.  You can't build fast I/O libraries using pins_arduino.h.  You need to use some compile time trick so digital read and write compile to cbi/sbi instructions.

Paul Stoffregen defined the symbol CORE_TEENSY.  This permits the Teensy to be distinguished from the Leonardo.  This define allows add both Teensy and Leonardo to be added to libraries for fast digital I/O and software SPI.

Currently I use the Sanguino mapping for 644/1284 in my fast I/O libraries.  It had PA0 = D31 but D31 was analog pin 0.
972  Using Arduino / Storage / Re: Arduino Mega 2560 and Micro SD card + 74HC4050... Pleas help on: August 03, 2012, 06:35:16 pm
Change this to make chip select pin 53
Code:
const int chipSelect = 53;

This has not been need for years so just remove it.  The SD library has made SS an output since late 2009.
Code:
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.
  pinMode(53, OUTPUT);     // change this to 53 on a mega
973  Development / Other Hardware Development / Re: Pitolino - a small data logging gadget on: August 03, 2012, 06:20:00 pm
Since SS must be an output pin for SPI to work correctly use SS as chip select for an SPI device.  In this case using SS as SD chip select is a logical choice.
974  Development / Other Hardware Development / Re: Pitolino - a small data logging gadget on: August 03, 2012, 04:55:52 pm
Since you have lots of space, how about an option for a GPS instead of a RTC.  Lots of mobile logging applications need altitude, location, time, speed, and track.

I like this part http://www.adafruit.com/products/790.  It's only 16x16x6.5 mm.  It has an internal RTC that runs on low power when the GPS is not tracking.
975  Development / Other Hardware Development / Re: Pitolino - a small data logging gadget on: August 03, 2012, 03:38:08 pm
pito,

If you get to 50x50 mm, it's huge compared to loggers some of the users of SdFat have built.

50x50 mm is 25 sq cm.  A teensy at 18x30 mm is 5.4 sq cm. 

Using two boards makes it only 12 mm tall so it can fit in things like tiny airplanes as a "black box". 

Such a flight recorder is one of the smallest loggers I have seen.  It was custom built with an accelerometer.  It was about the same size as a Pro Mini or Teensy.
Pages: 1 ... 63 64 [65] 66 67 ... 109