This is the third thread I've found on this subject. I hope there aren't too many more.
Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.
Threads merged.
- Moderator
This is the third thread I've found on this subject. I hope there aren't too many more.
Please do not cross-post. This wastes time and resources as people attempt to answer your question on multiple threads.
Threads merged.
JD3:
Try this code out - it constantly checks for minimum and maximum recoil.
But it only displays once every second. The more you display the smaller your sample rate becomes.
If the sample rate is too slow, you will miss the recoil event.
Excellent, thank-you! It works! Well, as far as I know, I need to test this on a real on the market helmet to know for sure. I will let you know.
Where did you find the code? My only issue is it displays/scrolls just the maximum achieved G-load in the session, it doesn't reset to zero. Is there anyway of doing this? I would like to enter the results on to a chart at the desired intervals you see.
Oh, and Moderator, I am sorry that I appeared to be cross-posting. I thought I was OK because each thread was a different query i.e one was asking for coding help, one for basic what pin when help and the last was asking for paid assistance. But I can see how it could be seen/classified as cross-posting.
I wrote the sketch for detecting recoil with ADXL193. I have used it with several projects.
Here is the original version that I had modified and posted earlier.
I wasn't sure what you were doing or needed to display.
/*
Recoil Viewer designed by AB9VH Electronics James Douglas III - 2012
Sparkfun ADXL193 single axis accelerometer, 5v reference
X axis analog pin 0
ZERO G = 508 (calibrated data)
*/
int X = 0; // fresh data from accelerometer
int Xmax = 508; // max raw data, opposite of gravity
int Rmax = 0; // max recoil reading in g force
unsigned long time = 0; // time in millis of recoil event
boolean lcd = false; // okay to display info
void setup() {
Serial.begin(9600); // opens serial port for LCD shield
Serial.println("Recoil Viewer by AB9VH Electronics");
Serial.println();
time = millis(); // time of recoil event
}
void loop() {
X = analogRead(0); // read analog input
if (X > Xmax) { // recoil event is opposite of gravity
Xmax = X;
time = millis();
lcd = true;
}
if ((lcd == true) && (millis()-time >= 1000)) { // display 1 second after recoil
Rmax = (508-Xmax)*.5; // calculate max recoil
Serial.print(Rmax);
Serial.print("g ");
lcd = false;
}
if (millis()-time >= 4000) Xmax = 508; // reset max recoil after 4 seconds
}