Skip to content

“IoT Made Easy!" - CAN/WiFi bridge project for PIC32MZW1

Notifications You must be signed in to change notification settings

MicrochipTech/PIC32MZW1_CAN_WiFi_Bridge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Enable CAN-WiFi Bridge

Purpose

This example application bridge the CAN Bus and Wi-Fi peripherals to enable data transfer between CAN nodes and Wi-Fi peripherals.

Enable CAN-WiFi Bridging on WFI32E Applications developed with MPLAB® X IDE and MPLAB Harmony v3

Description

This sample application demonstrates how to bridge up the CAN Bus and Wi-Fi peripherals on the WFI32E device which is running in SoftAP Mode. This concentrator device allows to connect the physical CAN-bus to WLAN network. A third-party STA will connect to the WFI32E SoftAP device and a third-party CAN Bus node (Microchip CAN Bus Analyzer) will connect to the CAN Bus of the WFI32E device.

A TCP Client on the third-party STA will then connect to the TCP Server running on the WFI32E Bridge device. Once connected, the WFI32E device will be able to transmit or receive the network data from the TCP Client. The WFI32E device can also transmit or receive CAN Bus messages from the third-party CAN Bus node.

In this example, the CAN messages are sent from the Microchip CAN Bus Analyzer. The WFI32E Bridge device forward the CAN Bus messages to the TCP Client (python script) running on a third party STA (computer). The TCP Client (python script) echoes the same message back to the SoftAP device and the WFI32E forward the message back to the CAN Node (Microchip CAN Bus Analyzer).

Software requirement

The sample project has been created and tested with the following Software Development Tools:

  • MPLAB X IDE v5.50

  • MPLAB XC32 v2.50

  • MPLAB Harmony v3.6.4

    • mhc v3.7.1
    • csp v3.9.1
    • core v3.9.1
    • wireless_wifi v3.4.1
    • dev_packs v3.9.0
    • wireless_system_pic32mzw1_wfi32e01 v3.4.1
    • wolfssl v4.7.0
    • net v3.7.2
    • crypto v3.7.1
    • CMSIS-FreeRTOS v10.3.1
  • Python to run the TCP Client Script

Hardware setup

  • Computer connected to WFI32 Curiositiy board over USB POWER (J204)

  • J202 = VBUS

  • J301 = open

  • USB-to-UART cable between the computer and GPIO Header UART1 pins (Rx, GND, Tx) to observe the console logs.

  • Connect thru wiring the ATA6563 click board to the PIC32MZ W1 Curiosity Board as per the Pi connection below:

PIC32MZ W1 Curiosity Board ATA6563 click board
AN (RPA14), mikroBUS connector TX (pin 14)
PWM (RPB12), mikroBUS connector RX (pin 13)
+3.3V, mikroBUS connector 3V3 (pin 7)
+5V, mikroBUS connector 5V (pin 10)
GND, mikroBUS connector GND (pin 9)

Pin no Signal
1 -
2 CAN-Low
3 GND
4 -
5 -
6 -
7 CAN-High
8 -
9 -

ATA6553 click

The ATA6563 click board carries the AT6563 high-speed CAN transceiver. The transceiver is designed for high-speed (up to 5 Mbps) CAN applications in the automotive industry, providing differential transmit and receive capability to (a microcontroller with) a CAN protocol controller. It offers improved electromagnetic compatibility (EMC) and electrostatic discharge (ESD) performance. The transceiver is CAN FD (Flexible data-rate) ready, meaning it has increased data rates in comparison with classic CAN. Check out the AT6563 datasheet for more details.

In this demo application, the ATA6563 click board communicates with the WFI32 MCU through CAN1 Bus Lines.

With PPS, the CAN1 RX Line (C1RX) is routed to pin RPA14.

And the CAN1 TX Line (C1TX) is routed to pin RPB12.

Try it

  1. Clone/download the repo
  2. Open the project with MPLAB X IDE
  3. Open Harmony Configurator

  1. Under Project Graph > Root, set the AP parameters required for a station device to connect to the Bridge in WIFI SERVICE

  1. Under Project Graph > Root:

    • Select Net Service
    • Currently, NetService is configured to run a TCP Server which awaits connection from a TCP Client on port 5555.
  2. (if required) Save configurations and generate code via MHC

  3. Build and program the code

  4. Open a serial terminal (e.g. Tera Term) on the computer

  5. Connect to the USB-to-UART COM port and configure the serial settings as follows:

    • Baud: 115200
    • Data: 8 Bits
    • Parity: None
    • Stop: 1 Bit
    • Flow Control: None
  6. Reset WFI32E Curiosity Board by pressing MLCR button

  7. The bridge device shall come up as SoftAP and then as per the default Net Service configuration, the TCP Server shall come up, awaiting a connection from a TCP Client.

  1. Connect a Station (Laptop) to the SoftAP (with ssid DEMO_AP_SOFTAP) running on the WFI32E device

  1. Observe the Station connected to SoftAP device

  1. Start a TCP Client using Python Script on laptop, giving the server IP as the PIC32MZW1 AP Mode IP Address, and the TCP port as 5555
tcp_client <SoftAP Ip Address> <Port No>

  1. TCP Server received a connection

  1. TCP Client is ready to receive data

  1. Open CAN Bus Analyzer software and make the following configurations:
Description Settings
CAN Bitrate Control 500 Kbps
CAN Mode Control Normal
Bus Termination Control ON

  1. Under Tools -> Transmit, send following CAN message from CAN Bus Analyzer software

    • ID: 0x469, DLC: 8, DATA: 1, 2, 3, 4, 5, 6, 7, 8

  1. WFI32E Bridge display the message received on the console

  1. The Server transfer the CAN message received to the TCP Client. You can observe the CAN message on laptop command prompt.

  1. The TCP Client echo the same message back to the WFI32E (TCP Server).

  1. The WFI32E Bridge transfer the TCP Client message to the CAN Bus.
    CAN Bus Analyzer software receives the message under Tools -> Rolling Trace.

Demo

About

“IoT Made Easy!" - CAN/WiFi bridge project for PIC32MZW1

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages