arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

DEMO: APA102 RGB LED control via UCANS32K146 using Logitech F310

hashtag
Introduction

This tutorial aims to explain how to connect an APA102 based RGB LED "pixel led" board and control light intensity via a Joystick with ROS2.

hashtag
Items needed

For this demo you will need:

  • An APA102 based RGB LED "pixel led" board

  • UCANS32K146 or UCANS32K1SIC board

  • NAVQ board

Shown below is a RGB LED headlight board (as used in ) with 10 leds numerated fom LED1 to LED10.

hashtag
Daisy chain connection of APA102 LEDs

The 10-LED PCB board has 4 wired connections: DATA CLK, PWR, GROUND. The DATA line(wire) of the board connects to the Data_in of the first LED. Each LED is daisy chained to the next from Data_out pin of one to Data_IN of the next, and so on.

circle-info

There are other APA102 LED boards that might be used. For example there are 3-LED boards also on El Mandadero. These boards can also daisy chain from one board to the next. From the software point of view these are just considered one long string of LEDs.

hashtag
Connecting the LED board to the UCAN board.

The 10-LED "headlight board" shown here is built from an American standard taillight. The internal board has been changed from a simple "on-bright, on-dim" direct DC wiring to the digital connection to these RGB LEDs. Therefore an extra black wire was added to the plastic assembly.

10-LED "Headlight"
Signal
SPI Port (P1) Pin
UCAN Jumper wire color

Arbitrary colored jumper wires were used to connect between the 10=LED headlight board and the SPI port pin header on the UCAN board. The colors used on the UCAN side were as follows:

Jumper wire color
UCAN/SPIRole

The wires on the UCAN board are shown connected in the following image:

NOTE that the color codes above are non-standard. They should be checked when any different LED boards are being connected.

NOTE that the power 5V may also PREFERRABLY be supplied by using the servo 5V output and providing external 5V power from the BEC header (BEC = 5V DCDC converter) See below for board reference:

hashtag
Software procedure

hashtag
NavQPlus software

Connect to NavQPlus via a serial console or though ssh over Ethernet or Wifi. (See NavQPlus gitbook documentation for more details)

hashtag
CAN tools

Ensure can-utils and Python are installed on NavQPlus, if not, install the required packages:

hashtag
Configure CAN bus

Then, reset and configure the NavQPlus CAN bus interfaces:

hashtag
ROS2 setup

If not already installed, Install ros2_orchestrator ROS packages from GitHub.

circle-info

You need to set up your ssh keys for GitHub. If you want to use your token, just change the ssh URLs to HTTPS URLs.

<todo: change links from rudislabs to NXP>

Build the package:

run the following command in a bash terminal to automatically set up your ROS environment at startup of a bash terminal:

Then source your bashrc to ensure it is effective in the current session.

Now, run the following ROS command. It will install dependent packages:

After it runs re-source your bashrc and re-run the same launch script:

Open a second ssh session, and run the joy node to begin the connection with the joystick:

hashtag
Operation of the demo

Now your LEDs are ON and you should be able to control the light intensity.

Use the left and right buttons of the joystick (buttons in front of the device - see picture below) to play with the colors.

Jumper wires

MOSI

4

Orange

White

GND

7

Black

Black (original Wire)

PWR (5V)

SPI pin 1* or P11 'BEC PWR'

Red

Red

CLK

2

Yellow

Black

GND

Red

Power 5V

Yellow

Clock

Orange

MOSI (Data)

SDI = Data_IN APA102 LEDs connect in a daisy chain manner
ELM-6D0-001 board
Wires connection to UCAN board

Black (Added wire)

sudo apt-get update 
sudo apt-get dist-upgrade 
sudo apt-get install can-utils 
pip install python-can 
pkill python3 
sudo ip link set can1 down 
sudo ip link set can0 down 
sudo ip link set can0 up type can bitrate 1000000 loopback off restart-ms 100 
sudo ip link set can1 up type can bitrate 1000000 dbitrate 4000000 loopback off fd on fd-non-iso off restart-ms 100 
mkdir -p ~/git/ros2/src 
cd ~/git/ros2/src 
git clone git@github.com:rudislabs/ros2_orchestrator.git 
colcon build --symlink-install 
sudo echo "source /home/$USER/git/ros2/install/setup.bash" >> ~/.bashrc
source ~/.bashrc 
ros2 launch ros2_orchestrator orchestrate.launch.py 
ros2 launch ros2_orchestrator orchestrate.launch.py 
ros2 run joy joy_node 
El Mandadero project