Shop OBEX P1 Docs P2 Docs Learn Events
ColorPAL data rate — Parallax Forums

ColorPAL data rate

maern1maern1 Posts: 2
edited 2013-02-01 21:55 in Accessories
I'm currently using a ColorPAL sensor to make color measurements over an extended period of time and would like to slow the rate at which it logs an RGB measurement. Currently it is taking ~18 RGB readings/sec. Any way to change that rate? I'm using ColorPAL_sense.spin.

Thanks in advance

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-01-30 08:34
    Why not just throw away 17 readings, and then keep the 18th?
  • kwinnkwinn Posts: 8,697
    edited 2013-01-30 22:40
    Or add a number of readings and take an average.
  • maern1maern1 Posts: 2
    edited 2013-01-31 17:46
    I would like to add a number of readings and take an average. I have to admit that I am really new to spin programming (and coding in general) and I don't know how to set up the program to do that. Any advice on how to implement?

    Thanks
  • kwinnkwinn Posts: 8,697
    edited 2013-02-01 21:55
    Select a nice round binary number of readings (4, 8, 16, 32) and add that many readings to obtain a sum of the readings. Take that sum and add half of the number of readings (2, 4, 8, 16) to the sum. Then shift the sum right by the number of bits required to represent the number of readings (2, 3, 4, 5).
Sign In or Register to comment.