Yeah but will the stamp actually read serial data down to that low baud rate? I tried communicating with something of that baud but all i got was a Zero, and a bunch of 1's.
If the baud rates match, AND the BS2 enters the "SERIN" BEFORE the 'sending' device starts sending, then yes it really will go that slow.
Now, you do have to run a ground wire, as well as the serial wire. And I don't know what device you have that actually talks at 160 baud -- that's a weird rate.
Usual rates are 50, 110, 300, 600, 1200 (VERY common), 2400, 4800, 9600 (1 mSec per byte, also common), 19200, 38400.
You may have to add 16384 to the value, to set the "inverted" flag, depending on if you have a Max232 in the circuit or not.
Post Edited (allanlane5) : 4/30/2008 8:27:00 PM GMT
Does the input to the stamp need to bo RS-232 or can it be TTL? I am trying to interface my stamp to the ALDL port on my car (thats where the weird baud of 160 came from) and i cant quite figure it out.
If you stick a 22 Kohm resistor in series (from the car to the I/O pin) it won't matter. The BS2 has "clipping" diodes on it, which will 'clip' a signal to 0 to +5, as long as you limit the current with something like the 22 Kohm resistor. If the signal is already 0 to +5 volts, it will still work.
I still cant get this stupid thing to work. maybe the problem is in my code(I will post it), it is probably all screwed up. i dont know why it is coming up with all ones though. i guess im not much of a programmer
'{$STAMP BS2}
'{$PBASIC 2.5}
A···· VAR···· Word
B···· VAR···· Bit
FOR A = 0 TO 161 ··· IF A = 161 THEN ····· END ··· ENDIF ··· SERIN 8, 14422, [noparse][[/noparse]B] ··· WRITE A, B ··· DEBUG DEC B · NEXT
END
you are right that would be kinda stupid wouldnt it. i knew there was stupid stuff wrong with my code like that. so what i am trying to read is 20 words containing 7 bits of data and store it in the eeprom. what do i need to do in my program to make that work correctly.
You don't need a conditional..... ··· IF A = 161 THEN ····· END ··· ENDIF
to check the loop as it will branch out when it comes to the end of the loop. If you wanted to branch out early then a conditional would be needed.
Comments
BS2, BS2e, and BS2pe = INT(1,000,000
Now, you do have to run a ground wire, as well as the serial wire. And I don't know what device you have that actually talks at 160 baud -- that's a weird rate.
Usual rates are 50, 110, 300, 600, 1200 (VERY common), 2400, 4800, 9600 (1 mSec per byte, also common), 19200, 38400.
You may have to add 16384 to the value, to set the "inverted" flag, depending on if you have a Max232 in the circuit or not.
Post Edited (allanlane5) : 4/30/2008 8:27:00 PM GMT
'{$STAMP BS2}
'{$PBASIC 2.5}
A···· VAR···· Word
B···· VAR···· Bit
FOR A = 0 TO 161
··· IF A = 161 THEN
····· END
··· ENDIF
··· SERIN 8, 14422, [noparse][[/noparse]B]
··· WRITE A, B
··· DEBUG DEC B
· NEXT
END
MyBuf BYTE(20)
SERIN <SerPin>, <baudmode>, [noparse][[/noparse]STR MyBuf\20]
Something like that. This will take 20 of your available 26 bytes of RAM, but you only need it for a little bit.
··· IF A = 161 THEN
····· END
··· ENDIF
to check the loop as it will branch out when it comes to the end of the loop. If you wanted to branch out early then a conditional would be needed.