Shop OBEX P1 Docs P2 Docs Learn Events
The Memsic Dual-Axis Accelerometer Chapter 3 Parallax Book: Smart Senors & Applications Version 1.0 — Parallax Forums

The Memsic Dual-Axis Accelerometer Chapter 3 Parallax Book: Smart Senors & Applications Version 1.0

I worked through all the scaling samples. Got my LCD working with all the samples. Understood brads to degrees. Figured out measuring rotations, tilt angles. After completing everything in Chapter 3, some of which taxed my brain, I have no idea how to apply this information to something I want to do. I want to do something "real" simple. I would like this tilt sensor to send a variable output voltage to one of the pins 0 to 15. The variable output voltage would be in relation to either the x or y axis and how much I tilt the sensor. I can figure the sine, cosine, tangent, arcsine, arccosine, arctangent --even sweep the numbers between -127 and 127-- and get the debug screen to display numbers. I have no idea how to convert these numbers to an output pin which has a variable voltage in relation to the sweep of -127 to 127. I know there are "many" things this accelerometer will do, but all I am wanting to do is convert tilt to a variable output voltage. Say 0 to 1 volt on one of the output pins. This is a great book, and great work explaining the basic stamp and the many things the accelerometer will do. Problem is, in all the examples---on the debug screen, and LCD-- nothing is directed to be an output on one of the output pins--except the LCD. Not one example beyond the bebug screen and LCD of how to apply this tilt sensor. I would like to see just one example in the book, where the tilt angle of the accelerometer would change the brightness of an LED. Now that is simple. The tragic thing is this: After going through all this complex information, I am not able to change the brightness of a LED with this tilt sensor. Something is wrong with this picture, maybe I am stupid, or thick headed, but I do understand the material in the book. Is there anything-- anywhere-- that would show me an example of the tilt sensor and basic stamp changing the brightness of a LED? Of course changing the brightness of and LED gets back to what I want to do, make one of the basic stamp output pins have a variable voltage in relation to tilt. I am kind of irritated at myself. After all this hard work racking my brain, and working through Chapter 3 and this tilt sensor, I can't even do the simplest of things. Is something wrong with me?

Comments

  • kwinnkwinn Posts: 8,697
    edited 2016-09-03 03:23
    Keith, nothing wrong with you. It takes time and the occasional bit of help to learn all the things that can be done with a micro.

    Controlling a led or producing a dc voltage is actually quite simple to do. All you need is use the PWM function (page 355 of the Stamp manual). It can vary the brightness of a led and current limiting resistor connected to a pin, and if you want a DC voltage an RC filter on the pin can produce that.
  • Thanks Kwinn. I was in hopes I could do something with the tilt sensor beyond the debug screen.
  • I have thought a lot about where I am at with the basic stamp and coding. I have finished the projects in 4 Parallax books. I think I am about like the boy who is in first year in high school, first year in Algebra. I am learning the algebra formulas, but have no clue how to apply algebra. With the "great" Parallax books, I have had a overload of debug! I am burned out on the debug screen. I want to see samples of the code leaving the basic stamp.
    Maybe I am wrong, but it seems that 95% of the basic stamp teaching material never gets further than the debug screen. I have found myself wanting samples of stuff leaving the basic stamp, and leaving the debug screen. I worked through a difficult chapter on the Parallax tilt sensor. Got all the numbers correct on the debug screen.
    But I do not have a clue what the numbers on the debug screen mean. Are they a string of zeros and ones, are they voltage readings, pulse train---what? See what I mean? In the following tilt display, can someone tell me what the numbers on the debug screen mean? You might ask what application----OK what if I want a variable voltage output related to the tilt. In this example what do the numbers mean? Here is the code--and the code works!
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    angle VAR Word
    x VAR Word
    y VAR Word

    DO
    PULSIN 6, 1, x
    PULSIN 7, 1, y

    x = (x MIN 1875 MAX 3125) - 1875 ** 13369 - 127
    y = (y MIN 1875 MAX 3125) - 1875 ** 13369 - 127

    angle = x ATN -y
    angle = angle */ 361

    'LCD Display Routine
    SEROUT 14, 84, [ 138, " ",138, DEC angle, 7,
    152, " ", 152, SDEC x,
    159, " ", 159, SDEC y ]

    PAUSE 350

    LOOP
  • kwinnkwinn Posts: 8,697
    In the above case (-127 to +127 out) +127 means the sensor is measuring maximum (3 g) acceleration in one direction on that axis. If it was -127 it would be 3 g acceleration in the opposite direction on the same axis. This reading also depends on how the accelerometer is physically oriented. It is pretty well documented in this data sheet.

    You could modify the calculation to show +- g, angle, slope, or any other result that could be deduced from the acceleration measurement. For instance if you put it in a road grader it could measure the slope/grade of the road in both the front/rear and side to side direction.
Sign In or Register to comment.