Interfacing with an VN100 (INS/AHRS SENSOR)

Posts: 19
Joined: Mon Feb 28, 2011 5:00 am

Interfacing with an VN100 (INS/AHRS SENSOR)

Postby ismaeelbit » Wed May 11, 2011 5:44 am

Dear Lubin,
Am working on Interfacing an INS/AHRS sensor with PIC24FJ126GA010 ON EXPLORER 16 board using SPI. The datasheet of the sensor is hereby attached.
I already examined your example with respect to ADIS16100 rate gyro, I am trying to follow this example to communicate with this sensor
developmental board VN100.pdf
(2.21 MiB) Downloaded 280 times
but I dont know how you get the read command input to SPI and how to apply same to this sensor.

I really need your assistance on this sensor.
(1.18 MiB) Downloaded 269 times
(1.41 MiB) Downloaded 212 times

Posts: 19
Joined: Mon Feb 28, 2011 5:00 am

Re: Interfacing with an VN100 (INS/AHRS SENSOR)

Postby ismaeelbit » Mon Jun 13, 2011 12:05 pm

Hi Lubin,
I was able to compile a model for interfacing with an IMU sensor VN100 after series of debugging of the c-programme been used. However, when program the chip, it does not work.
No error in compiling

Code: Select all

### Starting Real-Time Workshop build procedure for model: UAV_VN1002b
### Generating code into build directory: D:\EMBEDDED WORKS\BUILD CODES\UAV_VN1002b_dspic\sources
Warning: The file containing block diagram 'sensorMCUSlugsMKII' is shadowed by a file of the same name
higher on the MATLAB path. This can cause unexpected behaviour.  For more information see "Avoiding
Problems with Shadowed Files" in the Simulink documentation.
PT### Invoking Target Language Compiler on UAV_VN1002b.rtw
   D:\EMBEDDED WORKS\BUILD CODES\UAV_VN1002b_dspic\sources\UAV_VN1002b.rtw
   C:\Documents and Settings\Admin\My Documents\MATLAB\install_dsPIC_R2007b_PhD_Ismaeel_Tijani_Shahril_Pawanchee_Malaysia (1)\dspic\dspic.tlc
   -OD:\EMBEDDED WORKS\BUILD CODES\UAV_VN1002b_dspic\sources
   -IC:\Documents and Settings\Admin\My Documents\MATLAB\install_dsPIC_R2007b_PhD_Ismaeel_Tijani_Shahril_Pawanchee_Malaysia (1)\dspic
   -IC:\Documents and Settings\Admin\My Documents\MATLAB\install_dsPIC_R2007b_PhD_Ismaeel_Tijani_Shahril_Pawanchee_Malaysia (1)\blocks
   -ID:\EMBEDDED WORKS\BUILD CODES\UAV_VN1002b_dspic\sources\tlc
   -IC:\Program Files\MATLAB\R2007b\rtw\c\tlc\mw
   -IC:\Program Files\MATLAB\R2007b\rtw\c\tlc\lib
   -IC:\Program Files\MATLAB\R2007b\rtw\c\tlc\blocks
   -IC:\Program Files\MATLAB\R2007b\rtw\c\tlc\fixpt
   -IC:\Program Files\MATLAB\R2007b\stateflow\c\tlc
   -aOPTIM_GCC="-mcpu=24fJ128GA010 -O3 -fschedule-insns -fschedule-insns2"
   -aLDFLAGS=" -Xlinker -t -Xlinker --report-mem -Xlinker -Map=../ -Xlinker --heap=0 -Xlinker -cref"
   -aLDPICTYPE=" -Xlinker --script=C:\PROGRA~1\MICROC~1\MPLABC~2\support\PIC24F\gld\p24fJ128GA010.gld"
   -aLDLIBPIC=" C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libpic30-coff.a C:\PROGRA~1\MICROC~1\MPLABC~2\lib\PIC24F\libpPIC24Fxxx-coff.a C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libc-coff.a C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libm-coff.a"

### Loading TLC function libraries

Warning:  The data type "ufix1" uses a word size that is not available on the intended target. 
    Fixed-point signals using this data type will be put inside a larger word.  When used,
extra software will be generated to force this larger word to emulate a smaller
word.  This emulation is helpful when your prototype target and your final
production target are not the same.  If the smaller word size does NOT exist
on the final production target, then consider increasing the word size to
one that is supported.

### Initial pass through model to cache user defined code
### Caching model source code
### Writing main
--- Multi Rate & Single Tasking implementation
### Writing header file UAV_VN1002b_types.h
### Writing header file UAV_VN1002b.h
### Writing source file UAV_VN1002b.c
### Writing header file UAV_VN1002b_private.h
### Writing header file autobuild.h
### Writing source file UAV_VN1002b_main.c
### TLC code generation complete.
### Evaluating PostCodeGenCommand specified in the model

Embedded Coder for dsPIC V3.5b(29-May-2011) for Matlab R2007b.

Licence Accorded to  Ismaeel Tijani
                     Faculty of Engineering
                     Intelligent Mechatronics Research Unit (IMRU)
                     Mechatronics Engineering Department
                     Faculty of Engineering,IIUM,KUALA LUMPUR

 Facturation to :    Shahril Pawanchee
                     Managing Director
                     WNF Resources Sdn Bhd
                     Kuala Lumpur, MALAYSIA
                     Tel: +603 6187 3179 Fax: +603 4147 3179

Check updates and new informations at :

### Processing Template Makefile: C:\Documents and Settings\Admin\My Documents\MATLAB\install_dsPIC_R2007b_PhD_Ismaeel_Tijani_Shahril_Pawanchee_Malaysia (1)\dspic\dspic_pic30_gcc.tmf
-- Bypassing matlab internal LCC configuration --
### which is generated from C:\Documents and Settings\Admin\My Documents\MATLAB\install_dsPIC_R2007b_PhD_Ismaeel_Tijani_Shahril_Pawanchee_Malaysia (1)\dspic\dspic_pic30_gcc.tmf is up to date
''pic30-gcc  -c -mcpu=24fJ128GA010 -O3 -fschedule-insns -fschedule-insns2    -O   -I. -I..\.. -IC:\PROGRA~1\MATLAB\R2007b/simulink/include -IC:\PROGRA~1\MATLAB\R2007b/extern/include -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src/ext_mode/common -ID:\EMBEDD~1\BUILDC~1\UAV_VN~2\sources -ID:\EMBEDD~1\BUILDC~1 -IC:\PROGRA~1\MATLAB\R2007b\rtw\c\libsrc   -I C:\PROGRA~1\MICROC~1\MPLABC~2\include    UAV_VN1002b_main.c
''pic30-gcc  -c -mcpu=24fJ128GA010 -O3 -fschedule-insns -fschedule-insns2    -O   -I. -I..\.. -IC:\PROGRA~1\MATLAB\R2007b/simulink/include -IC:\PROGRA~1\MATLAB\R2007b/extern/include -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src/ext_mode/common -ID:\EMBEDD~1\BUILDC~1\UAV_VN~2\sources -ID:\EMBEDD~1\BUILDC~1 -IC:\PROGRA~1\MATLAB\R2007b\rtw\c\libsrc   -I C:\PROGRA~1\MICROC~1\MPLABC~2\include    dsPIC_Multiplexed_out_UART2.c
''pic30-gcc  -c -mcpu=24fJ128GA010 -O3 -fschedule-insns -fschedule-insns2    -O   -I. -I..\.. -IC:\PROGRA~1\MATLAB\R2007b/simulink/include -IC:\PROGRA~1\MATLAB\R2007b/extern/include -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src/ext_mode/common -ID:\EMBEDD~1\BUILDC~1\UAV_VN~2\sources -ID:\EMBEDD~1\BUILDC~1 -IC:\PROGRA~1\MATLAB\R2007b\rtw\c\libsrc   -I C:\PROGRA~1\MICROC~1\MPLABC~2\include    dsPIC_UART2_Interrupt.c
''pic30-gcc  -c -mcpu=24fJ128GA010 -O3 -fschedule-insns -fschedule-insns2    -O   -I. -I..\.. -IC:\PROGRA~1\MATLAB\R2007b/simulink/include -IC:\PROGRA~1\MATLAB\R2007b/extern/include -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/ert -IC:\PROGRA~1\MATLAB\R2007b/rtw/c/src/ext_mode/common -ID:\EMBEDD~1\BUILDC~1\UAV_VN~2\sources -ID:\EMBEDD~1\BUILDC~1 -IC:\PROGRA~1\MATLAB\R2007b\rtw\c\libsrc   -I C:\PROGRA~1\MICROC~1\MPLABC~2\include    UAV_VN1002b.c
" ================================================================"
"*** Embedded Target for dsPIC by Lubin KERHUEL -"
" | Licence Accorded to Ismaeel Tijani                           |"
" |                                |"        
" |          Companie : Faculty of Engineering                   |" 
" |                     Intelligent Mechatronics Research Unit (IMRU)|"
" |                     Mechatronics Engineering Department      |"       
" |                     Faculty of Engineering,IIUM,KUALA LUMPUR |"
" |                     50728,MALAYSIA                           |"             
" | Financial Service : Shahril Pawanchee                        |"
" | Contact                        |"
" |                     Managing Director                        |"
" |                     WNF Resources Sdn Bhd                    |"
" |                     Kuala Lumpur, MALAYSIA                   |"
" |                     Tel: +603 6187 3179 Fax: +603 4147 3179  |"
" | Version 3.5b                              29-May-2011        |"
" | For Matlab 7.5             R2007b                            |"
" ================================================================"   
''pic30-gcc   -mcpu=24fJ128GA010  UAV_VN1002b_main.o VN100.o VN_lib.o VN_math.o VN_user.o dsPIC_Multiplexed_out_UART2.o dsPIC_UART2_Interrupt.o imu.o UAV_VN1002b.o     rtwlib.a  C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libpic30-coff.a C:\PROGRA~1\MICROC~1\MPLABC~2\lib\PIC24F\libpPIC24Fxxx-coff.a C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libc-coff.a C:\PROGRA~1\MICROC~1\MPLABC~2\lib\libm-coff.a -o ..\../UAV_VN1002b.cof -Xlinker --script=C:\PROGRA~1\MICROC~1\MPLABC~2\support\PIC24F\gld\p24fJ128GA010.gld -Xlinker -t -Xlinker --report-mem -Xlinker -Map=../ -Xlinker --heap=0 -Xlinker -cref    
c:\program files\microchip\mplab c30\bin\bin\..\bin/pic30-coff-ld.exe: mode pic30_coff
Program Memory  [Origin = 0x200, Length = 0x155fc]
section                    address   length (PC units)   length (bytes) (dec)
-------                    -------   -----------------   --------------------
.text                        0x200               0x858           0xc84  (3204)
.text                        0xa58              0x1cee          0x2b65  (11109)
.dinit                      0x2746               0x13a           0x1d7  (471)
.text                       0x2880               0x2b8           0x414  (1044)
.isr                        0x2b38                 0x2             0x3  (3)
                     Total program memory used (bytes):         0x3dd7  (15831) 12%
Data Memory  [Origin = 0x800, Length = 0x2000]
section                    address      alignment gaps    total length  (dec)
-------                    -------      --------------    -------------------
.ndata                       0x800                   0           0x178  (376)
.nbss                        0x978                   0            0xb4  (180)
.ndata                       0xa2c                   0             0xc  (12)
.nbss                        0xa38                   0             0x2  (2)
                        Total data memory used (bytes):          0x23a  (570) 6%
Dynamic Memory Usage
region                     address                      maximum length  (dec)
------                     -------                      ---------------------
heap                             0                                   0  (0)
stack                        0xa3a                              0x1dc6  (7622)
                        Maximum dynamic memory (bytes):         0x1dc6  (7622)
"    ---24fJ128GA010---"
"*** Created "executable": ..\../UAV_VN1002b.cof"   
''pic30-bin2hex ..\../UAV_VN1002b.cof 
"*** Converted UAV_VN1002b.cof to UAV_VN1002b.hex"   
"***   MPLAB: file -> import, choose UAV_VN1002b.hex. Configure -> Configuration Bits : Verify ! Download into the chip and run."      
"***   Alternatively, (re-)compile the MPLAB project : Within Matlab, right-click UAV_VN1002b.mcp -> open outside Matlab will open the MPLAB project. Compile, modify..."   
### Successful completion of Real-Time Workshop build procedure for model: UAV_VN1002b
(34.5 KiB) Downloaded 194 times

Site Admin - Expert
Posts: 616
Joined: Wed Mar 07, 2007 11:23 pm
Location: Marseille - France

Re: Interfacing with an VN100 (INS/AHRS SENSOR)

Postby LubinKerhuel » Mon Jun 27, 2011 11:24 pm

Hi Ismaeel,

As I understand, you are willing to use the SPI drivers provided by Vector Nav to accec to the VN-100 variables.
If I were you, I would use directly the dsPIC drivers. Including C files from others should just be more complicated, thus provided the required driver already exist and that its limitation is Ok with your application, just use it.

The interresting document is UM001.pdf. page 13. provide an example of the sequence to send to the VN-100.
for example, repeating sequence 01 08 00 00 00 00 00 00 will allows to get the computed Yaw,Pitch,Roll. (Do remember to set the Chip Select line properly.)
This should be quite similar to what has been done with the ADIS16100 rate gyro you mentionned.

Thus, first things is to check that SPI bus is working by having the VN-100 SPI output line to respond. Then, find the best sequence to be send to the VN-100 to get the data you want. Provided that sequence will be repeated, you might use the SPI block based on interrupt which will be even more efficient. (however, in a debuging step, prefere using the "standard" SPI block.


Posts: 19
Joined: Mon Feb 28, 2011 5:00 am

Re: Interfacing with an VN100 (INS/AHRS SENSOR)

Postby ismaeelbit » Fri Jul 01, 2011 5:50 am

Thanks for this reply. I have thougth of using SPI block directly, but my problem is that I am yet to figure out how best to send the series of bytes command to the SPI using the blocksets, and also how to read out the response hex. data.

In the example of the gyro sensor, you only send one byte of command to spi. If you have an idea or example on how to set-up the spi using the block sets to send the data I will be grateful to have it.

I am working on cascading the SPI like you did for one Rx UART example! I may try that latter and update you in the mean time.

Posts: 71
Joined: Tue Jul 07, 2009 1:06 pm
Location: West Point, New York

Re: Interfacing with an VN100 (INS/AHRS SENSOR)

Postby resodad » Tue Sep 06, 2011 12:33 pm

I used SPI to read / write to EEPROM. It is somewhat different from your need, but some of the work may help you along. See my post:
SPI EEPROM Record and Playback on Explorer 16

Posts: 19
Joined: Mon Feb 28, 2011 5:00 am

Re: Interfacing with an VN100 (INS/AHRS SENSOR)

Postby ismaeelbit » Sat Nov 19, 2011 9:02 am

Thanks John, I already got this sensor interfaced and working fine now.

Hope to make my experience available once I get some free time

Return to “Advanced Simulink & RTW Questions”

Who is online

Users browsing this forum: No registered users and 1 guest