Skip to content

kmatch98/tinylogicfriend

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinylogicfriend

TinyUSB-based logic analyzer code for Sigrok

Make it easy to use a microcontroller board as a logic analyzer.

Main features:

  • A driver for sigrok that can communicate with a wide array of microcontroller boards.
  • Use tinyUSB to create easy-to-modify embedded code that can be adapted to various chip families.
  • A basic list of human-readable (SCPI) commands for communication between sigrok and the tinyLogicFriend microcontroller board.

Key components:

  • libsigrok: sigrok device driver to communicate with tinyLogicFriend, this runs on the host computer
  • tinyLogicFriend (This repository): microcontroller code that can be adapted to each board family, this runs on the microcontroller board
    • uses tinyUSB for handling communication to sigrok
    • has parsing for handling SCPI commands from the host computer
    • include an outline for adding the board-specific to:
      • setup channels, triggers, sampling rates and sample counts
      • Read signals and send back to the host computer
  • a basic communication protocol between sigrok and tinyLogicFriend to set up the instrument and to initiate and read measurements

Using and hacking:

  1. Install the sigrok suite. This can be run at the command line using sigrok-cli or using the PulseView graphical interface. You will need to get a version that includes the tinyLogicFriend sigrok driver. Right now, you need to build it for yourself using the tinyLogicFriend driver from my github libsigrok repository. I strongly recommend using sigrok-util to build for your platform. You will need to replace the baseline libsigrok library with this version that includes the tinyLogicFriend driver. Then build everything, including libsigrok, sigrok-cli and PulseView. So far, I have succesfully built PulseView with tinyLogicFriend on an iMac running MacOS Big Sur.

  2. If your board is supported: Download the appropriate .UF2 file from the \boards directory.

  3. Connect your tinyLogicFriend to your host computer via USB (be sure you are using a USB cable with the signal lines connected).

  4. Put your board into bootloader mode (usually by double-clicking.

  5. Copy to your board the appropriate .UF2 file (the one named the same as your board).

  6. Start up sigrok-cli or PulseView and confirm that your tinyLogicFriend is detected.

If your board is not yet supported:

  1. Download the example file and update the following sections of these files according to your board's requirements:
    • Add entry in boards/
    • If your chip is not supported, create the logic_capture.c and logic_capture.h under the directory mcu/(VENDOR)/(CHIP_FAMILY)
  2. Run make with the board, chip VENDOR and CHIP_FAMILY for example: make BOARD=itsybitsy_m4 VENDOR=microchip CHIP_FAMILY=samd51
  3. Connect to the host computer via USB and put your board into bootloader mode (usually by double-clicking the reset button).
  4. Build the UF2 file (from the .bin file that is created in the _build directory) and copy the UF2 file onto the board's boot drive, for example: python uf2conv.py -c -b 0x4000 -o _build/itsybitsy_m4/itsybitsy_m4-tinylogicfriend.uf2 _build/itsybitsy_m4/itsybitsy_m4-tinylogicfriend.bin; cp _build/itsybitsy_m4/itsybitsy_m4-tinylogicfriend.uf2 /Volumes/ITSYM4BOOT

Some implementation details:

  • Includes a basic set of SCPI (Standard Commands for Programmable Instruments) commands suitable for basic digital logic analysis
  • Uses a USB TMC (Test and Measurement Class) to connect between sigrok and tinyLogicFriend

Current status of tinyLogicFriend:

  • Code is available for ATMEL-SAMD Cortex M4, currently with builds for two boards
  • The sampling uses interrupts and Run Length Encoding, with a clock running at 48 MHz
  • Can decode I2C signals running at 100 kHz
  • Current Limitations (for future improvement):
    • Triggers are set on all channels for both edges
    • Fastest square wave measurement is around 200 kHz

Communication protocol: SCPI command set

  • IDN? Get identification details of the board

  • CHANnel:COUNT? Get number of channels

  • CHANnel<n>:NAME? Get channel number <n> name

  • CHANnel<n>:STATus either OFF or ON Set channel reading status (Implemented in parser, but not hooked up to chip controls.)

  • CHANnel<n>:STATus? Get channel read status (Implemented in parser, but not hooked up to chip controls.)

  • CHANnel<n>:FILTer either OFF or ON For Run-length encoding mode, whether filtering is placed on the interrupt pin. (Is interrupt filtering applied for all pins or each individually?)

  • CHANnel<n>:FILTer? Get filter status, only relevant when MODE RLE

  • TRIGger:OPTions? (Implemented in parser, but not hooked up to chip controls.)

    Get trigger options <v>

    • X=trigger off
    • 0=on zero
    • 1=on one
    • R=rising
    • F=falling
    • E=any edge
  • CHANnel<n>:TRIGger <v> Set trigger type (Implemented in parser, but not hooked up to chip controls.)

  • CHANnel<n>:TRIGger? Get trigger type for channel <n> (Implemented in parser, but not hooked up to chip controls.)

  • RATE:MIN? Get minimum sampling rate (in Hz)

  • RATE:MAX? Get maximum sampling rate (in Hz)

  • RATE:STEP? Get sampling rate step size (in Hz)

  • RATE <xxxx> Set sampling rate

  • RATE? Get sampling rate

  • SAMPles <xxx> Set number of samples to be captured. Set to 0 for continuous sampling. Sample count is relative to the sampling rate clock, even when run-length encoding is used

  • SAMPles? Get number of samples

  • SAMPles:MAX? Get maximum number of samples

  • MODE <Y> Either RLE or CLOCK. Run-length encoded or sample at configured sampling rate.

  • MODE? Either RLE or CLOCK

  • Run Start measurement

  • STOP Stop measurement

  • DATA? Request a data packet

About

TinyUSB-based logic analyzer code for Sigrok

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 94.3%
  • Python 3.3%
  • C++ 1.2%
  • Other 1.2%