Giter Club home page Giter Club logo

behavior_box's Introduction

[TOC]

behavior_box

This repository contains all the firmware and src of behavior_box system.

RaspBoard

Upload firmware to onboard arduino

There is a atmega328p to manage ATX power supply on RaspBoard. It work at 3.3V, 8MHz. So you can consider it as a "arduino pro mini". You can upload firemware through USBtinyISP or linuxspi. The firmware is in ./raspboard/ATX/RaspBoardPowCtrl/

Install ATX service

Then raspberry pi can't control ATX power supply directly. So we design a circuit of atmega328p to manage ATX. And raspberry pi will send system status to atmega328p to control ATX indirectly.

It can send two kinds of status. First one is "system on". When atmega328p get this signal, it will hold on ATX power supply. And when it get "system off" signal, it will hold on ATX for one minitus, then turn off. Second one is "reset". In this situation, atmega328p will hold on ATX and wait "system on" signal for 5 minitus.

Script is in "./raspboard/ATX/"

# install sys on service
sudo ./sys_on_service.sh

# install reset service
sudo ./reset_service.sh

Real time clock

Because raspberry pi doesn't have any real time clock(RTC) chip on raspboard. RTC chip on it. So when you power on it, raspberry pi must connect to internet and read web time. But when internet is unreachalbe, system time goes wrong. So we design a external RTC for raspberry pi on the raspboard. Therefor you can get "real time" without internet.

Before using it, you should put in battery(CR2302) and set time. There are three scripts in folder ./raspberry/RTC help you read or set RTC chip .

# read RTC
./readRTC.sh
# read time from system and write it to RTC
./systime2RTC.sh
# read time from RTC and write it to system
sudo ./RTC2systime.sh

MCU board

Due modification

Arduino Due is different from the avr based arduino board (like uno). It must be erased before uploading. For normal usage, the atmega16u2 acting as USB bridge to expose the UART, If the host pc set it's sertial port at baud rate 1200, the ATMEGA16U2 will assert the Erase pin and Reset pin of the SAM3X. Then SAM3X will switch to bootloader mode. But native serial port on raspberry pi doesn't have this function. Therefore Due must be added extra pins to receive erase and reset signal.

  1. Solder the missing pin on Due /README/SolderMissingPins.PNG

These pins can receive the erase signal from raspberry pi.

  1. upload new firmware to atmega16u2 on Due

precompiled hexfile source code

With new firmware, the onboard programmer atmega16u2 can recieve the erase signal from raspberry pi, then it process the erasing and reseting routine. Because this firmware is base on LUFA. So the firmware can't be uploaded with arduino IDE. In stead, you can use external programmer (for example , USBtinyISP) to upload the firmware.

For **windows** user, you can upload hexfile with software "AVRdude GUI", you can download it [here][4].

For **linux** user, you can using command below to upload hexfile.
`sudo avrdude -p atmega16u2 -c usbtiny -U flash:w:xxx.hex` (recommended)

For **raspberry linuxspi** mode user, before uploading you should edit "/etc/avrdude.conf" firstly. Then use the command below :
`sudo avrdude -p atmega16u2 -c linuxspi -P /dev/spidev0.0 -U flash:w:xxx.hex` ([detail instruction][5])
  1. Then you can attach due to MCU board.

Compile and Upload firmware from raspberry pi3 to Due

Patch bossac

Before upload firmware to Due, the programmer bossac must be patched. The new programmer will trigger the erase and reset proccess before uploading. Original bossac locate in "/home/pi/.arduino15//packages/arduino/tools/bossac/1.6.1-arduino/bossac", and replace it with patched bossac.

After patch, you can simply use arduino IDE to compile and upload your code.

CLI mode

You also can use command line to compile and upload your code.(bossac patch needed) These scripts are in ./raspberry/CLI.

# compile, and binary file will be putted in a temporary folder.
./DueCompile.sh Blink/Blink.ino

# compile and specify a folder which binary file will be putted in.
./DueCompile.sh Blink/Blink.ino ./FirmwarFolder
# upload
./DueUpload.sh Blink.ino.bin
# Compile and upload
./DueCompileUpload.sh Blink/Blink.ino

behavior_box's People

Contributors

panjingwei1945 avatar xyza11808 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.