Shop OBEX P1 Docs P2 Docs Learn Events
So i need a little help — Parallax Forums

So i need a little help

worthyamherstworthyamherst Posts: 46
edited 2011-07-07 12:19 in Propeller 1
Im working with the discontinued tranceiver receiver pair, one on a basic stamp and the other on a propeller board. For the stamp im simply using the sample code for the transmitter given, but im have a hard time getting the transmitter to sync with the receiver.

This si the sample code for the transmitter:
' -----[ I/O Definitions ]-------------------------------------------------
Tx PIN 1 ' Transmitter (27981)DATA pin
' -----[ Constants ]-------------------------------------------------------
EOM CON 255 ' Value to signal end-of-message
#SELECT $STAMP ' Select Baud constants
#CASE BS2, BS2E, BS2PE
T1200 CON 813
T2400 CON 396
T4800 CON 188
T9600 CON 84
T19K2 CON 32
#CASE BS2SX, BS2P
T1200 CON 2063
T2400 CON 1021
T4800 CON 500
T9600 CON 240
T19K2 CON 110
#CASE BS2PX
T1200 CON 3313
T2400 CON 1646
T4800 CON 813
T9600 CON 396
T19K2 CON 188
#ENDSELECT
Inverted CON $4000 'Value for inverted serial format
Baud CON T9600+inverted '9600 baud, 8,N,1 inverted
' -----[ Variables ]-------------------------------------------------------
string VAR Byte(16) 'Array to hold received data
idx VAR Word 'Index into message data
StrLen VAR Byte 'Length of string received
char VAR Byte 'Current character from message
cValue VAR Byte 'Holder for CRC calculation
crc VAR Word 'Calculate Crc value
' -----[ EEPROM Data ]-----------------------------------------------------
Message DATA "Parallax produces our own RF modules from products made by"
DATA " the wireless module leader, Linx Technologies.", CR
DATA "The Parallax RF modules provide a very easy and low-cost"
DATA " method of sending data between microcontrollers", CR
DATA "from 500 ft+ line-of-sight (depending on conditions).", CR
DATA "This device can be connected to a PC serial port using a"
DATA " MAX232 line driver.", CR
DATA "The circuit isn't supported by Parallax, but it's possible"
DATA " to make this connection with a few dollars of parts.", CR
DATA EOM
' -----[ Initialization ]--------------------------------------------------
 
' -----[ Program Code ]----------------------------------------------------
LOW Tx 'Initialize transceiver interface
DO
idx = Message 'Point idx to start of message data
DO
strLen = 0 'Set string length to zero
crc = 0 'Start Crc at zero
DO
strLen = strLen + 1
READ idx, char 'Read a character from message data
idx = idx + 1 'Point to next character in message
string(strLen-1) = char 'Put character into string array
cValue = char 'Prepare to add char to Crc value
GOSUB CalcCRC 'Add cValue to Crc value
IF (strLen = 15) OR (char = EOM) THEN EXIT 'Exit loop when ready
LOOP 'Keep reading message characters
' Send packet
PULSOUT Tx,9600 'Send sync pulse to radio
' Send preample "UUUU!", string length, string data, crc
SEROUT Tx, Baud, ["Hello World!", strLen, STR string\strLen,
crc.LOWBYTE, crc.HIGHBYTE]
PAUSE 100 'Give receiver time to process
LOOP WHILE char <> EOM 'Keep sending until EOM character
LOOP 'Start all over at the beginning
 
' -----[ Subroutines ]-----------------------------------------------------
' CRC Checksum Calculation Routine
CalcCRC:
CValue= crc.HIGHBYTE ^ cValue >> 4 ^ (crc.HIGHBYTE ^ cValue)
crc = cValue ^ (cValue << 5) ^ (cValue << 12) ^ (crc << 8)
RETURN



~~~~~~~~~~~~~~~~~


the coding im using on the propeller for the receiver is:
CON
'ClkFreq: 80 Mhz
_XINFREQ = 5_000_000 'Adjust the frequency 
_CLKMODE = XTAL1 + PLL16X 'Adjust the frequency
rx = 0
baudRate = 2400
polarity = 0
bits = 8
OBJ
bs : "BS2_Functions" 'Basic Stamp 2 library
VAR
byte number 
PUB start
BS.start(31, 30)
repeat
number := BS.serin_char(rx, baudRate, polarity, bits) 'receive from BS; Tried to use "BS.serin_dec", but didn't work
BS.serout_char(30, number, baudRate, 1, 8) 'show data received on screen
waitcnt(clkfreq/2 + cnt) '0.5 sec pause

So, any suggestions or hints or programming fixing, becaus eim currently only picking up static on the receiver

Comments

Sign In or Register to comment.