Higher voltage will increase the servos’ torque and make Nybble move faster. The downside is it will increase current draw, reduce battery life, affect the stability of circuit, and accelerate the wearing of the servos. Based on my tests, 5.5V seems to result in a balanced performance.
For initial installation, don’t put screws on the NyBoard as you may need to take it out for tuning the potentiometer. Make sure all the servos can rotate fine in normal working condition before making fine calibrations.
The I2C switch changes the master of I2C devices (gyro/accelerometer, servo driver, external EEPROM). On default “Ar”, NyBoard uses the on-board ATmega328P as the master chip; On “Pi”, NyBoard uses external chips connected through the I2C ports (SDA, SCL) as the master chip.
NyBoard is designed for two use cases. One is for Nybble that uses metal geared servos, the other is for DIY robots that may use plastic geared servos. Plastic servos can only stand 6V so there is a step down chip on NyBoard. The chip is rated for 5A maximal output, but can only be achieved with multiple proper settings and careful tuning.
When using NyBoard with the metal geared servos of Nybble, optimized performance can be achieved by some adjustment. For NyBoard_V0_1, you will need to do some soldering work as discussed in the forum post. For NyBoard_V0_2, you can connect the jumper switch SW3 between BATT and V_S (Considering safety for plastic servos, by default NyBoard comes with SW3 connecting V_S and V+).
If you have previously added other libraries and see an error message "XXX library is already installed", I would recommend you delete them first (instruction: https://stackoverflow.com/questions/16752806/how-do-i-remove-a-library-from-the-arduino-environment). Due to different configurations of your Arduino IDE installation, if you see any error messages regarding missing libraries during later compiling, just google and install them to your IDE.
Go to the library manager of Arduino IDE (instruction: https://www.arduino.cc/en/Guide/Libraries), search and install
Adafruit PWM Servo Driver
To save programming space, you can comment out the unused decoder in IRremote.h. It will save about 10% flash!
On Mac, find Documents/Arduino/libraries/IRremote/src/IRremote.h and set unused decoders to 0:
#define DECODE_RC5 0#define SEND_RC5 0#define DECODE_RC6 0#define SEND_RC6 0#define DECODE_NEC 1#define SEND_NEC 0#define DECODE_SONY 0#define SEND_SONY 0...#define DECODE_HASH 1 // special decoder for all protocols
Go to jrowberg/i2cdevlib: I2C device library collection for AVR/Arduino or other C++-based MCUs, download the zip file and unzip. You can also git clone the whole repository.
Use Add .ZIP Library to find Arduino/MPU6050/ and Arduino/I2Cdev/. Click on the folders and add them one by one. They don’t have to be .ZIP files.
If you get NyBoard V1_*, you can simply choose Arduino Uno.
If you have NyBoard V0_* which runs at 20MHz, you need to add our customized configuration file following the next steps:
Open the Preferences... panel
In the Additional Boards Manager URLs field, add https://raw.githubusercontent.com/PetoiCamp/OpenCat/master/Resources/NyBoard/boardManager/package_petoi_nyboard_index.json. If there are already URLs listed in this field, separate them with commas or click on the icon next to the field to open up an editor and add this URL to a new line. Make sure there's no space in the address when you copy-paste the link.
Click on the OK button to close the Preferences panel (you have to close the previously opened Additional Boards Manager URLs editor first, to close the Preference panel)
Open the Boards Manager... window with the Tools -> Board: XXXX -> Boards Manager... menu item.
In the Filter your search... field, type NyBoard
Select the entry and click on Install
Click on the Close button
Select ATmega328P (5V, 20 MHz) NyBoard from the Tools -> Board: XXXX menu (NyBoardV0_1 and NyBoardV0_2 are using the same board settings.)
● Locate the file boards.txt
To access, right-click on Arduino.app and choose Show Package Contents
IMPORTANT! If you have installed the Arduino IDE via the Microsoft Store, you likely will not have access to the folder where critical configuration files are stored. The easiest solution is to uninstall the IDE and download/re-install it directly from https://www.arduino.cc.
Downloading from the terminal or from the software manager might not give you the latest version which can be an issue. Please download the latest version from Arduino’s site: https://www.arduino.cc/en/Main/Software
Unzip the package and
The location of boards.txt files is:
Fedora: boards.txt is symlinked under:
Arch: boards.txt is found at:
Ubuntu (on 18.04 when installing with
apt-get install arduino):
after locating boards.txt:
● Make a copy of boards.txt in case you want to roll back.
● Create new boards.txt.
You can download my boards.txt file, or:
Edit your boards.txt with admin privilege. Find the section of
pro.name=Arduino Pro or Pro Mini
and insert the
## Arduino Pro or Pro Mini (5V, 20 MHz) w/ ATmega328P## --------------------------------------------------pro.menu.cpu.20MHzatmega328=ATmega328P (5V, 20 MHz) NyBoardpro.menu.cpu.20MHzatmega328.upload.maximum_size=30720pro.menu.cpu.20MHzatmega328.upload.maximum_data_size=2048pro.menu.cpu.20MHzatmega328.upload.speed=57600pro.menu.cpu.20MHzatmega328.bootloader.low_fuses=0xFFpro.menu.cpu.20MHzatmega328.bootloader.high_fuses=0xDApro.menu.cpu.20MHzatmega328.bootloader.extended_fuses=0xFDpro.menu.cpu.20MHzatmega328.bootloader.file=atmega/ATmega328_20MHz.hexpro.menu.cpu.20MHzatmega328.build.mcu=atmega328ppro.menu.cpu.20MHzatmega328.build.f_cpu=20000000L## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328P## --------------------------------------------------
code block in the Arduino Pro or Pro Mini section as below. Save and quit your editor.
##############################################################pro.name=Arduino Pro or Pro Minipro.upload.tool=avrdudepro.upload.protocol=arduinopro.bootloader.tool=avrdudepro.bootloader.unlock_bits=0x3Fpro.bootloader.lock_bits=0x0Fpro.build.board=AVR_PROpro.build.core=arduinopro.build.variant=eightanaloginputs## Arduino Pro or Pro Mini (5V, 20 MHz) w/ ATmega328P## --------------------------------------------------pro.menu.cpu.20MHzatmega328=ATmega328P (5V, 20 MHz) NyBoardpro.menu.cpu.20MHzatmega328.upload.maximum_size=30720pro.menu.cpu.20MHzatmega328.upload.maximum_data_size=2048pro.menu.cpu.20MHzatmega328.upload.speed=57600pro.menu.cpu.20MHzatmega328.bootloader.low_fuses=0xFFpro.menu.cpu.20MHzatmega328.bootloader.high_fuses=0xDApro.menu.cpu.20MHzatmega328.bootloader.extended_fuses=0xFDpro.menu.cpu.20MHzatmega328.bootloader.file=atmega/ATmega328_20MHz.hexpro.menu.cpu.20MHzatmega328.build.mcu=atmega328ppro.menu.cpu.20MHzatmega328.build.f_cpu=20000000L## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328P## --------------------------------------------------
● Download ATmega328_20MHz.hex and put it in your Arduino folder ./bootloaders/atmega/. You should see other bootloaders with the .hex suffix in the same folder.
Restart your Arduino IDE. In Tools->Boards, select Arduino Pro or Pro Mini. You should find ATmega328P (5V, 20 MHz) in the Processor menu.
Every NyBoard has to go through functionality checks before shipping, so they should already have a compatible bootloader installed. However, in rare cases, the bootloader may collapse then you won't be able to upload sketches through Arduino IDE.
Well, it's not always the bootloader if you cannot upload your sketch:
Sometimes your USB board will detect a large current draw from a device and deactivate the whole USB service. You will need to restart your USB service, or even reboot your computers;
You need to install the driver for the FTDI USB 2.0 to UART uploader;
You haven't selected the correct port;
Bad luck. Tomorrow is another day!
If you really decide to re-burn the bootloader:
If you get NyBoard V1_*, you can simply choose Arduino Uno under the Tool menu of Arduino IDE.
If you have NyBoard V0_* which runs at 20MHz, you need to choose NyBoard (ATmega328P 5V, 20MHz).
Select your ISP (In-System Programmer). The above screenshot shows two popular programmers: the highlighted USBtinyISP is a cheap bootloader you can buy, while the checked Arduino as ISP can let you use a regular Arduino as ISP!
Connect the programmer with the SPI port on NyBoard. Notice the direction when connecting. Make sure they have good contact.
Burn bootloader. If it's your first time doing so, wait patiently until you see several percent bars reach 100% and no more messages pop up for one minute.
The following picture shows two common FTDI boards.
On the red board, the jumper selector should be put on 5V (not 3.3V) on the uploader for Arduino. Match the GND on both the uploader and the 6-pin socket on NyBoard.
Connect your computer with the FTDI uploader (the red chip with 6 male pins) through mini-USB to USB cable. The uploader has three LEDs, power, Tx and Rx. Right after connection, the Tx and Rx should blink for one second indicating initial communication, then dim. Only the power LED should keep litting up. You can find a new port under Tool->Port as “/dev/cu.usbserial-xxxxxxxx” (Mac) or “COM#” (Windows).
For Linux, once the uploader is connected to your computer, you will see a “ttyUSB#” in the serial port list. But you may still get a serial port error when uploading. You will need to give the serial port permission. Please go to this link and follow the instructions: https://playground.arduino.cc/Linux/All/#Permission
If Tx and Rx keep litting up, there’s something wrong with the USB communication. You won’t see the new port. It’s usually caused by overcurrent protection by your computer, if you’re not connecting NyBoard with external power supply and the servos move all at once.
In later versions, there may be a different version of the FTDI uploader. Just check the marks on the chip and connect it with NyBoard correctly.
Starting from Jan.1st, 2021, we include our official bluetooth dongle in the standard Nybble kit. It can be used for wirelessly uploading sketches and communicating with the robot. The default passcode is 0000 or 1234, and baudrate is set to 115200. After connecting to the computer, you can use it in the same way as the wired uploader.
Download a fresh OpenCat repository from GitHub: https://github.com/PetoiCamp/OpenCat. It’s better if you utilize GitHub’s version control feature. Otherwise make sure you download the WHOLE Nybble FOLDER every time. All the codes have to be the same version to work together.
There are several testX.ino codes in ModuleTests folder. You can upload them to test certain modules separately. Open any testX.ino sketch with prefix “test”. (I recommend using testBuzzer.ino as your first test sketch)
For NyBoard V1_*, choose the board as Arduino Uno and later set the baudrate to 115200 in both the code and the serial monitor.
For NyBoard V0_*, choose the board as NyBoard (ATmega328P 5V, 20MHz) and later set the baudrate to 57600 in both the code and the serial monitor.
Compile the code. There should be no error messages. Upload the sketch to your board and you should see Tx and Rx LEDs blink rapidly. Once they stop blinking, messages should appear in the serial monitor.
If there're input prompts, make sure you set "No line ending". Otherwise the invisible '\n' or '\r' characters will confuse the parsing functions.
For Linux machines, you may see the following error message:
You will need to add execution previlige to the avr-gcc to compile the Arduino sketch:
sudo chmod +x filePathToTheBinFolder/bin/avr-gcc
Further more, you need to add execution permission to all files within /bin, so the command would be :
sudo chmod -R +x /filePathToTheBinFolder/bin
With the FTDI to USB converter connecting NyBoard and Arduino IDE, you have the ultimate interface to communicate with NyBoard and change every byte on it.
I have defined a set of serial communication protocol for NyBoard:
All the token starts with a single Ascii encoded character to specify its parsing format. They are case-sensitive and usually in lower case.
As shown in the serial protocol, the arguments of tokens supported by Arduino IDE's serial monitor are all encoded as Ascii char strings for human readability. While a master computer (e.g. RasPi) supports extra commands, mostly encoded as binary strings for efficient encoding. For example, when encoding angle 65 degrees:
Ascii: takes 2 bytes to store Ascii characters '6' and '5'
Binary: takes 1 byte to store value 65, corresponding to Ascii character 'A'
Obviously, binary encoding is much more efficient than Ascii string. However, the message transferred will not be directly human readable. In the OpenCat repository, I have put a simple Python script ardSerial.py that can handle the serial communication between NyBoard and Pi.
In Pi's terminal, type
Under Interface option, find Serial. Disabled the serial login shell and enable the serial interface.
If you plug Pi into NyBoard's 2x5 socket, their serial ports should be automatically connected at 3.3V. Otherwise pay attention to the Rx and Tx pins on your own AI chip, and its voltage rating. The Rx on your chip should connect to the Tx of NyBoard, and Tx should connect to Rx.
If you want to run it as bash command, you need to make it executable:
chmod +x ardSerial.py
You may need to change the proper path of your Python binary on the first line:
./ardSerial.py <args> is almost equivalent to typing <args> in Arduino's serial monitor. For example,
./ardSerial.py kcr means "perform skill crawl".
Both ardSerial.py and the parsing section in Nybble.ino need more implementations to support all the serial commands in the protocol.
With the additional current draw by Pi, Nybble will be less capable for intense movements, such as trot (the token is
ktr). The system is currently powered by two 14500 batteries in series. You may come up with better powering solutions, such as using high drain 7.4 Lipo batteries, or 2S-18650. There're a bunch of considerations to collaborate software and hardware for a balanced performance. With Nybble's tiny body, it's better to serve as a platform for initiating the communication framework and behavior tree rather than a racing beast.
Though you can program NyBoard directly with the FTDI uploader, external power is required to drive the servos.
When powering the NyBoard with only USB FTDI, there's obviously charging and uncharging in the servo's capacitor and cause the yellow LED to pulse. However the USB's current is not sufficient to keep the servos working. The servo circuit has to be powered by external batteries to work properly.
NyBoard requires 7.4~9V external power to drive the servos. On Nybble, we are using 8V standard to configure all the parameters as a whole system. That's usually two Li-ion or Li-poly batteries connected in series. A single battery is 4.2V when fully charged and can work normally until voltage drops to 3.6V. That’s about 7.2V with two batteries connected in series. Before installation, dial the potentiometer on NyBoard clockwise to try minimum output first (about 4.5V), then dial it up until it can make the robot work properly. With our kit servos, it actually works better to connect SW3 between BATT with V_S directly and bypass the step-down chip (so no need to tune the potentiometer).
When looking for batteries, search for keywords “14500 3.7V li-ion battery unprotected”. I’ve noticed that the overcurrent protection of some batteries could be triggered by peak current draw-(usually >2.5A), causing NyBoard to reset or malfunction. Try find batteries with higher discharge rating.
The included battery holder is sized for 14500 batteries, that’s 14 mm in diameter, and 50 mm in length. 50 ± 1 mm should still fit in. They are the same size as AA batteries, but much more powerful. Make sure not to use them in regular AA devices. If you are in the US, we have tested with EBL 14500 li-ion batteries.
You can also design other battery holders to carry larger batteries for better performance. That’s especially necessary if you mount a Raspberry Pi or want Nybble run faster.
Be careful with the polarity when connecting the power supply. Make sure you can find the positive (+) and negative (-) sign on both the NyBoard's power terminal and your power supply.
Loosen the screws of the power block. Insert the wires of the battery holder then tighten the screws. When turn the switch on, both the blue LED (for chip) and the yellow LED (for servo) should lit up.
In the kit shipped after Jan.1st, the terminal is replaced with an anti-reverse socket, so you won't be able to plug in the wrong direction.
It can last hours if you're mainly coding and testing postures, or less than 30 mins if you keep Nybble running.
When the battery is low, the yellow LED will blink slowly. Although NyBoard can still drive one or two servos, it will be very unstable to drive multiple servos at once. That will lead to repeatedly restarting the program, or awkward joint rotations. In rare cases, it may even alter the bits in EEPROM. You will need to reupload the codes and re-save the constants to recover.
You will need compatible smart chargers for the batteries. Keep batteries attended during charging.
After playing, remember to remove the batteries from battery holder to avoid over discharging.
It's ok to connect both FTDI and battery at the same time. You can type in serial commands while the battery is connected. I do notice that the USB serial port could be disabled randomly. I think that's due to the sudden current draw by servos. It will trigger the computer’s over current protection and disable the USB port. In that case, you can change the USB port you're connecting to, reset the USB bus, or restart the computer. So actually it’s better to power the board by battery before plug in the FTDI.