diff --git a/docu/EXP Tech.pdf b/docu/EXP Tech.pdf new file mode 100644 index 0000000..60482f9 Binary files /dev/null and b/docu/EXP Tech.pdf differ diff --git a/docu/chassis_datasheet.pdf b/docu/chassis_datasheet.pdf new file mode 100644 index 0000000..f4fa68e Binary files /dev/null and b/docu/chassis_datasheet.pdf differ diff --git a/docu/l293_datasheet.pdf b/docu/l293_datasheet.pdf new file mode 100644 index 0000000..a5c982a Binary files /dev/null and b/docu/l293_datasheet.pdf differ diff --git a/docu/nodeMCU_pinout.png b/docu/nodeMCU_pinout.png new file mode 100644 index 0000000..9370412 Binary files /dev/null and b/docu/nodeMCU_pinout.png differ diff --git a/docu/notes.txt b/docu/notes.txt new file mode 100644 index 0000000..e33b0e9 --- /dev/null +++ b/docu/notes.txt @@ -0,0 +1,9 @@ +https://hackaday.com/2016/06/14/hackaday-prize-entry-micro-robots-for-education/ + +https://www.adafruit.com/product/3216 + +https://www.exp-tech.de/plattformen/robotik/roboterfahrzeuge/7673/adafruit-mini-round-robot-chassis-kit-2wd-with-dc-motors?gclid=EAIaIQobChMIrpHIq4Ke4QIVSeAYCh0LTgdWEAQYCCABEgIQcfD_BwE + +https://www.exp-tech.de/plattformen/robotik/roboterfahrzeuge/7898/adafruit-mini-3-layer-round-robot-chassis-kit-2wd-with-dc-motors?gclid=EAIaIQobChMIrpHIq4Ke4QIVSeAYCh0LTgdWEAQYCyABEgI76vD_BwE + + diff --git a/docu/pin_out.txt b/docu/pin_out.txt new file mode 100644 index 0000000..680761c --- /dev/null +++ b/docu/pin_out.txt @@ -0,0 +1,21 @@ +Breadboard | NodeMCU, GPIO, index | H-bridge +------------------------------------- + 13 | D0, 16, 0 | 15 # driver channel 4 input + 14 | D1, 5, 1 | 10 # driver channel 3 input + 15 | D2, 4, 2 | 9 # driver 3/4 enable (pwm) + 16 | D3, 0, 3 | 2 # driver channel 2 input + 17 | D4, 2, 4 | 7 # driver channel 1 input + 20 | D5, 14, 5 | 1 # driver 1/2 enable (pwm) + 26 | GND + +Motor example: + First motor: + GPIO16 -> HIGH (index 0) + GPIO05 -> LOW (index 1) + GPIO04 -> HIGH (index 2) + + Second motor: + GPIO00 -> HIGH (index 3) + GPIO02 -> LOW (index 4) + GPIO14 -> HIGH (index 5) + diff --git a/nodemcu_firmware/.flashing_notes.txt.swp b/nodemcu_firmware/.flashing_notes.txt.swp new file mode 100644 index 0000000..ffea10f Binary files /dev/null and b/nodemcu_firmware/.flashing_notes.txt.swp differ diff --git a/nodemcu_firmware/flashing_notes.txt b/nodemcu_firmware/flashing_notes.txt new file mode 100644 index 0000000..c6efdad --- /dev/null +++ b/nodemcu_firmware/flashing_notes.txt @@ -0,0 +1,2 @@ +esptool.py --port /dev/ttyUSB0 write_flash -fm qio 0x00000 nodemcu-master-9-modules-2019-04-08-19-43-38-float.bin + diff --git a/nodemcu_firmware/init.lua b/nodemcu_firmware/init.lua new file mode 100644 index 0000000..4a685dd --- /dev/null +++ b/nodemcu_firmware/init.lua @@ -0,0 +1,46 @@ +dofile('motor.lua') + +cfg={} +cfg.ssid="robot-1" +cfg.pwd="roborally" +wifi.ap.config(cfg) + +sv = net.createServer() + +Peer = {} +function Peer:create(sck) + local peer = {} + setmetatable(peer, Peer) + peer.buffer = {} + return peer +end +function Peer:receive(sck, data) + self.buffer = self.buffer .. data + if #self.buffer >= 4 then + dir = string.byte(self.buffer,1) + if dir > 127 then dir = -256+dir end + motor_dir(1, dir) + + dir = string.byte(self.buffer,2) + if dir > 127 then dir = -256+dir end + motor_dir(2, dir) + + delay = string.byte(self.buffer,3) * 256 + string.byte(self.buffer, 4) + tmr.delay(delay) + + motor_dir(1, 0) + motor_dir(2, 0) + self.buffer = {} + sck:close() + end +end + +if sv then +-- listen to port 80 and call callback function if data is received + sv:listen(80, +function(conn) + peer = Peer:create(conn) + conn:on("receive", peer:receive(conn)) + conn:send("robot-1 at your service") + end) +end diff --git a/nodemcu_firmware/motor.lua b/nodemcu_firmware/motor.lua new file mode 100644 index 0000000..18fcc22 --- /dev/null +++ b/nodemcu_firmware/motor.lua @@ -0,0 +1,28 @@ +motor = {} +motor[1] = {} +motor[1][1] = 0 +motor[1][2] = 1 +motor[1][3] = 2 + +motor[2] = {} +motor[2][1] = 3 +motor[2][2] = 4 +motor[2][3] = 5 + +for i,m in ipairs(motor) do + for i,g in ipairs(m) do + gpio.mode(g, gpio.OUTPUT) + gpio.write(g, 1) + end +end + +function motor_dir(m, dir) + if dir ~= 0 then + gpio.write(motor[m][3], 1) + gpio.write(motor[m][1], (1-dir)/2) + gpio.write(motor[m][2], (1+dir)/2) + else + gpio.write(motor[m][3], 0) + end +end + diff --git a/nodemcu_firmware/motor.lua.1 b/nodemcu_firmware/motor.lua.1 new file mode 100644 index 0000000..18fcc22 --- /dev/null +++ b/nodemcu_firmware/motor.lua.1 @@ -0,0 +1,28 @@ +motor = {} +motor[1] = {} +motor[1][1] = 0 +motor[1][2] = 1 +motor[1][3] = 2 + +motor[2] = {} +motor[2][1] = 3 +motor[2][2] = 4 +motor[2][3] = 5 + +for i,m in ipairs(motor) do + for i,g in ipairs(m) do + gpio.mode(g, gpio.OUTPUT) + gpio.write(g, 1) + end +end + +function motor_dir(m, dir) + if dir ~= 0 then + gpio.write(motor[m][3], 1) + gpio.write(motor[m][1], (1-dir)/2) + gpio.write(motor[m][2], (1+dir)/2) + else + gpio.write(motor[m][3], 0) + end +end + diff --git a/nodemcu_firmware/motor.lua.2 b/nodemcu_firmware/motor.lua.2 new file mode 100644 index 0000000..3f51483 --- /dev/null +++ b/nodemcu_firmware/motor.lua.2 @@ -0,0 +1,47 @@ +motor = {} +motor[1] = {} +motor[1][1] = 0 +motor[1][2] = 1 +motor[1][3] = 2 + +motor[2] = {} +motor[2][1] = 3 +motor[2][2] = 4 +motor[2][3] = 5 + +for i,m in ipairs(motor) do + for i,g in ipairs(m) do + gpio.mode(g, gpio.OUTPUT) + gpio.write(g, 1) + end +end + +function motor_dir(m, dir) + if dir ~= 0 then + gpio.write(motor[m][3], 1) + gpio.write(motor[m][1], (1-dir)/2) + gpio.write(motor[m][2], (1+dir)/2) + else + gpio.write(motor[m][3], 0) + end +end + +Peer = {} +function Peer:create(sck) + local peer = {} + setmetatable(peer, Peer) + peer.buffer = {} + return peer +end +function Peer:receive(sck, data) + self.buffer = self.buffer .. data + if #self.buffer >= 4 then + + sck:close() + end +end + +function(conn) + peer = Peer:create(conn) + conn:on("receive", peer:receive) +end diff --git a/nodemcu_firmware/nodemcu-master-9-modules-2019-04-08-19-43-38-float.bin b/nodemcu_firmware/nodemcu-master-9-modules-2019-04-08-19-43-38-float.bin new file mode 100644 index 0000000..95b1536 Binary files /dev/null and b/nodemcu_firmware/nodemcu-master-9-modules-2019-04-08-19-43-38-float.bin differ diff --git a/nodemcu_firmware/nodemcu-master-9-modules-2019-04-08-19-43-38-integer.bin b/nodemcu_firmware/nodemcu-master-9-modules-2019-04-08-19-43-38-integer.bin new file mode 100644 index 0000000..01a09b4 Binary files /dev/null and b/nodemcu_firmware/nodemcu-master-9-modules-2019-04-08-19-43-38-integer.bin differ diff --git a/nodemcu_firmware/notes.txt b/nodemcu_firmware/notes.txt new file mode 100644 index 0000000..24fcd9a --- /dev/null +++ b/nodemcu_firmware/notes.txt @@ -0,0 +1,12 @@ +# flashing firmware onto NodeMCU +esptool.py --port /dev/ttyUSB0 write_flash -fm qio 0x00000 nodemcu-master-9-modules-2019-04-08-19-43-38-float.bin + +# connecting to NodeMCU via serial terminal +cu -l /dev/ttyUSB0 -s 115200 dir + +# uploading code to NodeMCU +nodemcu-uploader upload motor.lua +nodemcu-uploader upload init.lua + +# sending data over wifi via socket +nc 192.168.4.1 80 diff --git a/nodemcu_firmware/serial_terminal.txt b/nodemcu_firmware/serial_terminal.txt new file mode 100644 index 0000000..1a39c01 --- /dev/null +++ b/nodemcu_firmware/serial_terminal.txt @@ -0,0 +1 @@ +cu -l /dev/ttyUSB0 -s 115200 dir diff --git a/nodemcu_firmware/upload_notes.txt b/nodemcu_firmware/upload_notes.txt new file mode 100644 index 0000000..2e569eb --- /dev/null +++ b/nodemcu_firmware/upload_notes.txt @@ -0,0 +1,2 @@ +nodemcu-uploader upload motor.lua +nodemcu-uploader upload init.lua