Motor drive: Difference between revisions

From Rsewiki
(5 intermediate revisions by the same user not shown)
Line 23: Line 23:
* Adafruit-GFX-Library to get the paint functions for the display
* Adafruit-GFX-Library to get the paint functions for the display
* Adafruit_SSD1306 to get the specifics for the used display
* Adafruit_SSD1306 to get the specifics for the used display
cd ~/
mkdir -p git
cd git
  git clone https://github.com/adafruit/Adafruit_BusIO.git
  git clone https://github.com/adafruit/Adafruit_BusIO.git
  git clone https://github.com/adafruit/Adafruit_SSD1306.git
  git clone https://github.com/adafruit/Adafruit_SSD1306.git
Line 36: Line 40:
  ln -s ~/git/elapsedMillis
  ln -s ~/git/elapsedMillis


== Compile and upload ==
=== Get code from SVN ===
 
The code is available on SVN:
 
cd
svn checkout svn://repos.gbar.dtu.dk/jcan/scorpi
 
The main package for this page is:
* The motor_driver firmware for Teensy 4.1
 
Other parts will be described on other pages, like.
* The teensy_interface from Teensy board(s) to MQTT
* ROS2 code starts with a YDLidar driver and is in the ROS2 directory
 
== Moror drive ==


Compile and upload to Teensy
Compile and upload to Teensy.


  cd ~/scorpi/motor_drive
  cd ~/scorpi/motor_drive
  make
  make


This should produce a file called motor_drive.hex ready to be uploaded:
This should produce a file called motor_drive.hex, ready to be uploaded:


NB! before you upload, press the power reset button, to avoid power shutdown.
NB! Before you upload, press the power reset button to avoid power shutdown.


  Press had hold "power reset"
  Press had hold "power reset"
Line 51: Line 69:
  Release "power reset" when "alive" LED starts blinking
  Release "power reset" when "alive" LED starts blinking


=== Raspberry 5 ===
=== Compile on Raspberry Pi 5 ===


Compiling motor drive on the Raspberry 5 failed in one of the Teensy libraries.
Compiling motor drive on the Raspberry 5 failed in one of the Teensy libraries.

Revision as of 15:30, 10 August 2024

Back to scorpi

Load arduino and Teensyduino

Install Arduino version 1.8.19 for the platform, find it here https://www.arduino.cc/en/software

Unpack in the Downloads directory (to fit the path in the Makefile)

cd ~/Downloads
tar -xf arduino-1.8.19-linuxaarch64.tar.xz

Install Teensyduino from https://www.pjrc.com/teensy/td_download.html

Make the installer executable and install it on top of the Arduino installation.

chmod +x TeensyduinoInstall.linuxaarch64
./TeensyduinoInstall.linuxaarch64

Additional Arduino libraries

Additional libraries from Ardufruit are needed for the small display:

  • Adafruit_BusIO to get additional services from the I2C interface
  • Adafruit-GFX-Library to get the paint functions for the display
  • Adafruit_SSD1306 to get the specifics for the used display
cd ~/
mkdir -p git
cd git
git clone https://github.com/adafruit/Adafruit_BusIO.git
git clone https://github.com/adafruit/Adafruit_SSD1306.git
git clone https://github.com/adafruit/Adafruit-GFX-Library
git clone https://github.com/pfeerick/elapsedMillis.git

The obtained libraries should be included in the Arduino/Teensyduino library list, e.g. if the GIT repositories are in a ~/git directory:

cd Arduino-1.8.19/hardware/teensy/avr/libraries
ln -s ~/git/Adafruit_BusIO
ln -s ~/git/Adafruit-GFX-Library
ln -s ~/git/Adafruit_SSD1306
ln -s ~/git/elapsedMillis

Get code from SVN

The code is available on SVN:

cd
svn checkout svn://repos.gbar.dtu.dk/jcan/scorpi

The main package for this page is:

  • The motor_driver firmware for Teensy 4.1

Other parts will be described on other pages, like.

  • The teensy_interface from Teensy board(s) to MQTT
  • ROS2 code starts with a YDLidar driver and is in the ROS2 directory

Moror drive

Compile and upload to Teensy.

cd ~/scorpi/motor_drive
make

This should produce a file called motor_drive.hex, ready to be uploaded:

NB! Before you upload, press the power reset button to avoid power shutdown.

Press had hold "power reset"
make upload
Release "power reset" when "alive" LED starts blinking

Compile on Raspberry Pi 5

Compiling motor drive on the Raspberry 5 failed in one of the Teensy libraries.

This was fixed by renaming a few files in the library:

cd ~/Downloads/arduino-1.8.19/hardware/teensy/avr/libraries/USBHost_t36/
mv BluetoothConnection.cpp BluetoothConnection.cpp.not  
mv bluetooth.cpp bluetooth.cpp.not
mv joystick.cpp joystick.cpp.not

It was probably in the Bluetooth part, but I failed to remove Bluetooth from joystick.cpp, so all USB-host joystick support has gone.

No joystick is OK for this project.

The code compiles but does not run! The same code runs fine when compiled on a normal Ubuntu.