y. Wireless data transfer and signal frequency and phase measurement with PIC32MX250F128B: standalone or on adapter to K8055-1 or K8055N-2 experiment board

PIC32 microcontrollers have much more advanced logic to capture and analyze signals. They also feature peripheral pin select (PPS) unit that allows for a variety of different pin to microcontroller functional unit mappings.

Wireless communication hardware

Wireless communication can be achieved with a HopeRF or similar 1-bit transceiver module or a transmitter-receiver module pair. The modules can be directly connected to the microcontroller. RFC85 digital transmitter module has a high voltage operating range (from 2.0 V to 5.5 V). It is also compatible with logical “0” and logical “1” voltage levels for integrated circuits (ICs) with 3.3 V and 5 V power supplies.

But there are two different receiver modules: RFC83C module is intended for 5 V ICs, while RFC83CL module interconnects with 3.3 V ICs. Velleman K8055 experiment boards (K8055-1 and K8055N-2) can interface with both 3.3 V (RFC83CL) and 5 V (RFC83C) modules, because it has an inbuilt ULN2803A IC that acts as an adapter for different digital input voltage levels. Additionally, PIC32MX250F128B microcontroller also features some 5 V tolerant pins that may be used to directly interface with a RFC83C module. The others may only be used with a RFC83CL module.

Alternatively, you can use RFM69CW module with SPI interface and inbuilt wireless communications controller. It is cheap and much more efficient!

Phase modulated signal capture

The 1-bit wireless communication is difficult to achieve without using some kind of modulation. PIC microcontrollers have a good hardware support for phase modulated signal capture. While PIC18 microcontrollers have two (E)CCP units, PIC32 microcontrollers feature much more advanced input capture and output compare units. PIC32MX microcontrollers have 5 input capture units (ICx) and 5 output compare units (OCx). Each ICx unit's 1-bit input can be mapped to a number of different microcontroller chip pins. A phase modulated signal analysis is based on the same premises as on (E)CCP, but much more accurate. Each input capture unit features a 4 word first-in first-out (FIFO) buffer. Buffer locations are 32-bit and they can be accessed sequentially via ICxBUF registers (where x = {1, …, 5}).

ICx unit operation is based on timers 2 and/or 3. Timers 2 and 3 are 16-bit, but they can be used together as one 32-bit timer. The latter (also called 32-bit timer 2/3 mode) enables one to achieve 32-bit precision. An input capture unit operation is controlled via ICxCON register. In 16-bit mode timer 2 or timer 3 may be selected as time base, while both timers are used in 32-bit mode. The latter interferes with the output compare units operation described in the next paragraph.

Phase modulated signal generation

PIC32’s output compare units (OCx) are used to generate a phase modulated signal that can be transmitted via a wireless transmitter or a transceiver module. PIC32MX microcontrollers have 5 output compare units. Each may only use timer 2 or 3 for its time base. In 32-bit timer mode (timer 2 + timer 3) output compare units must share the time base with input capture units. If data transmission and reception is performed with the same speed, this limitation should not pose a major problem, because output compare units also have 32-bit registers.

Data transfer protocol

Digital data can be transferred with a simple protocol that relies on different PWM levels. Different signal lengths that are produced by the transmitter are sampled by the receiver. Each level always falls within a certain PWM value range. Therefore one can split the whole available span of PWM modulation to a number of ranges that depict certain communication messages. Test application reveals that there are about 20 distinguishable ranges that may carry different communication protocol messages.

A communication protocol is usually conceived as a final automaton. It is important when a sender starts a message and when the message ends. It is also important to clearly distinguish between different parts of the message. The simplest communication protocol may just make use of the PWM modulation to send about 20 different commands to the receiver (like a remote). A more sophisticated protocol will enable transmission of text messages, or numeric values. Therefore it will have to send data sequentially. Since there are about 20 different communication commands, a number of them can be used to carry raw data and the others may be used as control codes. Data communication protocol is currently not jet included in VB.NET examples, but it is simple enough for any experienced programmer to conceive.

VB.NET examples

There are a 32-bit and a 64-bit VB.NET example: PIC32MX250F128B Transceiver Application with 32-bit precision.zip and PIC32MX250F128B Transceiver Application with 32-bit precision x64.zip. The examples also work on the standalone circuit (see the shematic on the right). RFC85 wireless transmitter module is simple to connect to a modified or an original Velleman K8055-1 or K8055N-2 experiment board. All you have to do is to connect PWM1 or PWM2 output to the RFC85 module. The external PWM outputs have an open collector, so a resistor to the RFC85 power supply must be added. RFC85 module may have its own 3.3 V or 5 V power supply. Alternatively, SK2 or SK3 jumper socket +5 V pin can be used to obtain +5 V from the experiment board.

RFC83C receiver can also have its own power supply, or may draw power from SK2 or SK3 +5 V power pin. If you use RFC83CL, you need a +3.3 V power supply. An external power supply may be used, or alternatively an intermediate SDIP-28 socket with direct connections to GND, Vdd and RPB5 mapped to IC3 (input capture 3 input) may be placed under PIC32MX250F128B microcontroller.

RFC83C(L) data input must be directly or indirectly connected to RPB9 that is mapped to IC3. An indirect connection is simpler, because we just connect the RFC83C(L) output to the I1 input in the experiment board. Alternatively, RFC83CL may be connected directly to PIC32MX250F128B microcontroller via the intermediate SDIP-28 socket.

NOTE: The direct connecton of transmitter or receiver circuits to the micrcontroller increases PWM precision. PWM precision is also increased, if a crystal oscilllator with a higher frequency is used. This is due to the fact that we need as high peripheral clock as possible to precisely measure signal frequency and phase.

ALSO READ:

- Packet based wireless communications

- WIRELESS CHAT

- How to properly configure RFM69CW and transfer data?

- PC USB Projects DLL v4.8 for all microcontrollers (wireless communications porotocol)

- Wireless communications

- Velleman K8055 board to 32-bit PIC32MX250F128B adapter schematic

- Velleman K8055N board to 32-bit PIC32MX250F128B adapter schematic

- Basic circuit for PIC32MX2xxFxxxB to work over USB with an 8.000000 MHz crystal resonator

- Basic circuit for PIC32MX2xxFxxxB to work over USB with a 20 MHz external oscillator

- PC USB Projects PROGRAMMING GUIDE

Standalone wireless transceiver circuit. Click on the schematic to enlarge it. For advanced wireless communications read: How to properly configure RFM69CW and transfer data?

Connecting RFC85 wireless transmitter and RFC83C wireless receiver to Velleman K8055-1 or K8055N-2 experiment board. Click on the schematic to enlarge it.

Alternativelly, you can use a makeshift connection from this photo (PWM output, PWM input from this photo is not used) to connect RFC85 transmitter. RFC83C receiver is receiver is remains connected to I1. NOTE: PIC18F2550 from this photo should be replaced with K8055-1 to PIC32MX250F128B adapter. Click on the photo to enlarge it.

PIC32MX250F128B transciever application with source code. Click on the screenshot to enlarge it.