Shop OBEX P1 Docs P2 Docs Learn Events
Stamp not communicating through serial port — Parallax Forums

Stamp not communicating through serial port

I have a Stamp program that polls an Icom amateur radio through its CI-V port (TTL) and reads the operating frequency. When I connect the Stamp directly to the radio through an I/O port, it works just fine.

I now need the program to poll the radio through the serial port on the Stamp Board of Education - I use an RS-232 to TTL level converter to connect to the radio. I have tested the level converter, and it's working as it's supposed to.

I changed my SERIN and SEROUT commands to Pin 16 to use the serial port, but I'm not getting any results - it acts like there is no connection at all. I tried both True and Inverted baudmodes as well.

Maybe I need to do something else besides change the Pin - does anyone have a suggestion?

Thanks ...

Here's my code:

'============================================
' Poll Radio - Display Frequency

' {$STAMP BS2sx}
' {$PBASIC 2.5}

'>>> Seetron OLED display uses PIN 0 <<<

'=================Initialize Display =================
BaudModeInverted CON 16624 '9600, 8N1, Inverted - Seetron OLED
BaudModeTrue CON 240 '9600, 8N1, True
LCDserial CON 0 'Serial Output to Pin 0 for OLED

HIGH LCDserial 'Sets Pin 0 to high for output
PAUSE 100 'Waits for OLED to wake up
SEROUT LCDserial, BaudModeInverted, [$03] 'Sets font to default
SEROUT LCDserial, BaudModeInverted, [$0C] 'Clears screen - cursor top left (Form Feed)
PAUSE 5 'Pause 5ms after each Form Feed ($0C)
'=========================================================================

IcomOutput VAR Byte(11) '11-item array to hold data from radio

GOSUB Main 'Polls radio - gets and displays response

Main:
SEROUT 16, BaudModeTrue,[$FE, $FE, $80, $E0, $03, $FD] 'Request for Frequency (command $03)
'SEROUT 16, BaudModeInverted,[$FE, $FE, $80, $E0, $03, $FD] 'Request for Frequency (command $03)

SERIN 16, BaudModeTrue, [STR IcomOutput\11] 'Array to hold data from radio
'SERIN 16, BaudModeInverted, [STR IcomOutput\11] 'Array to hold data from radio
'Only array values 8, 7 and 6 are used to calculate MHz as an integer - no decimals

'=========================================================================
'Frequency calculations here - based on array values 8, 7 and 6:

Frequency VAR Word
IcomThousands VAR Byte
IcomHundreds VAR Byte
IcomOnes VAR Byte

IcomThousands = IcomOutput(8)
IcomHundreds = IcomOutput(7)
IcomOnes = IcomOutput(6)

'Multiplies digits and adds together for Frequency:
Frequency = (IcomThousands.NIB1 * 10000) + (IcomThousands.NIB0 * 1000) + (IcomHundreds.NIB1 * 100) + (IcomHundreds.NIB0 * 10) + IcomOnes.NIB1

'================================================================================================

SEROUT LCDserial, BaudModeInverted, ["Frequency: ", DEC Frequency] 'Displays Frequency
SEROUT LCDserial, BaudModeInverted, [$0D] 'Carriage Return
PAUSE 1000 'Wait one second between polls
SEROUT LCDserial, BaudModeInverted, [$0C] 'Clears screen - cursor top left (Form Feed)
PAUSE 5 'Pause 5ms after each Form Feed ($0C)

RETURN 'Return to Main program

Comments

  • The serial port on the Board of Education is not really RS-232. If you look at the schematic for the BOE and the BS2sx, you'll see how the transmit pin is driven by a 5V I/O pin and the data from the serial port is echoed back to the the PC (or radio). The 5V signal (inverted) may not be able to drive the RS-232 to TTL converter and the echoing may interfere with what your program (or the radio) expects. You're better off going back to using the direct I/O pins to radio TTL interface.
  • Mike:

    Many thanks - I didn't realize the port wasn't really RS-232. That is probably my problem. I've had success with a direct I/O connection, so I'll stick with that ...
Sign In or Register to comment.