Shop OBEX P1 Docs P2 Docs Learn Events
Quick question about timing — Parallax Forums

Quick question about timing

BasilBasil Posts: 380
edited 2007-03-29 02:10 in Propeller 1
Hi All,

I don't need any detailed answer just yet.

For my Rocket controller project, i need to take 2 x 12bit samples from an ADC using SPI interface (for the accelerometer and barometer).
With the accel., I need to convert g's to acceleration, differentiate to get velocity, then again to get altitude.

With barometer I need to convert straight to alt.

I then need to store the accels. raw data, acceleration, velocity and altitude along with the barometer's raw data and altitude into the shared memory on the Prop.

How quickly do you think I could do this? I can use 1, 2 or 3 COG's (less is better obviously)

This probably isn't a simple answer! but any thoughts are appreciated.

Alec

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-28 22:58
    There's no way to tell with the information you've given. With only one external ADC, you can't get your readings in parallel. You'll have to figure out how fast you can read them based on the ADC's datasheet and the maximum SPI clock rate. A Spin routine might be able to clock an ADC at 20-50KHz. Assembly can probably read the ADC at its maximum speed. If you can do all the conversion arithmetic in integer or fixed point arithmetic, you should be able to do that pretty quickly. How quickly depends entirely on the calculations involved. If you need floating point, the speed is mostly set by that of the floating point library routines and those are described in the documentation for the floating point library. Access to the main (shared) memory is pretty much instantaneous compared to the other work necessary. I wouldn't worry about it.
  • BasilBasil Posts: 380
    edited 2007-03-28 23:29
    Hi Mike,

    Thanks for that.

    I should mention that I am aiming for about 0.5 to 1ms to do all of this.
  • rjo_rjo_ Posts: 1,825
    edited 2007-03-28 23:38
    Alec

    How big is the rocket? If you are running out of cogs... this might be a perfect application for Sid's prop-on-prop piggyback. Mine survived the US mail, so it should survive a rocket launch or two...with the added weight of about one socketed Prop. If you want to add television... you could also get GPS capabilities by adding Brian Hitt's board.. add a little transmitter and you could transmit live data overlaid on the camera view to the ground.

    Rich
  • BasilBasil Posts: 380
    edited 2007-03-28 23:49
    Hi Rich,

    I am designing this to be used in alot of rockets smile.gif

    I don't think ill run out of COG's as its all basic stuff. I am planning on using expansion boards for things like GPS and telemtry. If they prove to be to much for 1 prop I may add a prop to those expansion boards which need it smile.gif

    I will take a look at the piggy-prop smile.gif it looks like a great idea for the expansion boards if needed!
  • BasilBasil Posts: 380
    edited 2007-03-29 00:08
    Mike,

    I am using the attached ADC smile.gif
    It shows a max sampling rate of 50 ksps.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-29 00:33
    Basil,
    It's the maximum clock rate that we're interested in here. If you want maximum speed, you'll have to do this in assembly. You'd use one cog for the ADC which would store its readings in some kind of buffer in main memory. Your calculation routines would run in another cog and store their results in a table in main memory. You may need to have some kind of external memory to store your results. I'd suggest a Ramtron FRAM (ferroelectric RAM) which works like an EEPROM, but doesn't take very long to write into (unlike an EEPROM which takes 5ms or so). These come in 32K and 64K byte sizes.
  • BasilBasil Posts: 380
    edited 2007-03-29 00:56
    Mike Green said...
    Basil,
    It's the maximum clock rate that we're interested in here. If you want maximum speed, you'll have to do this in assembly. You'd use one cog for the ADC which would store its readings in some kind of buffer in main memory. Your calculation routines would run in another cog and store their results in a table in main memory. You may need to have some kind of external memory to store your results. I'd suggest a Ramtron FRAM (ferroelectric RAM) which works like an EEPROM, but doesn't take very long to write into (unlike an EEPROM which takes 5ms or so). These come in 32K and 64K byte sizes.

    Thanks Mike,

    Thats what I had in mind.

    Data will be sampled at (hopefully) 1ms intervals, maybe more frequently, and calculated to find acceleration, altitude, velocity etc.

    The results of all the calulations will be checked to see if they meet some preset parameters (for apogee detection, launch detection etc).

    I may do the comparisons in another cog depending on how complex they are.

    **Edit: up until now, all these values are stored in main memory**

    If event parameters are met, another cog will trigger outputs etc and record values (alt, acceleration) at which the event happened in external memory (FRAM), while the 'main' cog(s) continues to sample and calc as above, continuously overwriting the previous samples.

    Regarding storage, every 10ms, 20ms, 50ms or 100ms (user decides), I will write the most recent results (in a separate cog so as not to interupt main loop) to external storage, along with the time after launch they were sampled.

    Thats the theory anyway!

    Oh, and max clock rate for the ADC is 1MHz at 3v smile.gif

    Regards,

    Alec

    Post Edited (Basil) : 3/29/2007 1:03:00 AM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-29 01:10
    If you're only going to store data in external memory every 10ms minimum, you can save money and get more storage by using EEPROMs. The largest available are 128K bytes and you can easily attach 2 to a pair of I/O pins.
  • BasilBasil Posts: 380
    edited 2007-03-29 01:46
    Hi Mike,

    128K? I thought there was a 1Mbit version? It has write cycle times of 5ms which seems to be standard. Ill be writing approx 5bytes of data at a time i'd say.

    Time 16bits (2 bytes)
    Accel. Raw 12bits (1.5 bytes)
    Barr. Raw 12bits (1.5 bytes)

    I'd like to be able to write all the calcuated values too but that could take it up to much time. (approx 20bytes)
  • Mike GreenMike Green Posts: 23,101
    edited 2007-03-29 01:57
    The EEPROMs are sold by the bit, not the byte. A 24LC1024 is a 128K byte EEPROM.

    You can write up to a page of data in one 5ms cycle. The larger EEPROMs have a page size of either 128 or 256 bytes. You could write a whole packet (maybe 32 bytes) of data in one 5ms cycle.
  • BasilBasil Posts: 380
    edited 2007-03-29 02:10
    Mike Green said...
    The EEPROMs are sold by the bit, not the byte. A 24LC1024 is a 128K byte EEPROM.

    You can write up to a page of data in one 5ms cycle. The larger EEPROMs have a page size of either 128 or 256 bytes. You could write a whole packet (maybe 32 bytes) of data in one 5ms cycle.

    Oh! bit and bytes... quite a difference blush.gif

    Thanks for the clarification on the page thing smile.gif
Sign In or Register to comment.