Shop OBEX P1 Docs P2 Docs Learn Events
External memory question — Parallax Forums

External memory question

max72max72 Posts: 1,155
edited 2008-12-13 13:09 in General Discussion
Hi,
I would like to ask a couple of questions about the possibility to use an external RAM.
I am planning to use the GPS module to have speed calculated with a moving average over a few minutes.
In order to do that I was thinking of calculating distance and time interval between samples, accumulate the values in two working variables, and store the sampled data in RAM.
When I add another sample, I subtract the oldest, and update the average speed.
To do that I have to store all my samples in RAM.
Is there a bettere way? What kind of external memory should I use?

Thanks in advance,
Massimo

Comments

  • BeanBean Posts: 8,129
    edited 2008-12-11 11:43
    Massimo,
    The SX48 has about twice the RAM of the SX28, maybe that would work.
    Otherwise, the only external RAM I have used is a 32KB chip with the SX48. It needs alot of I/O pins.
    If you look at the schematic for the Javelin you can see how the external RAM is connected.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    "The welfare of the people in particular has always been the alibi of tyrants." ~ Camus
    www.iElectronicDesigns.com

    ·
  • max72max72 Posts: 1,155
    edited 2008-12-11 12:05
    Thanks.
    Would it be possible to use a I2C sram like the PCF8570 from NPX?
    http://www.nxp.com

    I have to decide how long I would sample and the data format, so maybe it would be enough to use the internal RAM.

    Massimo
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-12-11 12:54
    Here is a picture of my SX48 protoboard addon pcb, which
    features 32KB ram (300mil or 600mil wide), eeprom, rs232.
    If I recall correctly this used ports A, D and E for onboard
    features. Ports B and C and the RS232 signals where available
    at the 0.1" 2x17 pin header.
    I could dig up the schematics and code but that would take a while
    because I am currently migrating to a new pc. The picture
    was grapped from my camera.

    regards peter
    1280 x 960 - 318K
  • max72max72 Posts: 1,155
    edited 2008-12-11 13:39
    It clearly shows it can be done, and it helps a lot.

    Thanks,
    Massimo
  • RsadeikaRsadeika Posts: 3,837
    edited 2008-12-11 14:05
    Peter, could you take a snapshot of the back of the board, I am curious to see what it looks like with all the soldering on the back.
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-12-11 14:23
    The only items soldered on the protoboard are socket headers.
    The addon pcb has pin headers that go into the socket headers.

    regards peter
  • Old_LadyOld_Lady Posts: 20
    edited 2008-12-11 14:41
    Rsadeika said...
    Peter, could you take a snapshot of the back of the board, I am curious to see what it looks like with all the soldering on the back.
    I will take a guess here that he had this board fabricated, so that the connections are not shown as wires soldered from pin to pin, instead the connections are inside the board, shown as traces.·
    Correct me if I'm wrong.· smile.gif
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-12-11 14:53
    Yes, the addon pcb was designed by me and professionally manufactured.

    regards peter
  • RobotWorkshopRobotWorkshop Posts: 2,307
    edited 2008-12-11 15:04
    Very cool project Peter! I like the layout of the board. Are these something that you are going to make more of? I've had a few of those SRAM chips sitting around waiting to be used in some project. Looks like it would be nice to try with the SX48.

    Robert
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-12-11 15:10
    I must still have a few unpopulated boards, probably three.
    PM me if·you're interested.

    regards peter
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-12-11 23:33
    Here is the schematic for that addon pcb.
    By using 2 latch ic's only 12 I/O lines are required to
    interface the external ram. So you could use that schematic
    to add external ram to sx18/ss20 or sx28 as well.
    Originally this board was to be my entry for the sx design contest
    2006/2007 using the CSC sx/c compiler, but CSC never got
    the compiler to work and so I had to cancel my entry.

    regards peter
  • Dave HeinDave Hein Posts: 6,347
    edited 2008-12-12 03:49
    Massimo,

    You can filter the data with much less memory with a recursive filter.· The filter is as follows:

    Y(i) = A*X(i) + (1-A)*Y(i-1)

    X(i) is the current sample, Y(i-1) is the previous filter output, and Y(i) is the current filter output. The value of "A" is less than one, and it depends on how much filtering you want.· It seems like for your application,·"A" would have a value of 0.01 ot 0.005.

    Your computations need to be done with a bit more precision than the input data, otherwise you will lose precsion on the results.· If the input data is 16 bits, the intermediate results should probably be 24 bits.

    Dave
  • max72max72 Posts: 1,155
    edited 2008-12-12 14:03
    Dave,
    I tested the formula but I have troubles with it.
    I had in mind a formula like the one in
    http://en.wikipedia.org/wiki/Moving_average
    If I test in a spreadsheet random data with a moving average and your filter I cannot get the same values.
    If the data are slowly varying the difference is smaller, or if the samples increase, nontheless the results are different.
    Moreover your algorithm could be a problem if my samples are not equally spaced (with a GPS loosing the fixing a couple of seconds).

    Could you confirm it or am I missing you point?

    Thanks,
    Massimo
  • Dave HeinDave Hein Posts: 6,347
    edited 2008-12-12 23:01
    Massimo,

    There are pros and cons to both filters.· The moving average filter has a finite impulse response, and it is easy to implement.· The simple recursive filter has an infinite impulse response.· However, it requires less memory.· The results will be different between the two filters.· For your application I don't think the difference is important.· You just want to smooth out the velocity measurements.· If you required a specific frequency response, then you would need either a more complicated recursive filter or a more general finitie impulse response (FIR) filter.

    The recursive filter can be implemented without multiplications if you use powers of two.· With a filter coefficient of 1/128, the previous filter value be reduce by 127/128 and the new input value would be multiplied by 1/128.· This would be done by shifting the previous value down by 7 bits, and subtracting it from the unshifted value to scale it by 127/128.· The new input value would be shifted down by 7 bits to scale it by 1/128.

    The effect of irregular time intervals will be about the same for both filters, so that doesn't really make much difference.

    Dave
  • max72max72 Posts: 1,155
    edited 2008-12-13 07:36
    Dave,
    now it is much clearer.

    Thank you for the explanations.

    Massimo
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-12-13 13:09
    Little addition to my external ram schematic.
    This should allow multiple MCU's to access·the
    same ram chip (shared ram).
    The protocol used for arbitation is I2C-like using signals
    CPL and CPH. This only works with 74HC(T)373 latches
    because these·are transparent while their LE input·is high.
    Please comment on the proposed protocol if you
    think there is a better way.

    regards peter
Sign In or Register to comment.