Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Data Logger Shield Gone Haywire (Arduino Brain Library) on: May 25, 2012, 10:44:31 am
And yes, just so we're clear, I'm aware that my modifications to the lighttemplogger sketch wouldn't actually log brain data to the card. I'm just trying to take it slow and get the Brain library to work with a logging sketch before I actually get logging.
2  Using Arduino / Programming Questions / Data Logger Shield Gone Haywire (Arduino Brain Library) on: May 25, 2012, 10:42:19 am
(also posted to LadyAda forums)

So I've got the awesome Data Logger Shield. When I upload the demo sketch (lighttemplogger - http://github.com/adafruit/Light-and-Temp-logger http://github.com/kitschpatrol/Arduino-Brain-Library/zipball/master ), it works great! Time to make it do something useful. I want to log data from an EEG toy using the Arduino Brain Library (http://frontiernerds.com/brain-hack).Turns out the Brain library already outputs data in CSV, sweet.

I don't know much about coding, so I just took the relevant bits of the Brain library's BrainSerialOut program:
Code:
#include <Brain.h>

// Set up the brain parser, pass it the hardware serial object you want to listen on.
Brain brain(Serial);

void loop() {
if (brain.update()) {
  Serial.println(brain.readErrors());
Serial.println(brain.readCSV());
}
}

and grafted them onto lighttemplogger:

Code:
#include <SD.h>
#include <Wire.h>
#include "RTClib.h"
#include <Brain.h>
[...]
Code:
// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;

// the logging file
File logfile;

Brain brain(Serial);
[...]

Code:
void loop(void)
{
  DateTime now;
// Expect packets about once per second.
// The .readCSV() function returns a string (well, char*) listing the most recent brain data, in the following format:
// "signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"
if (brain.update()) {
  Serial.println(brain.readErrors());
Serial.println(brain.readCSV());
}

  // delay for the amount of time we want between readings
  delay((LOG_INTERVAL -1) - (millis() % LOG_INTERVAL));
 
[...]

Right, then.

When I run lighttemplogger, I get the following happy output over serial monitor:
Code:
Initializing SD card...card initialized.
Logging to: LOGGER47.CSV
millis,stamp,datetime,light,temp,vcc
999, 1337967332, "2012/5/25 17:35:32", 1023, 535.42, 1.10
1999, 1337967333, "2012/5/25 17:35:33", 1023, 535.42, 1.10
2999, 1337967334, "2012/5/25 17:35:34", 1023, 535.42, 1.10

When I run my version of the code (with the Brain library Frankensteined in), I get something a little more monstrous:
Code:
Initializin
ÿÿÿÿÿ¸ÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ À¸ÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ¸ÕßÜÿ À¸ÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ Š¸ÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ðÄã¸ÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ Š¸ÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ñ¸ÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ŸÕßÜÿ ¸ÕßÜÿ ŸÕßÜÿ à¸ÕßÜÿ Š¸ÕßÜÿ

Any ideas what could be going wrong here?
3  Using Arduino / Audio / Generating high frequency tones on: May 17, 2012, 11:15:14 am
Hi all,
I want to generate high frequency tones (20kHz and up). Looking at programs like the Arduino DDS signal generator (http://interface.khm.de/index.php/lab/experiments/arduino-dds-sinewave-generator/) though, it looks like it's limited to a 32kHz sampling rate, which means a 16kHz max output frequency. Why is this?
4  Using Arduino / General Electronics / Re: TTL to Optocoupler to Arduino RX Pin - Help? on: March 18, 2012, 11:17:08 am
retrolefty,
Huh, so it's kind of like the Nyquist thing in audio, then. What's the effective frequency of a serial data transmission at 9600 or 115200 baud?
5  Using Arduino / General Electronics / Re: TTL to Optocoupler to Arduino RX Pin - Help? on: March 18, 2012, 02:16:29 am
Thanks!
How much bandwidth should an oscilloscope have to troubleshoot these kinds of signals?
6  Using Arduino / General Electronics / Re: TTL to Optocoupler to Arduino RX Pin - Help? on: March 17, 2012, 02:43:25 pm
Techone,
Thanks for the link. I looked at the 4N35 originally but kept reading about how slow it was; I assume that's one reason you had so many problems! Do you mean that the 6N137 or 6N138 might also be too slow? It seems hard to imagine they'll be outperformed by a circuit using the 4N35, even with the extra components you used.
7  Using Arduino / General Electronics / Re: TTL to Optocoupler to Arduino RX Pin - Help? on: March 17, 2012, 10:50:20 am
John,
Thanks! How should I reconfigure the circuit so that it doesn't invert the signal?
8  Using Arduino / General Electronics / TTL to Optocoupler to Arduino RX Pin - Help? on: March 17, 2012, 10:01:48 am
Hi,
I want to put an optocoupler between a TTL signal and the Arduino's RX pin. The signal is 9600 baud.
It looks like I should use a 6N137 or 6N138 optocoupler.

Can someone point me at a schematic showing which resistor values I should use and how I should wire things?

I've done some research and found out the following. It looks like I'll need two resistors: one between +5V and the LED anode on the TTL/input side, and one between +5V and V_E (6N137) or V_0 (6N138) on the Arduino RX side. 330 ohms was suggested by one site for the LED resistor, but that was for a situation where the LED anode was being driven directly by the TTL output.

I'm trying to connect a MindFlex to the Arduino (http://frontiernerds.com/brain-hack) but for safety reasons -- and because people have reported problems with the MindFlex after connecting it directly -- I want to make sure there's an optoisolator between the two.

Thanks!
Pages: [1]