Remote control by location (PIC in Oshonsoft)

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Hi,
I've been working with a mate, who has been adding more structure to the program, while I've been trouble shooting.
There have been lots of issues, and I wondered if any were caused my me making the PCBs. I'm up to PCB8, and hopefully somewhere near the final design of the board, so I decided to have them made professionally. II received them back yesterday.

Today I propagated the first board, then smoke tested it, 'no smoke'. I connected all of the peripherals in turn and they almost all worked, I think the issues are separate, and to be looked at later.

It was nice to work on the manufactured PCB, as this is my first time. Before when soldering in the PIN connectors, I had to slide the plastic separator to the other end, solder then one the bottom of the board, then solder the top of the board, then slide the plastic back, and this was problematic, and took some time, so lined holes are a luxury.

The incremental encoder compass is on the second PIC, and an SPI SLAVE, but the DATA is still sent via one of the tracks, which hasn't been changed from out of date programs, so this needs doing.

Next I've got to make one for my frined, and carry on developing.
Cheers, C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Hi,
UPDATE:
We are still plodding on, and at the moment working on the UART.

One of the clever additions to the program, approx 1 year ago was GUARDS, which manage timing of DATA, plus a switch between incoming DATA. 1x of the peripherals being switched is now on SPI, and I am investigation another one also, that may be SPI. This means that if I'm correct, only the RADIO control between BASE and REMOTE with need to be managed. Again, if I'm correct this will mean, much a faster and neater proram.
Cheers, C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Hi,
In SPI beteen 2x PIC does SLAVE have to mirror MASTER SEND/RECEIVE section e,g,
Here, s2m is first, then m2s in SLAVE, so is this the same order for the MASTER?

EDIT, ANSWER: I found earlier programs, and their convention is to: e,g, MASTER sends m2s first. SLAVE sends s2m first.

C.
SSPBUF = s2m
While slave4431_cs = 0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Hi,
Here are 2x programs, with results. Why aren't they exchanging BYTES?

For some reason, I'm not allowed to post the second Program? I've added only the MAIN LOOP from the MASTER
C.
Code:
MAIN:

m2s = 7

pic4431_cs = 0

    SSPBUF = m2s
    WaitUs 10  'wait  10us
    While Not SSPSTAT.BF  'If buffer empty do nothing
    Wend
    s2m = SSPBUF
    WaitUs 2
    
    Hserout "FROM MASTER=  ", m2s, CrLf  'Show DATA to SEND
    WaitMs 20  '10

    Hserout "FROM SLAVE=  ", s2m, CrLf  'show received data
    WaitMs 20  '10  'Must be >9

    Toggle rled  'tell the world something has happened
WaitMs 100

Goto MAIN

End
 

Attachments

Last edited:

jjw

Joined Dec 24, 2013
823
It hangs here:

SSPBUF = s2m 's2m = 8
While slave4431_cs = 0 <-------
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF 'm2s = 7
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
hi C,
Have you tried using the Tools/Oscilloscope to monitor the SPI data exchange.?
E
Hi E,
I use an analogue analyser for this kind of thing, and that would be next, soon.
Thanks, E.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,837
[IMG align="left" alt="djsfantasi"]https://secure.gravatar.com/avatar/695fccdba0690b3e2ae0a8be151b42f6?s=96[/IMG]

djsfantasi
Joined Apr 11, 2010 8,099
Wednesday at 11:20 PM

Note that in sagor’s reply, if A[ ] has a dimension of 10, it’s last element is A[9]. This can be confusing. Remember that when an array is used, it’s indices always start at 0. Thus, for n (eg 10) elements, the last element will always be n-1 (eg 9). Also remember that the first element will always be A[0].
Hi D,
To clarify: Is this correct? an array counts upwards from '0' to (X)
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Hi,
I'm trying ARRAYS and so far got the first of an ARRAY to work s2m(1), but how do I get the second part s2m(2) to work?
C
Code:
main:

'QEIDEG.LB = 0x08
'qeideg.HB = 9
's2m = qeideg.LB
s2m(1) = 8
s2m(2) = 9

's2m = 8

SSPBUF = s2m(1)  's2m  's2m = 8
While slave4431_cs = 1  'Waiting till CS goes ON =0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF  'm2s = 7



SSPBUF = s2m(2)  's2m  's2m = 8
While slave4431_cs = 1  'Waiting till CS goes ON =0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF  'm2s = 7


Toggle yled
WaitMs 100

Goto main
 

sagor

Joined Mar 10, 2019
1,050
Hi,
I'm trying ARRAYS and so far got the first of an ARRAY to work s2m(1), but how do I get the second part s2m(2) to work?
C
Code:
main:

'QEIDEG.LB = 0x08
'qeideg.HB = 9
's2m = qeideg.LB
s2m(1) = 8
s2m(2) = 9

's2m = 8

SSPBUF = s2m(1)  's2m  's2m = 8
While slave4431_cs = 1  'Waiting till CS goes ON =0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF  'm2s = 7



SSPBUF = s2m(2)  's2m  's2m = 8
While slave4431_cs = 1  'Waiting till CS goes ON =0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF  'm2s = 7


Toggle yled
WaitMs 100

Goto main
How is S2M declared? Your previous listing (post #1087) only showed declaring it as a byte, not as a byte array.
You cannot have an array unless you declare it with the DIM statement like: (example of 10 byte array)
Dim s2m(10) As Byte
And remember the first byte is s2m(0)
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
How is S2M declared? Your previous listing (post #1087) only showed declaring it as a byte, not as a byte array.
You cannot have an array unless you declare it with the DIM statement like: (example of 10 byte array)
Dim s2m(10) As Byte
And remember the first byte is s2m(0)
Hi S,
s2m is declared: [ DIM s2m(2) as BYTE ] I did this this morning, and for testing, I'm only using 2 BYTES.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
Then S2M has only two pointers, S2M(0) and S2M(1). There is no S2M(2)
Hi S,
Yes, I now realise '0' is the first one.

When I test I try all sorts of combinations e,g, below.

So far I haven't seen [ 9 ]

NOTE: Commented out sections.
C
Code:
main:

s2m(0) = 8
s2m(1) = 9

SSPBUF = s2m(0)  's2m = 8
While slave4431_cs = 1  'Waiting till CS goes ON =0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF  'm2s = 7

SSPBUF = s2m(1)   's2m = 8
While slave4431_cs = 1  'Waiting till CS goes ON =0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF  'm2s = 7

Toggle yled
WaitMs 100

=====================================================
main:

s2m(0) = 8
s2m(1) = 9

'SSPBUF = s2m(0)  's2m = 8
'While slave4431_cs = 1  'Waiting till CS goes ON =0
'Wend
'While Not SSPSTAT.BF
'Wend
'm2s = SSPBUF  'm2s = 7

SSPBUF = s2m(1)   's2m = 9
While slave4431_cs = 1  'Waiting till CS goes ON =0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF  'm2s = 7

Toggle yled
WaitMs 100

==============================================================
main:

s2m(0) = 8
s2m(1) = 9

SSPBUF = s2m(1)   's2m = 9
While slave4431_cs = 1  'Waiting till CS goes ON =0
Wend
While Not SSPSTAT.BF
Wend
m2s = SSPBUF  'm2s = 7

Toggle yled
WaitMs 100
 

sagor

Joined Mar 10, 2019
1,050
First "main" will overwrite m2s with second value, first response will be lost...
I don't see the difference between the next two "main" code sections, both are sending s2m(1)
 

Thread Starter

camerart

Joined Feb 25, 2013
3,837
First "main" will overwrite m2s with second value, first response will be lost...
I don't see the difference between the next two "main" code sections, both are sending s2m(1)
Hi S,
Because I don't know how to do it, in order to see the result =9 I try all sorts of combinations. This is why things look similar.

All of these 'MAIN' sections are from the SLAVE. The MASTER should receive 8 and 9 from S2M in the SLAVE and output them to a terminal screen on the computer. With all of the combinations, I've tried, I have not seen 9 yet.
C
 

Attachments

jjw

Joined Dec 24, 2013
823
Hi S,
Because I don't know how to do it, in order to see the result =9 I try all sorts of combinations. This is why things look similar.

All of these 'MAIN' sections are from the SLAVE. The MASTER should receive 8 and 9 from S2M in the SLAVE and output them to a terminal screen on the computer. With all of the combinations, I've tried, I have not seen 9 yet.
C
s2m should be an array of bytes, not words as it is now.
 
Top