My package arrives 3 Jan 2019. Unfortunately although my project needs camera mine doesn't include the Sony camera board. So i purchased my own camera and received it by end of Jan 2019
The board can use Arduino IDE and spresense SDK for development. At a glance the arduino IDE seems a more logical choice to try out for first attempt.
Installation and Making Sure it works
The board requires us to stick a strong daylight blocker to the chip, something very unconventional to me. Originally i have missed this step. The matter is worsened by the fact that i initially connect the board with a non data microUSB cable and it doesn't boot as a com port device. I became worried as i read the documentation and find that there is a warning that without this blocker sticker the chip might malfunctioned. Anyhow, after i change my cable and put on the sticker, it works. The details on the installation is as followed.
Following the guide on https://developer.sony.com/develop/spresense/developer-tools/get-started-using-arduino-ide/set-up-the-arduino-ide, i reach this stage that the driver is working.
Then, we download the board using board manager. in fact it is first time i know can do this addtitonal board settings via json
The we follow through the guide to burn the bootloader onto the board.
This project is based on the spresense reference board library version 1.1.3 with Arduino 1.5 IDE
Camera Installation
Follow instruction in 3.3 and 3.4 on https://developer.sony.com/develop/spresense/developer-tools/get-started-using-nuttx/hardware-overview#_how_to_connect_and_prepare_the_spresense_main_board_and_spresense_camera_board
after starting the board with the camera, open the serial monitor, set the baud rate to 115200, then we will be able to monitor the board camera operation
Motor Testing
To test the motor, download the Cytron motor driver library
To test the motor, download the Cytron motor driver library and make the connections and setup as seen in the photo below. There are two sets of MD13s 13A motor driver. One of the set connects to PWM pin 3 and 9 of the spresense, while another set connects to PWM pin 5 and 6.
#include "CytronMotorDriver.h"
// Configure the motor driver.
CytronMD motor1(PWM_PWM, 3, 9); // PWM 1A = Pin 3, PWM 1B = Pin 9.
CytronMD motor2(PWM_PWM, 5, 6); // PWM 2A = Pin 5, PWM 2B = Pin 6.
// The setup routine runs once when you press reset.
void setup() {
}
// The loop routine runs over and over again forever.
void loop() {
motor1.setSpeed(128); // Motor 1 runs forward at 50% speed.
motor2.setSpeed(-128); // Motor 2 runs backward at 50% speed.
delay(1000);
motor1.setSpeed(255); // Motor 1 runs forward at full speed.
motor2.setSpeed(-255); // Motor 2 runs backward at full speed.
delay(1000);
motor1.setSpeed(0); // Motor 1 stops.
motor2.setSpeed(0); // Motor 2 stops.
delay(1000);
motor1.setSpeed(-128); // Motor 1 runs backward at 50% speed.
motor2.setSpeed(128); // Motor 2 runs forward at 50% speed.
delay(1000);
motor1.setSpeed(-255); // Motor 1 runs backward at full speed.
motor2.setSpeed(255); // Motor 2 runs forward at full speed.
delay(1000);
motor1.setSpeed(0); // Motor 1 stops.
motor2.setSpeed(0); // Motor 2 stops.
delay(1000);
}
this is the code used for testing and the video belows shows the test result
Testing the GNSS
To test the GNSS, we use the code from the gnss.ino example. After loading the code, open the serial monitor. I have tested it in the room in front of the window yet it cannot get the fix, although 2 satellites are found.
after that i try it outdoor. while it found more satellites it still cannot get a fix
i also test with example GNSS tracker.ino, also there is not GPS fix
Testing the Audio
to do this
1) install the mp3_dec_installer with the sd card attached to Spresense
2) copny the mp3 with windows explorer, when the sd card is attached to pc, and copy the mp3 file the sd card
3) connect the speaker to the audio jack, with the sd card on spresense
4) run the sketch Audio\application\player
one thing i quite blur is that the serial monitor shows main player error code: 5 although it does successfully play the sound through a connected speaker
servo motor testing
originally i also want to use a servo motor to tilt the camera up and down. Nonetheless i tested the servo.ino it works flawlessly with smaller rc servo. with the 6V grade servo that can be driven with Arduino Mega, it can drive it properly. Hence i don't use it
Putting all together
So after testing, i decide that i just let the bot roam the garden and take random photo. To do this, i use a permanently on power bank to power up the Spresense, and a battery pack to power on the motor and motor driver
The camera is hold into place with flexible wire so i can tilt it to some angle i want. the entire Spresense sits on a rc servo tilting plate, so we can extend the bot with tilting control. The motors are designated motor1 and motor2 individually. To use them with the MD13s we first include the necessary header file and then define two CytronMD object. The settings should be PWM_DIR instead PWM_PWM
for Spresense, pin 4,7 are non PWM pins hence they are chosen for directional control. Pin 3,5 are used for speed control respectively
#include "CytronMotorDriver.h"
// Configure the motor driver.
CytronMD motor1(PWM_DIR, 3, 4); // PWM 1A = Pin 3, DIR=4
CytronMD motor2(PWM_DIR, 5, 7); // PWM 2A = Pin 5, DIR=pin 7
The bot will roam a few direction. in the coding it is forward, backward, left, right
below is code snippet of running forward. The drive incorporate a simple ramping.
void movefront()
{
motor1.setSpeed(128); // Motor 1 runs forward at 50% speed.
motor2.setSpeed(128); // Motor 2 runs forward at 50% speed.
delay(1000);
motor1.setSpeed(255); // Motor 1 runs forward at full speed.
motor2.setSpeed(255); // Motor 2 runs forward at full speed.
delay(10000);
motor1.setSpeed(0); // Motor 1 stops.
motor2.setSpeed(0); // Motor 2 stops.
delay(5000);
}
depending on how one want to control the bot, if we want to move further than what movefront() does, simply call it another time, just as below
movefront();
delay(2000);
movefront();
Taking photo
Both GPS and photo taken is saved to the memory card. Due to problem with GPS fix, it all saved as zero only
Other major problems being most of the time the pets will run away at the approach of the bots and reach some hiding places inaccessible to the bots
surely, it is more complicated than i have thought off and i have insufficient time to resolve every problem. But i will continue to dwell on it
Comments