Shop OBEX P1 Docs P2 Docs Learn Events
scale code — Parallax Forums

scale code

mmorelandmmoreland Posts: 89
edited 2011-11-16 19:59 in Accessories
I was using a dual axis accelerometer (mimsic 2125) with a BS2p. After switching to a BS2pe, it no longer reported the correct angle. The scale code that appears in the literature ($1E1) seems to be incorrect. I'm using the rotational angle code straight from the download from the Parallax product page. Any ideas what I'm doing wrong, or any ideas what the scale code should be?

Comments

  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-11-14 16:48
    Hi, the code provided on the product page describes a scale of $0C0 for the BS2p and $1E1 for the BS2pe. How large of an error are you getting.

    Jeff T.

    EDIT: the units of measurement for the BS2pe are 2uS and for the BS2p 0.8uS a ratio of ~1 : 2.5, the ratio of $1E1 to $0C0 is also 1 : 2.5
  • mmorelandmmoreland Posts: 89
    edited 2011-11-14 17:20
    The $0C0 code worked perfectly when I was using the BS2p. I don't know what $0C0 means...is it ASCII code? The $1E1 code produced angle measurements that didn't make sense for my use, that is in the 200-300 degree range. I'm measuring angles between 5 and 70 degrees, and the accelerometer is in a small box that mounts to a tilting device that moves through that 65 degree angle. I assumed ASCII code, and started adjusting the code by guesswork because I had nothing to go on, and I found that a code of $100 restored it to nearly the same range for its position as with the BS2p. I don't know if what I've done makes any sense. It's working, sort of, but I wish I knew what was going on. Thanks for your reply.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-11-14 17:34
    The scale values in the example Memsic code don't match the examples in the help file, odd. Here's the scaling the help file gives for Pulsin. Perhaps you can try each of your Stamp modules with these directives and compare.
    #SELECT $STAMP
      #CASE BS2, BS2E, BS2PE
        Scale       CON     $200            ' 2.0 us per unit
      #CASE BS2SX, BS2P, BS2PX
        Scale       CON     $0CC            ' 0.8 us per unit
    #ENDSELECT
    
    

    Jeff T.

    EDIT: the numbers $200 and $0CC are values used with the "multiply middle" operator( */ ) check it out in the PBasic help file
  • mmorelandmmoreland Posts: 89
    edited 2011-11-14 18:49
    I'll try $200. Where does one find the "PBasic help file?"
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-11-14 19:05
    Hi, the help file is part of the IDE, on the menu bar, go Help - Contents then under PBasic reference go PBasic Operators.

    Yes I would think $200 for the BS2pe but for your results to match what you had on the BS2p then the BS2p should have had $0CC not $0C0 ($CC = 0.79uS and $C0 =0.75uS when your aiming for 0.8uS)

    Jeff T.
  • mmorelandmmoreland Posts: 89
    edited 2011-11-15 20:52
    $100 works for the BS2pe while $0C0 worked for the BS2p. $200 displays a 90 degree tilt (from 0 to 90) in about 75 degrees (estimate) while $100 is very close to perfect and good enough for my purposes. I found something by Tracy Allen on operators by using a Google search, but I wasn't able to follow your directions above...just couldn't find it. My fault; unfamiliar with the terms.
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2011-11-16 05:28
    Thats good, what matters is that it is working to your satisfaction.

    The following link is to the Basic Stamp Syntax and Reference Manual download. The multiply middle operator is described on page 112

    http://www.parallax.com/tabid/440/Default.aspx

    A quick note on $200 and $0CC which represent 2 and 0.8 respectively (which the section on multiply middle explains) and how it is used with the Memsic.

    The Memsic documentation gives an example using a BS2 where it says if the accelerometer is laying flat the Debug screen will display ~2500. The 2500 is the number of units in the measured pulse duration. Each unit for the BS2 (and the BS2pe) is 2 microseconds therefore 2500 x 0.000002 = 0.005 (5 milliseconds). That is the measured pulse width.

    If using the BS2p the units are not 2 microseconds they are 0.8 microseconds therefore for the same 5 millisecond pulse you should get 6250 counts. To prove this 6250 x 0.8 = 0.005 (5 milliseconds).

    Thats where the "scale" in the Memsic code is derived from.

    Jeff T.
  • mmorelandmmoreland Posts: 89
    edited 2011-11-16 19:59
    Thanks, Jeff. I've a copy of the manual, so I'll go get it and read the section. And thanks for your explanations. I wish I knew why $100 works better than the prescribed $200. I also wish the accelerometer were a little more accurate. I have rotated it very carefully and slowly while recording angles, and I see that some parts of the rotation signal a specific angle for considerably more than a degree while the degree between two such angles produces a signal for only an instant. It means that my set up cannot find every degree, so I've had to set its accuracy to +/- one degree to prevent the array from searching back and forth looking for a degree that only registers for perhaps .1 degree of rotation. I suppose had I spent more money, I could have obtained an accelerometer with more accuracy, at least one for which every degree would be contained in the same quantity of angular measure. On the other hand, if that's the worst thing that happens on this project, I'll count myself lucky. mm
Sign In or Register to comment.