Shop OBEX P1 Docs P2 Docs Learn Events
clock speed and r/c circuit (RCTIME) — Parallax Forums

clock speed and r/c circuit (RCTIME)

mspeediemspeedie Posts: 12
edited 2009-04-27 11:35 in General Discussion
I wrote some code that runs perfectly on the Basic Stamp. Because SX chips are so much cheaper, I'm converting the code to SX/B. My code has some RCTIME functions that don't seem to be working on the SX28. Could it be the different clock speeds of the chips? Also, a side question, is there an easy (or not-so-easy) way to see debug statements using SX28?

Thanks for the help!

Comments

  • ZootZoot Posts: 2,227
    edited 2009-02-20 04:30
    Time to hit the manual and the SX/B help file smile.gif

    - RCTIME should work nearly the same as on the Stamp, but read the manual -- and check your resolution. Make sure you have an accurate clock source (either an external resonator or the SX-Key).

    - there is no "debug" on the SX like there is on the Stamp. You can "WATCH" variables which lets you see their values on your PC while you are running a program. Read up on debugging -- there is a lot you can do, but it's not like the Stamp.

    - you can program your SX to send ASCII serial data a la "DEBUG" on the Stamp. You would need level-shifter circuitry to convert the TTL serial data from the SX to RS-232 for your PC, but if you just need to see variable values (like the results of an RCTIME) then using the regular debug features would probably be simplest.

    - can post your circuit and code? Otherwise it's just guesswork from this end.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    When the going gets weird, the weird turn pro. -- HST

    1uffakind.com/robots/povBitMapBuilder.php
    1uffakind.com/robots/resistorLadder.php
  • mspeediemspeedie Posts: 12
    edited 2009-04-27 05:36
    Here's an explanation of the following code: I ran the RCTime function 100 times, and timed the counter loop. The entire process took 64 seconds. Subtracting (100*20ms pause=2s), the total time for the 100 RCTime routines took 62 seconds. This is 620ms per RCTime function. This makes no sense to me as running the command using the BASIC Stamp takes about 2ms.

    So, here's the code... I'm attaching a picture of the SX proto board (ignore the red wires, they are my home-made Vin). I have two resisters in series coming from pin rb.7 totalling approximately 220-ohms, then a 0.1uF cap and 15k-ohm in parallel to ground.

    ' =========================================================================
    '
    ' File...... test RC-Time Circuit 2009-04-25.sxb
    ' Purpose... test rc-time
    ' Author....
    ' E-mail....
    ' Started...
    ' Updated... 2009-
    '
    ' =========================================================================


    '
    ' Program Description
    '


    '
    ' Device Settings
    '

    DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
    FREQ 4_000_000


    '
    ' IO Pins
    '

    PhotoR PIN RB.7 ' RC-Time from photo-resistor

    '
    ' Constants
    '


    '
    ' Variables
    '

    T VAR Word



    '
    INTERRUPT
    '

    ISR_Start:
    ' ISR code here

    ISR_Exit:
    RETURNINT ' {cycles}


    ' =========================================================================
    PROGRAM Start
    ' =========================================================================

    Pgm_ID:
    DATA "SX/B Template", 0


    '
    ' Subroutines / Jump Table
    '


    '
    ' Program Code
    '

    Start:
    ' initialization code here

    Main:
    ' main code here




    COUNTER = 0


    high ra.0

    do while counter < 100
    HIGH PhotoR
    pause 20
    PULSIN PhotoR, 1, T

    counter = counter + 1
    loop

    low ra.0

    do
    loop

    GOTO Main


    '
    ' Page 1 Code
    '

    'Page_1:
    ' ADDRESS $200

    'P1_Start:
    ' GOTO P1_Start ' error if Pg0 overruns Pg1


    '
    ' Page 2 Code
    '

    'Page_2:
    ' ADDRESS $400

    'P2_Start:
    ' GOTO P2_Start ' error if Pg1 overruns Pg2


    '
    ' Page 3 Code
    '

    'Page_3:
    ' ADDRESS $600

    'P3_Start:
    ' GOTO P3_Start ' error if Pg3 overruns Pg4
    600 x 800 - 116K
    800 x 600 - 111K
    800 x 600 - 107K
  • BeanBean Posts: 8,129
    edited 2009-04-27 11:35
    Your posted program doesn't even have a RCTIME command in it ????
    Did you mean PULSIN ???

    PULSIN does have different timing in SX/B than on the Basic Stamp.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
Sign In or Register to comment.