FBTUG-FarmBot 韌體設計

編輯歷史

時間 作者 版本
2017-05-09 13:03 – 13:05 Joe Ho r535 – r542
顯示 diff
(60 行未修改)
跟據這個圖
*
+
+
發現,他用D9來控制水閥,但並沒有偵測流速器的地方
目前PINS.H中,9是用來控制風扇,10和8是用來控制加熱器(跟本是3DP的用途啊)
(189 行未修改)
2017-05-06 22:31 – 22:58 Joe Ho r279 – r534
顯示 diff
(65 行未修改)
加入RAMPS 1.4 詳細Pin 腳圖示, 方便參考-
- *
- 根據 官方命令列表 , Pin 4 & 5 可以控制Servo 的角度, 加入 Pin6 給water flow sensor 使用
*
- Pin 4 & 5 Servo 的code, 目前有些code 是被remark 掉的, 必須加回測試 (待驗証)
- //pinMode(SERVO_0_PIN , OUTPUT);
+ Servo controll
+ 根據 官方命令列表 , Pin 4 & 5 可以控制Servo 的角度*
+ Pin 4 & 5 Servo 的code, 目前有些code 是被remark 掉的, 必回測試 後可以使用. //pinMode(SERVO_0_PIN , OUTPUT);
//pinMode(SERVO_1_PIN , OUTPUT);
(2 行未修改)
- Source Code Explaination
+ Water Flow Sensor
+ 目前Arduino MEGA 2560 共有6 個外部中斷可以使用, 加入 Pin20 給water flow sensor 使用.
+ *
+ 測試代碼:
+ volatile double waterFlow;
+ void setup() {
+ Serial.begin(115200); //baudrate
+ waterFlow = 0;
+ attachInterrupt(3, pulse, RISING); //DIGITAL Pin 2: Interrupt 03 }
+ void loop() {
+ Serial.print("waterFlow:");
+ Serial.print(waterFlow*1000);
+ Serial.println(" mL");
+ delay(500);
+ }
+
+ void pulse() //measure the quantity of square wave
+ {
+ waterFlow += 1.0 / 5880.0;
+ }
+ S
+ 測試code 的原理:
+ Water flow sensor 每 1L trigger 5880 次的方波.---> 請參考各廠牌的spec
+ 使用attachInterrupt() 的正緣觸發(RISING), 每次都發interrupt 到pulse() 來計算流量.
+
+ ource Code Explaination
*
*farmbot_arduino_controller.cpp 一切的程式由此開始
(148 行未修改)
2017-05-05 23:35 – 23:56 Joe Ho r54 – r278
顯示 diff
(63 行未修改)
目前PINS.H中,9是用來控制風扇,10和8是用來控制加熱器(跟本是3DP的用途啊)
所以原團隊應該還沒處理這一個部份
+
+ 加入RAMPS 1.4 詳細Pin 腳圖示, 方便參考-
+ *
+ 根據 官方命令列表 , Pin 4 & 5 可以控制Servo 的角度, 加入 Pin6 給water flow sensor 使用
+ *
+ Pin 4 & 5 Servo 的code, 目前有些code 是被remark 掉的, 必須加回測試 (待驗証)
+ //pinMode(SERVO_0_PIN , OUTPUT);
+ //pinMode(SERVO_1_PIN , OUTPUT);
+
+ Command 格式:
+ "F61 P4 V45\n" -- Pin4 的 servo 轉45度
(151 行未修改)
2017-05-02 04:24 – 04:24 姚穎 r52 – r53
顯示 diff
(218 行未修改)
2017-04-26 08:12 – 08:12 姚穎 r50 – r51
顯示 diff
(218 行未修改)
2017-04-08 09:50 – 09:50 姚穎 r48 – r49
顯示 diff
(218 行未修改)
2017-04-07 11:51 姚穎 r47
顯示 diff
(200 行未修改)
"F21 P2\n" => Read parameter P2
R01
- R21 P2 V0
+ R21 P2 V0X Y Z S
R02
R00
(13 行未修改)
2017-04-02 21:37 wuulong sheu r46
顯示 diff
(216 行未修改)
*宜蘭深溝目前安裝 firmware版本
git commit hash : a6028a0 (其實就是目前最新版本)
-
- g
2017-04-02 21:37 (unknown) r45
顯示 diff
(220 行未修改)
2017-04-02 21:37 – 21:37 wuulong sheu r43 – r44
顯示 diff
(216 行未修改)
*宜蘭深溝目前安裝 firmware版本
git commit hash : a6028a0 (其實就是目前最新版本)
+
+ g
2017-03-24 10:05 – 10:08 ComaYoung Hu r13 – r42
顯示 diff
(214 行未修改)
R00
- 宜蘭
+ *宜蘭深溝目前安裝 firmware版本
+ git commit hash : a6028a0 (其實就是目前最新版本)
2017-03-24 10:05 (unknown) r12
顯示 diff
(217 行未修改)
2017-03-24 10:05 – 10:05 ComaYoung Hu r9 – r11
顯示 diff
(63 行未修改)
目前PINS.H中,9是用來控制風扇,10和8是用來控制加熱器(跟本是3DP的用途啊)
所以原團隊應該還沒處理這一個部份
-
+ Source Code Explaination
*
*farmbot_arduino_controller.cpp 一切的程式由此開始
(143 行未修改)
R02
R00
+
+ 宜蘭
2017-03-20 06:37 (unknown) r8
顯示 diff
(215 行未修改)
2017-03-20 06:37 – 06:37 wuulong sheu r3 – r7
顯示 diff
(90 行未修改)
const char modeCode = 'M';
const char msgQueueCode = 'Q';
+
+
+ Study - FarmBot OS Build Process
+ Problem Fixed
+ *Elixir need installed (Default apt version too old)
+ *hex need manual installed
+ *NERVES_TARGET need to setup as rpi3
+
+ *
+ *# these bring-up experience include many try and error, the sequence of environment setup maybe out of order or loss some of the necessary detail. The purpose to log these is to save another try and error that have been done.
+ *
+ *# environment Linux 16.10 VirtualBox image. http://www.osboxes.org/ubuntu/ , Ubuntu 16.10 Yakkety Yak (Final)
+ *
+ *
+ *
+ *# install erlang, elixir to get mix work
+ *
+ *wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb
+ *
+ *sudo apt-get update
+ *
+ *sudo apt-get install esl-erlang
+ *
+ *sudo apt-get install elixir
+ *
+ *
+ *
+ *# basic build environment setup
+ *
+ *sudo apt install git
+ *
+ *sudo apt install build-essential
+ *
+ *sudo apt install erlang-dev
+ *
+ *sudo apt install libmnl-dev
+ *
+ *sudo apt install ssh-askpass
+ *
+ *
+ *
+ *#install ellixir package manager and utility
+ *
+ *mix local.hex
+ *
+ *mix local.rebar
+ *
+ *
+ *
+ *#expected some nerves bootstrap
+ *
+ *mix archive.install https://github.com/nerves-project/archives/raw/master/nerves_bootstrap.ez
+ *
+ *
+ *
+ *#need fwup environment
+ *
+ *wget https://github.com/fhunleth/fwup/releases/download/v0.12.0/fwup_0.12.0_amd64.deb
+ *
+ *sudo dpkg -i fwup_0.12.0_amd64.deb
+ *
+ *
+ *
+ *export MIX_ENV=prod
+ *
+ *export NERVES_TARGET=rpi3
+ *
+ *mix firmware
+ *
+ *
+ *
+ Makefile Description: tree information to show dependences and tasks
+ *
+ * release-rpi3: scripts/build_release_images.sh rpi3 3.0.1
+ * rpi3:
+ * env-rpi3: export NERVES_TARGET=rpi3
+ * prod_env: export MIX_ENV=prod
+ * system-rpi3: scripts/build_system.sh rpi3
+ * create-build-rpi3: scripts/clone_system.sh rpi3
+ * firmware-rpi3: scripts/build_firmware.sh rpi3
+ *
+
+ Study - Arduino + RAMPS
+ BuildUp Steps
+ *Drive RAMPS test code from wiki to check hardware
+ *Compile and upload current Arduino firmware(need mark //motorEnabled = false;)
+
+ Study - RPI/Arduino/RAMPS/Web
+ *Using Web to control motors - (Firmware 3.0.2)
+ *Web function check ( control checked, sequence test ok, upgrade arduino OK)
+
+ Arduino 命令介面驗證
+ Arduino 透過 USB線(實際上是 UART), 透過定義好的命令來操控。
+ 改裝與 debug 的需求,常會需要直接針對 Arduino 這部分來確認。
+
+ 通訊介面: UART 115200 N81
+ 命令基本上是以換行(\n, \r\n 不行)來切開,欄位符號為空白
+ 請參考官方命令列表,以下為簡單運行範例。"" 內為輸入,其他為輸出,\n 為換行
+
+ "F83\n" => Report software version
+ R01
+ R83 GENESIS V.01.04
+ R02
+ "F82\n" => Report current position
+ R01
+ R82 X0 Y0 Z0
+ R02
+
+ "F21 P2\n" => Read parameter P2
+ R01
+ R21 P2 V0
+ R02
+ R00
+
+
+ "G00 X2 Y2 Z2\n" => Move to location at given speed
+ R01
+ R81 XA0 XB0 YA0 YB0 ZA0 ZB0
+ R99 stopped
+ R81 XA0 XB0 YA0 YB0 ZA0 ZB0
+ R82 X2 Y2 Z0
+ R02
+ R00
2017-03-20 06:28 (unknown) r2
顯示 diff
(92 行未修改)
2017-03-20 06:28 wuulong sheu r1
顯示 diff
FBTUG-FarmBot 韌體設計
+
+ 韌體
+ *Arduino Related : Overview, commands, PINs
+ *Software Overview
+ *Command line flash tool installation安裝在rpi中編譯和下載ino到arduino的工具
+ *sudo apt-get install arduino gcc-avr avr-libc avrdude python-configobj python-jinja2 python-serial
+ *mkdir tmp
+ *cd tmp
+ *git clone https://github.com/miracle2k/python-glob2
+ *cd python-glob2
+ *wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
+ *sudo python setup.py install
+ *git clone git://github.com/amperka/ino.git
+ *cd ino
+ *sudo make install
+ *其中arduino 是arduino環境
+ *gcc-avr,avr-libc 是arduino mcu的編譯器和lib
+ *avrdude 是 debug和燒錄的工具
+ *ConfigObj - a Python module for easy reading and writing of config files.
+ *Jinja2 is a full featured template engine for Python.
+ *python-serial Python serial port access library
+ command line flash tool use farmbot程式碼下載和上傳
+ NOTE: We tag releases when they are stable. The latest version (on master) is not guaranteed to be stable.
+ See releases to find a stable release.
+ OPTION A: For less stable "edge" version: 方法一,下載穩最新的版本
+ *git clone https://github.com/FarmBot/farmbot-arduino-firmware
+ OPTION B: For stable release 1.0:方法,下載穩定的 1.0版本
+ *git clone -b 'alpha-1.0' --single-branch https://github.com/FarmBot/farmbot-arduino-firmware
+ To flash the firmware onto the device, run this: 編繹和上傳
+ *cd farmbot-arduino-firmware
+ *ino build
+ *ino upload
+ 整體的系統包含了 setup和 main,以上是main的架構
+ * +--------------------------+
+ * |farmbot_arduino_controller| farmbot的主要控制核心
+ * +-----------+--------------+
+ * v
+ * +--------------------------+
+ * |Command | 指令接收層
+ * +-----------+--------------+
+ * v
+ * +--------------------------+
+ * |GCodeProcessor | gcode的處理(辨識g-code交由對應的handler執行)
+ * +-----------+--------------+
+ * v
+ * +--------------------------+
+ * |***Handler | 執行g-code的handler有好幾隻
+ * +-------+-----------+------+
+ * | |
+ * | +---+
+ * v v
+ * +--------------+ +-----------+
+ * |StepperControl| | PinControl| 包含馬達的控制和io的讀取
+ * +--------------+ +-----------+
+ *
+ *目前的接腳請參考 腳位表
+ *目前能接收的g-code請參考 g-code表
+
+ 看了一下,控制水閥的程式 F01(用時間控制水量)和F02(用流速器控制水量),發現目前都沒有對相應的程式
+ 跟據這個圖
+ *
+ 發現,他用D9來控制水閥,但並沒有偵測流速器的地方
+ 目前PINS.H中,9是用來控制風扇,10和8是用來控制加熱器(跟本是3DP的用途啊)
+ 所以原團隊應該還沒處理這一個部份
+
+
+
+ *
+ *farmbot_arduino_controller.cpp 一切的程式由此開始
+ *setup()
+ *pin_setup
+ *依據 pins.h 去設定各個週邊的腳位,如果未來有加入自已的硬體,也需要在此加入
+ *// Dump all values to the serial interface
+ *timer attach interrupt and start
+ *loop()
+ *parsing commands from serial input
+ *gCodeProcessor->execute(command);
+ *GCodeProcessor.cpp
+ *GCodeHandler* handler = getGCodeHandler(command->getCodeEnum());
+ *
+ *Command.cpp
+ const char axisCodes[3] = { 'X', 'Y', 'Z' };
+ const char axisSpeedCodes[3] = { 'A', 'B', 'C' };
+ const char speedCode = 'S';
+ const char parameterIdCode = 'P';
+ const char parameterValueCode = 'V';
+ const char parameterValue2Code= 'W';
+ const char elementCode = 'E';
+ const char timeCode = 'T';
+ const char modeCode = 'M';
+ const char msgQueueCode = 'Q';
2017-03-20 06:28 (unknown) r0
顯示 diff
-
+ FBTUG-FarmBot 韌體設計