Shop OBEX P1 Docs P2 Docs Learn Events
New to coding and need help making a simple code — Parallax Forums

New to coding and need help making a simple code

Hey, so I'm working on my research project and I am trying to make a simple code. I have a 555 timer set up to input a signal into the Basic Stamp, and then output the same signal to a different pin. I want the simplest and fast code to do that. I need to measure the smallest time delay possible for the basic stamp to then compare for more complex programs. I just don't know how to code that. Any help will be much appreciated. I have already tried an IF THEN ELSE loop but that seems to be taking way too long for the processor. the time delay for the input signal to the output signal ranges from 160-650 microseconds which is way to slower for what this processor can do for such a short code.

Comments

  • Which Basic Stamp? Could you please post what you have written so far?
  • Several hundred microseconds is indeed the sort of time required to copy a signal from one pin to another with a Basic Stamp. Here's a link to some discussion of Basic Stamp execution times. For something like:

    loopIt:
    out5 = in3
    goto loopIt

    figure about 700us.

    Remember that the Basic bytecodes are stored in a serial (I2C) EEPROM and read and interpreted by an interpreter written in PIC assembly.

    If you need higher speed, consider using a Propeller. If you're constrained to use a Basic Stamp, try one of the faster models like the BS2px. The above link does discuss the speed of some of the faster models.
  • Its the BS2 Rev J Basic Stamp, it's green. The code I have written so far is as follows:

    DO

    IF (IN3 = 1) THEN

    HIGH 14

    ELSE

    LOW 14

    ENDIF

    LOOP

    Thank you for the link as well. Im glad to hear that my timing is correct but still surprised at how slow it is for a microprocessor, usually they are pretty fast.
  • kwinnkwinn Posts: 8,697
    Have you tried:

    DO
    OUT14 = IN3
    LOOP

    Don't have any Stamps to try it myself.
  • If you do as Mike and Kwinn suggested, the code will also need to have the DIRection set for the pin you want to be an output.
    DIR14 = 1  ' set p14 as an output
    DO
      OUT14 = IN3   ' make it follow IN3
    LOOP
    

    All the pins initially default to input. A command like HIGH 14 both sets the direction and the state, but OUT14 only defines the state of the output register. The output takes effect only if the corresponding direction register bit is also set to 1.

    The BS2 is executing interpreter instructions at 5mHz, but the it has to read the instruction tokens out of the relatively slow eeprom and then jumps to code that actually does the work. Very roundabout, but very convenient. Good for lots of things that happen in the blink of an eye but not faster.
  • Awesome thank you so much!!
    I will give it a try and check out the time delay on it and see if it is faster or slower than the original one I have made.
Sign In or Register to comment.