No Luck With CMPS14 Module

John Todd

Member
#picaxe 08m2
#terminal 4800
#no_data
main:
for b1=1 to 2
sertxd ("the value of b1 is ",#b1,13,10);Terminal
b1=b1+1
next b1
;#Picaxe 08M2
#Terminal 4800

; --CMPS14 COMPASS CONNECTIONS----
;CMPS14 Power Supply is 3.6V
;CMPS14 MODE PIN is Connected to 0V to Enable Serial Data Transfer
Symbol TX_PIN = C.1 ;Used to send Carriage Return to Initiate CMPS14 Bearing
;Connected to CMPS14 RX PIN]
Symbol RX_PIN = C.2; ;Connected to CMPS14 TX PIN]
Symbol DO_PIN = C.4; SerOut Compass Data
;----------------------------------------------------------------------
Symbol direction = w1 ; b3:b2
Symbol dir.lsb = b2
Symbol dir.msb = b3
;-------------------------------------------------------------------------
Do
High TX_PIN
SetFreq M32
Pause 100
SerOut TX_PIN, T9600_32, ( $13 );Send Carriage RETURN to Initiate 16Bit tCompass sample

SerIn RX_PIN, T9600_32, dir.msb, dir.lsb;CMPS14 Receive 16Bit "HIGH BYTE" FIRST Data

SetFreq MDEFAULT
Pause 100
;----------------------------------------------------------------------
;Change this section to use serout for bearing data
SerOut DO_PIN, n4800_8,(#dir.msb,dir.lsb);Send Output @ 4800,8,n,1to OPEN LOG
;-----------------------------------------------------------------------
SerTxd( "Direction=", #direction, CR, LF );Terminal
;-----------------------------------------------------
Pause 1000
Loop
; Many Thanks to "inglewoodpete" and others for your HELP!!
;Notes:-
;I am trying to get the CMPS14 MODULE to send bearing data to an OpenLog @ 4800,8,n,1
;I am old and NOT experienced enough to find faults, I have read the manuals many times?
;CMPS14 and PicAxe
;I am getting No Response in terminal window
Thanks,JOHN
 

Aries

New Member
One obvious thing is that you are sending $13 (= 19 decimal) to the CMPS14, which is "Device control character 3". Carriage return is decimal 13.

When you say you get nothing in the terminal window, does that include the statement at the beginning (The value of b1 is 1")?
Also, I don't think you want to increment b1 within the loop as well as using it as the loop counmter.
 

hippy

Technical Support
Staff member
One obvious thing is that you are sending $13 (= 19 decimal) to the CMPS14, which is "Device control character 3". Carriage return is decimal 13.
The $13 seems to be correct with respect to what should be sent according to the datasheet; "0x13 Get Bearing 16 bit". It is describing it as "send carriage return" in the code comment which is not correct. The code seems to be based on my suggestion in the related thread -

https://picaxeforum.co.uk/threads/compass-interface.31617/#post-328135

The most likely reasons for no output is nothing is being received so SERIN hangs forever. The following version of the earlier code provides better debugging diagnostics -
Code:
#Picaxe 08M2
#Terminal 4800
#No_Data

Symbol TX_PIN    = C.1
Symbol RX_PIN    = C.2

Symbol direction = w1 ; b3:b2
Symbol dir.lsb   = b2
Symbol dir.msb   = b3 

PowerOnReset:
  Pause 2000
  SerTxd( "Started", CR, LF )

MainLoop:
  Do
    High TX_PIN
    SetFreq M32
    Pause 100
    SerOut TX_PIN, T9600_32, ( $13 )
    SerIn [16000,Timedout], RX_PIN, T9600_32, dir.msb, dir.lsb
    SetFreq MDEFAULT
    Pause 100
    SerTxd( "Direction=", #direction, CR, LF )
    Pause 1000
  Loop

Timedout:
  SetFreq MDEFAULT
  Pause 100
  SerTxd( "Timed out", CR, LF )
  Goto MainLoop
 
Top