Remote control by location (PIC in Oshonsoft)

Thread Starter

camerart

Joined Feb 25, 2013
3,831
hi,
You don't need a full program to test the transfer, create a short debug program.

Use a spare master/slave pair of PIC's and plug them into the PCB sockets, unless you are using solder in PIC's??

E
Hi E,
I've just remembered, that there already is a suitable program in the 18F4431 SLAVE.
You will recall writing an SPI exchange pair of programs for each PIC, which exchange SPI DATA. ERIC<>ABCD
This is still in the SLAVE, so anything sent from the MASTER will be sent back.

In the MASTER is an incremental COUNT routine. If the result of this is sent to the SLAVE, then after the initial ABCD is returned, then the SENT numbers are SENT back.

Here is the first result. NOTE: BYTEs are mixed with WORDS so there are errors, which I will try to fix next.
C
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Hi,
I watched the Mars Helicopter with interest. I wonder if they got any of their ideas from here, as this must be a similar system. There is no GPS on Mars, so I think they use a visual location system instead.
I wonder how long it took took make theirs in man hours compared to this:)
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Hi,
I'm copying sections of the test CODE, into the FULL CODE.
The first FULL test is the BMP280 Altimeter sensor.
Here is a Logic analyser view of the SPI from the BMP280, it show the CHIP SELECT high when it should be low.
Here is a view of a section of CODE where I think the error is, but not sure?

Has anyone any idea what may be happening, or what I can do to find out what's going on please?
C.
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Which pin is the altmtr_cs on the Pic?
Are you using SW- and HW Spi at the same Pic?
Hi J,
'BMP280 ALTIMETER
Symbol altmtr_cs = LATD.3 'BMP280 BAROMETER/TEMP
'BMP280 CALC
Dim data As String

I've never been 100% whether it is SW or HW, but I'm not using the Oshonsoft set-up, so I assume it's SW.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Hi,
The MASTER SLAVE SPI is working.
Here, I'm trying to READ the BMP280 Altimeter.
#964 shows a logic analyser READing, but I'm getting the same READing with the BMP20 unplugged.
Here is a logic READing + the Terminal view, if they are both the same DATA, then this is from the SLAVE, and I'm not READing the BMP280 at all.
C
 

Attachments

jjw

Joined Dec 24, 2013
823
Hi J,
'BMP280 ALTIMETER
Symbol altmtr_cs = LATD.3 'BMP280 BAROMETER/TEMP
'BMP280 CALC
Dim data As String

I've never been 100% whether it is SW or HW, but I'm not using the Oshonsoft set-up, so I assume it's SW.
C.
The program in #964 is using the Spi functions in Oshonsoft ( SW Spi)
I assumed that you want to use the Spi module in the Pic (HW Spi),
setup of the SPI, using SSPBUF etc?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,831
The program in #964 is using the Spi functions in Oshonsoft ( SW Spi)
I assumed that you want to use the Spi module in the Pic (HW Spi),
setup of the SPI, using SSPBUF etc?
Hi J,
I was stopped from posting example CODES.
I can see SPICSON/OFF which shouldn't be there, but I use the SSPBUF method normally.
I can kind of see errors, but they are foggy, so I'll have to look into it.
C
 

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Hi,
Here are two sections from the FULL CODE.
Can both sections be in the PROCESS Proc spi_wr_rd() , as one section WRITEs nd the other READs?

I think I have to slave_cs to a changeable VARIABLE so it isn't specific so that all peripherals can be READ WRITE. Is this correct?
C
 

Attachments

Last edited:

jjw

Joined Dec 24, 2013
823
Hi,

I think I have to slave_cs to a changeable VARIABLE so it isn't specific so that all peripherals can be READ WRITE. Is this correct?
C
You select each peripheral with a separate pin from the Pic before writing or reading, no need for a variable for the CS.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,831
You select each peripheral with a separate pin from the Pic before writing or reading, no need for a variable for the CS.
Hi J,
Ok, thanks.
I've added the JPG to #970 (I wasn't able to post the CODE any other way)
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Hi,
UPDATE:
Still trying to figure out how to get 'burst mode' correctly from the Ak8963C compass.
By trial and error, I think I'm almost there.

Here is an image showing part of the program, plus the digital analyser and terminal READings.
You may see patterns, which are a little out of sync.
When moving the compass 6x of the READings move, but I'm not sure quite which is which.
The WIA READ show 0x48 which is the ID of the Chip, so that's correct.

So, a few changes here and there, and I should have it going. How time flies:)
C.
 

Attachments

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Hi,
This is not a precise question, more of asking for a guess as to what's happening.


I'm trying to READ the AK8963 registers from WIA + 6xmeasurements.

Here is a section of CODE along with the registers from the D/S.

Using this HSEROUT READ: Hserout "REGISTER READ ", #b(0), " ", #b(2), " ", #b(3), " ", #b(4), " ", #b(8), " ", #b(9), " ", #b(10), CrLf

I get this result: see JPG

Why is it not 00, 03, 04, 05, 06, 07, 08?
C





Code:
compss_cs = 0  'CHIP SELECT COMPASS ON

    For i = 0 To 9  'READ WIA +6x registers
            rd_adr = 0x80 + i  '00=WRITE 80=READ
            WaitUs 1
            SSPBUF = rd_adr
            While Not SSPSTAT.BF
            Wend
            WaitUs 1
            SSPBUF = 0  'Dummy BYTE
            While Not SSPSTAT.BF
            Wend
            data = SSPBUF
            b(i) = data
    Next i
    
compss_cs = 1  'CHIP SELECT COMPASS OFF
        
    wia_raw = b(0)  'byte
    str_wia = #wia_raw  '??????????????
    info_raw = b(1)  'byte
    str_info = #info_raw  'INFO
    st1_raw = b(2)
    str_st1 = #st1_raw  'STATUS

    x_raw.LB = b(3)  'BYTE
    str_xlb = #x_raw.LB
    x_raw.HB = b(4)  'BYTE
    str_xhb = #x_raw.HB
    y_raw.LB = b(5)
    str_ylb = #y_raw.LB
    y_raw.HB = b(6)
    str_yhb = #y_raw.HB
    z_raw.LB = b(7)
    str_zlb = #z_raw.LB
    z_raw.HB = b(8)
    str_zhb = #z_raw.HB

    x_nc = x_raw  'SINGLE = WORD
    y_nc = y_raw
    z_nc = z_raw

    st_2_raw = b(9)  'byte
    cntl_1_raw = b(10)
    cntl_2_raw = b(11)
    astc_raw = b(12)

    i2c_dis_raw = b(15)  'i2c???????
    asax_raw = b(16)
    asay_raw = b(17)
    asaz_raw = b(18)
 

Attachments

jjw

Joined Dec 24, 2013
823
Hi,
This is not a precise question, more of asking for a guess as to what's happening.


I'm trying to READ the AK8963 registers from WIA + 6xmeasurements.

Here is a section of CODE along with the registers from the D/S.

Using this HSEROUT READ: Hserout "REGISTER READ ", #b(0), " ", #b(2), " ", #b(3), " ", #b(4), " ", #b(8), " ", #b(9), " ", #b(10), CrLf

I get this result: see JPG

Why is it not 00, 03, 04, 05, 06, 07, 08?
C





Code:
compss_cs = 0  'CHIP SELECT COMPASS ON

    For i = 0 To 9  'READ WIA +6x registers
            rd_adr = 0x80 + i  '00=WRITE 80=READ
            WaitUs 1
            SSPBUF = rd_adr
            While Not SSPSTAT.BF
            Wend
            WaitUs 1
            SSPBUF = 0  'Dummy BYTE
            While Not SSPSTAT.BF
            Wend
            data = SSPBUF
            b(i) = data
    Next i
   
compss_cs = 1  'CHIP SELECT COMPASS OFF
       
    wia_raw = b(0)  'byte
    str_wia = #wia_raw  '??????????????
    info_raw = b(1)  'byte
    str_info = #info_raw  'INFO
    st1_raw = b(2)
    str_st1 = #st1_raw  'STATUS

    x_raw.LB = b(3)  'BYTE
    str_xlb = #x_raw.LB
    x_raw.HB = b(4)  'BYTE
    str_xhb = #x_raw.HB
    y_raw.LB = b(5)
    str_ylb = #y_raw.LB
    y_raw.HB = b(6)
    str_yhb = #y_raw.HB
    z_raw.LB = b(7)
    str_zlb = #z_raw.LB
    z_raw.HB = b(8)
    str_zhb = #z_raw.HB

    x_nc = x_raw  'SINGLE = WORD
    y_nc = y_raw
    z_nc = z_raw

    st_2_raw = b(9)  'byte
    cntl_1_raw = b(10)
    cntl_2_raw = b(11)
    astc_raw = b(12)

    i2c_dis_raw = b(15)  'i2c???????
    asax_raw = b(16)
    asay_raw = b(17)
    asaz_raw = b(18)
Maybe I don't understand, but when you read the contents of the registers, why should they be 03 to 08?
These values are the addresses of the registers.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,831
Maybe I don't understand, but when you read the contents of the registers, why should they be 03 to 08?
These values are the addresses of the registers.
Hi J,
Perhaps I wasn't clear!
I'm trying to READ the 6x registers with the measurement DATA on. I would expect that when I READ 03 - 08, this would give the correct 6x READings. When I READ 02-03-04-08-09-10, this gives me the 6x changing READings, that I assume to be the 6x I need.
Is this clearer?
C.
 

jjw

Joined Dec 24, 2013
823
Hi J,
Perhaps I wasn't clear!
I'm trying to READ the 6x registers with the measurement DATA on. I would expect that when I READ 03 - 08, this would give the correct 6x READings. When I READ 02-03-04-08-09-10, this gives me the 6x changing READings, that I assume to be the 6x I need.
Is this clearer?
C.
X,Y,Z 16 bit words.
03 contains X low byte, 04 X high byte etc.
If you make correctly a function periph_rd()
you can do

X.lb = periph_rd ( 0x83 )
X.hb =periph_rd ( 0x84 )
Y.lb = periph_rd ( 0x85 }
etc...
Testing data ready might be needed.
2's complement conversion, when calculating the angles.
 
Top