Shop OBEX P1 Docs P2 Docs Learn Events
SERIN on SIN — Parallax Forums

SERIN on SIN

J^3J^3 Posts: 121
edited 2009-05-11 19:33 in BASIC Stamp
Good Afternoon everyone,

I am trying to talk from one stamp on the PDB through the level shifter to another stamp on a seperate board through the programing port.· I can command the seperate board no problem using the debug window, but when I try to command it from the stamp on the PDB through the level shifter I get nothing.· I have scoped both transmissions; the timing and·levels ·of both transmissions are identical.· Any sugestions?
'File:Relay_Test_Slave
'Date:31MAR09
 
' {$STAMP BS2}
' {$PBASIC 2.5}
'-----Program Description---------------------------------------------------------------------

'-----Pin Declarations------------------------------------------------------------------------
'-----Variables-------------------------------------------------------------------------------
relay   VAR Byte
'-----Constants-------------------------------------------------------------------------------
Baud      CON $4054
'Baud      CON 84
TimeOut   CON 2000
Rx        CON 16
Tx        CON 16
'-----EEPROM Data-----------------------------------------------------------------------------

'-----Initialization--------------------------------------------------------------------------
OUTH = %00000000
DIRH = %11111111
'-----Program---------------------------------------------------------------------------------
Main:
DO
  SERIN Rx, Baud, TimeOut, Blink, [noparse][[/noparse]DEC4 relay]
  SEROUT Tx, Baud, [noparse][[/noparse]DEC5 relay]
  OUTH = ~relay
LOOP
'-----Subroutines-----------------------------------------------------------------------------
Blink:
    'OUTH = $10
    'PAUSE 200
    'OUTH = $00
    GOTO Main

'File:Relay_Test_Master
'Author:
'Date:
' {$STAMP BS2}
' {$PBASIC 2.5}
'-----Program Description---------------------------------------------------------------------
Rx  PIN 0
Tx  PIN 1
'-----Pin Declarations------------------------------------------------------------------------

'-----Variables-------------------------------------------------------------------------------
celsius VAR Word
relay   VAR Byte
repeat  VAR Word
'-----Constants-------------------------------------------------------------------------------
'Baud    CON $4054
Baud    CON 84
TimeOut CON 2000
EndL    CON 10
'-----EEPROM Data-----------------------------------------------------------------------------

'-----Initialization--------------------------------------------------------------------------
relay = 0
DIRL = %00000011
'-----Program---------------------------------------------------------------------------------
DO
  SEROUT Tx, Baud, [noparse][[/noparse]$35, CR]
  PAUSE 1000
LOOP


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
There are 10 types of people that understand binary, those who do, and those who don't.

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-05-08 23:35
    Your level shifter (if its an RS232 chip) is an inverter, and the programming port is another inverter. So your transmit and receive polarities have to be the same for your scheme to work. Set both baudrates to 84, and you should get communication.

    -Phil
  • J^3J^3 Posts: 121
    edited 2009-05-10 00:05
    Thanks for the·reply Phil,

    I believe I have already tried using 84 for both units and still nothing.· I will try again though to double check, and let you know.· Won't be until Monday though.· Thanks again.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people that understand binary, those who do, and those who don't.
  • J^3J^3 Posts: 121
    edited 2009-05-11 19:12
    No luck even with changing the baud.· Any other suggestions.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    There are 10 types of people that understand binary, those who do, and those who don't.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-11 19:33
    When you use port 16 for SERIN or SEROUT, the data is always inverted regardless of the Baud constant. Unless you have an odd number of inverters between the two Stamps, you'll need to use a Baud constant of 16468 on the master Stamp. You can use the same on the slave or you can use 84. It doesn't matter.
Sign In or Register to comment.