1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Hi everyone i am dong my project designing a 3d solid state

  1. Jun 10, 2010 #1
    hi everyone.... i am dong my project designing a 3d solid state

    hi everyone.... i am dong my project designing a 3d solid state accelerometer.The accelerometer should detect and measure steps. Can any one of you help regarding the design of it........
  2. jcsd
  3. Jun 14, 2010 #2


    User Avatar

    Staff: Mentor

  4. Jul 7, 2010 #3
    Re: accelerometer........

    What do you need to know? I bought an analog output accelerometer for a senior design project a few years back -- it was used to measure car acceleration, but the design was sensitive enough to measure gravity quite easily. A simple interface to a PIC microcontroller and an A/D converter (12 bit) is trivial. When you speak of "detecting steps" do you mean if someone is holding it, you want to know when they step -- how hard they thrust -- what??

    Most of that is a software issue; eg: processing the signal from the accelerometer once it is acquired.
    I found that if the accelerometer is mounted close to the A/D converter -- a very simple R/C filter will remove spurious noise and give excellent SNR. The farther away the accelerometer is from the data acquisition, the more noise problems resulted.

    Analog accelerometers are quite inexpensive now, especially since they are used in hard drives to park the heads on laptops when someone "drops" it in hopes of protecting data (or voiding your warranty....possibly in self defense).
  5. Jul 12, 2010 #4
    Re: accelerometer........

    The thing with my project is that when a movement happen after holding the accm3d it should send the analog values that is X,Y,Z value to PIC16F877a to get converted to digital and diplay it on 4 digit SEVen segment display which was connected across the other port. So i need a PIC C code for that. Then i introduce compass to another port to program it in such a way that it should show the direction of the movement. All this comes in a single program. please help me with this program......if you want look at my block diagram see the attachment
  6. Jul 12, 2010 #5


    User Avatar

    Staff: Mentor

    Re: accelerometer........

    It's your school project, Gopi, so you should be doing the work. What other C programs have you written for the PIC?
  7. Jul 13, 2010 #6
    Re: accelerometer........

    Berkeman is right, to learn anything you need to produce the final code and even if I wanted to I couldn't produce much C code in my present condition & circumstances. (Today I have been awake less than 4 useful hours.) I have already done a similar project, so I can tell you in my sleep a few things -- but new ideas aren't going to be quickly assimilated. (After a Murphy Sunday to Tuesday -- I wouldn't even want to try) All of my hardware routines were done in assembly, and only the high level interface program was done in C for convenience; esp. for my other teammates who weren't assembly level programmers.... There wasn't enough memory in the chip to do everything in C code anyhow -- and I mentored my other team mates on how to write code in C to replace the libraries that came with the compiler which were too big. It was a great learning experience, but a bit of work which is *specific* to optimizations of our project.

    I don't see the attachment to know your general idea, still... as I am able ... which isn't predictable/consistent -- I am willing to give you some pointers as you get stuck -- though I don't want and am not able to do your project for you.

    A PIC16F877 is in the 16 series of microcontrollers; most people don't program them with a C compiler -- I happened to have a C compiler for (other) 16F controllers from CCSC, If you are thinking the IDE from Microchip comes with C for free, look carefully, for as a year ago when I loaded the latest IDE the C compiler *hitches* were available, but the actual software was separate.
    If that is still the case, there is an open source project for 16 series mnemonics, but it isn't GCC and it is alpha software which if you are asking me for code now, isn't going to be a viable solution for you.
    Do you have a full C compiler, then, that you haven't spoken of; if so, which company makes it? -- for that affects how you code your program. Microcontroller C compilers generally need special consideration to operate 8 bit MCUs. C is really a 32 bit language which gets shoehorned into 8 bits using various hacks and routines written by the compiler company. It feels like C, but the code efficiency is horrible for such a small memory device.

    Your accelerometer datasheet already has a wiring diagram for a pic12F chip which will be nearly identical to your own (change pin numbers based on data-sheet). A couple of things to notice -- the PIC is powered from the accelerometer; this may or not be a convenience issue. The A/D converters on the PICS are ratiometric. If you change the power supply to the A/D converter -- you get different numbers. #1 -- To make the system stable -- design so that at least your A/D and accelerometer share in some way -- the same voltage reference. #2 -- be careful that the reference power supply isn't being heavily loaded because the pic microcontroller is switching large power swings (for itself, not absolute...) on its logic pins -- especially at high speed. #3 -- your solution isn't mine; I used an external A/D chip with a digital interface, so my program software had different requirements than yours does and my code won't help you much anyway.

    What I have told you is nothing more than what is on the datasheet -- and what you can find in "Design notes" from various companies for different accelerometers, etc.

    Here is a sample of the kinds of things a design note closer to your project ought to talk about -- that I can produce off the top of my head. You have a 3.33mV swing, so questions you need to think about are -- what is my operating point in terms of G. eg: how much will gravity bias the chip axes such that 'I' will not have +-3G on at least one axis, but more like =-1G+2G or whatever your design really has. How am 'I' going to deal with the zero point floating at some vaguely defined value, which might even change with temperature (Datasheet for composite surf board doesn't say...what does AnalogDev datasheet tell 'me' about zero point accuracy of the ACTUAL chip). Can a simple number coded as zero offset for all time be accurate enough for 'my' project? How many mV/uV/step can 'I' actually measure with the microcontroller ADC given the number of bits, and that full scale is __ volts, and that the accelerometer only outputs a two volt swing which is 2V/__ Volts. Is it fine enough to detect a 50% smaller signal than the smallest one I am expecting is significant?

    Without knowing the idea, I can't suggest anything about software design pitfalls; nor can I point you toward specific design notes easily available on the web... Big hint; don't blantantly copy without checking the copyrights, understanding the code fully, and being sure you aren't wasting your time.
    There are general questions one needs to answer at every step of a project -- and the one you must watch out for the most, is that you have limited program space. 14K of 8 bit instructions, is like 7K of 16 bit instructions, is like 3.5K of 32 bit instructions. 4096 commands (lines of C code or often less) is what you most likely have if you are not careful.
    A text message like "Hello world, press A key to continue." Requires 38, PIC 16F instructions *just to store*, not to mention every time it is "printed", the call print routine takes several instructions to set things up, eg: 5-10 instructions would not be unusual. A real good time saver *in the future* is to waste a little time now writing dummy routines and compiling them to find out how much space typical operations cost.

    For example: try this program.

    int dummy( int a, int b ) {
    int c,d;
    c=a; b=d;
    return c+d;

    main() {
    int a,b,c;

    how much space does this *Simple* progam take. How much more (and I guarantee it will be more) would the code take if c+d is replaced with c*d. How about (gasp) c/d.
    If it doesn't surprise you, you know more than you need to do the project -- and are going to have an easy time of it and are just being lazy asking for help. If it does surprise you, you are normal and need to do more thinking perhaps guided a little.

    Best wishes.
  8. Jul 15, 2010 #7
    Re: accelerometer........

    Thank you any way, i have started working on the program i am almost done with programming the compass.One of my lab assistant in the university was telling me that we can program the PIC16F877a with assembly language only.But i remember i have done that with PIC C coding............

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook