0

code help - best use of sensors to switch functions
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: code help - best use of sensors to switch functions

by mohawkpiper on Thu Mar 08, 2018 4:11 am

Does that mean I can do the same with the gyro/accel? It is a bit unstable... i didnt relate it to power/ combined ground with pixels. Or does it need more than the 100 ma the 3.3 v pin on the side of the teensy 3.2 can supply? and is the 3.3v pin on the back of the teensy the same as the 3.3v pin on the side? or are those two separate sets of 3.3v and ground?
User avatar
mohawkpiper
 
Posts: 111
Joined: Sat Oct 13, 2012 3:28 am

Re: code help - best use of sensors to switch functions

by adafruit_support_bill on Thu Mar 08, 2018 8:16 am

You'll have to remind me which gyro/accel you are using. The analog reference issue really only applies to analog sensors like the ADXL335 (I don't believe we stock any analog output gyros).

Accelerometers in general tend to have 'noisy' output because vibration is also a form of acceleration. And your application is going to have lots of vibration. You can mitigate that somewhat with a vibration-absorbing mounting. But you will probably need to do some software filtering as well.

adafruit_support_bill
 
Posts: 68551
Joined: Sat Feb 07, 2009 10:11 am

Re: code help - best use of sensors to switch functions

by mohawkpiper on Sun Mar 11, 2018 4:42 am

im using the lsm9ds0.... i was originally wondering because even when it isnt moving at all it fluctuates a bit.... but yea... took it out today and yea... there is a lot of vibration haha.

It’s cool, I realize i will have to do some software filtering and got something in there that i think will help a bit. might need some tweaking, but im taking it out again tomorrow so I’ll get to see how what i’ve written will help.

Overall it’s pretty fun though! Thanks!
User avatar
mohawkpiper
 
Posts: 111
Joined: Sat Oct 13, 2012 3:28 am

Re: code help - best use of sensors to switch functions

by mohawkpiper on Tue Apr 03, 2018 2:42 am

So I've taken it out a few times now... and the vibrations from the board moving over the ground continually sets off the "landing pattern". I have ideas of how to solve it through the code, and I tweak the code, test it at home on the floor (tests great) then take it out and it just keeps setting off the landing pattern again.

so I guess I am tweaking the code based off of what I am assuming the data the accelerometer is sending to the teensy, and also, i cant really simulate at home what it is actually like on the mountain.

So I have a new question...
Is there an easy way I can somehow take it out live on the mountain, and write all the accelerometer's y-axis data to disk somewhere so I can put it into a graph and visually see what kind of readings I am actually getting? I am assuming maybe writing it to an SD card? How would I easily graph the data?

If i could see the data I wouldn't have to make assumptions about the readings, and I could software filter it better.

Or... does anybody have some software filtering code that would work well for this already?

It totally plays the landing pattern when I land something... but it also plays it constantly all the time. I don't want to get rid of it entirely...

ps.
here is a quick vid of actually using it night boarding!
https://youtu.be/ih4rfqfomMM
you can see the landing pattern trigger well landing on the rail at 0:38

Thanks!

G
User avatar
mohawkpiper
 
Posts: 111
Joined: Sat Oct 13, 2012 3:28 am

Re: code help - best use of sensors to switch functions

by adafruit_support_bill on Tue Apr 03, 2018 6:19 am

Looking good!

To analyze the accelerometer data for a run, you could connect up an SD card and just log the data in CSV format. Then you can import it into a spreadsheet later to analyze and/or graph it.

adafruit_support_bill
 
Posts: 68551
Joined: Sat Feb 07, 2009 10:11 am

Re: code help - best use of sensors to switch functions

by mohawkpiper on Thu Apr 12, 2018 2:46 am

ok..
so i ordered the micro SD breakout...
https://www.adafruit.com/product/254

and i got it hooked up. and ive got it writing the y acceleration to the card. I even added a switch i can press prior to taking a jump that will break out the y accel into its own section then press the switch again when i am done for easy finding of jumps vs just riding in all the data.

I still need to figure out how to graph it... but I think i saw links somewhere around here as to how to do so. Then I will have to take it out for real...

QUESTION though...
when i first started playing with the gyro/accel (this one... https://www.adafruit.com/product/3387 )
it was giving me readings for y-accel right around -1 ish, when the board wasnt moving at all.

NOW it is right around -9.10.... when the breakout board isnt even moving.

I have taken the board out a few times... and snowboarding/jumps/rails im assuming can be rough on stuff...

would just hard impacts be the cause of this? is there any way I can sort of 'reset' it back to close to 0?

if there is nothing i can do about it... is there a better accelerometer I can purchase that you guys offer? originally i purchased the one i did because i wanted the gyro too... and I am currently using the gyro but it's not even really noticeable with what i am doing so i am willing to settle for just an accelerometer (without the gyro, and i dont use the mag at all) if there is one that is more stable and wont wander its default state with use.

suggestions?

Thanks!

G
User avatar
mohawkpiper
 
Posts: 111
Joined: Sat Oct 13, 2012 3:28 am

Re: code help - best use of sensors to switch functions

by adafruit_support_bill on Thu Apr 12, 2018 6:33 am

when i first started playing with the gyro/accel (this one... https://www.adafruit.com/product/3387 )
it was giving me readings for y-accel right around -1 ish, when the board wasnt moving at all.

NOW it is right around -9.10.... when the breakout board isnt even moving.

What are the X, Y and Z readings while at rest? And how is the accelerometer mounted to the board?

At rest, the sensor will always be subject to the acceleration due to gravity. This is roughly 9.8 m/s^2 on the earth's surface. So the axis closest to vertical will have the highest reading. If you calculate the overall acceleration for all three axis (sqrt(x**2 + y**2 + z**2)) when the sensor is at rest, it should come out to about 9.8.

By the way - if you hadn't noticed, your board made the 'front page': https://blog.adafruit.com/2018/04/09/fr ... snowboard/

adafruit_support_bill
 
Posts: 68551
Joined: Sat Feb 07, 2009 10:11 am

Re: code help - best use of sensors to switch functions

by mohawkpiper on Thu Apr 12, 2018 11:27 pm

The snowboard is pretty much flat on a bed table...

This is how the accel is mounted on the board....

ImageImage

The perfboard that all the stuff (accelerometer included) is soldered onto is screwed right into the waterproof case, and the waterproof case is sitting on a bed of silicon, which glues it right down to the snowboard.

The SD reader is just floating.. but because I hadn't planned for that when i first designed the layout.. and I will remove it when I am done with it.

and after looking at these pics i realized I think i am reading the wrong axis... up and down should be Z... not Y. (I come from a 3D background and Y is up and down so I guess I just went straight to Y without even checking...)

this is what i am printing...
Code: Select all | TOGGLE FULL SIZE
myFile.print("(");
    myFile.print(a.acceleration.x);myFile.print(", ");
    myFile.print(a.acceleration.y);myFile.print(", ");
    myFile.print(a.acceleration.z);myFile.print(")");
    myFile.print(", ");


and this is roughly what it is returning...
(-2.61, -9.06, 2.94),
(-2.66, -9.06, 2.89),
(-2.65, -9.07, 2.97),
(-2.68, -8.91, 3.04),
(-2.62, -9.08, 2.86),
(-2.55, -9.08, 3.02),................

and yes, if you plug all those into the overall acceleration i get roughly around 9.87

but now I am even a little more confused... so if I should in fact be using the Z axis for up and down... why is the Y axis the largest value in negative? Shouldn't it be Z because of gravity like you said? or am I just looking at the breakout board wrong and Y is in fact up and down?

These readings were printed with the board exactly how it is in the pics....

I guess I'll just have to take it out and see what I get and go from there :P

and....
That's awesome it made the front page! I had no clue! Thanks for sharing!
User avatar
mohawkpiper
 
Posts: 111
Joined: Sat Oct 13, 2012 3:28 am

Re: code help - best use of sensors to switch functions

by mohawkpiper on Fri Apr 13, 2018 12:09 am

mohawkpiper wrote:
but now I am even a little more confused... so if I should in fact be using the Z axis for up and down... why is the Y axis the largest value in negative? Shouldn't it be Z because of gravity like you said?



oops i figured it out. at first i had the axis swapped in the print... and printed to the SD card. realized it and fixed it, but accidentally copied the swapped values out of the SD card file, instead of the fixed values. Z is actually the largest value.

Thanks so much... a lot of this was just user error. (mixing up the axis!!!) but I don't think i would have caught that without you asking about its mounting and explaining the gravity (who woulda thought lol) and square root of the squared sums etc....

I'm already seeing a lot just jumping around on it at home.

again... Thanks so much!
User avatar
mohawkpiper
 
Posts: 111
Joined: Sat Oct 13, 2012 3:28 am

Re: code help - best use of sensors to switch functions

by mohawkpiper on Fri Apr 13, 2018 12:43 am

Check it out test graphs...

Image

the blue and grey line are the board just sitting on the bed desk.
The orange line is me picking it up off the bed desk and dropping it on the floor.
The yellow line is me shaking the crud out of it while it is on the floor.

woot woot!
User avatar
mohawkpiper
 
Posts: 111
Joined: Sat Oct 13, 2012 3:28 am

Re: code help - best use of sensors to switch functions

by adafruit_support_bill on Fri Apr 13, 2018 6:14 am

Photobucket seems to be down at the moment, so I can't see the images. But it sounds like you are converging on a solution?

I come from a 3D background and Y is up and down

It can be confusing moving between systems. In 2D graphics, Y is always vertical. But in some systems the origin is at the top, and in others it is at the bottom.
In navigation systems, the Y axis is generally left-to right
My 3D printers and CNC router all have the Y axis move front-to-back.
But the new 5-axis mill has the Y moving vertically.

adafruit_support_bill
 
Posts: 68551
Joined: Sat Feb 07, 2009 10:11 am

Re: code help - best use of sensors to switch functions

by mohawkpiper on Fri Apr 13, 2018 12:43 pm

yea i think i'm good... i answered a bunch of my own questions replying to your questions :P

Thanks so much!
G
User avatar
mohawkpiper
 
Posts: 111
Joined: Sat Oct 13, 2012 3:28 am

Please be positive and constructive with your questions and comments.