New to coding and need help making a simple code
pinkdolphin02
Posts: 13
in BASIC Stamp
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
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.
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.
DO
OUT14 = IN3
LOOP
Don't have any Stamps to try it myself.
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.
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.