-
Notifications
You must be signed in to change notification settings - Fork 361
Software setup
Note: If you have previously added other libraries and see 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 it and install 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, IRremote and QList.
Go to https://github.com/jrowberg/i2cdevlib, download the zip file and unzip. Find MPU6050/ and I2Cdev/ in the Arduino folder. Add their .ZIP library one by one.
Add board "Arduino Pro or Pro Mini (5V, 20 MHz) w/ ATmega328P" in Arduino IDE.
-
- Locate the files
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\
You should find a boards.txt already there.
-
- Make a copy of boards.txt in case you want to roll back.
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
code block. Save and quit your editor.
##############################################################
pro.name=Arduino Pro or Pro Mini
pro.upload.tool=avrdude
pro.upload.protocol=arduino
pro.bootloader.tool=avrdude
pro.bootloader.unlock_bits=0x3F
pro.bootloader.lock_bits=0x0F
pro.build.board=AVR_PRO
pro.build.core=arduino
pro.build.variant=eightanaloginputs
## Arduino Pro or Pro Mini (5V, 20 MHz) w/ ATmega328P
## --------------------------------------------------
pro.menu.cpu.20MHzatmega328=ATmega328P (5V, 20 MHz) NyBoard
pro.menu.cpu.20MHzatmega328.upload.maximum_size=30720
pro.menu.cpu.20MHzatmega328.upload.maximum_data_size=2048
pro.menu.cpu.20MHzatmega328.upload.speed=57600
pro.menu.cpu.20MHzatmega328.bootloader.low_fuses=0xFF
pro.menu.cpu.20MHzatmega328.bootloader.high_fuses=0xDA
pro.menu.cpu.20MHzatmega328.bootloader.extended_fuses=0xFD
pro.menu.cpu.20MHzatmega328.bootloader.file=atmega/ATmega328_20MHz.hex
pro.menu.cpu.20MHzatmega328.build.mcu=atmega328p
pro.menu.cpu.20MHzatmega328.build.f_cpu=20000000L
## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328P
## --------------------------------------------------
pro.menu.cpu.16MHzatmega328=ATmega328P (5V, 16 MHz)
pro.menu.cpu.16MHzatmega328.upload.maximum_size=30720
pro.menu.cpu.16MHzatmega328.upload.maximum_data_size=2048
pro.menu.cpu.16MHzatmega328.upload.speed=57600
pro.menu.cpu.16MHzatmega328.bootloader.low_fuses=0xFF
pro.menu.cpu.16MHzatmega328.bootloader.high_fuses=0xDA
pro.menu.cpu.16MHzatmega328.bootloader.extended_fuses=0xFD
pro.menu.cpu.16MHzatmega328.bootloader.file=atmega/ATmegaBOOT_168_atmega328.hex
pro.menu.cpu.16MHzatmega328.build.mcu=atmega328p
pro.menu.cpu.16MHzatmega328.build.f_cpu=16000000L
-
- Download ATmega328_20MHz.hex and put it in your Arduino folder ./bootloaders/atmega/. You should see other bootloaders with .hex suffix in the save folder.
-
- Restart your Arduino IDE. In Tools->Boards, select Arduino Pro or Pro Mini. You should find ATmega328P (5V, 20 MHz) in Processor menu.
Note: 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.
Every NyBoard has to go through functionality checks before shipping, so they should already have compatible bootloader installed. However, in rare cases, the bootloader may collapse then you won't be able to upload sketch 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 contacts;
-
- Bad luck. Tomorrow is another day!
If you really decide to re-burn the bootloader:
-
Select the ATmega328P (5V, 20 MHz) board under the Tool tab of Arduino IDE.
-
Select the correct programmer. You can even use a regular Arduino as ISP!
-
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.
Download a fresh OpenCat repository from GitHub.
Open any testX.ino sketch with test prefix. (I recommend using testBuzzer.ino as your first test sketch)
Choose board as Arduino Pro or Pro Mini and compile. There should be no error messages. Upload the sketch to your board and you should see messages in the serial monitor. Make sure that your baudrate setting (57600) and board frequency(16MHz or 20MHz) matches with the configuration.
If there're input prompts, make sure you set "No line ending". Otherwise the invisible '\n' or '\r' characters will confuse the parsing function.
With the FTDI to USB converter connecting NyBoard and Arduino IDE, you have the ultimate interface to communicate with NyBoard and even change every byte on it.
I have define a set of serial communication protocol for NyBoard:
All the token starts with a single Ascii encoded character to specify its parsing format.
Note: Some tokens haven't been implemented, such as 'h'. Token 'i' and 'l' still have some bugs.
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.
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 the USBserial port can be disabled randomly. I think that's due to some peak current draw when servos are working. The computer will shut down the USB port for protection. In that case, you can change the USB port you're connecting to, reset the USB bus, or restart the computer.
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.
In Pi's terminal, type sudo raspi-config
.
Under Interface option, find Serial. Disabled the serial login shell and enable the serial interface.
A good tutorial on Instructable
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.
2. Change the permission of ardSerial.py
If you want to run it as bash command, you need to make it executable:
chmod +x ardSerial.py
You may need to change to the proper path of your Python binary on the first line:
#!/usr/bin/python
You need to unplug the FTDI converter if you want to control Nybble with Pi's serial port.
Typing ./ardSerial.py <args>
is almost equivalent to typing <args>
in Arduino's serial monitor.
For example, ./ardSerial.py kcr
means "call skill crawl".
Both ardSerial.py and the parsing section in Nybble.ino need more implementations to support all the serial commands in the protocol.
Note: Reduced motion capability when connected to Pi!
I have to mention that 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 2S-14500. 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 initiate the communication framework and behavior tree rather than a racing beast.
Copyright © 2018 Petoi LLC
- Home
- Introduction
- Framework of hardware
- Control hierarchy and communication
- Motion module, calibration and test
- Sensors and test
- Sensor fusion and perception
- Programming movement
- Behaviors(TBD)