FLEX usb data communication using Scilab and Scicos

From ErikaWiki

Revision as of 17:40, 30 September 2008 by Paolo.gai (Talk | contribs)
Jump to: navigation, search

This demo focuses on the USB data communication between the FLEX Board and a host PC. The three accelerometer values are represented in a Scicos scope. A pdf guide is included in the zip archive.


Contents

PIC18 USB firmware

The FLEX Full USB connection is provided by the PIC18F2550 that communicates with the dsPIC through a SPI protocol. Download the FLEX_USB.cof (furnished with USB_DEMO_wiki software) inside the microcontroller using MPLAB IDE. Usually, there is no need to change the configuration bits. In some cases the a configuration bit must be changed manually. After importing the cof file, check under MPLAB IDE in Configure → Configuration bits that address 0x300000 has value 0x24. If the proposed value is 0x04 unselect the checkbox and insert the correct value. After flashing the device, reset the board and connect the USB cable.

Interfacing with the PC

This is a one time operation that has to be done before using the FLEX Full Board.

  1. After programming the Flex board, connect it to the PC
  2. The PC automatically recognize the device as a HID device. Open the PC control panel → system → device manager: open the Human Interface Device (as shown in the Figure below).
    Usb 1a.jpg
  3. Double click on one of the devices, in order to identify the device with VID = 0x04d8 and PID = 0x0033 on the property window. This is the FLEX board. See the Figure below
    Usb 1b.jpg
  4. Click on the driver tab as in the Figure below:
    Usb 1c.jpg
  5. Click on Update driver → search the driver in the computer → manually search the driver.
    Usb 1d.jpg
  6. Specify the path of the folder libusb furnished with USB_DEMO_wiki software (USB_DEMO_wiki\DEMO_USB_ONLY_3CH\PC_3ch_USB\libusb).
    Usb 1e.jpg
  7. The PC will load this as a new driver for the FLEX Full Board.
    Usb 2.jpg

Creating the USB PC application

First of all you have to download and install Visual studio 2008 C++ express edition from the Microsoft website. Then check the support for Visual studio 2008 C++ express edition into your Scilab version. Check this web page: [1]

To compile external code, Scilab must detect and support Visual studio 2008 C++ express edition with dynamic link. This is required for using the flex_usbdll.dll and flex_usbdll.lib.

To compile the USB demo compilation under Scilab/Scicos, launch Scilab and after the startup execution write:

cd <path of the demo folder>
exec go.sce;
scicos;
Open the PC_3ch.cos' example (schematic is depicted below):

Usb 3.jpg

Connect the FLEX Full Board and then open the simulate menu under Scicos and click run. The result is a scope showing in a scope the three axis accelerometer values. In the second scope the three accelerometer values of a remote node are depicted. The remote node is a separate FLEX Board with a ZigBee transceiver (device). The FLEX Full Board connected to the PC through USB is the ZigBee coordinator (see the dsPIC coordinator Scicos schematic).

The block used for the PC application is the flex_usb_datain:

Usb 4.jpg

The number written inside the block represents the logical channel number and this must correspond to a usb logical channel in the dsPIC schematic.

The block is currently not inserted in the Scicos palettes (we'll do this in the next version). To add it to an existing palette, please follow the instructions at How to add a new Scicos block to ERIKA Enterprise.

dsPIC

To test the demo application, the dsPIC needs to be flashed. The firmware can be found in the folder USB_DEMO_wiki\DEMO_USB_ONLY_3CH\PC_3ch_USB\cof.

Personal tools