Upload Sketch For NyBoard (software 1.0)
You can use Arduino IDE to config the NyBoard and upload sketch.
The following video shows the software configuration using our robot dog Bittle. The steps are identical to Nybble except that you need to change the model definition in OpenCat.h to Nybble.
1. NyBoard
1.1 Read the user manual
Find the version information for your board on NyBoard. As shown below:
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252F6XupunQevRtFsmxKyrES%252FNyBoardV1_1.jpg%3Falt%3Dmedia%26token%3D7be45110-1abf-4327-a7ae-04fc85e9ced5&width=768&dpr=4&quality=100&sign=ace5dbab&sv=1)
Nybble
Find the version info on NyBoard. Read the user manual for NyBoard V0_1, NyBoard V0_2 , NyBoard V1_0, or NyBoard V1_1 (a light revision) accordingly.
Bittle
Find the version info on NyBoard. Read the user manual for NyBoard V1_0 or NyBoard V1_1 (a light revision) accordingly.
Take NyBoard V1_0 as an example, as shown in the following figure:
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FdDaqIl2GPLhhaY3qpK7q%252Fassets_-MPQ2vWEZUH7ol6XE55o_-Mafr-LQL8D20NOtf8CC_-Mafr2YhCeDW2NsKIqde_NyBoardV1new_A.png%3Falt%3Dmedia%26token%3D8167cd5f-146b-48b3-8323-cfa22bec9ea5&width=768&dpr=4&quality=100&sign=4d3ca04d&sv=1)
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252F2M1quSKkmxD8fY6ABhGT%252Fassets_-MPQ2vWEZUH7ol6XE55o_-Mafr-LQL8D20NOtf8CC_-Mafr2YgZpKEumQgfq4g_NyBoardV1new_B.png%3Falt%3Dmedia%26token%3D9e1326aa-ec30-4a79-9431-9f212630314e&width=768&dpr=4&quality=100&sign=65a755ca&sv=1)
Wrong operations may damage your NyBoard!
1.2. Dial the slide switch to Arduino.
The slide switch changes the master of I2C devices (gyro/accelerometer, servo driver, external EEPROM).
On default “Arduino”, NyBoard uses the onboard ATmega328P as the master chip;
On “Pi”, NyBoard uses external chips connected through the I2C ports (SDA, SCL) as the master chip.
Sometimes if you cannot go through the bootup stage, maybe you have accidentally dialed the switch to "RPi".
The following section is kept for Nybble older versions (V0)
1.3. Dial the potentiometer clockwise to start from the lowest voltage.
From NyBoard V0_2, we provide a jumper selector to bypass the potentiometer. If you are using the metal servos in a standard Nybble kit, this section can be skipped.
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 the circuit, and accelerate the wearing of the servos. Based on my tests, 5.5V seems to result in a balanced performance.
For the 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 conditions before making fine calibrations.
1.4. Adjust the NyBoard for optimized performance (no need for NyBoard V1_0).
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+).
V_S means power for the servo. The jumper switch chooses whether to power the servos (V_S) by the step-down chip (V+) or by the batteries (BATT) directly. So BATT and V+ should never be connected directly.
It turns out that NyBoard works more stable when powering the metal-geared servos directly with BATT rather than V+. However, if you are using NyBoard to drive your own plastic geared servos, you do need to use the step-down circuit.
NyBoard powers the metal-geared servos directly with the 7.2V battery. It's 8.4V when fully charged. You CANNOT use NyBoard to drive your own plastic geared servos directly.
2. Downloads and installations
You will need the newest Arduino IDE to set up the environment. Older versions tend to compile larger hex files that may exceed the memory limit.
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.
If you downloaded the OpenCat(sw 1.0) code from GitHub after Jan 3, 2022, you can skip all the following libraries.
2.1. Install through the library manager
Go to the library manager of Arduino IDE (instruction: https://www.arduino.cc/en/Guide/Libraries), search and install
Adafruit PWM Servo Driver
QList (optional)
IRremote
The IRremote library was updated recently. And for some reason, they even changed the encoding of the buttons. You MUST roll back the library's version to 2.6.1 in the library manager.
To save programming space, you MUST comment out the unused decoder in IRremote.h. It will save about 10% flash!
Find Documents/Arduino/libraries/IRremote/src/IRremote.h and set unused decoders to 0. That is, only DECODE_NEC and DECODE_HASH are set to 1, and others are set to 0.
2.2 Install by adding .ZIP library
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.
2.3. Add NyBoard support to Arduino IDE
With NyBoard V1_*, you can simply choose Arduino Uno.
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FHReg8TNf79FVD6L7hLb4%252Funo.png%3Falt%3Dmedia%26token%3Dd85c1c76-470e-41de-b856-c6c2d9f8f504&width=768&dpr=4&quality=100&sign=c7e7320c&sv=1)
The following section is kept for Nybble older versions (V0)
If you have NyBoard V0_* which runs at 20MHz, you need to add our customized configuration file following the next steps:
Automatic method (many thanks to A-Ron!)
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.)
Manual Board Installation Method
Only if the above method fails
● Locate the file boards.txt
Mac location:
/Users/UserName/Library/Arduino15/packages/arduino/hardware/avr/version#/
Or:
/Applications/Arduino.app/Contents/Java/hardware/arduino/avr
To access, right-click on Arduino.app and choose Show Package Contents
Windows location:
C:\Program Files(x86)\Arduino\hardware\arduino\avr\
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.
Linux
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 sudo install.sh
The location of boards.txt files is:
Fedora: boards.txt is symlinked under:
/etc
Arch: boards.txt is found at:
/usr/share/arduino/hardware/archlinix-arduino/avr/
Mint:
location_of_installation/arduino/hardware/arduino/avr
Ubuntu (on 18.04 when installing with apt-get install arduino
):
/usr/share/arduino/hardware/arduino/boards.txt
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
code block in the Arduino Pro or Pro Mini section as below. Save and quit your editor.
● 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.
If you cannot find the board, your Arduino IDE may be using the boards.txt in another path. Search boards.txt in all the folders on your computer. Find out the right file that's in effect.
Only if the bootloader of NyBoard collapsed, which is very unlikely to happen
2.4. Burn the bootloader (no need for normal use)
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 the UART uploader;
You haven't selected the correct port;
Bad contacts;
Bad luck. Tomorrow is another day!
If you really decide to re-burn the bootloader:
With 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.
2.5. Connect the uploader (sometimes referred to as the programmer)
This step does not require the Nyboard to be mounted on the robot.
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FJ5KfoJTcbq4VagZMSsGs%252FusbAdapter1.jpg%3Falt%3Dmedia%26token%3Dbb053922-ce58-445c-9605-306412579778&width=768&dpr=4&quality=100&sign=67176b62&sv=1)
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252F6JztISWrSlnV2CmZ3rSk%252FPlug_in_usb_uploader.jpeg%3Falt%3Dmedia%26token%3D68c71c7f-3007-431d-9d03-045aab232aa0&width=768&dpr=4&quality=100&sign=4ef8e8a0&sv=1)
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FlDLMDOZT2l8jcT8Zasbv%252FusbAdapter2.jpg%3Falt%3Dmedia%26token%3D4231c2cc-d590-4caa-9a94-77358ef14e83&width=768&dpr=4&quality=100&sign=326d7b96&sv=1)
The following picture shows two FTDI boards in previous kits for Nybble.
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.
First connect the computer and the FTDI uploader with a miniUSB-USB cable. The red model uploader has three LED lights, power, Tx and Rx, and the blue model uploader has no power light. At the moment when the computer USB is connected, the Tx and Rx lights will flash and then go out, indicating that there is an initial information transmission. Then you can find the corresponding serial port “/dev/cu.usbserial-xxxxxxxx” (Mac OS) or “COM#” (Windows OS) in Tools->Port of Arduino IDE.
Connect your computer with the uploader through USB to micro-USB cable. The uploader has three LEDs, power, Tx, and Rx. Right after the connection, the Tx and Rx should blink for one second indicating initial communication, then dim. Only the power LED should keep lighting up. You can find a new port under Tool->Port as “/dev/cu.usbserial-xxxxxxxx” (Mac) or “COM#” (Windows).
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FUJdhE97cCp9X5sJy5vnd%252FUSBserial.png%3Falt%3Dmedia%26token%3Da6bc292c-cebf-4422-981a-3e9007f3bb53&width=768&dpr=4&quality=100&sign=95a39418&sv=1)
If Tx and Rx keep lighting 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 an external power supply and the servos move all at once.
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
2.6. Connect Bluetooth uploader (optional)
It’s possible to program and communicate with Bittle wirelessly. You can even control Nybble / Bittle with a smartphone APP or web API from there!
We include our official Bluetooth dongle in the standard Nybble / Bittle kit. It can be used for wirelessly uploading sketches and communicating with the robot. The baud rate is set to 115200.
You need to connect it to your computer like what you do with a Bluetooth AirPod. The default passcode is 0000 or 1234. Then you can select it under Tools->Port of Arduino IDE, and use it in the same way as the wired uploader.
For the specific connection method, please refer to the corresponding chapter of the Dual-Mode Bluetooth module.
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FhpFexBFyMb9PT118OCo7%252Fbluetooth.png%3Falt%3Dmedia%26token%3D34caad28-854e-4f84-9c79-d874caa87d17&width=768&dpr=4&quality=100&sign=19691ce&sv=1)
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FHtLWy0Uv04ubroaBSWbL%252Fblue.jpg%3Falt%3Dmedia%26token%3D1f585c2a-23e7-4314-b1ab-8e4085411fc8&width=768&dpr=4&quality=100&sign=8c2d71f8&sv=1)
You will need to set its baudrate to 57600 to use it on NyBoard V0_* for Nybble.
On Mac, the Bluetooth may lose connection after several uploads. In that case, delete the connection and reconnect to resume the functionality.
The Bluetooth dongle is not included in the kit sold by Seeed Studio or its partners. Please write to support@petoi.com for more information.
2.7. Download the OpenCat package
Download the 1.0 OpenCat repository from GitHub: https://github.com/PetoiCamp/OpenCat/tree/1.0
If you download the Zip file of the codes, you will get an OpenCat-1.0 folder after unzipping. You need to rename it to OpenCat before opening the OpenCat.ino.
No matter where you save the folder, the file structure should be:
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)
Open up the serial monitor and set up the baudrate:
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 on the serial monitor.
Make sure you set "No line ending" to before entering your commands. Otherwise, the invisible '\n' or '\r' characters will confuse the parsing functions.
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FUj3OHmDv2n6DenYZeA7s%252FserialMonitor.png%3Falt%3Dmedia%26token%3D81eaec76-f4eb-44c7-8592-e78b4ed19254&width=768&dpr=4&quality=100&sign=a83058d0&sv=1)
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FPaQ7rnddFCxM4gYz60oK%252Fmonitor.png%3Falt%3Dmedia%26token%3D9ca1d638-c9fc-458c-951c-3f671b167b0c&width=768&dpr=4&quality=100&sign=919ea178&sv=1)
For Linux machines, you may see the error message like "permission denied".
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FaHpxRwrHaIInugshoyr7%252FLinux%2520error%2520message.jpeg%3Falt%3Dmedia%26token%3D52432a37-00c7-44fd-b11a-cd1f2f08a7e1&width=768&dpr=4&quality=100&sign=84d4ea10&sv=1)
You will need to add execution privilege to the avr-gcc to compile the Arduino sketch:sudo chmod +x filePathToTheBinFolder/bin/avr-gcc
Furthermore, you need to add execution permission to all files within /bin, so the command would be : sudo chmod -R +x /filePathToTheBinFolder/bin
3. Arduino IDE as an interface
With the USB/Bluetooth uploader 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:
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FL1AsYWwELmvk3PDxvPsk%252FserialProtocol.png%3Falt%3Dmedia%26token%3Dda0f3a66-94a2-4c83-bf98-3f312b80b214&width=768&dpr=4&quality=100&sign=72396081&sv=1)
All the token starts with a single Ascii encoded character to specify its parsing format. They are case-sensitive and usually in lower case.
Some commands, like the c and m commands can be combined.
For example:
Successive "m8 40", "m8 -35", "m 0 50" can be written as "m8 40 8 -35 0 50". You can combine up to four commands of the same type. To be exact, the length of the string should be smaller than 30 characters. You can change the limit in the code but there might be a systematic constraint for the serial buffer.
Some tokens haven't been implemented, such as 'h'. Token 'i' and 'l' still have some bugs in software version 1.0.
4. Raspberry Pi serial port as an interface
Only when using Pi as a master controller. Nybble / Bittle doesn't need a Pi to move.
You need to disconnect the serial uploader to communicate with Pi's serial port.
You can solder a 2x5 socket on NyBoard to plug in a Raspberry Pi. Pi 3A+ is the best fit for Nybble / Bittle's dimension.
Nybble
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FF7xI2jCCYv1bZL0gwtuW%252F_B2L8832%2520Large.jpeg%3Falt%3Dmedia%26token%3D3120428a-8f50-4df8-8cf4-8fd9d3045212&width=768&dpr=4&quality=100&sign=e32630ed&sv=1)
Bittle
After you solder on the socket, you won't be able to install the back cover of Bittle.
You need to unplug the 6-pin programmer for the NyBoard before mounting the Pi to the board.
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FhpujFaHgr0YefHwiXCUi%252FPi01.jpg%3Falt%3Dmedia%26token%3Dcbd0bb62-dd2e-4c45-884d-d319925a7606&width=768&dpr=4&quality=100&sign=b137a674&sv=1)
The red Pi standoff can be 3D printed.
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252FcjXUzB7gi4vYX08PMIED%252FPi3a.jpg%3Falt%3Dmedia%26token%3D7b3954a8-4219-41ed-bdd9-12e4ae14a7a6&width=768&dpr=4&quality=100&sign=fd6be72d&sv=1)
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'
What about value -113? It takes four bytes as an Ascii string but still takes only one byte in binary encoding, though the content will no longer be printable as a character.
Obviously, binary encoding is much more efficient than the 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.
4.1. Config Raspberry Pi serial port
In Pi's terminal, type sudo raspi-config
Under the Interface option, find Serial. Disabled the serial login shell and enable the serial interface to use the primary UART:
Run raspi-config with sudo privilege:
sudo raspi-config
.Find Interface Options -> Serial Port.
At the option
Would you like a login shell to be accessible over serial?
select 'No'.At the option
Would you like the serial port hardware to be enabled?
select 'Yes'.Exit raspi-config and reboot for changes to take effect.
You also need to DISABLE the 1-wire interface of Pi to avoid repeating reset signals sent by Pi's GPIO 4.
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.
Note: If you installed Ubuntu OS on Raspberry Pi, please config it as follows:
add
enable_uart=1
to/boot/config.txt
remove
console=serial0,115200
from/boot/firmware/cmdline.txt
on Ubuntu and similar to/boot/cmdline.txt
on Raspberry Pi OSdisable the serial console:
sudo systemctl stop serial-getty@ttyS0.service && sudo systemctl disable serial-getty@ttyS0.service
make sure you have
pyserial
installed if you're using the python serial library, not python-serial from apt.create the following udev file (I created
/etc/udev/rules.d/50-tty.rules
):
reload your udev rules:
sudo udevadm control --reload-rules && sudo udevadm trigger
change the group of the new serial devices:
The devices are now under the tty group. Need to add the user to the tty group and dialout group:
update the permissions for group read on the devices:
reboot
Or just create a script that will do this automatically.
4.2. Change the permission of ardSerial.py
If you want to run it as a 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:
#!/user/bin/python
4.3. Use ardSerial.py as the commander of Bittle
NyBoard has only one serial port. You need to UNPLUG the FTDI converter if you want to control Bittle with Pi's serial port.
Typing ./ardSerial.py <args>
is almost equivalent to typing <args> in Arduino's serial monitor. For example, ./ardSerial.py kcrF
means "perform skill crawl Forward".
Both ardSerial.py and the parsing section in OpenCat.ino need more implementations to support all the serial commands in the protocol.
For Nybble:
Reduced motion capability may happen when connected to Pi! A stronger battery is needed.
With the additional current drawn by Pi, Nybble will be less capable for intense movements, such as trot (the token isktr
). 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 are a bunch of considerations to collaborate software and hardware for 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.
5. Battery
Though you can program NyBoard directly with the USB 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.
Bittle
5.1. Voltage
NyBoard requires 7.4~8.4V external power to drive the servos. We include our customized Li-ion battery with built-in charging and protection circuit in the Bittle kit. Short press the battery's button will show its status. Blue light indicates it has power, and red means the power is low.
5.2. Connection and Power On
Be careful with the polarity when connecting the power supply. The terminal on NyBoard has an anti-reverse socket, so you won't be able to plug in the wrong direction. See here for the detailed connection instruction.
Please long press the button of the battery for 3 seconds to power on the battery.
Reversed connection may damage your NyBoard!
5.3. Battery life varies according to usage
It can last hours if you're mainly coding and testing postures, or less than 30 mins if you keep Bittle running.
The battery light will turn red when the power is low. The power will be cut off automatically.
5.4. Charging
Use a 5V-1A USB charger to charge the battery. We don't recommend using fast chargers. The battery will NOT supply power during charging. Keep the battery in your sight when charging.
5.5. After use
After playing, remember to turn off the battery. It's recommended to unplug the battery from the NyBoard's terminal.
Nybble
5.1. Voltage
NyBoard requires 7.4~9V external power to drive the servos. On Nybble, we are using the 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 to find batteries with higher discharge ratings.
Read this forum post to find batteries that work on Nybble.
5.2. Dimensions
The included battery holder is sized for 14500 batteries, which is 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 to run faster.
5.3. Connection
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.
Reversed connection may damage your NyBoard!
Loosen the screws of the power block. Insert the wires of the battery holder then tighten the screws. When turning the switch on, both the blue LED (for the chip) and the yellow LED (for servo) should lit up.
![](https://docs.petoi.com/~gitbook/image?url=https%3A%2F%2F1565080149-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F-MQ6a951Q6Jn1Zzt5Ajr-887967055%252Fuploads%252F8ibzuI86imXNdt6tSfl2%252FNybble_battery.jpg%3Falt%3Dmedia%26token%3Ddd5880c0-e6bc-4f7e-a002-394193c9fec0&width=768&dpr=4&quality=100&sign=36dfa873&sv=1)
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.
5.4. Battery life varies according to usage
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.
5.5. Charging
You will need compatible smart chargers for the batteries. Keep batteries attended during charging.
5.6. After use
After playing, remember to remove the batteries from the battery holder to avoid over-discharging.
5.7. Signal interference
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 overcurrent 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 plugging in the FTDI.
Last updated