Shopping Cart


Your Cart is currently empty.

Home Digit-LS
Digit-LS

The Digit-LS is a smart, programmable multi-IO device that can be programmed and controlled from your PC by a simple USB connection. The Digit-LS is based on the Microchip PIC 18F4550 microcontroller, giving you access to all functionality inside this IC. A Digit-LS comes with built-in operation system that will do all the USB protocol work for you. Just specify your configuration and additional code that needs to be executed on any data that is sent up and down your USB connection. Also you can run code on the device permanently, for instance to perform real-time monitoring tasks. No programmer is needed, Digit-LS can program itself with the software that can be downloaded from our website.

Demonstration Video

The demonstration video below will show you how the Digit-LS interacts with your computer using the example software. After watching this video, you can start thinking of what you can do with your Digit-LS and develop your own applications.

 

 

Features

  • USB connector
  • Power and status indicators (LEDs)
  • Reset and Load pushbuttons
  • 30 digital input / output pins
  • 12 channel 10-bit A/D converter
  • 2 Capture/Compare/PWM modules
  • Serial port (USART) with separate header on module
  • SPI/I2C-port
  • 4 timer modules
  • 16 kB available program memory for custom configuration software
  • 1 kB available SRAM data memory
  • 256 bytes available EEPROM data memory with easy access library calls
  • Automatic handling of USB protocol, just supply callback code to act on USB events
  • Continous execution of custom code on device
  • Power supply from USB or external power
  • Drivers available for Windows XP 32-bit, Windows Vista 32-bit and Windows 7 32-bit.
  • Linux compatibility through libusb

USB communication with a Digit-LS

Before you can control your Digit-LS from a PC, you need to do take the following steps:

  • Develop a Custom Configuration for the Digit-LS, this is a piece of code where you define the USB Interface layout and the callback functions that will process the data that was passed through the USB connection. 
  • Program the Digit-LS with this code using its USB cable and the programming tool dlscoder.exe (available from our website).

To communicate with the Digit-LS from your PC, write code that performs these steps:

  • Determine the device name that the Plug-and-Play system assigned to your Digit-LS
  • Obtain a file handle to the device and the endpoint you want to communicate with
  • Send or read data as if you were reading from or writing to a file
  • Close the file handle when you are done

The lines of code below with explanation will give you a good idea of how it works. Please note that code with a light blue background is code that runs on the Digit-LS device, code with a light green background runs on the PC.

For the Digit-LS, you will need to define a USB Interface layout and some callbacks to handle USB Events. A simple USB Interface layout (some parts left out for brevity) would look like this:

rom EndPointInfoT    Info_EndPointIntf1[] = {
    "LEDS",                    /* Endpoint Name              */
    EP_LEDS_Init,              /* Init Handler               */
    EP_LEDS_Transaction,       /* Transaction Handler        */
    EP_LEDS_Exit,              /* Exit Handler               */
    &EP_LEDS_Buf,              /* Pointer to OUT Buffer      */
    NULL,                      /* Pointer to IN Buffer       */
   FALSE,                     /* Use MarioMatic             */
{
...
}
}

To access the endpoint defined in this layout from the PC, you need to obtain a file handle to it. This is done by concatening the device name that was assigned by Windows upon plugging in the Digit-LS, and the name of the endpoint you intend to access. So the full path will have this form:

<device name>\<endpoint name>

In this example it would be something like this:

\\?\usb#vid_04d8&pid_fd7c#7&350cd513&0&2#{22d34da1-6306-41d8-9377-5c00b735c7be}\LEDS

(The device name part will most likely be different in your situation). In your PC code you would first derive the device name using the macro that is supplied in the header file
 dlsfdevp.h. Then add the endpoint name. Finally use CreateFile() to get a file handle for this endpoint. In code it would look like this:

/* Get device path */
if (!FIND_DEV_PATH ((LPGUID)&GUID_CLASS_DIGITLS_1_0, NULL, -1,
FullName, sizeof (FullName))) {
    fprintf (stderr, "No Digit-LS found.\n");
    exit (-10);
}
wcscat (FullName, L"\\LEDS");    /* Open device */
hDevice = CreateFile(FullName,
                GENERIC_WRITE,
                0,
                NULL,
                OPEN_EXISTING,
                0,
                NULL );

Now with this file handle you can send data to the endpoint using WriteFile(), for instance using the code below.

UCHAR WriteBytes[8];
WriteBytes[0] = 0;
WriteBytes[0] = 0;
WriteBytes[0] = 1;
WriteBytes[0] = 0;
WriteBytes[0] = 1;
WriteBytes[0] = 0;
WriteBytes[0] = 1;
WriteBytes[0] = 0;

WriteFile(hDevice,
        WriteBytes,
        nrWriteBytes,
        &nrWriteBytes,
        NULL);

When the data arrives in the Digit-LS, it will run the transaction callback you defined in the Interface layout, in this case EP_LEDS_Transaction(). Suppose you would have 8 LEDS connected to the outputs of PORT D on your Digit-LS, the code below could be used to switch these LEDS on or off depending on the data we just received.

int EP1Transaction(byte EPno, PacketT TransType)
{
   PORTDbits.RD0 = (EP01Buf._byte[0] != 0);
   PORTDbits.RD1 = (EP01Buf._byte[1] != 0);
   PORTDbits.RD2 = (EP01Buf._byte[2] != 0);
   PORTDbits.RD3 = (EP01Buf._byte[3] != 0);
   PORTDbits.RD4 = (EP01Buf._byte[4] != 0);
   PORTDbits.RD5 = (EP01Buf._byte[5] != 0);
   PORTDbits.RD6 = (EP01Buf._byte[6] != 0);
   PORTDbits.RD7 = (EP01Buf._byte[7] != 0);
   APICalls->EPSetOUTReady (EPno, DTS_TOGGLE);
   return 1;
}

The data that was sent from the PC, will end up in the buffer defined in the Interface layout, in this case EP01Buf[]. For this endpoint, the buffer is 8 bytes long. For each byte in the buffer we received, we check if it is zero or not and make the corresponding port high or low accordingly. Then by using the API call EPSetOUTReady(), we notify the Digit-LS that we are done processing. 

When you are done sending data to the Digit-LS from your PC, you should close the file handle like this:

CloseHandle (hDevice);

For further details on how to operate a Digit-LS, see the Digit-LS documentation.

Digit-LS build-it-yourself kits and assembled units are available from our webshop. If you are new to Digit-LS development, we recommend the starterkit that includes the MODRC1 module featuring a number of electronic controls and gadgets to be controlled from your computer. Examples and source code is available from our website.

Last Updated on Tuesday, 13 April 2010 15:30
 
Copyright Sofrides IO