Remote control by location (PIC in Oshonsoft)

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
With RespecT
The Crlf has nothing to do with the MidStr command, you are only select 3 chars form the msg.
E
Hi E,
I follow, but I wanted you to check that the sentence being sent from the 18F4431 is acceptable, before going and farther.
I tried the example you gave and it produced this:

I wanted to make sure that I was on the right track.
C.
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,849
hi,
Drop the Case test sub routine, use the MidStr() ,the QEI will be a string variable,, when you have parsed it out convert to numeric if you intend doing maths on it.

ie: after parsing the QEI section, try nQEI = #QEI. ; dont forget to dim nQEI as a Word


E
 

jjw

Joined Dec 24, 2013
823
Hi E,
I follow, but I wanted you to check that the sentence being sent from the 18F4431 is acceptable, before going and farther.
I tried the example you gave and it produced this:

I wanted to make sure that I was on the right track.
C.
Hi
The syntax in the picture is wrong.
The correct is string1=Midstr( string2, n1, n2 )
which extracts n2 characters from string2 starting at position n1.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi
The syntax in the picture is wrong.
The correct is string1=Midstr( string2, n1, n2 )
which extracts n2 characters from string2 starting at position n1.
Hi E and J,

Firstly can I clarify what $SENTENCE is coming from the 18F4431.

Here is the QEI section from the program and a terminal view of the TX DATA signal.

Is this ok?

The use of 'n' numbers is a bit confusing, would it be possible to use the actual sentence words please?
C
----------------------------------------------------------------------------------------
get_count:

Toggle yled
WaitMs 300

qeideg.LB = CAP2BUFL
qeideg.HB = CAP2BUFH
While SSPBUF = 0
Wend
If SSPBUF = qeideglb Then
SSPBUF = qeideg.LB
Else
If SSPBUF = qeideghb Then
SSPBUF = qeideg.HB
Endif
Endif

Hserout "$QEIDEG", ",", #qeideg, ",", CrLf


Goto get_count
--------------------------------------------------------------------------------
 

Attachments

ericgibbs

Joined Jan 29, 2010
18,849
hi C,
I mistyped some info in an earlier post!:(
It should have read:

QEIDEG= MidStr(msg,9,3)
Where a typical String msg = $QEIDEG,123,?
So the QEIDEG value is a String = '123'

Do you follow OK.?
E.

It would be easier to follow if you chose a different 'name' for the variable eg: Deg= MidStr(msg,9,3)

eg: clip from your last post:
Hserout "$QEIDEG", ",", #qeideg, ",", CrLf
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
I mistyped some info in an earlier post!:(
It should have read:

QEIDEG= MidStr(msg,9,3)
Where a typical String msg = $QEIDEG,123,?
So the QEIDEG value is a String = '123'

Do you follow OK.?
E.

It would be easier to follow if you chose a different 'name' for the variable eg: Deg= MidStr(msg,9,3)

eg: clip from your last post:
Hserout "$QEIDEG", ",", #qeideg, ",", CrLf
Hi E,

I changed [ QEIDEG= MidStr(msg,9,3) ] to [ QEIDEG= MidStr(msg1,9,3)

This didn't produce anything for QEIDEG in the variables in SIM.
C
----------------------------------------------------------
get_valq: '$QEIDEG,???,?
Select Case csv 'COMMA POSITION VALUES
Case 2
QEIDEG = MidStr(msg1, 9, 3)
Case Else
EndSelect
msg1 = ""
Return
---------------------------------------------
 

ericgibbs

Joined Jan 29, 2010
18,849
hi C,
You should not use the Case Statement for testing just one comma value.

Use only a single line in your Code, no gosubs or returns required

QEIDEG = MidStr(msg1, 9, 3) ' assuming the msg1 = $QEIDEG,123,?

This will give a String value of QEIDEG

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
You should not use the Case Statement for testing just one comma value.

Use only a single line in your Code, no gosubs or returns required

QEIDEG = MidStr(msg1, 9, 3) ' assuming the msg1 = $QEIDEG,123,?

This will give a String value of QEIDEG

E
Hi E,
It didn't work, so I tried changing the numbers, and leftstr/rightstr, and saw numbers in the QEIDEG variable, but as before they dissapeared, ending with the '?'
I wonder if this section has anything to do with the problem? It chooses which of the $SENTENCES to Parse.
C.
-------------------------------------------------------------
csv = 0
For txi = 1 To rxin
char = str1(txi)
strchr = Chr(char)
If strchr <> "," Then
msg1 = msg1 + strchr
Else
csv = csv + 1
If str1(1) = "Q" Then
Gosub get_valq 'QEI4431
'SET DATASWITCH: 'C/S S0=L S1=L =TX4431, S0=H S1=L =HC-12, S0=L S1=H =GPS
dataswitch_S0 = 1 'Set to next in sequence: REMOTE
dataswitch_S1 = 0
rled = 1
yled = 0 'REMOTE
Endif
If str1(1) = "R" Then
Gosub get_valr 'REMOTE
dataswitch_S0 = 0 'Set to next in sequence: GPS
dataswitch_S1 = 1
rled = 0
yled = 1 'GPS
Endif
If str1(5) = "C" Then
Gosub get_valg 'GPS
dataswitch_S0 = 0 'Set to next in sequence QEIDEG 4431
dataswitch_S1 = 0
rled = 0 'QEIDEG
yled = 0
Endif
Endif
Next txi
-------------------------------------------------------------------------------------------
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
Back to the QEIDEG topic, try this Parsing1.bas program.

E
Hi E,
With this program the Hardware UART stops at'$' and LOOPs quickly around the two RED lines.
C.
----------------------------------------------------------------------
If msgflg = 1 Then 'intr has read the GPS msg into arrays
Disable High

Hserout "Incoming msg1= "

Hserout rxinp
Hserout CrLf, CrLf


Hserout "Parsed String= "
deg1 = MidStr(rxinp, 9, 3) 'get the degree part of the msg1
Hserout deg1, CrLf, CrLf

wdeg1 = StrValW(deg1) 'convert to word variable

Hserout "Numeric Degs= "
Hserout #wdeg1, CrLf

rxinp = ""
msgflg = 0

Enable High
Endif

Goto main
--------------------------------------------------------------------
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
I've been trying to get the DATA SWITCH to work, but So far I've failed :(

I tried a simple continuity test on the 2x dataswitch_S*, and found dataswitch_S0 shorted to GND.

Here is the bottom of the PCB showing the link, once cut it now works.

Here is a terminal view of the 18LF4620 RX PIN.
C
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
Back to the QEIDEG topic, try this Parsing1.bas program.

E
Hi E,
I tried [ Parsing1 ] but had difficulty transposing the varable, but I did get the QEIDEG to parse another way. I think I SENT the DECIMAL, then RECEIVED it.

I'm not getting 0 to 359 Degrees, but the 2x BYTES added together incorrectly. I'll come back to it later, as I'm testing the REMOTE signal/DATASWITCH.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
Show how you are trying to add the bytes.
E
Hi E,
This is a section from the 18F4431 BASE PIC. QEI READ
c
------------------------------------------------------------------------
get_count:

Toggle yled
WaitMs 300

qeideg.LB = CAP2BUFL
qeideg.HB = CAP2BUFH
While SSPBUF = 0
Wend
If SSPBUF = qeideglb Then
SSPBUF = qeideg.LB
Else
If SSPBUF = qeideghb Then
SSPBUF = qeideg.HB
Endif
Endif
WaitMs 10

'qeideg.LB = 100
'qeideg.HB = 1

'Hserout "QEIDEG.LB", ",", #qeideg.LB, ",", CrLf
'Hserout "QEIDEG.HB", ",", #qeideg.HB, ",", CrLf

Hserout "$QEIDEG", ",", #qeideg, ",", CrLf


Goto get_count
-------------------------------------------------------
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
Run this demo program, it shows how to use the convert.
E
Hi E,
I think I have it set to your suggestion, but it counts 0 to 359 4X in one revolution of the knob.
I remember that there is a setting in the D/S and old programs, to correct this, and I'm now checking.
Thanks,
C.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
I'm still trying to get [ $QEIDEG,123? ] to parse properly.

Here is the program: (Warning it takes a long time to simulate)

With the Hardware UART, Copy and past [ $QEIDEG,123? ] and it will report '123' (See variables)

In real life there is a DATASWITCH with 2x select inputs 'dataswitch_S0' and' dataswitch_S1' (See variables)
S0=0 S1=0 then input $QEIDEG,123?
S0=1 S1=0 then input $REMOTE,5,7,9,?
S0=0 S1=1 then input $GPRMC,123519,A,4807.038,N,01131.000,W,022.4,084.4,230394,003.1,W*6A?

If $GPRMC,123519,A,4807.038,N,01131.000,W,022.4,084.4,230394,003.1,W*6A? is first then $QEIDEG,123? adds digits.
Anyone know how to correct this please?
EDITED
C.
 

Attachments

Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
If anyone is trying the above simulation, you may also notice that: Gosub get_valq 'QEI4431 does not RETURN to Gosub get_valq 'QEI4431
Any ides what's happening, and how to correct it please.
C.
-----------------------------------------------------------------------------------------
For txi = 1 To rxin 'rxiCCCCCCC
char = str1(txi)
strchr = Chr(char)
If strchr <> "," Then
msg1 = msg1 + strchr
Else
csv = csv + 1
If str1(1) = "Q" Then
Gosub get_valq 'QEI4431
dataswitch_S0 = 1 'Set to next in sequence: REMOTE
dataswitch_S1 = 0
rled = 1
yled = 0 'REMOTE
Endif
If str1(1) = "R" Then
Gosub get_valr 'REMOTE
dataswitch_S0 = 0 'Set to next in sequence: GPS
dataswitch_S1 = 1
rled = 0
yled = 1 'GPS
Endif
If str1(5) = "C" Then
Gosub get_valg 'GPS
dataswitch_S0 = 0 'Set to next in sequence QEIDEG 4431
dataswitch_S1 = 0
rled = 0 'QEIDEG
yled = 0
Endif
Endif
Next txi
--------------------------------------------------------------------------------------------
 
Top