Decode RS232 compass string in BS2
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
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
pdf
![](/plugins/FileUpload/images/file.png)
186K
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
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?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
-Audun