Tuesday, 11 September 2012

Radio kills the video star.

A little project involving USB.

a simple Common Lisp program to send data from PC to an homemade board based on pic18lf2455 via USB hid interface.The friend Pascal. J. Bourguignon provided the with-open-usb macro.

This simple project starts from the need to provide a way to send and receive data over a custom board based on pic18lf2455. The application uses the microchip USB stack firmware for pic18 microcontrollers series and could take a bunch of commands to perform different operations such like: read digital signals timing and configure a digital radio chip (CC110L from TI). The main Lisp application has got three files:

  • usb.asd;
  • usb.lisp;
  • package.lisp;
  • README.txt

For this project I used Quicklisp 2012081400, Quickproject, SBCL 1.0.57, Emacs 23 and Slime from Wheezy distro. The Lisp program could:

  • Lit/unlit 3 different LEDs on board;
  • Capture digital RF signals timings from main antenna;
  • Control digital radio CC110L micro from TI;
  • handle USB communication;
  • read a two keys pad.

Here a tipical session on the SBCL REPL.


*slime-repl sbcl*
; SLIME 2012-05-25
CL-USER> (ql:quickload "usb")
To load "usb":
  Load 1 ASDF system:
    usb
; Loading "usb"
............
("usb")
CL-USER> (usb::send-command usb::*ccp1-on-command* :listen 4 :debug t)
Found device Vendor ID: 0x04D8, Product ID: 0x003C
Device opened.
Configuration 1 set.
Interface 0 claimed.
AltInterface 0 set.

Sending:
0x77 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

Receiving:
0x77 0x3C 0x00 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF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FF 0xFF 0xFF
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF

(#8m( 119   60    0    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255)
 #8m( 119   60    1    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255)
 #8m( 119   60    2    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255)
 #8m( 119   60    3    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255))
CL-USER> 
-->

in this session the CCP1 is activated via a specific command, the program then fetches three timings packets (64 bytes each) over the USB, the first packet is the response to the command. In this case there are all timeouts (data = 0xffff). In this other session the program do the same with a 30 MHz RF signal captured from the antenna.


*slime-repl sbcl*
CL-USER> (usb::send-command usb::*ccp1-on-command* :listen 4 :debug t)
Found device Vendor ID: 0x04D8, Product ID: 0x003C
Device opened.
Configuration 1 set.
Interface 0 claimed.
AltInterface 0 set.

Sending:
0x77 0x02 0x01 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 

Receiving:
0x77 0x02 0x01 0x00 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 

0x77 0x3C 0x00 0x00 0x82 0x03 0x03 0x00 0x07 0x00 0x28 0x00 0x48 0x00 0x3E 0x00 
0x34 0x00 0x2B 0x00 0x28 0x00 0xC0 0x01 0x04 0x00 0x0C 0x00 0x39 0x00 0x3C 0x00 
0x36 0x00 0x2E 0x00 0x27 0x00 0x26 0x00 0x22 0x00 0x22 0x00 0x20 0x00 0x1F 0x00 
0x1D 0x00 0x1D 0x00 0x1D 0x00 0x1D 0x00 0x81 0x03 0x02 0x00 0x05 0x00 0x21 0x00 

0x77 0x3C 0x01 0x00 0x4D 0x00 0x3A 0x00 0x31 0x00 0xD6 0x01 0x02 0x00 0x06 0x00 
0x1E 0x00 0x8E 0x00 0x43 0x00 0x2C 0x00 0x26 0x00 0x26 0x00 0x24 0x00 0x1F 0x00 
0x20 0x00 0x1E 0x00 0x1D 0x00 0x1D 0x00 0x1D 0x00 0x1D 0x00 0x72 0x03 0x04 0x00 
0x0A 0x00 0x43 0x00 0x4C 0x00 0x39 0x00 0x2F 0x00 0x2A 0x00 0xCF 0x01 0x02 0x00 

0x77 0x3C 0x02 0x00 0x10 0x00 0x20 0x00 0x2D 0x00 0x33 0x00 0x3E 0x00 0x4B 0x00 
0xBA 0x03 0x03 0x00 0x0A 0x00 0x23 0x00 0x39 0x00 0x4B 0x00 0x62 0x00 0x11 0x02 
0x02 0x00 0x06 0x00 0x1B 0x00 0x47 0x00 0x61 0x00 0x52 0x00 0x3C 0x00 0x33 0x00 
0x15 0x00 0x26 0x00 0x24 0x00 0x22 0x00 0x1F 0x00 0x1E 0x00 0x85 0x03 0x02 0x00 

(#8m( 119    2    1    0  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255  255)
 #8m( 119   60    0    0  130    3    3    0    7    0   40    0   72    0   62    0   52    0   43    0   40    0  192    1    4    0   12    0   57    0   60    0   54    0   46    0   39    0   38    0   34    0   34    0   32    0   31    0   29    0   29    0   29    0   29    0  129    3    2    0    5    0   33    0)
 #8m( 119   60    1    0   77    0   58    0   49    0  214    1    2    0    6    0   30    0  142    0   67    0   44    0   38    0   38    0   36    0   31    0   32    0   30    0   29    0   29    0   29    0   29    0  114    3    4    0   10    0   67    0   76    0   57    0   47    0   42    0  207    1    2    0)
 #8m( 119   60    2    0   16    0   32    0   45    0   51    0   62    0   75    0  186    3    3    0   10    0   35    0   57    0   75    0   98    0   17    2    2    0    6    0   27    0   71    0   97    0   82    0   60    0   51    0   21    0   38    0   36    0   34    0   31    0   30    0  133    3    2    0))
CL-USER> (usb::send-command usb::*ccp1-off-command* :listen 1 :debug t)
Found device Vendor ID: 0x04D8, Product ID: 0x003C
Device opened.
Configuration 1 set.
Interface 0 claimed.
AltInterface 0 set.

Sending:
0x77 0x02 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 

Receiving:
0x77 0x02 0x01 0x00 0x1A 0x00 0x4A 0x00 0x73 0x00 0xB7 0x00 0x74 0x03 0x09 0x00 
0x39 0x00 0x9B 0x00 0x70 0x02 0x02 0x00 0x08 0x00 0x60 0x00 0xCC 0x00 0x6D 0x00 
0x4A 0x00 0x35 0x00 0x2F 0x00 0x2A 0x00 0x24 0x00 0x8A 0x03 0x02 0x00 0x04 0x00 
0x18 0x00 0x6F 0x00 0x59 0x00 0x42 0x00 0xEF 0x01 0x04 0x00 0x05 0x00 0x0D 0x00 

(#8m( 119    2    1    0   26    0   74    0  115    0  183    0  116    3    9    0   57    0  155    0  112    2    2    0    8    0   96    0  204    0  109    0   74    0   53    0   47    0   42    0   36    0  138    3    2    0    4    0   24    0  111    0   89    0   66    0  239    1    4    0    5    0   13    0))
CL-USER> 
-->

Program could redirect output into a file and perform never ending sampling.

The RSS Feed

Tuesday, 13 December 2011

Playing with a TS7200.

Technologic Systems TS-7200 is a PC104 form factor SBC board based on  Cirrus Logic EP9302. This is an ARM 9 microcontroller based on ARM920T core plus a bunch of less and more useful peripherals. This piece of hardware would be very funny to use and experiment on if you're gonna install a linux distro on it. First of all, as you can see on the previous sites I wrote, the system come with

  • 200MHz ARM9 CPU

  • PC/104 expansion bus

  • 32MB SDRAM

  • 8MB NOR Flash

  • 1 10/100 Ethernet

  • 2 USB 2.0 (12 Mbit/s max)

  • 1 Compact Flash socket

  • 2 COM ports

  • 20 DIO lines

  • 2 12-bit ADC

  • Watchdog timer, SPI bus

  • Matrix Keypad and text LCD support 

  • Redboot bootloader (installed)

  • TS-linux busybox (installed)



  • now you can forget the TS-linux stuff on it and install your own linux distro and boot it from a CF. My system has got a 4 GB Sandisk CF (30 MB/s) with Debian Lenny on it.

    Wednesday, 9 November 2011

    Qt 4.6 tutorial in Lisp

    ;;
    ;; first qt tutorial
    ;;

    (defpackage :qt-tutorial1
      (:use :cl :qt)
      (:export :main))

    (in-package :qt-tutorial1)
    (named-readtables:in-readtable :qt)

    (defvar *qapp*)

    (defun main ()
      (let ((hello-button (#_new QPushButton "Hello world!")))
        (#_resize hello-button 100 30)
        (#_show hello-button)))

    Sunday, 7 August 2011

    A new simulation: Maxim MAX770-MAX773 Figure 2a step up converter, here a simulation results

    Thursday, 23 June 2011

    Finally a simulation!

    This is a simulation about a three-phase transformer feeding an AC/DC converter.

    Thursday, 5 May 2011

    After all they are only circuits

    On circuit-simulator an almost complete software to deal with electrical circuits e.g.: diode, switches, generators and so on at the cheap price of nothing. Docs for this program are still in development as the google code wiki page.