Accelerologger: error opening test.txt problem!!!

Now I have solved my silly mistake I have run into another problem!!!

I looked in the serial monitor and I am getting the:

error opening test.txt

Part of the code being carried out! Here is a Fritzing diagram of the Accelerologger:

The diagram is a bit messy but it’ll do to show the circuit config. I ran the default SD Card Reader code on it:

#include <SD.h>
#include <SPI.h>

File myFile;

int pinCS = 10;

void setup() {

Serial.begin(9600);
pinMode(pinCS, OUTPUT);

// SD Card Initialization
if (SD.begin())
{
Serial.println("SD card is ready to use.");
} else
{
Serial.println("SD card initialization failed");
return;
}

// Create/Open file
myFile = SD.open("test.txt", FILE_WRITE);

// if the file opened okay, write to it:
if (myFile) {
Serial.println("Writing to file...");
// Write to file
myFile.println("Testing text 1, 2 ,3...");
myFile.close(); // close the file
Serial.println("Done.");
}
// if the file didn't open, print an error:
else {
Serial.println("error opening test.txt");
}

// Reading the file
myFile = SD.open("test.txt");
if (myFile) {
Serial.println("Read:");
// Reading the whole file
while (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
}
else {
Serial.println("error opening test.txt");
}

}
void loop() {
// empty
}

With this code, it worked perfectly. Here is the response received in the serial monitor:

SD card is ready to use.
Writing to file…
Done.
Read:
Testing text 1, 2,3…
Testing text 1, 2,3…
Testing text 1, 2,3…
Testing text 1, 2,3…
Testing text 1, 2,3…
Testing text 1, 2,3…

Geez!!! all these problems! I hope I eventually get to the bottom of them all!

Thanks for everyone’s help!

EJBuilder

Accelerologger: More Problems With New Code!!!

This is now solved!!! Check it out what a silly mistake! NO VOID SETUP!!!!!!

Here is the new code:

#include <SparkFun_ADXL345.h>

#include <SD.h>
#include <SPI.h>

//ADXL345 adxl = ADXL345(10); For SPI Cumunication
ADXL345 adxl = ADXL345();
File myFile;
const int threshold = 1499;
const int switchPin = 7;
int switchState;
int ctr = 0;
int pinCS = 10;
int x,y,z;
int sumX, sumY, sumZ;

void loop() {
//define int x, y, z in setup instead
// also define int sumX, sumY, sumZ in setup
adxl.readAccel(&x, &y, &z);
sumX += x;
sumY += y;
sumZ += z;

switchState = digitalRead(switchPin);

if (switchState == HIGH) {
ctr++;
if (ctr > threshold) {
if (myFile) {
myFile.println(sumY/threshold);
Serial.println(sumY/threshold);
}
else {
Serial.println("error opening test.txt");
}
sumX = 0;
sumY = 0;
sumZ = 0;
ctr = 0;
}

} else //switchState != HIGH
{
myFile.close();
Serial.println("closed");
}
}

But I am having another problem it doesn’t upload it comes up with the error:

Arduino: 1.8.3 (Windows 10), Board: “Arduino Nano, ATmega328”

C:\Users\ETHANJ~1\AppData\Local\Temp\cclGBXne.ltrans1.ltrans.o: In function `main’:

C:\Program Files\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `setup’

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Nano.

This report would have more information with
“Show verbose output during compilation”
option enabled in File -> Preferences.

I hope we can figure out what is wrong!

EJBuilder

(P.S much thanks to Mike’s help!!!)

Accelerologger (Accelerometer Datalogger): Help needed with code!

Hi Everyone, For the scientific investigation awards I have been designing an accelerologger device that reads the speed of Its movement. So far I have constructed the hardware.

It consists of an Arduino Nano, an ADXL 3 axis gyro/accelerometer  and a Micro SD Card Reader . So far I have got each device (accelerometer/gyro + datalogger module) working succesfully and now have been trying to combine the code. Here is what I have done so far:

 

#include <SparkFun_ADXL345.h>
#include <SD.h>
#include <SPI.h>

//ADXL345 adxl = ADXL345(10); For SPI Cumunication
ADXL345 adxl = ADXL345();
File myFile;
const int threshold = 1499;
const int switchPin = 7;
int switchState;
int ctr = 0;
int pinCS = 10;


void setup() {
Serial.begin(9600);
Serial.println();
pinMode(pinCS, OUTPUT);
pinMode(switchPin, OUTPUT);

adxl.powerOn();

adxl.setRangeSetting(16);

adxl.setSpiBit(0);

if (SD.begin())
{
Serial.println(“SD card is ready…”);
} else
{
Serial.println(“SD card initialization failed”);
return;
}

// create and open a file
myFile = SD.open(“testRun.txt”, FILE_WRITE);
}

void loop() {
int x, y, z;
adxl.readAccel(&x, &y, &z);
switchState = digitalRead(switchPin);

if (switchState == HIGH) {
ctr++;
if (ctr > threshold) {
if (myFile) {
myFile.println(y);
Serial.println(y);
}
// if the file didn’t open, print an error:
else {
Serial.println(“error opening test.txt”);
}
}
ctr = 0;
} else
{
myFile.close();
Serial.println(“closed”);
}
}

That is it. It all most works perfectly. The only issues I am facing is that none of the accelerometer details are serially printed or written on the SD card in a text file. If anyone can help please take a look at the code and do.

 

EJBuilder

Hacking Drone Controller: Another Problem, SERIOUSLY???

Hi Everyone, With the drone controller that has been working well for a while, there has been a problem, again!!! I was fiddling with it the other day and I resoldered some the cables that had come loose and it was working perfectly straight after when I tested it (flying the drone). I came back after that and plugged the power source for it in (carefully making sure the polarity was correct) and it didn’t power on. As soon as this problem occurred the troubleshooting side of me kicked. First I did a continuity test on each of the components on the transmitter PCB. Each of results I compared to the other controller of the H8 Mini that I lost in a gust of wind since that is perfect apart from the missing buzzer. After that, I then did a resistance test on all of the components and compared them results as well. Everything was identical. Going of this I am guessing that it is either a wiring problem or a problem with the chip on the controller. If my dodgy way of troubleshooting is correct then we should be able to take off the chip of the lost H8 and replace it with our current one. So with the hassle that it is not all hope is lost (mabye).

Even if the problem is different we have that other board for parts it should be alright!

I hope we can solve it though!!!

EJBuilder

My Drone: EVERYTHING GONE WRONG!!!

Hi Everyone, Sorry to bring bad news on such a successful streak (great drone hacking success).  There is a way to hook up this thing called “vbat” on my drone and all I needed to do it was some wires, which of course as a electronics nerd, I have. “vbat” is, in other words, “voltage monitoring” for your flight controller. The joints on my quad’s PBD are very large (very big quantities of solder). The point is that I had to reflow some of those big joints (the battery terminals) to add the wires. I was using a 25-watt soldering iron, since that was all I had at the time (my new 40-watt one hasn’t turned up). Becuase the iron was quite underpowered, to reflow it I had it hold the iron to it for quite a while to even get it even close to melted. Anyway, once the “vbat” wires were added I was all happy about the new wires added and I plugged it into the computer and none of the lights turned on and there was no response from the board. I am guessing this big problem was caused by me overheating the board and now the chip is fried. This is not the final diagnosis, this is just an educated guess. There may even be a way to fix it, I do not know. Maybe Makerbob could take the flight controller to hackerspace, That would be good.

So that is how it happened, the ruin of my drone. If worse comes to worse I’ll have to buy a new FC.

 

 

 

Hacking Drone Controller: Further Progress!

Hi Everyone

I have done a few further modifications to the H8 Mini Drone Transmitter. On Saturday I mentioned that there was a cable that de-attached from it (that was the ground wire we added to the joystick pot), it turns out that if you are powering the transmitter through its battery cables we didn’t need it in the first place. The further progress that has been made is that I cut the trace for each of the joystick potentiometer’s signal pins, exposed the copper and attached cables to all four of the copper pads. Here is what it looks like:

I then covered the joints with hot glue to give them some more strength. But a ended up adding another some more wires (I’ll explain In a little bit) so I had to pull some off:

As mentioned before I added some other wires. These were some female ended wires were to the joystick pot pins this is so when we are finished flying autonomously we can connect the added wire so we can fly normally again.

I have also have been working on some code:

const int throttle = A0;
const int yaw = A1;
const int pitch = A2;
const int roll = A3;
const int dDelay = 100;
const int threshold = 99;
int lowerMinus = 255;
int low = 0;
int mid = 115/*find the hovering point and replace with that value*/;
int high = 225;
int pitchMid = (133/*find middle point of pitch */);
int ctr = 0;

void setup() {
pinMode(throttle, OUTPUT); //Set pin A0, A1, A2, A3 to an OUTPUT.
pinMode(yaw, OUTPUT);
pinMode(pitch, OUTPUT);
pinMode(roll, OUTPUT);
analogWrite(throttle, low); //Arm the Quad
delay(1000);
analogWrite(throttle, high);
delay(1000);
analogWrite(throttle, low);
delay(1000);
}

void loop() {
analogWrite(throttle, high); //
delay(dDelay);
digitalWrite(throttle, low);
delay(dDelay);
}

void forward(int forwardTime) {
analogWrite(throttle, mid);
analogWrite(pitch, high);
delay(forwardTime);
analogWrite(pitch, low);
delay(500);
analogWrite(pitch, pitchMid);
analogWrite(throttle, lower/*ADD A LOWERING function*/);
}

void lower(int lowerRate) {
ctr++;
if (ctr > lowerRate) {
lowerMinus--;
ctr = 0;
}
}

So that is what I have done so far

I can’t wait until we get it flying around properly

EJBuilder

 

 

 

 

 

 

Post Editing Problems??? *FIXED*

Hi Bob, I have had a problem that is really starting to get to me. It is regard editing my posts once approved by Bob. I can’t do it!!! Can this be changed by you or is this a long term problem?

*solved*