Saturday, August 5, 2023

DIY USB Video Camera Using MK82FN256VLL15 Microcontroller and OV7670 Camera Module

FRDM-K82F is a low cost development board using MK82FN256VLL15 microcontroller. Here, I will test its FlexIO connector using OV7670 camera module. [NXP16, NXP16B]

Hardware

We need to solder 18 pin female connector, Header2x9, on the back of the FRDM-K82F board to connect OV7670 module as illustrated in the following figure.


Figure. FRDM-K82 attached with OV7670 camera module.


Wednesday, November 30, 2022

Translation and Rotation of Images in Six Degree of Freedom Using OpenCV

I would like to share a small C++ function to translate and rotate images in 3D space in six degree of freedom (6 DoF). It also adjusts brightness and contrast. I use OpenCV library to perform some image processing.



Monday, November 7, 2022

Near Field Communication (NFC) Using PN7150RPIM

Using OM5578 PN7150 NFC controller with Raspberry Pi is discussed.


Hardware Module

PN7150RPIM demo kit consists of PN7150 controller which is soldered on Raspberry Pi Interface board. It also includes NTAG216 a NFC card for testing [1]. There are three different versions of interface board for PN7150 NFC controller - Raspberry Pi interface, BeagleBone interface, or Arduino interface [2]. As illustrated in Figure 1, it only uses 6 pins - 3.3V, and GND for power, SDA and SCL for I2C, a GPIO input IRQ for interrupt, and a GPIO output for Enable pin. There is also an optional 5V power VANT.


Figure 1. PN7150 NFC Controller Board Pins.


The Raspberry Pi version is used as SBC interface for this discussion. Its connections to the header is shown in the following Figure [3].


Figure 2. PN7150 RPi Interface Board Connections.


Library

There is NXP Linux libnfc-nci software stack on GitHub that supports PN7150 NFC controller [4] which we will clone as follows.

$ sudo apt install autoconf automake libtool git pkg-config
$ git clone https://github.com/NXPNFCLinux/linux_libnfc-nci.git


Then, navigate into the directory and generate the configuration script. The machine should have automake, autoconf and libtool packages installed before running the script.

$ cd linux_libnfc-nci/
$ ./bootstrap


There are three options to generate the Makefile to map Linux NFC stack-
--enable-i2c
To use PN5xx I2C kernel mode driver which is default.
--enable-alt
To access GPIO and I2C resources from the user space in case the existing kernel offers access to them.
--enable-lpcusbsio
For USB devices implementing PN7150 with HID interface expose via LPCUSBSIO. protocol.
In our case, we will use --enable-alt option as the Raspberry Pi supports using GPIO and I2C through /sys/class/gpio and /dev/i2c-dev interface [5]. The stack is illustrated in the following figure.


Figure 3. libnfc-nci SW stack.


The i2c bus and GPIO pin can be configured in phTmlNfc_alt.h which is in ./src/halimpl/pn54x/tml/i2c directory. The existing values are

#define I2C_BUS "/dev/i2c-1"
#define I2C_ADDRESS 0x28
#define PIN_INT 23
#define PIN_ENABLE 24


Execute the following commands to generate the Makefile for the above settings, build and install the library.

$ ./configure --enable-alt
$ make 
$ sudo make install 


The install path is at /usr/local/lib. And for that you can use

$ export LD_LIBRARY_PATH=/usr/local/lib


or create config file as follows.

$ sudo sh -c "echo /usr/local/lib/ > /etc/ld.so.conf.d/nfc-nci.conf"


And load the configuration.

$ sudo ldconfig


C++ Examples

Example C++ programs to use NXP Linux libnfc-nci software stack as reader, emulator, etc. are also available on GitHub [6] which we will clone as follows.

$ git clone https://github.com/NXPNFCLinux/linux_libnfc-nci_examples


Then, you can navigate into an example directory, build, and run.

$ cd linux_libnfc-nci_examples/xxxx
$ make 
$ ./xxxx 




References

[1] NXP Semiconductors. PN7150 Raspberry Pi SBC Kit Quick Start Guide. 2019-07-08.
url: https://www.nxp.com/docs/en/application-note/AN11758.pdf.

[2] NXP Semiconductors. PN7150 NFC Controller SBC Kit User Manual. 2019-07-10.
url: https://www.nxp.com/docs/en/user-guide/UM10935.pdf.

[3] NXP Semiconductors. NFC's SBC Interface Boards User Manual. 2016-05-02.
url: https://www.nxp.com/docs/en/user-guide/UM10956.pdf.

[4] NXP Semiconductors. PN71xx Linux Software Stack Integration Guidelines. 2018-08-10.
url: https://www.nxp.com/docs/en/application-note/AN11697.pdf.

[5] NXP Semiconductors. Easy set-up of NFC on Raspberry Pi. 2018-08-14.
url: https://community.nxp.com/docs/DOC-341231.

[6] NXP Semiconductors. linux_libnfc-nci_examples.
url: https://github.com/NXPNFCLinux/linux_libnfc-nci_examples.

Wednesday, July 6, 2022

Friday, April 1, 2022

PCA9535 GPIO Expander

PCA9535 is a GPIO expander with 16 IO lines which has I2C bus interface. It provides additional IOs for I2C bus master such as SBC or MCU that can be used to read push button or sensor, to control LED, etc. PCA9555 is identical to PCA9535 except the presence of internal pull-up resistor which increases power consumption when the IOs are low. PCA9535C is another variation of PCA9535 with open drain outputs. Its operating supply voltage range is 2.3V to 5.5V. There are 3 hardware pins which allow to use 8 different I2C bus addresses, from 0x20 to 0x27.


Tuesday, October 5, 2021

16 Channel RS485 Modbus Relay Board

Controlling a 16 channel RS485 Modbus relay board is discussed in this post. The board needs to be powered with a 12V power supply. It has has a DIP switch to set its ID. If only the switch 1 is on and others are off, its ID will be 1. To communicate the board from a PC, a USB to RS485 converter can be used. The setup is illustrated in the following figure.


Figure 1. RS485 relay board using 12 V power supply, and a USB converter.


Alternatively, you can use a USB UART adapter together with a UART to RS485 converter. Wire connection for this setup is shown below.


Figure 2. Wire connection for UART to RS485 converter.


Unlike conventional RS485 devices, these devices do not have the control line for transmit or receive. They use autoflow control as shown below.


Figure 3. RS485 autoflow control.


Friday, September 17, 2021

V4L2 Capturing as Bitmap Image

V4L2 (Video for Linux 2) consists of drivers and API for video capturing on Linux [1]. In this article, we will discuss about using the library and analysis of video capture example. There are utilities for controlling media devices on Linux called v4l-utils [2]. We will explore about using and testing webcam with them also.


Wednesday, July 7, 2021