USB GPIO Modules

8 Channel USB Pluggable GPIO Module

0 views August 2, 2022 aryakrishna 0

Introduction

Numato Lab’s NL-USBG-C-008 USB GPIO Module helps you to connect real-world devices to your computer easily through USB. Built in USB to serial conversion allows the module to be used without any USB specific knowledge. Besides providing standard General Purpose IOs, this product has multiple Analog Inputs multiplexed with GPIOs as well.

 

Features:

  • 8 TTL (5V) compatible GPIOs
  • 6 analog inputs with 10-bit resolution (multiplexed with digital IOs)
  • USB interface with CDC support. As easy as using a serial port, no USB knowledge required
  • All IOs available on easy to plug terminals
  • Can be powered from USB or external power supply
  • Can be controlled using Serial Terminal Emulation programs or your favourite programming language such as C/C++, python, perl, etc…

IO0 to IO5 can be used as Analog to Digital Converter(ADC0 to ADC5) inputs as well. It is recommended to use a series resistor with the GPIO/ADC pins when interfacing with other circuits.

Some of the possible uses of this module includes:

  • Home Automation
  • Lighting Control
  • Garden Equipment Control
  • Industrial Automation
  • Test Fixtures
  • DIY and Hobby

This product is compatible with the following operating systems:

  • Windows XP and later versions (Windows 7, 8/8.1, 10 and future versions)
  • Windows 7 Embedded and later
  • Linux
  • Mac OS X
  • Android
  • Or any other operating system that supports USB CDC devices.

And these are some of the languages that can be used for programming:

  • C/C++
  • Visual Basic (VB6, VB2008, VB2010 express and other editions)
  • Visual Basic for Applications (Microsoft Office VBA)
  • Perl
  • Python
  • JAVA
  • Android
  • Javascript (Node.js)
  • And many more…

A complete list of sample code is available here.

Technical Specifications

Parameter ValueUnit
Number of GPIOs8
Number of analog inputs (Multiplexed with GPIOs)6
Digital circuit power supply voltage (USB or external)5V
Maximum current drawn by digital circuitry95mA
IO Specifications
Maximum IO source current : IO0 – IO725mA
Maximum IO sink current : IO0 – IO725mA
GPIO input low voltage 0.8V
GPIO input high voltage 2V
GPIO output low voltage 0V
GPIO output high voltage 5V
ADC Specifications
Resolution10bits
Full scale range0 – VDDV
Reference voltageVDDV
Recommended Impedance of Analog Voltage Source2.5KΩ
Other Information
USB Vendor IDv0x2A19
USB Product ID0x0808

* All parameters considered nominal. Numato Systems Pvt. Ltd. reserves the right to modify products without notice.

How to use Pluggable 8 Channel USB GPIO Module

It is very easy to set up and use the module. It needs only a USB A to type B cable. Use any of the Serial Terminal Emulator software to control the module using the easy-to-use command set.

Components/Tools Required

Along with the module, you may need the items in the list below for easy and fast installation.

  • USB A to type B cable
  • Medium size Philips screwdriver

Connection details

  • Connect the device to a USB port on the host system.
  • Install the Numato Lab CDC Driver (Only for windows, available on the product page)
  • Open any of the Serial terminal Emulator Software and connect the module using the COM port number
  • Control/ monitor the module using the commands available.

Refer documentation “Driver Installation”

The module is connected to the PC through a Type B cable. The digital circuitry is powered from the USB.

Sending Commands

This product supports a very simple command set that is designed to be less cryptic and easy to use manually or through a program written in many supported languages.

The Commands Set

This product supports a very simple command set that is designed to be less cryptic and easy to use manually (using serial terminal emulation programs) or through a program written in many supported languages.

List of currently supported commands.

No.CommandParametersExampleDescription
1vernoneverReturns firmware Version.
2idgetid getReads Module ID
set xxxxxxxxid set 12345678Assign ID to the module
3infononeinfoInformation on GPIO power-on status
4gpioset xgpio set 0Control the GPIOs
clear xgpio clear 0
read xgpio read 0Read GPIO status
readallgpio readallRead all GPIOs status at a time
writeall xx
gpio writeall ffControl all GPIOs at a time
iomask xxgpio iodir ffMask/unmask GPIOs
iodir xxgpio iomask ffSet GPIOs direction as input and output
poweron xx XXgpio poweron ff 00 Set power-on and direction value
5adcread xadc read 1Read Analog to Digital Converter input

The table below has more detailed information about available commands.

No.CommandExampleDescription
1ververReturns firmware version
2idid getReads the module ID
id set xxxxxxxxAssign ID to the module, where ‘x’ can be any alphanumeric character
ID should be 8 characters
3infoinfoDisplays the information on GPIO power-on status
3gpiogpio set xSet GPIO ‘x’ output status to high.

gpio set 0 – Sets GPIO 0 to high state
x can be 0 – 7
gpio clear xSets GPIO ‘x’ output status to low.

gpio clear 0 – Sets GPIO 0 to low state
x can be 0 – 7
gpio read xRead the GPIO status present at ‘x’.

gpio read 7 – Read status of GPIO 7 and print either ‘1’ or ‘0’ depending on the status
x can be 0 – 7
gpio
iomask xx
Mask/Unmask the GPIOs according to the bits of the hexadecimal value ‘xx’ mentioned.
0 – Mask the GPIO, 1 – Unmask the GPIO
gpio
iodir xx
Sets the direction of all GPIO in a single operation. A hexadecimal value(xx) must be specified with desired bit positions set to 0 or 1 with no “0x” prepended (eg 02, ff). A 0 in a bit position configures that GPIO as output and 1 configures as input. Before using gpio readall/writeall commands, the direction of GPIO must be set using “gpio iodir xx” command. GPIO direction set by using iodir command will be modified with subsequent set/clear/read commands
(only affects the GPIO accessed using these commands).
gpio iodir 00 – Sets all GPIO to output.
Refer Understanding readall/writeall commands for GPIO Modules to know more.
gpio readallReads the status of all GPIOs in single operation.


gpio readall – Read all GPIO status and print ‘xx’
xx is a hexadecimal value, with binary 1 at positions for GPIOs in high state and 0 for GPIOs in low state
gpio
writeall xx
Control all GPIOs according to the bits of the hexadecimal value ‘xx’ mentioned.
0 – Clear GPIO, 1- Set GPIO
gpio poweron xx XXSets the GPIO status on power-on according to the hexadecimal value and IO direction mentioned.
xx – poweron value [0 – Clear GPIO, 1- Set GPIO]
XX – GPIO direction [0 – output, 1 – input]

gpio poweron 0f 5d

‘0f’ ‘5d’ – 0000 1111 0101 1101

GPIOs 0 to 3 – input
GPIOs 4 to 7 – output
Set GPIOs 0,2,3,4&6, Clear GPIOs 1,5&7
Only GPIOs 5 & 7 will be in high state as outputs.
4adcadc read xReads the analog voltage present at the ADC input mentioned. “x” stands for the number of ADC input. The response will be a number that ranges from 0 – 1023. Please see examples below.
adc read 0 – Reads analog input 0
adc read 4 – Reads analog input 4

NOTE!

  1. For the commands like gpio writeall/iomask/iodir, the value should be in lower case hexadecimal value(00 – ff).
    Egs :- gpio writeall ce, gpio iodir d5, gpio iomask a8
  2. For the commands like gpio readall/notify on, the output will be showed in upper case hexadecimal value(00 – FF).

Refer Understanding readall/writeall commands for GPIO Modules to know more.

Accessing the module

NL-USBG-C-008 allows to communicate through any of the Serial Terminal Emulator Software

using simple easy to use commands mentioned in the command set above.

Refer documentation “Sending Commands to the Numato Lab USB Modules” to know more.

Additional Information

Analog to Digital Converters (ADCs)

6 GPIOs on board do support Analog to Digital Conversion. There is no special command required to execute to switch between analog and digital mode. Executing “adc” command will set the GPIO to analog mode and executing “gpio” command will set the GPIO back to digital mode on the fly. Resolution of the ADC is 10 bits unless otherwise noted. The input voltage range of the ADC is 0 – VDD (this product uses 5V power supply, so the range will be 0 – 5V). The result will be returned as a number starting at zero and ending at 1023. Zero indicates zero volts at the ADC input and 1023 indicates VDD (5V for this product) at ADC input.

GPIO with Switches

USBGpio Switch connection diagramIt is possible to read the position of a switch that is connected to a GPIO. A SPST or SPDT switch is recommended to use with GPIOs. Push switches do maintain the contacts closed only for a very short time so using them is discouraged. The fundamental idea of using a switch with GPIO is to have the switch cause a voltage level change at the GPIO pin when pressed. Usually this is achieved by using an external pull-up resistor along with the switch. The pull up resistor is connected between the GPIO and VDD and the switch is connected between the GPIO and ground. When the switch is not pressed, the pull-up resistor will cause the GPIO to stay at VDD voltage level. When the switch is pressed, the GPIO is short circuited to ground and stays at zero voltage. This change in voltage and thus the position of the switch can be read using “gpio read” command.

Frequently Asked Questions (FAQs)

Q. What are the serial parameters I need to use when communicating with this board?
A. Since this module uses USB as the underlying transport mechanism, most of the serial parameters do not affect the communication. You can leave all parameters to any legal value (Eg: 2400, 4800, 9600 etc… for baud rate) except Flow control. Flow control needs to be set to “None”.

Q. Where do I find driver for this product?
A. Visit http://numato.com and navigate to the product page. There will be a link to download windows driver. Linux does not require driver installation since in most cases they are shipped with the driver pre-installed.

Q. Why there is no .sys or .exe file in the Windows driver package I downloaded?
A. This product uses USB CDC driver binary which is already present on Windows. All Windows versions (with the exception of Embedded Editions) has this driver binary installed by default. The .inf and .cat files present in the zip file helps Windows identify the device properly and associate appropriate driver (.sys) to the device

Q. Does this product work with Linux?
A. Yes, this product works with Linux. Please see more details on how to use this product with Linux elsewhere in this document.

Q. Does this product work with Mac OSX?
A. Yes, this product works with Mac OSX. Please see more details on how to use this product with Mac elsewhere in this document.

Q. What are the serial terminal software that this product work with?
A. This product works with a lot of different Serial Terminal software. Some examples can be found elsewhere in this document. Different Serial Terminal software are written by different developers with different purposes in mind. So you may encounter some software that may not work with this product. But usually alternatives are available in most if not all cases.

Q. The GPIO looses its previously set value when trying to read the status. Why it is so?
A. When a gpio is to output a value (high/low), that particular GPIO is put to output mode. When you are trying to read the GPIO, it needs to be put in input mode. In input mode, the GPIO will go to high impedance state and thus looses the previously set value.

Q. I’m using x language for programming. How do I find out if this language can be used to program and control the GPIO module?
A. Find out if the language of interest supports some kind of APIs/Functions/Components for serial communication. If it does, most likely you should be able to use that language with this module.

Q. What is the connector marked as ICSP on this module?
A. This connector is used to program the on-board microcontroller. This connector is primarily intended for factory use.

Q. I need a customized version of this product, can Numato do the customization for me?
A. Yes, we can definitely do customization but there may be minimum order requirements depending on the level of customization required. Please write to [email protected] for a quote.

Q. Where can I buy this product?
A. All Numato products can be ordered directly from our web store http://www.numato.com. We accept major credit cards and Paypal and ship to almost all countries with a few exceptions. We do have distributors in many countries where you can place your order. Please find the current list of distributors at http://numato.com/distrib.

Suggest Edit