PDA

View Full Version : Dinsmore Compass sensor with Basic Stamp and Visual Basic contribution.



Jimbo30
02-25-2010, 08:28 AM
I just thought I would contribute a mini project of sorts.· If anyone in the future would like a general idea of how to communicate with a Dinsmore Digital Compass, BSII and Visual basic I have provided a successfully tested·experiment·at 200' of·RS-485.·

Basic Stamp code:

heading1·VAR Byte· 'Stores N,E,S,W
heading2·VAR Byte· 'Stores E and W for NE, NW, SE, SW
--------------------------------------------------------------------------
Main:
··· GOSUB compass·· 'Get compass readings
····High 14········· 'Set pin 14 high to set MAX485 IC to transmit
··· SEROUT 15, 16468, [heading1, heading2]· 'send info to slave VB6 GUI
··· PAUSE 2000
··· GOTO Main
----------------------------------------------------------------------------
compass:
· if in3 =0 then compassN
· if in1 =0 then compassS
· if in0 =0 then compassW
compassE:
· heading1 = "E"
· heading2 =· " "
· pause 210
· return
compassN:
· if in0 = 0 then compassNW
· if in2 =0 then compassNE
· heading1 = "N"
· heading2 = " "
· pause 210
· return
compassS:
· if in0 = 0 then compassSW
· if in2 = 0 then compassSE
· heading1 = "S"
· heading2 = " "
· pause 210
· return
compassW
··heading1 = "W"
· heading2 = " "
· pause 210
· return

compassNE
··heading1 = "N"
· heading2 = "E"
· pause 210
· return
compassNW
··heading1 = "N"
· heading2 = "W"
· pause 210
· return
compassSE
··heading1 = "S"
· heading2 = "E"
· pause 210
· return
compassSW
··heading1 = "S"
· heading2 = "W"
· pause 210
· return

-------------------------------------------------------------------
VB6 Code:· Please keep in mind this is RS485 and RS232 may need additional code.·

Furthermore, below is not all the code--just the important parts.


Form Load
Mscomm1.RTthreshold = 1·
Mscomm1.InputLen = 2
Mscomm1.Comport = 2
Mscomm1.settings = "9600,n,8,1
Mscomm1.Portopen = true
----------------------------------------------------------
private sub mscomm1_oncomm
dim heading1 As String·
dim heading2 As String

If Mscomm1.comevent = ComEvReceive THEN
·· heading1 = mscomm1.input
·· heading2 = mscomm1.input
labeldirection.caption = heading1 & heading2·· ' puts S,E,W,N, NE,NW,SE,SW in VB label
END IF



Post Edited (Jimbo30) : 2/25/2010 1:33:26 AM GMT