Skip to content

This is a client implemented in LabVIEW that interacts with an embedded device or constrained system that runs micropython, a stripped down version of Python. This Library can optionally be used with TestStand to perform tests against the target device / system

License

KMurphs/labview-client-for-micropython

Repository files navigation

labview-client-for-micropython

This is a client implemented in LabVIEW that interacts with an embedded device or constrained system that runs micropython. Essentially, this target device runs Python code.

MicroPython - a lean and efficient Python implementation for microcontrollers and constrained systems

Introduction

This is a small library / client implemented in LabVIEW to interact with a target device running MicroPython.

MicroPython is a project, that aims to put an implementation of Python 3.x on microcontrollers and small embedded systems. You can find the official website at micropython.org.

Essentially, a library for micropython will use a serial port to interact with the target device running micropython. One requires nothing else than that. And, as such, a program like Putty can be used to open a serial communication session to the device and, pretty much, run python code / commands.

Putty running on a laptop - And a Python REPL running on the remote device over serial port - The interactive prompt gives you control over the device and all its peripherals. And you can run Python Commands. LabVIEW can do the same.

Putty running on a laptop - And a Python REPL running on the remote device over serial port - The interactive prompt gives you control over the device and all its peripherals. And you can run Python Commands

What this library makes easy is the integration in Test Systems. One such example is TestStand which is a popular Test Executive Software Suite and developed by National Instrument.

As a matter of fact, this library was initially created for this very purpose. It is made available to speed up development of similar Systems.

API

The Public API consists of 4 simple LabVIEW functions / SubVIs:

  • Initialize.vi: To Initialize the comport
  • Close.vi: To close the comport
  • SendCommand.vi: Will send a command to the device and wait for its response
  • UploadScript.vi: Will take in a python script and send it over the serial port to the target device. SendCommand.vi can then be used to invoke functions and variables defined within this script.

When integrating with a Test Executive like TestStand, these are the VIs that will be called.

Getting Started

To get started, one needs some hardware running micropython. MicroPython requires a minimum 128K of Flash, 8K of RAM so not all arduino boards will support it (Officially 256k of code space and 16k of RAM). However, the official github page lists a few boards that will run micropython.

The PyBoard (running on a STM32F405xxxx) is the official board, but, alternatively, one can use the popular ESP32 or the ESP8266 as well.

Once Micropython is installed on your hardware, you can test that everything is working by opening a Serial Communication Session using Putty on the comport used by your board.

The same operation can be reproduced using this library by calling Initialize.vi first, then SendCommand.vi and UploadScript.vi as necessary.

Design

As stated previously, the library is written for LabVIEW and can be used with TestStand. The following provides an overview of the of the LabVIEW VIs that make up the library:

  • Initialize.vi: To Initialize the comport

LabVIEW VI to Initialize the comport to the micropython device

  • Close.vi: To close the comport

LabVIEW VI to Closes the comport to the micropython device

  • SendCommand.vi: Will send a command to the device and wait for its response

LabVIEW VI to Send a python command over the comport to the micropython device

  • UploadScript.vi: Will take in a python script and send it over the serial port to the target device. SendCommand.vi can then be used to invoke functions and variables defined within this script.

LabVIEW VI to Send a python script over the comport to the micropython device

transmit and receive operations are handled by the VI TxRx.vi. It will send a message to the target device and, optionally, wait, collect and aggregate response packets until some (stopping) conditions are met.

LabVIEW VI to Send and Receive function / VI to and from the micropython device

Similarily, TestStand will use the same set of steps to interact with a target device calling Initialize.vi as a setup action and Close.vi as a cleanup action. UploadScript.vi and SendCommand.vi will then be used to interact with the target.

TestStand Sequence to use the micropython library / client and perform test against a target device, i.e. the micropython device

The Screen snippet taken from the sample TestStand Sequence File provided in the repository.

References

About

This is a client implemented in LabVIEW that interacts with an embedded device or constrained system that runs micropython, a stripped down version of Python. This Library can optionally be used with TestStand to perform tests against the target device / system

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published