PyroElectro.com Forum Index PyroElectro.com
Build what you want, Be the pyro you are.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Personal G-Force Meter
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    PyroElectro.com Forum Index -> Projects
View previous topic :: View next topic  
Author Message
ThePyroElectro
PyroElectro Admin


Joined: 12 Nov 2007
Posts: 401
Location: Earth

PostPosted: Sat Apr 26, 2008 11:11 pm    Post subject: Personal G-Force Meter Reply with quote

The Personal G-Force Meter Project Write-up

Quote:
Being that my car already measures velocity & position, why not fill the void with an accelerometer & measure acceleration? The Personal G-Force Meter Does just that using standard 7-Segment LEDs for output. Check out the video for an overview of how it works!


Link


Questions & Comments?
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
mathewjenkinson
Newbie Pyro


Joined: 28 Apr 2008
Posts: 5

PostPosted: Mon Apr 28, 2008 11:35 pm    Post subject: Personal G-force meter Reply with quote

Does the g-force meter just read forward and and back G forces?
or if you were to take a tight bend would it tell you how many G forces you are exhibiting on the vehicle?

Looking at the way it was designed with just the Y axis being wired up it seems to be just forward and breaking acceleration? unless im wrong?

Tho saying that great design, i think im going to copy you and make one of my own Smile
Thanks
Mathew
Back to top
View user's profile Send private message
ThePyroElectro
PyroElectro Admin


Joined: 12 Nov 2007
Posts: 401
Location: Earth

PostPosted: Mon Apr 28, 2008 11:54 pm    Post subject: Reply with quote

Hi Matthew,

Unfortunately the sensor I had was half broken and I could only measure 1-axis the Y axis. Not wanting to waste the sensor I put it in this project for a simple 1-axis g-meter. Measuring the g-forces applied to you & your car on tight bends would require 2-axis + a little math.

So to answer your question: yup, just forward and backward. Seems sufficient enough to me being that most news websites noticed I only have a civic Shocked .

Good luck building it! Very Happy
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
mat_the_w
Newbie Pyro


Joined: 29 Apr 2008
Posts: 1

PostPosted: Tue Apr 29, 2008 3:19 pm    Post subject: Reply with quote

This is an interesting project. I had much the same idea, but never got around to implementation...story of my life...

Anyway, I had a couple of questions:
1. In the update_char_display function, you use the following code to update all three digits:

Code:
for(i=0;i<3;i++)
    {

        switch(i)
        {
            case 0 :    PORTB = all_digits[char_disp[i]] + 0b1000;
                        break;
            case 1 :    PORTD = all_digits[char_disp[i]];
                        break;
            case 2 :    PORTC = all_digits[char_disp[i]];
                        break;
            default :
                        break;
        }
    }


Was there any reason that you didn't simply do the following, and avoid both the loop overhead and the switch statement pipeline flush?
Code:
PORTB = all_digits[char_disp[0]] + 0b1000;
PORTD = all_digits[char_disp[1]];
PORTC = all_digits[char_disp[2]];


2. The raw ADC reading has the gravity_ss variable subtracted from it, then it is left-shifted by 5 (equivalent to multiplying by 32), and then divided by display_divider (which was set to 20):
Code:
            g_val = current_result - gravity_ss;
            g_val = g_val << 5;
            g_val = g_val / display_divider;

Since you are only measuring acceleration in the forwards/backwards direction, orthogonal to gravity, would you say the the variable name gravity_ss is a bit of a misnomer? I understand how the accelerometers work, and that 512 is the value that represents 0g when using a 10-bit ADC, it just seems like naming a variable like this will only serve to confuse people, especially when gravity isn't involved here.

3. Did you do any sensor calibration to see if 32/20 is actually a good number to scale the result by? If you rotate the sensor to be in line with gravity, does it display 1g?

Thanks for the project, and thanks for the good writeup.

--Matthew
Back to top
View user's profile Send private message
mathewjenkinson
Newbie Pyro


Joined: 28 Apr 2008
Posts: 5

PostPosted: Tue Apr 29, 2008 3:24 pm    Post subject: Reply with quote

ThePyroElectro wrote:


So to answer your question: yup, just forward and backward. Seems sufficient enough to me being that most news websites noticed I only have a civic Shocked .



If you can supply the code and a schematic ill build it Smile
I wanna build a HUD for my car and a G meter would be an excellent addition Smile
Back to top
View user's profile Send private message
ThePyroElectro
PyroElectro Admin


Joined: 12 Nov 2007
Posts: 401
Location: Earth

PostPosted: Tue Apr 29, 2008 3:32 pm    Post subject: Reply with quote

It's all right there man. Just scroll up to the first post and click the link to the write-up. Wink
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
mathewjenkinson
Newbie Pyro


Joined: 28 Apr 2008
Posts: 5

PostPosted: Tue Apr 29, 2008 3:47 pm    Post subject: Reply with quote

so the
Quote:
little math
thats needed to be calculated is already in the code? i just need to get my hands on a 2 axis accelerometer?
Back to top
View user's profile Send private message
ThePyroElectro
PyroElectro Admin


Joined: 12 Nov 2007
Posts: 401
Location: Earth

PostPosted: Tue Apr 29, 2008 6:29 pm    Post subject: Reply with quote

Hey Matthew,

Ah, sorry I misunderstood your previous post. Thought you were looking for the schematic for the project already created.

Quite honestly, I could just turn the sensor 90 degrees so that it would measure left to right instead of how it is right now, front to back. Laughing

The force you feel when going around turns fast is an angular force. When you turn you accelerate in two axis, y & x. In the middle of the turn you will reach the maximum force from the x-axis. Right now the device I built just measures Y-Axis.



In short, you could build the same device I built except mount the sensor turned 90 degrees OR you could use the data of two axis (x & y) to find the the total instantaneous G-force applied to car from both x & y vectors.

I'm trying not to go too far into the details because I'm not sure of your level with electronics. Let me know if you're curious about more details Very Happy .
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
ThePyroElectro
PyroElectro Admin


Joined: 12 Nov 2007
Posts: 401
Location: Earth

PostPosted: Tue Apr 29, 2008 6:51 pm    Post subject: Reply with quote

Hey Mat The W,

Quote:
Was there any reason that you didn't simply do the following, and avoid both the loop overhead and the switch statement pipeline flush?


I think that case statement is a leftover from a previous method I had tried and I never changed it. So yea, it could definitely be simplified as you wrote.

Quote:
2. The raw ADC reading has the gravity_ss variable subtracted from it, then it is left-shifted by 5 (equivalent to multiplying by 32), and then divided by display_divider (which was set to 20)


I'm hoping people aren't relying solely on the names of the variables in my code to understand what's going on since the code is so short! Better off going through it and doing the calculations yourself so that you know exactly what's going on. Confused

However, I named it gravity_ss, because in my head ss = SteadyState. When the sensor is not moved 512-512 = 0 so it does nothing and is infact steady state & shows 0.00.

Quote:
Did you do any sensor calibration to see if 32/20 is actually a good number to scale the result by? If you rotate the sensor to be in line with gravity, does it display 1g?


Yes, calibration was done. So that means the data is not actually scaled but instead turned into a whole number. This makes displaying the data easier. The theory section video shows how the tilt affect of natural gravity comes up on the sensor and yes it does hit 1 G when parallel to gravity. Wink

Thanks for the comments!
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
mathewjenkinson
Newbie Pyro


Joined: 28 Apr 2008
Posts: 5

PostPosted: Tue Apr 29, 2008 6:53 pm    Post subject: Reply with quote

Well, im from a mechanical background so i know what your talking about at the moment. Ive dabed in electronics a bit, and know some java, so i know the basics. - If you start from the most complex end ill either catch up or ask you to 'dumb down' so to speak. Smile

I was thinking about turning the sensor 90degrees, however that doesnt really provide a true 'G' reading if I were to break without turning.
So both X and Y axis need to be part of the calculations.
Back to top
View user's profile Send private message
ThePyroElectro
PyroElectro Admin


Joined: 12 Nov 2007
Posts: 401
Location: Earth

PostPosted: Tue Apr 29, 2008 7:04 pm    Post subject: Reply with quote

Yea, well really once you have the X-axis & Y-axis data finding the total force being applied to you/your car would be:

Total Force^2 = X_Data^2 + Y_Data^2

You're adding the X_Data & Y_Data Vectors to find the Total Force vector. But we don't care so much about the vector as just the point that it reaches to.

That should be all the 'little' math you'd have to add into the code. Shocked
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
mathewjenkinson
Newbie Pyro


Joined: 28 Apr 2008
Posts: 5

PostPosted: Tue Apr 29, 2008 7:11 pm    Post subject: Reply with quote

ok cool, what about wiring 2 axis into the microprocessor?
Im assuming it just goes into RA1/AN1?
Back to top
View user's profile Send private message
ThePyroElectro
PyroElectro Admin


Joined: 12 Nov 2007
Posts: 401
Location: Earth

PostPosted: Tue Apr 29, 2008 7:39 pm    Post subject: Reply with quote

Yea, then when you open the ADC you'd set AN0 & AN1 as analog inputs. And you'd need to readadc twice to get the two A/D input values.
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
eh2k8
Newbie Pyro


Joined: 29 Apr 2008
Posts: 3

PostPosted: Tue Apr 29, 2008 7:42 pm    Post subject: Getting the two axis going! Reply with quote

Hi I only spotted this project earlier and I'm going to get my teeth into it tomorrow but Im just have some quick questions, I really want it to have the x and y axis running and to show a true reading, but for the time being could I just connect the x and y terminals together on the accelerometer board? Also Im fairly handy with electronics but just havent got into PIC programming yet so could you please tell me what code to use and where to insert it in the original code to get a true reading of the G-forces, and then finally I presume as metioned already in a previos post the x axis would be connected to the RA1/AN1 input....... yes?

Thanks,
Eric
Back to top
View user's profile Send private message
ThePyroElectro
PyroElectro Admin


Joined: 12 Nov 2007
Posts: 401
Location: Earth

PostPosted: Tue Apr 29, 2008 8:06 pm    Post subject: Re: Getting the two axis going! Reply with quote

eh2k8 wrote:
but for the time being could I just connect the x and y terminals together on the accelerometer board?

This bothers me a lot. You will just get garbage data if you connect the two terminals together. Exclamation

Arrow X-Axis would go to AN0
Arrow Y-Axis would go to AN1

or vice versa, however you want to wire it. The modifications of the code would happen where the first ReadADC occurs, you'd add another ReadADC for the new port and shortly after the data is converted to the 'true' g_val for both x & y axis you'd use the formula above to get the total g_val that should be displayed. Cool
Back to top
View user's profile Send private message Send e-mail AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    PyroElectro.com Forum Index -> Projects All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group