Shop OBEX P1 Docs P2 Docs Learn Events
READ instruction data access time — Parallax Forums

READ instruction data access time

StephenMooreStephenMoore Posts: 188
edited 2012-05-20 19:07 in BASIC Stamp
I am trying to read bytes of data and shift them out in groups of 3 to a string of
WS2801 LED driver chips.
However, the LED driver chips latch the transmitted data if there is a 500 microsecond delay in transmission. I am only able to shift out data to two chips before the data is latched so that I cqn never access the down line driver chips. I believe this is because of slow data read times on the BS2px. I am reading the data from a different store than the slot my program is running in.

Has anyone else encountered this timing problem?

program1:
STORE 1
FOR idx1 = 0 TO 50 STEP 3
READ idx1, red, green, blue
SHIFTOUT dataPin, clkPin, 1, [red, green, blue]
NEXT
RETURN

Comments

  • StephenMooreStephenMoore Posts: 188
    edited 2012-05-19 00:04
    Never mind. I used the scratchpad RAM as a buffer and it works OK.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-19 07:34
    There's lots of information on Stamp execution timing here. Click on the "app-notes" link.
  • StephenMooreStephenMoore Posts: 188
    edited 2012-05-19 21:02
    Thanks Mr. Green.

    I did not see any timing info on a cross bank READ but the website is full of great data.

    If I use 126 bytes of scratchpad RAM, I can read R-G-B data for 42 LEDS from memory. I need 24 more bytes of storage. If I reserve variable RAM I am only left with 1 word for program use!

    I am still playing with the program itself but I am trying to load a string of 50 LEDs with R-G-B data. I can not exceed .5 msec between writes to the LED driver chip.

    Somehow I need to better utilize memory.

    sm
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-20 08:15
    Your timing constraint is really tight for a Stamp. You may have 24-bit color information, but usually very few of the colors are used at any one time. Often you could have a color lookup table in part of scratchpad RAM and each of the 50 LEDs would be represented by a single byte containing the color number. You can certainly fit 25 color entries plus the 50 color numbers in the scratchpad RAM.

    Unfortunately, schemes for better utilizing memory usually trade off speed for space and you have nothing to spare in either camp. You may be better off switching to another microcontroller with more memory and speed. The Propeller would be one that could handle this. If you already have some hardware built up, you could substitute a Spin Stamp for the BS2px as long as you don't have 5V sensors since you'd need to protect the Spin Stamp's 3.3V inputs from the 5V signals (a 3.3K series resistor would do that). You'd have to rewrite your program in Spin (or C or Forth), but we could help you get started with that.
  • StephenMooreStephenMoore Posts: 188
    edited 2012-05-20 18:38
    Good advice to move to the Propeller... less expensive too. However, I had a BS2px with Super Carrier Board laying around unused and I decided to get some value added use out of it. When I do move to a Prop USB Board, the PWM chips on the LEDs are only written to by the Prop so I think I would get away without a voltage translator. I also used an RCTIME circuit with a 10K potentiometer as a program selector so I would need to migrate that code.

    As it is, my basic stamp program reads the R-G-B color pattern for 1/2 of the LEDs from the alternate bank store and copies it twice to the LED string. To the un-discerning eye there is no duplicity and all of the LEDs get updated everytime with some sort of color pattern.

    Overall the project turned out pretty well. Here's a picture of one color scheme. With the great number of menu possibilities from the pot (1 to 1463) and all of the additional Stamp memory to store custom R-G-B tables, I've got more than enough color schemes. I also interpret a range of settings to give me delay values for dynamic color programs and maximum attained brightness on certain pot settings. Quite a lot of versatility from that RCTIME feature.

    Thanks for your help again.

    sm
    1024 x 683 - 39K
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-20 19:07
    There's a BS2_Functions object in the Propeller Object Exchange that implements most of the I/O functionality of the Stamps using Spin methods. One of these is RCTIME which provides the same functionality as the RCTIME statement in PBasic, so there's not much effort involved. The WS2801 should work just fine with a 3.3V supply and would be directly compatible with the Propeller at that voltage. Even if you power the WS2801 from 5V, the inputs to it are still compatible with the Propeller's I/O pins.
Sign In or Register to comment.