Communication Propeller - Basic Stamp
Hi guys,
I need to communicate Propeller with Basic Stamp 2pe.
I was thinking about using 2 wires, one for data in and one for data out, but it didn't work. I also tried to put a 22k resistor in the pin of the BS2pe that I was using for receive data from the propeller, but it also didn't work.
I searched about it here in the forum, but I didn't find anything. I only found some threads about communication between 2 props or 2 BS.
Can anybody help me with it?
Thanks in advance!
Daniel Reis
I need to communicate Propeller with Basic Stamp 2pe.
I was thinking about using 2 wires, one for data in and one for data out, but it didn't work. I also tried to put a 22k resistor in the pin of the BS2pe that I was using for receive data from the propeller, but it also didn't work.
I searched about it here in the forum, but I didn't find anything. I only found some threads about communication between 2 props or 2 BS.
Can anybody help me with it?
Thanks in advance!
Daniel Reis

Comments
I tried to connect both without resistors, and in a common ground as you said, Jonny, but it didn't work.
I used the BS2_Functions OBJ from OBEX, and tried to use the following line, to make a test:
BS.serout_dec(tx, number, baudRate, polarity, bits)
I used 9600 baudRate, polarity inverted (0), 8 bits
In Basic Stamp, I used:
SERIN rx, baud, timeout, fail, [DEC rec]
baud = 16468, that is 9600, 8-bit, no parity, inverted
And when I try to run this, Basic Stamp can't receive anything from propeller.
Is there anything wrong with my code?
It should work ok.
-Martin
If you would post both codes used, It would make this a lot easier.
'
Its hard to tell witch is at fault if any, being one sided.
'
What is the BS2's full code?
'
This is very easy to do, You just need both Micro's on the same page!
I tested both sending data from propeller to basic stamp and from BS to propeller, and everything worked fine.
Thanks everyone for the help!
I just didn't understand why the communication from propeller to BS uses polarity inverted and from BS to propeller uses it non-inverted. What's the reason?
Propeller:
CON 'ClkFreq: 80 Mhz _XINFREQ = 5_000_000 'Adjust the frequency _CLKMODE = XTAL1 + PLL16X 'Adjust the frequency rx = 0 tx = 1 baudRate = 9600 polarity = 0 bits = 8 OBJ bs : "BS2_Functions" 'Basic Stamp 2 library VAR byte number PUB start BS.start(31, 30) number := 0 repeat BS.serout_dec(tx, number, baudRate, polarity, bits) 'send data to BS number++ waitcnt(clkfreq + cnt) '1 sec pauseBS:
' {$STAMP BS2pe} ' {$PBASIC 2.5} tx CON 0 rx CON 1 baud CON $4054 timeout CON 3000 number VAR Byte start: SERIN rx, baud, timeout, fail, [DEC number] 'receive from propeller DEBUG CR, "Test ok, received: ", DEC number 'show data received on screen GOTO start 'loop fail: DEBUG CR, "Test failed, nothing received", cr GOTO start 'loopNow, from BS to propeller:
Propeller:
CON 'ClkFreq: 80 Mhz _XINFREQ = 5_000_000 'Adjust the frequency _CLKMODE = XTAL1 + PLL16X 'Adjust the frequency rx = 0 tx = 1 baudRate = 9600 polarity = 1 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 pauseBS:
' {$STAMP BS2pe} ' {$PBASIC 2.5} tx CON 0 rx CON 1 baud CON $54 number VAR Byte number = 0 start: SEROUT tx, baud, [DEC number] 'send data to propeller PAUSE 1000 '1 sec pause number = number + 1 GOTO start 'loopI connected TX pin of propeller(0) in RX of BS(0) and RX of propeller(1) in TX of BS(1), without resistors or anything else. I'm also using the same ground for BS and propeller