Shop OBEX P1 Docs P2 Docs Learn Events
Programming help. — Parallax Forums

Programming help.

cannibalmonkcannibalmonk Posts: 3
edited 2006-04-18 00:24 in BASIC Stamp
I am a student who is invovled with ballon satellite project sponspered by NAU and Nasa.
We are sending up a package that will take pictures and collect certain data way up high, however high weather ballons go up.
We bought a BASIC stamp, a few of the courses, and a accelerometer.

I am currently trying to program the accelerometer and the BASIC stamp to log data throughout the trip, which is about 2 hours long If I recall correctly. Therein lies the problem, I simply dont know how to program and am looking for some quick suggestions. Sadly enough, the launch is coming up real fast.

So far, I am trying to tweak the program, MEMSIC2125-Dual.BS2, to Write the approprite data thoughout the trip. I didnt think it whould be that hard, but it seems so.

I could use some guidance.

Thanks,
Sean

Post Edited (cannibalmonk) : 4/17/2006 5:56:07 AM GMT

Comments

  • cannibalmonkcannibalmonk Posts: 3
    edited 2006-04-17 06:07
    I have gone over some of the courses and the help file, but my brain is not clicking in.

    I have six varibles that I want to WRITE, every second or minute, or as many crammed into an hour that I can. Then I want to read them at a latter date.

    So they are stored in the EEPROM forever until I READ them with a seperate program or until I write over them, right?

    Any help whould be greatly appreciated.
  • FORDFORD Posts: 221
    edited 2006-04-17 11:00
    If you use the 'write' command to store data in a location, then yes,·it will be·there to read at any time later, unless...
    - You re-program the stamp.
    - You write to the same Eeprom location too many times, (the limit I think is around 1,000,000 writes to the one location, search this forum to be sure). So if you write to the location·a few times per second, the life of the stamp is going to be fairly short. If you only write to the location say, once an hour,·then you wont have any problems for a very long time.

    If you 'put' the data into Ram, it can be written as many times as you like, but then the data will be lost if the power is removed from the stamp.

    Hope this helps,
    Chris
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-17 14:16
    Your original post mentioned 2 hours of data.· Your second post mentioned 6 variables per second (or minute).· Let's break that down into how many bytes of EEPROM this will take to accomplish.· Each tilt variable is a Word (2 bytes).· At 6 of these (12 bytes) per second for two hours would require 86,400 bytes if you were only storing those two values.· Double this for both X and Y axis.· If you only did 6 per minute you would require 1440 bytes.· More reasonable, but on a BS2 it is likely your data would collide with your program.· You might want to think about a BS2pe for data logging, or at least get an external EEPROM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Ryan ClarkeRyan Clarke Posts: 738
    edited 2006-04-17 15:03
    Sean,

    You may also want to look at this page:

    http://www.parallax.com/html_pages/resources/custapps/app_nearspace.asp

    Paul's group does near space launches-

    Ryan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Ryan Clarke
    Parallax Tech Support

    RClarke@Parallax.com
  • allanlane5allanlane5 Posts: 3,815
    edited 2006-04-17 15:41
    Definitely you want to look into external SPI interfaced EEPROMS. You can hang several of these off the BS2 very easily. I believe the part number is like 26L640.

    P.S. That part number is apparently more like 24LC32.
  • cannibalmonkcannibalmonk Posts: 3
    edited 2006-04-18 00:24
    Thanks for the help, guys. That webpage is awesome, thanks.

    Could anyone help me to write down and retrive the measurments that I whould get during our launch with the attached program?

    Ive been at it for awhile now trying differnt things, but with no luck. I am trying to use the WRITE and READ commands, but nothing shows up in the debug window.




    ' =========================================================================
    '
    '   File...... MEMSIC2125-Dual.BS2
    '   Purpose... Memsic 2125 Accelerometer Dual-Axis Demo
    '   Author.... (C) 2003-2004 Parallax, Inc -- All Rights Reserved
    '   E-mail.... support@parallax.com
    '   Started...
    '   Updated... 07 SEP 2004
    '
    '   {$STAMP BS2}
    '   {$PBASIC 2.5}
    '
    ' =========================================================================
    
    ' -----[noparse][[/noparse] Program Description ]---------------------------------------------
    '
    ' Read the pulse outputs from a Memsic 2125 accelerometer and converts to
    ' G-force and tilt angle.
    '
    ' g = ((t1 / 10 ms) - 0.5) / 12.5%
    '
    ' Tilt = ARCSIN(g)
    '
    ' Refer to Memsic documentation (AN-00MX-007.PDF) for details on g-to-tilt
    ' conversion and considerations.
    '
    ' www.memsic.com
    
    ' -----[noparse][[/noparse] Revision History ]------------------------------------------------
    
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
    Xin              PIN     6                      ' X input from Memsic 2125
    Yin              PIN     7                      ' Y input from Memsic 2125
    
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
    
    ' Set scale factor for PULSIN
    
    #SELECT $STAMP
      #CASE BS2, BS2E
        Scale CON $200                              ' 2.0 us per unit
      #CASE BS2SX
        Scale CON $0CC                              ' 0.8 us per unit
      #CASE BS2P
        Scale CON $0C0                              ' 0.75 us per unit
      #CASE BS2PE
        Scale CON $1E1                              ' 1.88 us per unit
    #ENDSELECT
    
    HiPulse           CON      1                    ' measure high-going pulse
    LoPulse           CON      0
    
    DegSym            CON      176                  ' degrees symbol
    
    ' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
    
    xRaw              VAR       Word                ' pulse from Memsic 2125
    xmG               VAR       Word                ' g force (1000ths)
    xTilt             VAR       Word                ' tilt angle
    
    yRaw              VAR       Word
    ymG               VAR       Word
    yTilt             VAR       Word
    
    disp              VAR       Byte                ' displacement (0.0 - 0.99)
    angle             VAR       Byte                ' tilt angle
    
    ' -----[noparse][[/noparse] EEPROM Data ]-----------------------------------------------------
    
    ' -----[noparse][[/noparse] Initialization ]--------------------------------------------------
    Setup:
      PAUSE 250                                     ' let DEBUG window open
      DEBUG "Memsic 2125 Accelerometer", CR,
            "-------------------------"
    
    ' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
    Main:
      DO
        GOSUB Read_Tilt                             ' reads G-force and Tilt
    
        ' display results
        DEBUG CRSRXY, 0, 3
        DEBUG "X Input... ",
          DEC (xRaw / 1000), ".", DEC3 xRaw, " ms",
          CLREOL, CR,
          "G Force... ", (xmG.BIT15 * 13 + " "),
          DEC (ABS xmG / 1000), ".", DEC3 (ABS xmG), " g",
          CLREOL, CR,
          "X Tilt.... ", (xTilt.BIT15 * 13 + " "),
          DEC ABS xTilt, DegSym, CLREOL
    
        DEBUG CRSRXY, 0, 7
        DEBUG "Y Input... ",
          DEC (yRaw / 1000), ".", DEC3 yRaw, " ms",
          CLREOL, CR,
          "G Force... ", (ymG.BIT15 * 13 + " "),
          DEC (ABS ymG / 1000), ".", DEC3 (ABS ymG), " g",
          CLREOL, CR,
          "Y Tilt.... ", (yTilt.BIT15 * 13 + " "),
          DEC ABS yTilt, DegSym, CLREOL
    
        PAUSE 200                                    ' update about 5x/second
      LOOP
      END
    
      ' -----[noparse][[/noparse] Subroutines ]-----------------------------------------------------
    Read_G_Force:
      PULSIN Xin, HiPulse, xRaw                     ' read pulse output
      xRaw = xRaw */ Scale                          ' convert to uSecs
      xmG = ((xRaw / 10) - 500) * 8                 ' calc 1/1000 g
      PULSIN Yin, HiPulse, yRaw
      yRaw = yRaw */ Scale
      ymG = ((yRaw / 10) - 500) * 8
      RETURN
    
    Read_Tilt:
      GOSUB Read_G_Force
      disp = ABS xmG / 10 MAX 99                    ' x displacement
      GOSUB Arcsine
      xTilt = angle * (-2 * xmG.BIT15 + 1)          ' fix sign
      disp = ABS ymG / 10 MAX 99                    ' y displacement
      GOSUB Arcsine
      yTilt = angle * (-2 * ymG.BIT15 + 1)          ' fix sign
      RETURN
    
    ' Trig routines courtesy Tracy Allen, PhD. (www.emesystems.com)
    
    Arccosine:
      disp = disp */ 983 / 3                        ' normalize input to 127
      angle = 63 - (disp / 2)                       ' approximate angle
      DO                                            ' find angle
      IF (COS angle <= disp) THEN EXIT
      angle = angle + 1
      LOOP
      angle = angle */ 360                          ' convert brads to degrees
      RETURN
    
    Arcsine:
      GOSUB Arccosine
      angle = 90 - angle
      RETURN
    
    

    Post Edited (cannibalmonk) : 4/18/2006 12:27:12 AM GMT
Sign In or Register to comment.