Shop OBEX P1 Docs P2 Docs Learn Events
Decode RS232 compass string in BS2 — Parallax Forums

Decode RS232 compass string in BS2

AudunAudun Posts: 3
edited 2009-12-22 18:17 in BASIC Stamp
Hi,

I have a project where I want to import data from Honeywell HMR3000 compass module and add heading data in a variable in BS2.
HMR3000 sends an HPR string (heading, pitch, roll) on 9600baud 8N1.
Have tried to create a program code for this (see below)
I'm getting data in, but it seems pretty random what variable heading, pitch and roll data is stored.
I have no need for pitch and roll data, it is only heading data I need.

HMR string from Hyperterminal:

$PTNTHPR,289.1,N,0.1,N,-1.3,N*1D
$PTNTHPR,289.4,N,0.0,N,-1.1,N*33
$PTNTHPR,289.5,N,-0.1,N,-1.3,N*1C
·
Compass data serout to OSD video board in I/O 6
Compass data serin from HMR 3000 on I/O 8
·
osd··· CON·· 16572······· ········· ·'4800 baud serout string to OSD
n9600· CON·· 16468············· · ·'9600 baud serin compass
H····· VAR·· Word····················· · ·'variable for heading
HH···· VAR·· Word················· ···· 'variable for heading tenth
P····· VAR·· Word······················ · 'variable for Pitch
PP···· VAR·· Word······················· ·'variable for Pitch tenth
R····· VAR·· Word························ 'variable for Roll
RR···· VAR·· Word························· 'variable for Roll tenth
Preloop:
SEROUT 6,osd,[noparse][[/noparse]130]····················· ' clear screen OSD
PAUSE 500
SEROUT 6,osd,[noparse][[/noparse]133,1]··················· ' Background on OSD
SEROUT 6,osd,[noparse][[/noparse]128,1]
GOTO program
program:
SERIN 8,n9600,175,noHMR,[noparse][[/noparse]WAIT("HPR,"),DEC H, SKIP 1,DEC HH, SKIP 3, DEC P,SKIP 1,DEC PP, SKIP 3,DEC R, SKIP 1,DEC RR,SKIP 5]
GOSUB output1
GOTO program
output1:
SEROUT 6,osd,[noparse][[/noparse]129,2,1,"HEADING:"]
SEROUT 6,osd,[noparse][[/noparse]129,12,1,DEC3 H,".",DEC1 HH]
SEROUT 6,osd,[noparse][[/noparse]129,2,2,"PITCH:"]
SEROUT 6,osd,[noparse][[/noparse]129,14,2,DEC1 P,".",DEC1 PP]
SEROUT 6,osd,[noparse][[/noparse]129,2,3,"ROLL:"]
SEROUT 6,osd,[noparse][[/noparse]129,14,3,DEC1 R,".",DEC1 RR]
RETURN
noHMR:
SEROUT 6,osd,[noparse][[/noparse]129,14,8," NO HMR" ]
GOTO program

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-12-21 21:50
    You might try getting the whole line and parsing it after it's sent. The stamp is probably having trouble receiving and parsing the line at the same time.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • stamptrolstamptrol Posts: 1,731
    edited 2009-12-22 01:46
    I'd second Stephen's point. 4800 is about maximum for BS2 if any SERIN options are used.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • AudunAudun Posts: 3
    edited 2009-12-22 02:12
    Thanks for the info.
    I can change the baud rate to 4800 on the compass to try again.
    Is 4800baud max for Serine at all BS2 modules?
    It may be advantageous to use a BS2SX here?

    Does anyone know what the last 4 characters of the string from the compass means?
    Is this something to consider in this context?
  • FranklinFranklin Posts: 4,747
    edited 2009-12-22 03:00
    Page 10 of the manual talks about the output strings and should be of help.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • AudunAudun Posts: 3
    edited 2009-12-22 18:17
    Have changed baudrate to 4800, works fine now. Thanks

    -Audun
Sign In or Register to comment.