Shop OBEX P1 Docs P2 Docs Learn Events
Shiftout loop time — Parallax Forums

Shiftout loop time

NewzedNewzed Posts: 2,503
edited 2007-06-02 14:50 in BASIC Stamp
Tracy, I have some Nichia RGB chips hooked up to my Stamp piggyback and they are working very well.· However, I'm having a bit of trouble with the timing so all 9 colors stay on for the same amount of time.· Can you please tell me how lomg the Stamp takes to execute this:

shiftout red, clock, msbfirst,[noparse][[/noparse]18,18]
pulsout latch 5
low latch
shiftout red, clock, msbfirst,[noparse][[/noparse]0,0]
pulsout latch 5
low latch

Thanks

Sid


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Yesterday is history, tomorrow is a mystery, and today is a gift.

That is why they call it the present.

Don't have VGA?
Newzed@aol.com
·

Comments

  • metron9metron9 Posts: 1,100
    edited 2007-06-01 23:44
    2.28mS

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • NewzedNewzed Posts: 2,503
    edited 2007-06-01 23:47
    Metron, how did you arrive at that number?

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • metron9metron9 Posts: 1,100
    edited 2007-06-02 00:09
    Oops sorry I read the wrong number on the scope.

    It is actually 4.7mS

    The blue line that is 5mS long has a high and low command that takes 300uS so 5mS minus 300us= 4.7mS

    So by adding a HIGH and LOW command to toggle a port pin I can see the time on the scope.

    In the first one I read #7 upper left 2.584mS not sure what that is as i am not a seasoned scope reader



    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' {$PORT COM2}
    
    
    red CON 3
    clock CON 4
    latch CON 5
    
    
    
    HIGH 6
    SHIFTOUT red, clock, MSBFIRST,[noparse][[/noparse]18,18]
    PULSOUT latch,5
    LOW latch
    SHIFTOUT red, clock, MSBFIRST,[noparse][[/noparse]0,0]
    PULSOUT latch,5
    LOW latch
    LOW 6
    HIGH 6
    LOW 6
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
    846 x 427 - 17K
    365 x 209 - 7K
  • metron9metron9 Posts: 1,100
    edited 2007-06-02 00:14
    Here is another look with the clock line plotted in red

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
    382 x 296 - 8K
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2007-06-02 01:38
    Hi Sid,

    You already got a good answer, and that is the sort of thing you can do yourself. Put the sequence inside a DO:LOOP if you have an analog scope and need it to repeat.

    Alternatively, if you have a second stamp around there, or a Propeller (I know you do!), you can use its PULSIN function (or equiv) to measure the time that metron9 used to frame your time interval on pin p6. Subtract 120 microseconds for the time taken by the HIGH or LOW instruction.

    Alternatively yet again, if you have neither 'scope nor additional Stamp, put the snippet in a FOR:NEXT loop and let it run through 10000 iterations, while you time it on a stopwatch or wall clock. Have it beep when finished. Subtract the time taken by the FOR:NEXT and divide the total by 10000.

    By the way, is this an original BASIC Stamp, or a multislot? The times might be faster.

    Why the "LOW latch" after the PULSOUT? The PULSOUT will leave the pin low anyway.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • NewzedNewzed Posts: 2,503
    edited 2007-06-02 12:16
    Tracy, this is on my piggyback.· A BS2 actually does the work, but it is being instructed by a BS2E.· Instruction time for the BS2 is 250 us for a single instruction.· I can't use the Optascope because I need my debug screen to issue commands to the BS2E.· I'll run a time test as you suggested and see what I come up with.· There are several variations to the shiftout loop, depending on what color I want to display.· Some of them use no delays and some of them use varying delay times between shiftout n,n and shiftout 0,0 to acheive a good color mix.· I'll let you know.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
  • NewzedNewzed Posts: 2,503
    edited 2007-06-02 14:50
    Tracy and Metron -

    I have four different shiftout loops -

    One for red, green, blue and yellow.
    One for orange
    One for magenta
    One for cyan

    I inserted a "high 3" at the beginning of each loop and a "low 3" at the end.

    Here are the "high" times as measured with my HP 275MHz scope.· Please note that per Tracy, all the "low latch" commands have been deleted.

    red:···· '·· 5ms············· also applies to green,blue,yellow
    high 3
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]18,18]
    PULSOUT latch,5
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]0,0]
    PULSOUT latch, 5
    low 3

    org:·········· ·'· 23ms
    high 3
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]18,18]
    PULSOUT latch,5
    PAUSE 6
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]0,0]
    PULSOUT latch, 5
    PAUSE 2
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]36,36]
    PULSOUT latch,5
    PAUSE 1
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]0,0]
    PULSOUT latch, 5
    PAUSE 4
    low 3

    mag:········ · '·· 23ms
    high 3
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]72,72]
    PULSOUT latch,5
    PAUSE 1
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]0,0]
    PULSOUT latch, 5
    PAUSE 1
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]18,18]
    PULSOUT latch,5
    PAUSE 5
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]0,0]
    PULSOUT latch, 5
    PAUSE 5
    low 3

    cyan:······ ·'·· 20ms
    high 3
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]36,36]
    PULSOUT latch,5
    PAUSE 3
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]0,0]
    PULSOUT latch, 5
    PAUSE 2
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]72,72]
    PULSOUT latch,5
    PAUSE 3
    SHIFTOUT dat, clk, msbfirst, [noparse][[/noparse]0,0]
    PULSOUT latch, 5
    PAUSE 2
    low 3

    I may be off by a few tenths of a millisecond because I had to interpolate the reading at the end of the high trace.· Time/Div was set to give me a good visual reading.· Would you agree that these figures are about right?

    Sid



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Yesterday is history, tomorrow is a mystery, and today is a gift.

    That is why they call it the present.

    Don't have VGA?
    Newzed@aol.com
    ·
Sign In or Register to comment.