Only this pageAll pages
Powered by GitBook
1 of 69

🇹🇭 Thai

Loading...

Infrared Remote

Loading...

Mobile App

Loading...

Desktop APP

Loading...

Loading...

Loading...

Loading...

Arduino IDE

Loading...

Loading...

Loading...

Loading...

API

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Nyboard

Loading...

Loading...

BIBOARD

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

9.Servo(under construction)

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Communication Modules

Loading...

Loading...

Loading...

Loading...

Loading...

Extensible Modules

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Applications

Loading...

Loading...

Loading...

History

Loading...

Technical Support

Loading...

Loading...

Useful Links 🕸

ยินดีต้อนรับสู่ Petoi Doc Center

📚➡️🤖

นี่คือ GitBook hub เป็นพื้นที่สำหรับรวบรวมเอกสารและคู่มือการใช้งานสำหรับผลิตภัณฑ์ของเรา เรามุ่งเน้นที่พัฒนาและปรับปรุง model และ code ของพวกเราเพื่อนำสัตว์เลี้ยงหุ่นยนต์ไบโอนิคมาสู่โลกโปรดอ่านหมายเหตุเวอร์ชันอย่างละเอียดเพื่อกำหนดค่าหุ่นยนต์ของคุณ

ผลิตภัณฑ์

หากคุณต้องการความช่วยเหลือ โปรดส่งข้อความถึง support@petoi.com หรือโพสต์บนฟอรัมของเราที่ .

😼

🐶

petoi.camp

คาลิเบเตอร์และคอนโทรลเลอร์

📱🤖

การแนะนำ

ดานว์โหลดและติดตั้ง

แอพนี้ใช้งานได้ทั้งบนอุปกรณ์ Android และ iOS

คุณยังสามารถดาวน์โหลด android APK และติดตั้งบนโทรศัพท์ของคุณ คุณต้องเปิดเครื่องรูดก่อนการติดตั้ง

หากดองเกิล Bluetooth กะพริบในขณะที่แผงการเชื่อมต่อภายในแอพแสดงรายการการเชื่อมต่อ Bluetooth ที่ว่างเปล่า ก่อนอื่นให้ตรวจสอบว่าคุณได้ให้สิทธิ์ Bluetooth และตำแหน่งแก่แอพหรือไม่ หากยังคงแสดงรายการว่าง คุณอาจลองติดตั้งเวอร์ชันเสถียรก่อนหน้า

เชื่อมต่อกับหุ่นยนต์ของคุณ

หากเสียงบี๊บดังขึ้นซ้ำๆ หลังจากบู๊ตเครื่องหรือระหว่างใช้งาน แสดงว่าแบตเตอรี่เหลือน้อย กรุณาชาร์จในเวลา พอร์ตชาร์จอยู่ที่ปลายด้านหนึ่งของแบตเตอรี่

ไฟ LED บนดองเกิล Bluetooth ควรกะพริบเพื่อรอการเชื่อมต่อ เปิดแอปและสแกนอุปกรณ์บลูทูธที่มีอยู่ อย่าเชื่อมต่อหุ่นยนต์กับการตั้งค่าบลูทูธทั้งระบบของโทรศัพท์! เชื่อมต่ออุปกรณ์ด้วยชื่อ Bittle, Petoi หรือ OpenCat อย่าลืมเปิดบริการบลูทูธและให้สิทธิ์แอปเข้าถึงบริการ ในบางอุปกรณ์ คุณอาจต้องอนุญาตบริการระบุตำแหน่งสำหรับแอป แม้ว่าเราจะไม่ได้ใช้ข้อมูลเหล่านั้นก็ตาม

แอพจะส่งคำทักทายไปยังอุปกรณ์บลูทูธและคาดหวังการตอบกลับจากเฟิร์มแวร์ OpenCat คุณต้องติดตั้งรหัส OpenCat แบบเต็มบนหุ่นยนต์ของคุณก่อนที่จะเชื่อมต่อกับแอพ มิฉะนั้นแอปจะถือว่า "ไม่ใช่อุปกรณ์ Petoi" หุ่นยนต์ที่ประกอบไว้ล่วงหน้าควรติดตั้งเฟิร์มแวร์ไว้แล้ว มิฉะนั้น คุณต้องกำหนดค่าด้วย Arduino IDE หรือแอปเดสก์ท็อป

หากเชื่อมต่อ Bluetooth ไฟ LED จะสว่างคงที่ หุ่นยนต์จะเล่นทำนองสามเสียง หากหุ่นยนต์ไม่ตอบสนองหรือทำงานผิดปกติในภายหลัง ให้กดปุ่มรีเซ็ตบน NyBoard เพื่อรีสตาร์ทโปรแกรมบน NyBoard

แอพควรตรวจจับ Nybble หรือ Bittle โดยอัตโนมัติด้วยเฟิร์มแวร์ OpenCat ล่าสุด มิฉะนั้นจะแสดงการเลือกสำหรับ Nybble หรือ Bittle ตัวเลือก "เลือกหุ่นยนต์" ยังสามารถเข้าชมซ้ำได้ในแผงควบคุม

คาลิเบตข้อต่อ

Nybble

Bittle

อินเทอร์เฟซหน้าจอด้านบนจะแสดงขึ้นเมื่อคุณคาลิเบตเป็นครั้งแรก คุณยังสามารถคลิกเพื่อเปิดเมนูด้านขวาบนในแผงควบคุมและเลือก "ปรับเทียบ" เพื่อเข้าถึงอีกครั้ง

หุ่นยนต์ที่ประกอบไว้ล่วงหน้าควรติดตั้งขาอย่างถูกต้องแล้ว แต่ไม่ได้รับการปรับแต่งอย่างละเอียด

หากคุณกำลังสร้างหุ่นยนต์จากชุดอุปกรณ์ อย่าติดตั้งส่วนประกอบขาจนกว่าจะมีการคาลิเบต คุณต้องติดตั้งแบตเตอรี่และกดปุ่มบนแบตเตอรี่ค้างไว้เพื่อจ่ายไฟให้กับหุ่นยนต์

เข้าสู่อินเทอร์เฟซการสอบเทียบ คลิกปุ่ม "คาลิเบตเทียบ" และเซอร์โวทั้งหมดจะย้ายไปยังตำแหน่งการคาลิเบตทันที

หากคุณกำลังสร้างหุ่นยนต์จากชุดอุปกรณ์ ให้ติดตั้งส่วนประกอบที่เกี่ยวข้องกับเซอร์โวตามส่วนที่สองในภาพอินเทอร์เฟซการสอบเทียบ และพยายามตรวจสอบให้แน่ใจว่าชิ้นส่วนเหล่านี้ตั้งฉากกัน (ขาท่อนบนตั้งฉากกับลำตัว และ ขาท่อนล่างตั้งฉากกับท่อนบน) โปรดดูบทที่เกี่ยวข้องในคู่มือผู้ใช้สำหรับรายละเอียด:

  • Nybble

ใช้เครื่องมือรูปตัว L ที่ให้มาเพื่อเป็นข้อมูลอ้างอิง!

เมื่อทำการปรับเทียบ ก่อนอื่นให้เลือกหมายเลขดัชนีของข้อต่อเซอร์โวจากไดอะแกรม (เมื่อปรับเซอร์โวขา ให้ปรับต้นขาก่อน จากนั้นจึงปรับน่อง) จากนั้นคลิกปุ่ม "+" หรือ "-" เพื่อปรับแต่ง ข้อต่อไปยังสถานะมุมฉาก

หากออฟเซ็ตมากกว่า +/- 9 องศา คุณต้องถอดชิ้นส่วนเซอร์โวที่เกี่ยวข้องออกและติดตั้งใหม่โดยหมุนฟันซี่เดียว จากนั้นกดปุ่ม "+" หรือ "-"

ตัวอย่างเช่น หากคุณต้องใช้ -10 เป็นค่าการสอบเทียบ ให้ถอดขาออก หมุนด้วยฟันซี่เดียวแล้วติดกลับเข้าไปใหม่ ค่าการสอบเทียบใหม่ควรอยู่ที่ประมาณ 4 นั่นคือรวมได้สูงสุด 14 หลีกเลี่ยงการหมุนเพลาเซอร์โวระหว่างการปรับนี้

คุณสามารถสลับระหว่างการพัก ยืน และเดินเพื่อทดสอบการปรับเทียบ

Note:

คุณอาจต้องทำการคาลิเบตรอบที่สองเพื่อให้ได้ผลลัพธ์ที่ดีที่สุด

หลังจากการคาลิเบต อย่าลืมคลิกปุ่ม "บันทึก" เพื่อบันทึกค่าคาลิเบตอันใหม่ มิฉะนั้น ให้คลิก "<" ที่มุมซ้ายบนเพื่อยกเลิกการปรับเทียบ

ใช้แผงควบคุม

ในแผงควบคุม คุณสามารถใช้ปุ่ม pe-set เพื่อควบคุมหุ่นยนต์ได้

การเดิน

ท่าทางและพฤติกรรม

ท่าทางและพฤติกรรมในตัวสามารถกระตุ้นได้โดยการกดปุ่ม อย่ากดปุ่มบ่อยเกินไปและซ้ำๆ ให้เวลาหุ่นยนต์ทำงานปัจจุบันให้เสร็จ

ปุ่มที่กำหนดเอง

คุณยังสามารถกำหนดคำสั่งที่กำหนดเองได้โดยกดปุ่ม "+" กดปุ่มค้างไว้แล้วลากเพื่อเปลี่ยนตำแหน่งปุ่ม ดับเบิลคลิกที่ปุ่มคำสั่งเพื่อแก้ไข หลังจากเข้าสู่สถานะแก้ไข จะมีคอนโซลซีเรียลไลต์สำหรับทดสอบคำสั่งและกำหนดค่าหุ่นยนต์

คำสั่งที่กำหนดเองเพื่อลอง:

* move head (move joint angle)

m0 45

* move head left and right (move joint1 angle1 joint2 angle2 .... The angle is -127~128)

m0 -70 0 70

* sit

ksit

* move joints one by one

m 0 -70 0 70 8 -30

* MOVE joints simutanuosly

i 0 -45 8 -30 12 -60

ด้านล่างนี้คือดัชนีของข้อต่อสำหรับการอ้างอิงของคุณ สังเกตรูปแบบการจัดลำดับและพยายามจดจำให้ได้

* show current joint angles

j

* long meow once

u0 1

* short meow three times

u2 20

* play a short tone (beep tone duration, duration is 0~256)

b12 100

* play a melody (beep tone1 duration1, tone2 duration2, tone3 duration3, .... only 64 characters are allowed, the actual duration is calculated as 1/duration)

b14 4 14 4 21 4 21 4

คุณสามารถแบ่งปันทักษะใหม่ของคุณได้โดยส่งคำขอผสานไปยังโฟลเดอร์นี้.

การอัปเดตและการสนับสนุน

เราปรับปรุงแอปต่อไปและจะแจ้งให้คุณทราบเมื่อมีการอัปเดต โปรดส่งข้อความถึง support@petoi.com หากคุณมีคำถามใดๆ เกี่ยวกับแอป

การแนะนำเบื้องต้น

UI.py เป็นเป็นโปรแกรมทั่วไปที่เชื่อมต่อกับส่วนอื่นทั้งหมด:

  • UI.py

-> FirmwareUploader.py

-> Calibrator.py

-> SkillComposer.py

translate.py มีการองรับหลายภาษาใน UI สามารถเปลี่ยน UI เป็นภาษาที่ต้องการใช้งานได้

ก่อนเรียกใช้แอป คุณต้องใช้อะแดปเตอร์ USB ที่ให้มาหรือดองเกิลบลูทูธเพื่อเชื่อมต่อกับหุ่นยนต์ Petoi

เอ็กซีคิวเทเบิ้ลไฟล์โปรแกรม

หลังจากดาวน์โหลดเวอร์ชัน Mac แล้ว คุณต้องลากลงในโฟลเดอร์แอปพลิเคชัน

หากคุณเห็นข้อความขึ้นว่าไม่สามารถเปิด "Petoi Desktop App" ได้เนื่องจากไม่สามารถตรวจสอบผู้พัฒนาได้ คุณสามารถคลิกขวาที่ไอคอน กดปุ่ม Shift และคลิ๊ก Open.

เรียกใช้งานแอพจากเทอร์มินัล

ในกรณีของปัญหาเอ็กซีคิวเทเบิ้ลไฟล์โปรแกรม หรือถ้าคุณต้องการแก้ไขซอร์สและทดสอบ คุณสามารถรันโค้ดจากเทอร์มินัลได้เช่นกัน

ขึ้นอยู่กับการกำหนดค่า Python ที่มีอยู่ของคุณ คุณอาจต้องอัปเกรดเป็น Python3 และติดตั้งไลบรารีต่อไปนี้:

  • pyserial

  • pillow

คุณสามารถติดตั้งได้โดยพิมพ์ pip3 install pyserial pillow ใน เทอร์มินัล หรือใช้ตัวจัดการแพ็คเกจใน Anaconda

ในการรันโค้ด:

  1. ใน Terminal ใช้คำสั่ง cd เพื่อนำทางไปยังโฟลเดอร์ OpenCat/pyUI/ คุณสามารถใช้แป้น Tab เพื่อเติมชื่อพาธโดยอัตโนมัติ

  2. หลังจากเข้าสู่โฟลเดอร์ pyUI/ ให้ป้อน ls และตรวจสอบให้แน่ใจว่าคุณเห็น UI.py และซอร์สโค้ด python อื่น ๆ ในรายการ

  3. รัน python3 UI.py.

สำหรับผู้ใช้ระบบ Linux หากคุณพบข้อความแสดงข้อผิดพลาด "_tkinter.TclError: no display name and no $DISPLAY environment variable", คุณสามารถลง python3-tk, tk-dev,เป็นคำสั่งสำหรับ Ubuntu/Debian โดยใช้คำสั่งต่อไปนี้:

apt install python3-tk

apt install tk-dev

หลังจากการติดตั้งเสร็จสิ้น ให้รีบูตเครื่องคอมพิวเตอร์

การคาลิเบรทข้อต่อ

Robots can be precisely calibrated using the Petoi Desktop App.

หุ่นยนต์ที่ประกอบไว้ล่วงหน้าควรติดตั้งขาอย่างถูกต้องแล้ว แต่ไม่ได้รับการปรับแต่งอย่างละเอียด

หากคุณกำลังสร้างหุ่นยนต์จากชุดอุปกรณ์ อย่าติดตั้งส่วนประกอบขาจนกว่าจะมีการคาลิเบรท คุณต้องติดตั้งแบตเตอรี่และกดปุ่มบนแบตเตอรี่ค้างไว้เพื่อจ่ายไฟให้กับหุ่นยนต์

อินเทอร์เฟซการคาลิเบรทข้อต่อ

หมายเหตุ: เนื่องจาก Nybble ใช้เซอร์โวสองตัว (ส่วนหัวและส่วนท้าย) มากกว่า Bittle หมายเลขดัชนีร่วมของเซอร์โว Nybble และ Bittle จึงแตกต่างกัน และท่าทางการสอบเทียบของ Nybble และ Bittle หลังจากเข้าสู่สถานะการสอบเทียบก็จะแตกต่างกันเช่นกัน ดังที่แสดงต่อไปนี้ รูปภาพ (แถบเลื่อนเซอร์โวไม่พร้อมใช้งานในพื้นที่พื้นหลังสีเหลืองอ่อนในอินเทอร์เฟซ):

Nybble

Bittle

  1. คลิกปุ่ม "คาลิเบรท" และเซอร์โวทั้งหมดจะย้ายไปยังตำแหน่งสอบเทียบทันที

หากคุณกำลังสร้างหุ่นยนต์จากชุดอุปกรณ์ ให้ติดตั้งส่วนประกอบที่เกี่ยวข้องกับเซอร์โวตามภาพที่ด้านล่างของส่วนต่อประสาน และพยายามตรวจสอบให้แน่ใจว่าชิ้นส่วนเหล่านี้ตั้งฉากกัน (ขาท่อนบนตั้งฉากกับลำตัว และ ขาท่อนล่างตั้งฉากกับท่อนบน) โปรดดูบทที่เกี่ยวข้องในคู่มือผู้ใช้สำหรับรายละเอียด:

  • Nybble

  1. ใช้เครื่องมือรูปตัว L ที่ให้มาเพื่อเป็นข้อมูลอ้างอิงระหว่างการคาลิเบรท ตามหมายเลขดัชนีของข้อต่อที่แสดงที่ด้านบนของอินเทอร์เฟซ (เมื่อปรับเทียบเซอร์โว ให้ปรับขาท่อนบนก่อน แล้วจึงปรับขาท่อนล่าง) ลากแถบเลื่อนที่เกี่ยวข้อง (ด้านล่างหมายเลขดัชนี) หรือคลิกส่วนที่ว่างของแถบเลื่อนเพื่อปรับข้อต่อให้เป็นมุมฉาก

หากค่าออฟเซ็ทมากกว่า +/- 9 องศา คุณต้องถอดขาที่เกี่ยวข้องออกและติดตั้งใหม่โดยหมุนฟันซี่เดียว จากนั้นลากตัวเลื่อนที่เกี่ยวข้อง ตัวอย่างเช่น เมื่อปรับไปที่ +9 แล้วและยังคงไม่ถูกต้อง ให้ถอดขาที่ตรงกันออกแล้วขยับฟันหนึ่งซี่เมื่อทำการติดตั้ง จากนั้นคุณควรได้รับการชดเชยที่น้อยลงในทิศทางตรงกันข้าม

คุณสามารถสลับระหว่าง "พัก", "ยืนขึ้น" และ "เดิน" เพื่อทดสอบผลการคาลิเบรท

หมายเหตุ:

คุณอาจต้องทำการคาลิเบรทรอบที่สองเพื่อให้ได้ผลลัพธ์ที่ดีที่สุด

หลังจากการสอบเทียบ อย่าลืมคลิกปุ่ม "บันทึก" เพื่อบันทึกค่าชดเชยการสอบเทียบ มิฉะนั้น ให้คลิกปุ่ม "ยกเลิก" เพื่อละทิ้งข้อมูลการสอบเทียบ คุณสามารถบันทึกการปรับเทียบไว้ตรงกลางได้ในกรณีที่การเชื่อมต่อของคุณถูกขัดจังหวะ

เมื่อคุณปิดหน้าต่างนี้ จะมีกล่องข้อความแสดงด้านล่าง:

หากคุณต้องการบันทึกข้อมูลการสอบเทียบ โปรดคลิกปุ่ม "ใช่" หรือคลิกปุ่ม "ไม่ใช่" คลิกปุ่ม "ยกเลิก" เพื่อยกเลิกเพื่อออก

ขอบคุณที่เลือกหุ่นยนต์ Bittle หรือ Nybble ของ Petoi คู่มือนี้จะช่วยคุณตั้งค่าหุ่นยนต์บัดดี้และจัดเตรียม UI ที่เรียบง่ายขึ้นเพื่อปรับเทียบ ควบคุม และตั้งโปรแกรม สำหรับผู้ใช้ขั้นสูง เราขอแนะนำให้คุณอัปเดตหุ่นยนต์ด้วยเฟิร์มแวร์ บน Github เพื่อความเข้ากันได้ที่ดีที่สุดและคุณสมบัติใหม่ล่าสุด

คุณต้องเสียบ เข้ากับซ็อกเก็ต 6 พินบน NyBoard ให้ความสนใจกับลำดับพินของดองเกิลบลูทูธ กดปุ่มบนแบตเตอรี่ค้างไว้เพื่อเปิดพลังงานของหุ่นยนต์

ตรวจสอบให้แน่ใจว่าคุณได้อัปโหลดเฟิร์มแวร์ ก่อนการคาลิเบต

แผงด้านซ้ายกำหนดทั้งการเดินและทิศทางของหุ่นยนต์ และส่งคำสั่งรวมกัน เช่น "เดินไปทางซ้าย" และ "วิ่งไปข้างหน้า" หุ่นยนต์จะเคลื่อนที่ก็ต่อเมื่อเลือกการเดินและทิศทางเริ่มต้นเท่านั้น "ก้าว" ไม่มีทิศทาง และ "ถอยหลัง" มีทิศทางซ้ายและขวา ปุ่มหยุดชั่วคราว "||" จะหยุดการเคลื่อนไหวของหุ่นยนต์ชั่วคราวและปิดเซอร์โว เพื่อให้คุณสามารถหมุนข้อต่อไปยังมุมใดก็ได้ ปุ่ม "Turbo" ( )เปิด/ปิดไจโร ซึ่งเป็นเซ็นเซอร์ตรวจจับทิศทางร่างกายของหุ่นยนต์ การเปิดเครื่องจะทำให้หุ่นยนต์ปรับตามมุมของร่างกายและจะรู้ได้เองเมื่อกลับหัว การปิดจะลดการคำนวณและทำให้เดินเร็วขึ้นและเสถียรขึ้น

สามารถดูตารางคำสั่งโดยละเอียดเพิ่มเติมได้ใน .

ใน Github คือการรวบรวมทักษะใหม่ๆ ของหุ่นยนต์ OpenCat ซึ่งสามารถใช้อ้างอิงและใช้งานได้ (หลังจากดาวน์โหลด คุณสามารถบันทึกทักษะเดียวไปยังหน่วยความจำของหุ่นยนต์ผ่านแอปพลิเคชันเดสก์ท็อป Petoi -> และใช้ .ตั้งชื่อคำสั่งในกล่องข้อความ "ชื่อ" (เช่น "เรียกทักษะใหม่") ป้อน "T" ในกล่องข้อความ "รหัส" และบันทึก คลิกปุ่มฟังก์ชันนี้เพื่อดูผลของการดำเนินการทักษะนำเข้า)

** ดาวน์โหลดเวอร์ชันล่าสุดของ . **

Petoi Desktop App เป็นเครื่องมือที่ทำให้ง่ายขึ้นสำหรับเพื่อกำหนดค่าเฟิร์มแวร์ ปรับเทียบหุ่นยนต์ และออกแบบการเคลื่อนไหวที่กำหนดเองสำหรับหุ่นยนต์ โมดูลฟังก์ชันที่สำคัญคือ , และ .

ซอร์สโค้ดเขียนด้วย Tkinker ใน Python3 และเป็นโอเพ่นซอร์ส .

คุณสามารถดาวน์โหลด ของแอพเดสก์ท็อปเพื่อหลีกเลี่ยงอินเทอร์เฟซการเขียนโปรแกรม

เทอร์มินัล เป็นอินเทอร์เฟซในตัวบนเครื่อง Mac หรือ Linux สภาพแวดล้อมที่เทียบเท่าบนเครื่อง Windows เรียกว่า Command-Line Tool (CMD) ขอแนะนำให้คุณติดตั้ง เพื่อจัดการสภาพแวดล้อม Python ของคุณ นอกจากนี้ยังสามารถให้ Powershell เป็นเทอร์มินัลสำหรับเครื่อง Windows รุ่นเก่า

** ดาวน์โหลดเวอร์ชันล่าสุดของ . **

ตรวจสอบให้แน่ใจว่าคุณได้อัปโหลด OpenCat แล้ว ก่อนทำการคาลิเบรทรองรับเฟิร์มแวร์เวอร์ชัน 2.0 เท่านั้น

​

หลังจาก หรือ เชื่อมต่ออย่างถูกต้อง, เปิด (สำหรับ Windows: UI.exe / สำหรับ Mac: Petoi Desktop App) เลือกรุ่นและภาษา จากนั้นคลิกปุ่ม "Joint Calibrator" เพื่อเปิดอินเทอร์เฟซของ calibrator

OpenCat firmware
iOS 11+
Android 4.4+
Bluetooth dongle
"Main function" firmware
Serial Protocol
The SkillLibrary folder
Skill Composer
Customized buttons
Petoi Desktop APP
Firmware Uploader
Joint Calibrator
Skill Composer
https://github.com/PetoiCamp/OpenCat/tree/main/pyUI
pre-compiled executables
Anaconda
Petoi Desktop APP
"Main function" firmware
USB adapter
Bluetooth module
Petoi Desktop App

อัปโหลด Sketch สำหรับ NyBoard

Setup Process

หมายเหตุ: สามารถดูเวอร์ชั่นของบอร์ดได้ที่นี่

เลื่อน สวิตซ์I2C (SW2) เป็น Arduino.

สวิตช์ I2C เปลี่ยนอุปกรณ์หลัก I2C (gyro/accelerometer, servo driver, external EEPROM) ตามค่าเริ่มต้น “Arduino” NyBoard ใช้ ATmega328P แบบออนบอร์ดเป็นชิปหลัก บน “RPi” NyBoard ใช้ชิปภายนอกที่เชื่อมต่อผ่านพอร์ต I2C (SDA, SCL) เป็นชิปหลัก

หมายเหตุ:

  • บางครั้งหากคุณไม่สามารถผ่านขั้นตอนการบูทเครื่องได้ คุณอาจกดสวิตช์ไปที่ฝั่ง "RPi" โดยไม่ได้ตั้งใจ

Quick Start Tutorial Video

ขั้นตอนการตั้งค่าสำหรับ Nybble เกือบจะเหมือนกัน ยกเว้นว่าคุณต้องเปลี่ยนการกำหนดโมเดลเป็น #define NYBBLE. อย่าลืมอ่านขั้นตอนโดยละเอียดต่อไปนี้

Downloads and installations of Arduino IDE

ถ้าเป็นบอร์ด NyBoard V1_* เวอร์ชั่นใดก็ตามสามารถเลือกเป็น Arduino Uno ได้เลย

เฉพาะในกรณีที่ bootloader ของ NyBoard พัง ซึ่งไม่น่าจะเกิดขึ้น

Burn the bootloader (ไม่จำเป็นสำหรับการใช้งานปกติ)

NyBoard ทุกเครื่องต้องผ่านการตรวจสอบการทำงานก่อนจัดส่ง ดังนั้นพวกเขาจึงควรติดตั้ง bootloader ที่เข้ากันได้ไว้แล้ว อย่างไรก็ตาม ในบางกรณี bootloader อาจพัง จากนั้นคุณจะไม่สามารถอัปโหลดภาพร่างผ่าน Arduino IDE ได้

หากคุณไม่สามารถอัปโหลด sketch ของคุณได้ไม่ได้แปลว่าเป็นเพราะ bootloader เสมอไป:

  • บางครั้งบอร์ด USB ของคุณจะตรวจจับกระแสไฟขนาดใหญ่จากอุปกรณ์และปิดใช้งานบริการ USB ทั้งหมด คุณจะต้อง restart บริการ USB ของคุณใหม่ หรือแม้แต่ reboot เครื่องคอมพิวเตอร์ของคุณ

  • คุณต้องติดตั้ง driver สำหรับ FTDI USB 2.0 ไปยังตัวอัปโหลด UART

  • คุณไม่ได้เลือกพอร์ตที่ถูกต้อง

  • การเชื่อมต่อไม่ดี

  • โชคร้าย. พรุ่งนี้ลองใหม่อีกวัน!

หากคุณตัดสินใจที่จะเบิร์น bootloader ใหม่:

  • ด้วย NyBoard V1_* คุณสามารถเลือก Arduino Uno ภายใต้เมนูเครื่องมือของ Arduino IDE

  • เชื่อมต่อ programmer กับพอร์ต SPI บน NyBoard สังเกตทิศทางเมื่อเชื่อมต่อ ตรวจสอบให้แน่ใจว่าพวกเขาได้รับการติดต่อที่ดี

  • เบิร์น bootloader หากนี่เป็นครั้งแรกที่คุณทำเช่นนี้ ให้รอจนกว่าแถบเปอร์เซ็นต์จะถึง 100% และไม่มีข้อความปรากฏขึ้นอีกเป็นเวลาหนึ่งนาที

เชื่อมต่อตัวอัปโหลด (บางครั้งเรียกว่า programmer )

ขั้นตอนนี้ไม่จำเป็นต้องติดตั้ง NyBoard บนหุ่นยนต์

เชื่อมต่อตัวอัปโหลด Bluetooth (optional)

บน Mac บลูทูธอาจขาดการเชื่อมต่อหลังจากอัปโหลดหลายครั้ง ในกรณีดังกล่าว ให้ลบการเชื่อมต่อและเชื่อมต่อใหม่เพื่อให้ฟังก์ชันทำงานต่อ

หาก Bluetooth dongle ไม่เจออยู่ในชุดหุ่นยนต์โดย Seeed Studio หรือ partner ของเราโปรดส่งอีเมลถึง support@petoi.com เพื่อทราบข้อมูลเพิ่มเติม

ดาวน์โหลด OpenCat แพ็คเกจ

  • หากคุณดาวน์โหลดไฟล์ Zip ของ code คุณจะได้รับ OpenCat-main โฟลเดอร์หลังจาก unzip คุณต้องเปลี่ยนชื่อเป็น OpenCat ก่อนเปิด OpenCat.ino เพื่อให้ชื่อทั้งสองตรงกัน

ไม่ว่าคุณจะบันทึกโฟลเดอร์ไว้ที่ใด โครงสร้างไฟล์ควรเป็น:

  • มี code ที่ชื่อว่า testX.ino หลายไฟล์ในโฟลเดอร์ ModuleTests คุณสามารถอัปโหลดเพื่อทดสอบบางโมดูลแยกกันได้ เปิด testX.ino ใดๆ ที่มีคำนำหน้าว่า “test” (แนะนำให้ใช้ testBuzzer.ino เป็น sketch ทดสอบแรกของคุณ)

  • เปิด serial monitor และตั้งค่า baud rate บน NyBoard V1_* ให้เลือกบอร์ดเป็น Arduino Uno และตั้งค่า baud rate เป็น 115200 ทั้งใน code และ serial monitor

  • Compile code ไม่ควรมีข้อความแสดงข้อผิดพลาด เมืออัปโหลด sketch ไปยังบอร์ดของคุณและคุณจะเห็น LED Tx และ Rx กะพริบถี่ๆ เมื่อหยุดกะพริบ ข้อความควรปรากฏบน serial monitor

Upload

ในการกำหนดค่าบอร์ด โปรดทำตามขั้นตอนเหล่านี้

1. กำหนดค่าประเภทหุ่นยนต์และรุ่นของบอร์ด

เปิดไฟล์ OpenCat.ino และเลือกเวอร์ชันของหุ่นยนต์และบอร์ดของคุณ ตัวอย่างเช่น

#define BITTLE    //Petoi 9 DOF robot dog: 1x on head + 8x on leg
//#define NYBBLE  //Petoi 11 DOF robot cat: 2x on head + 1x on tail + 8x on leg

//#define NyBoard_V0_1
//#define NyBoard_V0_2
#define NyBoard_V1_0
//#define NyBoard_V1_1

สัญลักษณ์ // หมายถึงการปิดการใช้งานบรรทัดของ code และเปลี่ยนเป็นความคิดเห็น ตรวจสอบให้แน่ใจว่าคุณเปิดใช้งานตัวเลือกคู่ขนานเพียงบรรทัดเดียว

2.ตั้งค่า configuration mode

คอมเมนท์ในส่วน #define MAIN_SKETCH เพื่อให้โค้ดเปลี่ยนโหมดการกำหนดค่าบอร์ด อัปโหลดและปฏิบัติตาม serial prompts เพื่อดำเนินการต่อดังตัวอย่างด้านล่าง

// #define MAIN_SKETCH

หากคุณเปิดใช้งาน#define AUTO_INITโปรแกรมจะตั้งค่าโดยอัตโนมัติโดยไม่ต้องแจ้งให้ทราบล่วงหน้า จะไม่รีเซ็ตออฟเซ็ตของข้อต่อ แต่ปรับเทียบ IMU

3. เสียบตัวอัพโหลด USB เข้ากับคอมพิวเตอร์ของคุณ

4. เสียบตัวอัปโหลด USB เข้ากับ NyBoard

5. อัปโหลด configuration mode sketch

กดปุ่มอัปโหลด

6. เปิด serial monitor

คุณสามารถหาปุ่มนี้ได้ภายใต้เครื่องมือ Tools หรือที่มุมบนขวาของ IDE

ตั้งค่า serial monitor เป็น No line ending และ baud rate 115200

7.รีเซ็ตออฟเซ็ตของข้อต่อ

The serial prompts:

Reset joint offsets? (Y/n):

ป้อน 'Y' และกด Enter หากคุณต้องการรีเซ็ตออฟเซ็ตของข้อต่อทั้งหมดเป็น 0

โปรแกรมจะทำการรีเซ็ต จากนั้นอัปเดต constants และ instinctive skills ในหน่วยความจำ

คุณต้องป้อน 'Y' หรือ 'n' เพื่อผ่านขั้นตอนนี้ มิฉะนั้น parameters รวมถึง skill data จะไม่ได้รับการอัพเดตบนบอร์ด

8. IMU (Inertial Measurement Unit) calibration

The serial prompts:

Calibrate the IMU? (Y/n): 

ป้อน 'Y' และกด Enter หากคุณไม่เคยปรับเทียบ IMU หรือต้องการทำการปรับเทียบใหม่

วางหุ่นยนต์ราบบนโต๊ะและอย่าแตะต้อง หุ่นยนต์จะส่งเสียงบี๊บยาวหกครั้งเพื่อให้คุณมีเวลาเพียงพอ จากนั้นจะอ่านข้อมูลเซ็นเซอร์หลายร้อยรายการและบันทึกค่าชดเชย จะส่งเสียงบี๊บเมื่อการปรับเทียบเสร็จสิ้น

เมื่อ serial monitor แสดง "Ready!" คุณสามารถปิด serial monitor เพื่อทำขั้นตอนถัดไป

9. Calibrate the servo controller chip PCA9685

มีขั้นตอนเพิ่มเติมในการ Calibrate servo driver หลังจากการ calibrate IMU

Optional: Connect PWM 3 -> Grove pin A3 to calibrate PCA9685

คุณสามารถ calibrate servo controller (PCA9685 chip) เพื่อให้สัญญาณมุมแม่นยำยิ่งขึ้น ใช้สายจัมเปอร์แบบสั้นเพื่อเชื่อมต่อ PWM pin3 (pin สัญญาณของ pin เซอร์โวตัวใดตัวหนึ่ง) และ Grove pin A3

โปรแกรมจะวัดความกว้างของสัญญาณและ calibrate ชิปโดยอัตโนมัติหลังจากอ่านค่าที่เหมือนกันสามครั้งติดต่อกัน ค่าชดเชยการ calibrate จะถูกบันทึกไว้ในบอร์ดสำหรับการบูทครั้งต่อไป จากนั้นคุณสามารถไปยังขั้นตอนต่อไปได้

หากเซอร์โวตัวใดตัวหนึ่งหยุดทำงานแต่สามารถทำงานต่อได้หลังจากเปิดเซอร์โวใหม่ อาจเป็นเพราะสัญญาณ driver ไม่แม่นยำ ขั้นตอนนี้ไม่สามารถข้ามได้

10. อัปโหลด sketch ของฟังก์ชันหลัก

ยกเลิก comment #define MAIN_SKETCHเพื่อให้ใช้งานได้ code จะกลายเป็นโปรแกรมปกติสำหรับการทำงานหลัก จากนั้นอัปโหลด code

#define MAIN_SKETCH

เปิด serial monitor เมื่อ serial monitor แสดง " Ready! " หุ่นยนต์ก็พร้อมที่จะรับคำสั่งถัดไปของคุณ

11. The module macro in the code

Code เริ่มต้นทำงานในโหมดมาตรฐาน หากคุณมีโมดูลที่ขยายได้บางโมดูล คุณอาจยกเลิกการแสดงความคิดเห็น macro definition ของโมดูลนั้นๆ จะปิดใช้งานรหัส Gyro เพื่อประหยัดพื้นที่ในการเขียนโปรแกรมและเปิดใช้งานการสาธิตของโมดูล

ใน official modules ถูกกำหนดไว้ในไฟล์ส่วนหัวแยกต่างหากใน OpenCat/src/ คุณสามารถค้นหาได้ใน OpenCat/src/io.h -> readSignal() ลักษณะการทำงานของ OTHER_MODULES กำหนดไว้ใน OpenCat/OpenCat.ino -> otherModule() คุณสามารถศึกษาโค้ดตัวอย่างเพื่อเขียนฟังก์ชันของคุณเองได้

12. Modify the "joint - pin" mapping

ในบางกรณี คุณอาจต้องการปรับเปลี่ยนการ mapping ของ "pin ข้อต่อ" ของหุ่นยนต์ คุณสามารถแก้ไขได้ใน OpenCat/src/OpenCat.h ตรวจสอบให้แน่ใจว่าคุณกำลังแก้ไขบล็อกโค้ดที่สอดคล้องกับเวอร์ชันของบอร์ดที่จุดเริ่มต้นของ OpenCat.ino หลังจากแก้ไข อย่าลืมบันทึกการเปลี่ยนแปลงและทำขั้นตอนการอัปโหลดซ้ำตั้งแต่ขั้นตอนที่ 2

ซีเรียลมอนิเตอร์

เชื่อมต่อ USB Adapter

เปิด serial monitor และตั้งค่า baud rate บน NyBoard V1_* ให้ตั้งค่า " No line ending " และ baud rate เป็น 115200 ใน serial monitor

เชื่อมต่อ Bluetooth uploader (optional)

จากนั้นคุณสามารถเลือก Tools->Port บน Arduino IDE และใช้งานในลักษณะเดียวกับ USB Adapter

บน Mac บลูทูธอาจขาดการเชื่อมต่อหลังจากอัปโหลดหลายครั้ง ในกรณีดังกล่าว ให้ลบการเชื่อมต่อและเชื่อมต่อใหม่เพื่อให้ฟังก์ชันทำงานต่อ

หาก Bluetooth dongle ไม่เจออยู่ในชุดหุ่นยนต์โดย Seeed Studio หรือ partner ของเราโปรดส่งอีเมลถึง support@petoi.com เพื่อทราบข้อมูลเพิ่มเติม

อัปโหลด Sketch สำหรับ BiBoard

This chapter is for Advanced users with programming experience.

1. อ่านคู่มือเริ่มใช้งานฉบับย่อ

2. Set up BiBoard

2.1 เตรียม environment ในการพัฒนา ESP32

2.2 แก้ไขไฟล์ code ในแพ็คเกจ

  • sdkconfig.h

  • For Windows:

C:\Users{username}\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.*\tools\sdk\esp32\qio_qspi\include\sdkconfig.h

  • for Mac:

/Users/{username}/Library/Arduino15/packages/esp32/hardware/esp32/2.0.*/tools/sdk/esp32/qio_qspi/include/sdkconfig.h

ต่อท้ายบรรทัดโค้ดที่ส่วนท้ายของไฟล์:

2.3 เพิ่ม hardware partition

2.4 ดาวน์โหลด OpenCatEsp32 แพ็คเกจ

เราอัปเดต code อย่างต่อเนื่องเป็น Open-source project คุณสามารถติดดาวและติดตาม GitHub repository เพื่อรับฟีเจอร์ใหม่ล่าสุดและการแก้ไขข้อบกพร่อง คุณยังสามารถแบ่งปัน code ของคุณกับผู้ใช้ OpenCatEsp32 ทั่วโลก

  • Iหากคุณดาวน์โหลดไฟล์ Zip ของ code คุณจะได้รับโฟลเดอร์หลักของ OpenCatEsp32 หลังจากคลาย zip คุณต้องเปลี่ยนชื่อเป็น OpenCatEsp32 ก่อนเปิด OpenCatEsp32.ino เพื่อให้ชื่อทั้งสองตรงกัน .

ไม่ว่าคุณจะบันทึกโฟลเดอร์ไว้ที่ใด โครงสร้างไฟล์ควรเป็น:

  • มี code ที่ชื่อว่า testX.ino หลายไฟล์ในโฟลเดอร์ ModuleTests คุณสามารถอัปโหลดเพื่อทดสอบบางโมดูลแยกกันได้ เปิด testX.ino ใดๆ ที่มีคำนำหน้าว่า “test” (แนะนำให้ใช้ testBuzzer.ino เป็น sketch ทดสอบแรกของคุณ)

2.5 Compile and upload the sketch

แก้ไข definition ประเภทอุปกรณ์ใน BiBoard.ino ตามประเภทอุปกรณ์

แก้ไข definition รุ่นของบอร์ดใน BiBoard.ino ตามรุ่นของบอร์ด

หลังจากการแก้ไขเสร็จสิ้น คุณสามารถคลิกปุ่มอัปโหลดเพื่ออัปโหลด BiBoard.ino และการเปลี่ยนแปลงในโปรแกรมจะถูกบันทึกโดยอัตโนมัติ

2.6 Initialization

เมื่อเปิด BiBoard ที่เพิ่งตั้งค่าใหม่ จะต้องเชื่อมต่อ serial port เข้ากับคอมพิวเตอร์ และเริ่มต้นข้อต่อและ gyroscope accelerometer (IMU) ในหน้าต่าง serial port monitor

ตรวจสอบให้แน่ใจว่าตั้งค่า serial monitor เป็น baud rate 115200 และ no line ending

คุณจะเห็นคำถามหลายข้อ:

พิมพ์ 'Y' ซึ่งหมายถึงการรีเซ็ตเซอร์โวทั้งหมดเป็นศูนย์

พิมพ์ 'Y' กับคำถาม ซึ่งหมายถึงการ calibrate MPU6050 เช่น gyro/accelerometer sensor

วาง BiBoard FLAT ไว้บนโต๊ะ และห้ามสัมผัสระหว่างการปรับเทียบ บางครั้งโปรแกรมอาจหยุดที่ขั้นตอนการเชื่อมต่อ คุณสามารถปิดจอภาพอนุกรมแล้วเปิดใหม่อีกครั้ง หรือกดปุ่มรีเซ็ตบน BiBoard เพื่อเริ่มโปรแกรมใหม่ โปรแกรมเริ่มการปรับเทียบหลังจากเล่นเมโลดี้ 6 ครั้ง

รายละเอียดของข้อมูลการแสดงผลของ serial port มีดังนี้:

หลังจากการ calibrate IMU เสร็จสิ้น ทุกครั้งที่เปิดเครื่อง หุ่นยนต์จะเข้าสู่โปรแกรมการเปิดเครื่องตามปกติ

โปรแกรมหลักของ Bittle จะตัดสินว่ามันเริ่มต้นโดยการเปรียบเทียบ BIRTHMARK ใน EEPROM หรือไม่ และจะไม่เข้าสู่กระบวนการเริ่มต้นอีกเมื่อเปิดใช้งานในครั้งต่อไป หากคุณต้องการปรับเทียบเซอร์โวออฟเซ็ตใหม่หรือปรับเทียบ IMU (MPU6050) ใหม่ คุณสามารถป้อน 'R' ใน serial monitor เพื่อเริ่มต้นใหม่

2.7 Power on

  • กดปุ่มบนแบตเตอรี่ค้างไว้และวางหุ่นยนต์โดยให้ด้านหนึ่งขึ้น มันจะเข้าสู่สถานะ calibration state automatically ภาพด้านล่างแสดงขาบนและขาล่างที่ติดตั้งหลังจากหุ่นยนต์เข้าสู่สถานะการ calibate

  • หากคุณเปิดหุ่นยนต์และหุ่นยนต์ตั้งตรง (โดยหงายหลังขึ้น) หุ่นยนต์จะเริ่มจากท่า " rest " (พับขาและปลดล็อกเซอร์โว)

2.8 โหมดมาตรฐานและโหมดพิเศษ

Code จะเริ่มต้นทำงานในโหมดมาตรฐาน หากคุณมีโมดูลที่สามารถขยายได้บางโมดูล คุณอาจยกเลิกข้อคิดเห็น definition ของโมดูลเฉพาะ จะปิดใช้งานรหัส Gyro เพื่อประหยัดพื้นที่ในการเขียนโปรแกรมและเปิดใช้งานการสาธิตของโมดูล

ใน official modules ถูกกำหนดไว้ในไฟล์ส่วนหัวแยกต่างหากใน OpenCat/src/ คุณสามารถค้นหาได้ใน OpenCat/src/io.h -> readSignal() ลักษณะการทำงานของ OTHER_MODULES กำหนดไว้ใน OpenCat/OpenCat.ino -> otherModule() คุณสามารถศึกษาโค้ดตัวอย่างเพื่อเขียนฟังก์ชันของคุณเองได้

3. Configuration with App

BiBoard มีบลูทูธในตัว และคุณสามารถเชื่อมต่อกับแอพ Android ได้:

คุณสามารถตรวจสอบประวัติการอัปเดตและคุณลักษณะเพิ่มเติมได้ใน ChangeLog.md (BiBoard\ChangeLog.md)

ซีเรียลโปรโตคอล

เราได้กำหนดชุดของซีเรียลโปรโตคอลสำหรับหุ่นยนต์:

โทเคนทั้งหมดเริ่มต้นด้วยอักขระเดียวที่เข้ารหัสด้วย ASCII เพื่อระบุรูปแบบการวิเคราะห์ของตัวอักษร โดยโทเคนเหล่านี้จะมีความสำคัญต่อตัวพิมพ์เล็กและใหญ่ และโดยปกติจะเป็นตัวพิมพ์เล็ก

บางคำสั่ง เช่น คำสั่ง c และ m สามารถรวมกันได้ ตัวอย่างเช่น: คำสั่งต่อเนื่อง "m8 40", "m8 -35", "m 0 50" สามารถเขียนรวมกันเป็น "m8 40 8 -35 0 50" คุณสามารถรวมคำสั่งได้สูงสุด 4 คำสั่งที่เป็นประเภทเดียวกัน โดยเพื่อความถูกต้อง ความยาวของสตริงควรน้อยกว่า 30 ตัวอักษร คุณสามารถเปลี่ยนค่าขีดจำกัดในโค้ด แต่อาจมีข้อจำกัดเชิงระบบสำหรับบัฟเฟอร์ซีเรียล

  • “ksit”

  • “m0 30”

  • “m0 -30”

  • “kbalance”

  • “kwkF”

  • “ktrL”

  • “d”

เครื่องหมายอัญประกาศเพียงแค่บ่งบอกว่าพวกเขาเป็นสตริงตัวอักษร เมื่อคุณพิมพ์ในมอนิเตอร์ซีเรียล ไม่ต้องพิมพ์เครื่องหมายอัญประกาศ

เครื่องหมายอัญประกาศ = " "

คุณสามารถอ้างอิงถึงคำนิยามแมโครใน OpenCat.h เพื่อใช้ชุดโทเคนที่มีการอัปเดตล่าสุด

บางคำสั่งที่มีให้ใช้สำหรับทักษะหุ่นยนต์เพิ่มเติม:

ชื่อทักษะทั้งหมดในรายการสามารถเรียกใช้งานโดยการเพิ่ม 'k' ไปด้านหน้าและลบคำต่อท้าย ตัวอย่างเช่น มี "sitI" อยู่ในรายการ คุณสามารถส่ง "ksit" เพื่อเรียกท่านั่ง หากทักษะมีอักขระ "F" หรือ "L" เป็นอักขระที่สองจากท้าย นั่นเป็นการเดิน หมายความว่าเดินไปข้างหน้าหรือไปทางซ้าย เดินไปทางขวาเป็นการสะท้อนของการเดินไปทางซ้าย ดังนั้นคุณสามารถส่ง "kwkF", "kwkL", "kwkR" เพื่อให้หุ่นยนต์เดิน ในทำนองเดียวกัน ยังมีการเดินแบบอื่น ๆ เช่น รถโรงเรียน ("tr"), คลาน ("cr"), และการเดินขาละขา ("vt")

MicroPython คอนโทรลเลอร์

คู่มือการใช้โมดูล WiFi เป็นตัวควบคุม MicroPython

Part 1: Hardware Setup

1.1 hardware list

  • USB Uploader (CH340C)

  • WiFi ESP8266

1.2 Connection

นำโมดูล ESP8266 แทนที่ลงในอินเทอร์เฟซการกำหนดค่าโมดูลของ USB uploader แล้วค้นหาพอร์ต COM ที่เกี่ยวข้องใน Windows device manager

Part 2: Software Setup

2.1 Download Thonny

ดาวน์โหลดเวอร์ชันล่าสุดของ Thonny ซึ่งเป็นตัวแก้ไข Python แบบติดตั้งพร้อมใช้งาน MicroPython ได้เลย

2.2 Download the MicroPython firmware

ซอฟต์แวร์ ESP8266 ที่คอมไพล์แล้วถูกจัดหาไว้ในเว็บไซต์อย่างเป็นทางการของ MicroPython เนื่องจากโมดูล WiFi ของเราเป็นขนาด 4MB ดังนั้นโปรดเลือกซอฟต์แวร์ล่าสุดที่มีชื่อว่า ESP8266 พร้อมกับ 2MiB+ flash และดาวน์โหลดไฟล์ bin นั้น

2.3 Upload the MicroPython firmware to the ESP8266 module

มีวิธีการอัพโหลดซอฟต์แวร์ MicroPython ไปยังโมดูล ESP8266 2 วิธีด้วยกัน:

  • การใช้เครื่องมือดาวน์โหลด ESPtool ช่วยให้คุณสามารถควบคุมพาร์ติชันและการใช้งาน Flash ได้อย่างแม่นยำมากกว่า

  • การใช้เครื่องมือที่ซ่อนอยู่ใน Thonny

เพื่อความสะดวก เราจะใช้เครื่องมือที่ซ่อนอยู่ใน Thonny ขั้นตอนการใช้งานคือดังนี้:

  1. เปิดโปรแกรม Thonny หน้าต่างหลักจะเป็นดังรูปด้านล่าง โดย Thonny จะใช้ Python interpreter ในไดเร็กทอรีการติดตั้งโดยปริยาย

  2. เลือก Tools -> Options เพื่อเข้าสู่หน้าต่างตัวเลือก ในแท็บ General สามารถเลือกภาษาที่ต้องการได้ (ต้องรีสตาร์ทโปรแกรม)

  3. เปิด Thonny และเลือกหัวข้อ Tools -> Options เพื่อเข้าสู่หน้าต่างตัวเลือก ในแท็บ General ให้เลือกภาษาที่เราต้องการ (จะต้องทำการรีสตาร์ท) และในแท็บ Interpreter เราจะเปลี่ยน Interpreter เริ่มต้นจาก Python3 มาเป็น MicroPython (ESP8266) และเลือกพอร์ตที่ถูกต้อง

  4. ในขณะนี้โมดูล ESP8266 ยังไม่ได้อัปโหลดฟิร์มแวร์ MicroPython ให้คลิกที่ "Install or update firmware" ที่มุมล่างขวาของรูปภาพด้านบนเพื่ออัปเดตฟิร์มแวร์โดยใช้เครื่องมือที่มีอยู่ในโปรแกรม Thonny

  5. เลือกพอร์ต (COMx) ที่ ESP8266 module อยู่และเลือกตำแหน่งที่อยู่ของ firmware MicroPython (.bin file) ที่ดาวน์โหลดมา ตรวจสอบโหมดแฟลช: from image file (keep) (ความเร็วจะช้าลง แต่มันเพียงแค่ต้องไหวทนและไม่ง่ายต่อการทำผิดพลาด) และเลือกตัวเลือก Erase flash before installing กดปุ่ม Install

  6. ขั้นตอนนี้จะแสดงความคืบหน้าในมุมมองด้านล่างของอินเทอร์เฟซ โปรแกรมจะเริ่มลบ Flash ก่อนแล้วจึงเขียน Firmware จากนั้นจะแสดงคำว่า "Done" เมื่อการโปรแกรมเสร็จสมบูรณ์

  7. การเตรียมซอฟต์แวร์เสร็จสิ้นแล้ว และหน้าจอด้านล่างจะปรากฏขึ้นหลังจากปิดอินเตอร์เฟซการดาวน์โหลด ข้อความสีแดงเป็นเกี่ยวกับการพิมพ์ของ ESP8266 เนื่องจาก ESP8266 จะพิมพ์สตริงของรหัสด้วยอัตราเร็ว baud ที่แตกต่างกับ 115200 เมื่อเริ่มต้น สตริงรหัสนี้ไม่สามารถรู้จักได้โดย MicroPython Shell การปรากฏเครื่องหมาย >>> ของ Python แสดงว่า Firmware ถูกอัปโหลดสำเร็จ

ซอฟต์แวร์ OpenCat ทำงานได้ทั้งบน Nybble และ Bittle ซึ่งควบคุมโดย NyBoard ที่ใช้ ATmega328P สามารถดูเอกสารรายละเอียดเพิ่มเติมได้ที่ หรือ .

ก่อนอัปโหลดเฟิร์มแวร์ โปรดตรวจสอบว่าไม่ได้เชื่อมต่ออุปกรณ์ I2C ใดๆ กับอินเทอร์เฟซ I2C ของเมนบอร์ด มิฉะนั้น การอัปโหลดเฟิร์มแวร์จะล้มเหลว ตำแหน่งของอินเทอร์เฟซ I2C แสดงอยู่ด้านล่าง (ในช่องสีแดง)

คุณต้องใช้ เวอร์ชั่นใหม่ล่าสุดเพื่อตั้งค่า environment ในเวอร์ชันเก่ามักจะรวบรวมไฟล์ฐานสิบหกขนาดใหญ่ขึ้นซึ่งอาจเกินขีดจำกัดของหน่วยความจำ

●

เลือก ISP ของคุณ (ภายใน System Programmer) ยอดนิยม 2 ตัว: USBtinyISP หรือ Arduino as ISP !

สำหรับขั้นตอนเฉพาะ โปรดดูส่วนเชื่อมต่อ NyBoard ใน USB uploader module

สำหรับขั้นตอนเฉพาะ โปรดดูที่ส่วนเชื่อมต่อ NyBoard ใน Dual-Mode Bluetooth Module

เราอัปเดต code อย่างต่อเนื่องเป็น Open-source project คุณสามารถติดดาวและติดตาม เพื่อรับฟีเจอร์ใหม่ล่าสุดและการแก้ไขข้อบกพร่อง คุณยังสามารถแบ่งปัน code ของคุณกับผู้ใช้ OpenCat ทั่วโลก

ดาวน์โหลด ​OpenCat repo เวอร์ชั่นล่าสุดจาก GitHub: . จะดีกว่าถ้าคุณใช้คุณสมบัติการควบคุมเวอร์ชันของ GitHub มิฉะนั้น ตรวจสอบให้แน่ใจว่าคุณดาวน์โหลดทั้งโฟลเดอร์ OpenCat ทุกครั้ง codeทั้งหมดต้องเป็นเวอร์ชันเดียวกันจึงจะทำงานร่วมกันได้

ติดตั้ง หากไม่พบพอร์ต USB ภายใต้ Arduino -> Tools -> Port

สำหรับขั้นตอนเฉพาะโปรดดูส่วนเชื่อมต่อ ใน USB uploader module

เชื่อมต่อ USB Adapter เข้ากับเมนบอร์ดและเลือก serial port ที่ถูกต้อง โปรดดูส่วน เชื่อมต่อ NyBoard ในโมดูล USB Uploader สำหรับขั้นตอนเฉพาะ

คุณสามารถเลือก "Serial Monitor" ในแถบเมนู "Tools" หรือคลิกปุ่ม … เพื่อเปิดหน้าต่าง Serial Monitor:

สำหรับขั้นตอนเฉพาะ โปรดดูที่ ใน Dual-Mode Bluetooth Module

ด้วย USB adapter / Bluetooth module ที่เชื่อมต่อ NyBoard และ Arduino IDE คุณจะมีอินเทอร์เฟซที่ดีที่สุด - Serial Monitor เพื่อสื่อสารกับ NyBoard และเปลี่ยนทุก byte บนนั้น (ผ่านการส่ง serial commands ตาม ).

พารามิเตอร์เฉพาะของแต่ละโมดูลการทำงานของ BiBoard โปรดดู ของคู่มือเริ่มต้นใช้งานฉบับย่อของ BiBoard

สำหรับรายละเอียด โปรดดู ของคู่มือเริ่มใช้งานของ BiBoard

อ่านคู่มือผู้ใช้สำหรับตัวเลือกเพิ่มการกำหนดค่า

ดาวน์โหลด ​OpenCatEsp32 repository จาก GitHub: . จะดีกว่าถ้าคุณใช้คุณสมบัติการควบคุมเวอร์ชันของ GitHub มิฉะนั้น ตรวจสอบให้แน่ใจว่าคุณดาวน์โหลดโฟลเดอร์ OpenCatEsp32 ทั้งหมดทุกครั้ง code ทั้งหมดต้องเป็นเวอร์ชันเดียวกันจึงจะทำงานร่วมกันได้

โปรดดู และ สำหรับกระบวนการ calibrate ทั้งหมด

สามารถทดลองคำสั่งของซีเรียลได้ที่ :

ชุดความสามารถที่สมบูรณ์และใช้งานอยู่ถูกกำหนดไว้ใน หรือ : ตัวอย่างเช่น :

Download address:

Firmware download address:

NyBoard V1_0
NyBoard V1_1
Arduino IDE
What is a bootloader?
Arduino as ISP
Connect NyBoard section
Connect NyBoard section
GitHub repository
https://github.com/PetoiCamp/OpenCat
the driver
Connect NyBoard section
#define CONFIG_DISABLE_HAL_LOCKS 1
#define BITTLE    //Petoi 9 DOF robot dog: 1 on head + 8 on leg
//#define NYBBLE  //Petoi 11 DOF robot cat: 2 on head + 1 on tail + 8 on leg
//#define CUB
#define BiBoard     //ESP32 Board with 12 channels of built-in PWM for joints
//#define BiBoard2  //ESP32 Board with 16 channels of PCA9685 PWM for joints
Reset the joints' calibration offsets? (Y/n): 
- Calibrate the Inertial Measurement Unit (IMU)? (Y/n): 
* Start *
Scanning I2C network...
- I2C device found at address 0x54  !
- I2C device found at address 0x68  !
- done
Set up the new board...
// The device name to use when connecting with bluetooth
- Name the new robot as: BittleED    
Reset the joints' calibration offsets? (Y/n): 
Y

Initializing MPU...
- Testing MPU connections...attempt 0
- MPU6050 connection successful
- Initializing DMP...
- Calibrate the Inertial Measurement Unit (IMU)? (Y/n): 
Y

Put the robot FLAT on the table and don't touch it during calibration.
- Calibrating the Inertial Measurement Unit (IMU)...
>..........>..........
MPU offsets:
//           X Accel  Y Accel  Z Accel   X Gyro   Y Gyro   Z Gyro
//OFFSETS     3752,    -968,     942,     170,      76,      21
- Enabling DMP...
- Enabling interrupt detection (Arduino external interrupt 26)...
- DMP ready! Waiting for the first interrupt...
Bluetooth name: BittleED
Waiting for a client connection to notify...
Setup ESP32 PWM servo driver...
Ready!
const char* skillNameWithType[]={"bdFI","bkI","bkLI","crFI","crLI","hlwI","mhFI","mhLI","pcFI","phFI","phLI","trFI","trLI","vtFI","vtLI","wkFI","wkLI","balanceI","buttUpI","calibI","droppedI","liftedI","restI","sitI","strI","zeroN","bfI","ckI","climbCeilI","fdI","ffI","hiI","jyI","pdI","peeI","puI","pu1I","rcI","rlLI","rtI","stpI","tsI",};
Connect NyBoard section
Connect NyBoard section
serial protocol
Add hardware partition configuration option in Arduino IDE
https://github.com/PetoiCamp/OpenCatEsp32
App for BiBoard (Android 4.4+)
the serial monitor
InstinctBittle.h
InstinctNybble.h
https://thonny.org/
https://micropython.org/download/esp8266/

ติดตั้ง WebREPL

การทำให้สามารถดีบั๊กและอัพโหลดสคริปต์ได้จากระยะไกล

การสอนที่ผ่านมาช่วยให้หุ่นยนต์สามารถดำเนินการแบบเป็นลำดับได้โดยการแก้ไขโค้ด Python แบบออฟไลน์ แต่วิธีนี้ไม่สะดวกเพราะเมื่อต้องการแก้ไขโค้ด เราจะต้องถอด WiFi module ออกและแก้ไขในโหมดออฟไลน์ และเราไม่สามารถหยุดโปรแกรมและแก้ไขพารามิเตอร์ได้โดยยืดหยุ่น สาเหตุเพราะ ESP8266 มีพอร์ตซีเรียลเพียงตัวเดียว และเราต้องใช้มันในการสื่อสารกับ NyBoard โดยดีอีกฝั่ง MicroPython ใช้ฟังก์ชั่น WiFi ที่ ESP มีให้เพื่อให้สามารถทำการดีบั๊กโค้ด Python แบบไร้สายได้ผ่าน WebREPL

ด้วยเอกลักษณ์ของ ESP8266 และเอกสารอย่างเป็นทางการ ทางเราได้เขียนคู่มือต่อไปนี้:

1. Enable webREPL

หลังจากเชื่อมต่ออุปกรณ์แล้ว ให้เข้าสู่อินเตอร์เฟสของ MicroPython แล้วพิมพ์คำสั่งimport webrepl_setup webrepl_setup และทำตามขั้นตอนตามคำแนะนำ:

  1. การเปิดใช้งาน WebREPL เมื่อเปิดเครื่อง: E

  2. ตั้งค่ารหัสผ่านสำหรับ WebREPL โดยใช้คำสั่ง "Set password for it" และกรอกรหัสผ่านที่ต้องการ (เช่น 1234)

  3. การตั้งค่าเรียบร้อยแล้ว ให้ปิด shell โดยการพิมพ์ exit() แล้วกด Enter เพื่อออกจากโหมด shell และกลับไปยังหน้าจอคำสั่ง Thonny

  4. รีบูทโดยการพิมพ์y reboot the ESP8266: y

2. The script to setup webREPL

เราใช้สคริปต์ตัวอย่างด้านล่างนี้ เพื่อแทนที่ SSID และรหัสผ่านด้วยข้อมูลเครือข่ายของคุณในบริเวณใกล้เคียง:

หลังจากเรียกใช้งานสคริปต์ มันจะพยายามเชื่อมต่อกับเครือข่าย WiFi อยู่เสมอ และเมื่อเชื่อมต่อสำเร็จแล้ว มันจะเริ่มต้น WebREPL service ของอุปกรณ์โดยอัตโนมัติ

IP address นี้จะถูกกำหนดโดย DHCP ของเร้าเตอร์ ดังนั้นอาจจะเปลี่ยนไปตามเครือข่ายและการกำหนดค่าของเร้าเตอร์ กรุณาจำ IP address นี้เพื่อนำไปใช้ในการตั้งค่า WebREPL ต่อไป

3. Configure the WebREPL service

ขณะนี้เรากำลังดีบักสคริปต์ Python ผ่าน WebREPL และพอร์ตซีเรียลก่อนหน้านั้นถูกใช้สื่อสารกับ NyBoard ดังนั้นในตัวเลือก ให้เปลี่ยนพอร์ต USB-COMx ก่อนหน้านี้เป็น WebREPL

จากนั้นให้กรอกที่อยู่ IP, พอร์ต และรหัสผ่านของ WebREPL แล้วคลิก OK.

When WebREPL Connected is displayed, the connection is successful.

คุณสามารถทดสอบตัวอย่างอย่างง่ายได้ที่ blink.py.

WebREPL เป็นการบันทึกพอร์ตซีเรียลและรองรับการ Debug ไร้สาย ข้อเสียคือความเร็วช้า (เนื่องจากการล่าช้าของเครือข่าย) และเวลารอการรีเซ็ตซอฟต์แวร์ยาว ๆ

4. Separate the serial port from the debugger

ตอนนี้เราสามารถใช้ webREPL ในการดีบั๊กสคริปต์ได้แล้ว แต่เมื่อเราเปิดโปรแกรมตรวจสอบพอร์ตซีเรียล เราจะพบว่าเมื่อเรารันสคริปต์ พอร์ตซีเรียลจะส่งเนื้อหาในการดีบั๊กออกมาเป็นจำนวนมาก จำนวนนี้จะทำให้ NyBoard ตอบสนองช้าลงและล่มเหลว ดังรูปด้านล่าง:

เราหวังว่าเมื่อดีบั๊กโปรแกรม ซีเรียลพอร์ตจะแสดงเฉพาะคำสั่งที่เราต้องการ ไม่ใช่ข้อมูล Debug ที่ไม่จำเป็น เปิดไฟล์ boot.py บนอุปกรณ์ แก้ไขหมายเลขบรรทัด uos.dupterm(None, 1) และบันทึก ให้ยกเลิกการผูกพอร์ตซีเรียลและ REPL debug รีสตาร์ทโมดูล และจะไม่มีข้อมูลดีบั๊กถูกแสดงบนซีเรียลพอร์ต ดังตัวอย่าง:

เพื่อเพิ่มความสมบูรณ์ เราสามารถแสดงข้อมูล debug ผ่าน print() statement ซึ่งจะถูกแสดงใน Shell ผ่าน WiFi

ด้วยการใช้ ESP8266 และ webREPL คุณสามารถแก้ไขลำดับการทำงานของหุ่นยนต์ด้วย MicroPython ได้อย่างสะดวกด้วยครับ

คู่มือผู้ใช้ Python SerialMaster

วิธีการใช้ python script สำหรับสนุกและเรียนรู้ไปกับหุ่นยนต์ (Nybble😼 or Bittle🐶)?

การเตรียมการ

  1. Install python (version≥ 3.6, such as Anaconda3-5.2.0-Windows-x86_64.exe)

  2. Install pyserial library (version 3.5)

เชื่อมต่อซีเรียลพอร์

แต่เมื่อเชื่อมต่อผ่านทาง Bluetooth จะเห็นพอร์ตที่เชื่อมต่อ 2 พอร์ตดังรูป

เปิด Terminal (เช่น Anaconda Prompt) ใส่พาธที่สคริปต์ตั้งอยู่ (***\serialMaster) คุณสามารถใช้คำสั่งต่อไปนี้ในการเรียกใช้สคริปต์ สคริปต์จะตรวจสอบหมายเลขพอร์ตซีเรียลโดยอัตโนมัติตั้งแต่ต้นและเสร็จสิ้นการเชื่อมต่อ

Run the script

Method 1: Run the ardSerial.py

แน่นอน คุณยังสามารถเรียกใช้สคริปต์นี้โดยไม่ต้องใส่พารามิเตอร์ใด ๆ:

เมื่อระบบตรวจสอบว่ามีหมายเลขพอร์ตซีเรียลหลายตัว สคริปต์จะตรวจสอบหมายเลขพอร์ตซีเรียลทั้งหมดที่เชื่อมต่อกับหุ่นยนต์อย่างปกติ (คุณสามารถส่งคำสั่งซีเรียลไปยังหุ่นยนต์หลายตัวพร้อมกัน) เมื่อสคริปต์เริ่มทำงาน และพิมพ์ข้อมูลเตือนดังต่อไปนี้:

เมื่อสคริปต์เริ่มทำงานอย่างเป็นทางการ ข้อมูลเตือนต่อไปนี้จะถูกพิมพ์ออกมา:

คุณสามารถพิมพ์ 'quit' หรือ 'q' เพื่อออก

ต่อไปนี้คุณสามารถป้อนคำสั่งซีเรียลใน Terminal เพื่อควบคุมหุ่นยนต์ให้ดำเนินการต่าง ๆ ที่น่าสนใจ 😃 เช่น

Method 2: Run the custom scheduler, example.py

รายการ testSchedule ใน example.py ใช้เพื่อทดสอบคำสั่งพอร์ตซีเรียลต่าง ๆ ให้เรียกใช้โค้ดสคริปต์ต่อไปนี้เพื่อดูผลของการดำเนินการของคำสั่งพอร์ตซีเรียลในรายการ:

คุณยังสามารถอ้างอิงเนื้อหาของรายการ stepUpSchedule (ใน ***\serialMaster\demos\stepup.py) เขียนรายการพฤติกรรมตามความต้องการจริงของคุณ และเปิดเผยความคิดสร้างสรรค์ของคุณ 🤩

หมายเหตุ: เมื่อเรียกใช้สคริปต์ที่อยู่ในพาธ \serialMaster\demos คุณต้องใช้คำสั่ง "cd demos" เพื่อเข้าสู่พาธที่สคริปต์ตั้งอยู่ (\serialMaster\demos) ก่อน แล้วจึงใช้คำสั่ง python3 เพื่อเรียกใช้สคริปต์ (เช่น "python3 stepup.py")

['kbalance', 2]

  • 'kbalance' หมายถึงคำสั่งในการควบคุม Bittle ให้ยืนอยู่ในท่าปกติ

  • 2 หมายถึงเวลาที่หน่วงหลังจากเสร็จสิ้นคำสั่ง หน่วยเป็นวินาที

['d', 2]

  • d หมายถึงคำสั่งในการวางหุ่นยนต์ลงและปิดเซอร์โว

  • 2 หมายถึงเวลาที่หน่วงหลังจากเสร็จสิ้นคำสั่ง หน่วยเป็นวินาที

['c', 2]

  • c หมายถึงคำสั่งในการเข้าสู่โหมดการคาลิเบรท (calibration mode)

  • 2 หมายถึงเวลาที่หน่วงหลังจากเสร็จสิ้นคำสั่ง หน่วยเป็นวินาที หลังจากที่คำสั่งเคลื่อนไหวเหล่านี้เสร็จสิ้น คำสั่งถัดไปจะถูกดำเนินการหลังจากหน่วงเวลา 2 วินาที

['c', [0, -9], 2]

  • c หมายถึงคำสั่งในการเข้าสู่โหมดการคาลิเบรท (calibration mode)

  • 0 หมายถึงหมายเลขดัชนีของเซอร์โวข้อต่อ (joint servo)

  • -9 หมายถึงมุมการหมุน, หน่วยเป็นองศา

  • 2 หมายถึงเวลาที่หน่วงหลังจากเสร็จสิ้นคำสั่ง หน่วยเป็นวินาที

โดยใช้รูปแบบนี้คุณสามารถเข้าสู่โหมดการปรับแต่งเพื่อปรับแต่งมุมของเซอร์โวข้อต่อบางตัวได้ หมายเหตุ: หากคุณต้องการให้ค่าการแก้ไขในคำสั่งนี้มีผลให้เกิดผล คุณต้องป้อนคำสั่ง "s" หลังจากดำเนินการคำสั่งนี้

ตัวอย่างนี้หมายถึง เซอร์โวข้อต่อที่มีหมายเลขซีเรียลเป็น 0 หมุน -9 องศา หลังจากที่คำสั่งการเคลื่อนไหวเหล่านี้เสร็จสิ้น คำสั่งถัดไปจะถูกดำเนินการหลังจากหน่วงเวลา 2 วินาที

['m', [0, -20], 1.5]

  • m หมายถึงคำสั่งในการควบคุมการหมุนของเซอร์โวข้อต่อ

  • 0 หมายถึงหมายเลขดัชนีของเซอร์โวข้อต่อ (joint servo)

  • -20 หมายถึงมุมการหมุน (มุมอ้างอิงจากจุดเริ่มต้น ไม่ใช่มุมเพิ่มเติม), หน่วยเป็นองศา

  • 1.5 หมายถึงเวลาที่หน่วงหลังจากเสร็จสิ้นคำสั่ง หน่วยเป็นวินาที สามารถเป็นตัวเลขทศนิยมได้

['m', [0, 45, 0, -45, 0, 45, 0, -45], 2]

โดยใช้รูปแบบนี้คุณสามารถส่งคำสั่งหมุนของเซอร์โวข้อต่อหลายตัวพร้อมกัน และคำสั่งการหมุนเหล่านี้จะถูกดำเนินการลำดับการไปเรื่อย ๆ ไม่ใช่พร้อมกัน มุมของข้อต่อถูกจัดเก็บเป็นตัวอักษร ASCII ดังนั้นสามารถป้อนโดยตรงโดยมนุษย์ได้

ตัวอย่างนี้หมายถึง หมุนเซอร์โวข้อต่อที่มีหมายเลขดัชนีเป็น 0 ไปยังตำแหน่งมุม 45 องศาก่อน จากนั้นหมุนไปยังตำแหน่งมุม -45 องศา และเช่นนี้ต่อไป หลังจากที่คำสั่งการเคลื่อนไหวเหล่านี้เสร็จสิ้น คำสั่งถัดไปจะถูกดำเนินการหลังจากหน่วงเวลา 2 วินาที

['i', [ 8, -15, 9, -20], 2]

โดยใช้รูปแบบนี้คุณสามารถส่งคำสั่งหมุนของเซอร์โวข้อต่อหลายตัวพร้อมกัน และคำสั่งการหมุนเหล่านี้จะถูกดำเนินการพร้อมกัน มุมของข้อต่อถูกจัดเก็บเป็นตัวอักษร ASCII ดังนั้นสามารถป้อนโดยตรงโดยมนุษย์ได้

ตัวอย่างนี้หมายถึง หมุนเซอร์โวข้อต่อที่มีหมายเลขดัชนีเป็น 8 และ 9 ไปยังตำแหน่งมุม -15 และ -20 องศา พร้อมกัน หลังจากที่คำสั่งการเคลื่อนไหวเหล่านี้เสร็จสิ้น คำสั่งถัดไปจะถูกดำเนินการหลังจากหน่วงเวลา 2 วินาที

['M', [8, 50, 9, 50, 10, 50, 11, 50, 0, 0], 3]

  • M หมายถึงคำสั่งในการหมุนของเซอร์โวข้อต่อหลายตัว โดยจะทำการหมุนข้อต่อลำดับที่กำหนดไว้ มุมของข้อต่อถูกเข้ารหัสเป็นเลขฐานสองเพื่อเพิ่มประสิทธิภาพในการส่งข้อมูล

  • 8, 9, 10, 11, 0 หมายถึงหมายเลขดัชนีของเซอร์โวข้อต่อ (joint servos)

  • 50, 50, 50, 50, 0 หมายถึงมุมการหมุนของข้อต่อ (มุมอ้างอิงจากจุดเริ่มต้น ไม่ใช่มุมเพิ่มเติม) หน่วยเป็นองศา

  • 3 หมายถึงเวลาหน่วงหลังจากเสร็จสิ้นคำสั่ง หน่วยเป็นวินาที

['I', [20, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 36, 36, 36, 36], 5]

  • I หมายถึงคำสั่งในการหมุนของเซอร์โวข้อต่อทั้งหมดพร้อมกัน (ในปัจจุบันคำสั่งรองรับจำนวน 16 ข้อต่อ) มุมของข้อต่อถูกเข้ารหัสเป็นเลขฐานสองเพื่อเพิ่มประสิทธิภาพในการส่งข้อมูล

  • 20, 0, 0, 0, 0, 0, 0, 0, 45, 45, 45, 45, 36, 36, 36, 36 หมายถึงมุมการหมุนของข้อต่อแต่ละตัวที่สอดคล้องกับหมายเลขดัชนี 0-15 (มุมอ้างอิงจากจุดเริ่มต้น ไม่ใช่มุมเพิ่มเติม) หน่วยเป็นองศา

  • 5 หมายถึงเวลาหน่วงหลังจากเสร็จสิ้นคำสั่ง หน่วยเป็นวินาที

['b', [10,2], 2]

  • b หมายถึงคำสั่งในการควบคุมบัซเซอร์ให้ส่งเสียงเป่าวิทยุ (beep)

  • 10 หมายถึงเสียงดนตรี (music tone) ที่ใช้ในการสั่งให้บัซเซอร์ส่งเสียง

  • 2 หมายถึงความยาวของการเล่นเสียง (duration) ต่อเป็นเวลา 1/duration วินาที

  • 2 หมายถึงเวลาหน่วงหลังจากสิ้นสุดการเล่นเสียง หน่วยเป็นวินาที

['b',[0, 1, 14, 8, 14, 8, 21, 8, 21, 8, 23, 8, 23, 8, 21, 4, 19, 8, 19, 8, 18, 8, 18, 8, 16, 8, 16, 8, 14, 4],3]

  • b หมายถึงคำสั่งในการควบคุมบัซเซอร์ให้ส่งเสียงเป่าวิทยุ (beep)

  • 0, 14, 14, 21... หมายถึงเสียงดนตรี (music tone) ที่ใช้ในการสั่งให้บัซเซอร์ส่งเสียง ตามลำดับเสียง

  • 1, 8, 8, 8 หมายถึงความยาวของการเล่นเสียง (duration) ต่อเป็นเวลา 1/duration วินาที โดยเรียงตามเสียงดนตรีที่กำหนด ในที่นี้คือ 0, 14, 14, 21...

  • 3 หมายถึงเวลาหน่วงหลังจากเสียงดนตรีเล่นเสร็จ หน่วยเป็นวินาที

ใช่ ด้วยคำสั่ง tone คุณสามารถสร้างเสียงดนตรีง่าย ๆ หรือเล่นทั้งหมดในครั้งเดียวกันได้ โดยใช้รูปแบบดังตัวอย่างที่กล่าวมาก่อนหน้านี้

ความหมายของตัวอย่างนี้คือ: เล่นทั้งหมดของสัมผัสด้วยเสียงดนตรีแบบง่าย ๆ และหน่วงเวลา 3 วินาทีหลังจากที่สัมผัสด้วยเสียงดนตรีเสร็จสิ้น

ck = [

-3, 0, 5, 1,

0, 1, 2,

45, 0, 0, 0, 0, 0, 0, 0, 45, 35, 38, 50, -30, -10, 0, -20, 6, 1, 0, 0,

-45, 0, 0, 0, 0, 0, 0, 0, 35, 45, 50, 38, -10, -30, -20, 0, 6, 1, 0, 0,

0, 0, 0, 0, 0, 0, 0, 0, 30, 30, 30, 30, 30, 30, 30, 30, 5, 0, 0, 0,

]

['K', ck, 1]

  • 'K' หมายถึงข้อมูลทักษะ (skill data) ที่ส่งให้กับ Bittle ในเวลาเดียวกัน (realtime) โดยต้องใช้ฟอร์แมตของสตริงและรหัสของทักษะที่ต้องการส่งขึ้นไปใน Bittle

  • อาเรย์ของทักษะจะถูกส่งไปยังหุ่นยนต์และทำงานโดยการประมวลผลที่ตัวหุ่นยนต์ (execute locally on the robot) โดยไม่ต้องส่งข้อมูลกลับมายังคอมพิวเตอร์หรืออุปกรณ์อื่น ๆ อาทิเช่น Raspberry Pi หรือเซิร์ฟเวอร์

  • คุณสามารถแทรกทักษะลงในไลบรารีของทักษะ (skill library) หรือ InstinctX.h โดยใช้รูปแบบนี้

Pleaseขอให้นี่เป็นแรงบันดาลใจสำหรับการช่วย Nybble และ Bittle ในการค้นหาแรงบันดาลใจของพวกเขา และขอให้คุณมีความสุขกับการเล่น! 😍

การสื่อสารผ่านพอร์ตซีเรียลของ Raspberry Pi

หุ่นยนต์ไม่ต้องการ PI เพื่อเคลื่อนไหว

คุณต้องถอดปลั๊ก USB Adpter 6 พินสำหรับ NYBoard ก่อนที่จะติดตั้ง PI ไปยังบอร์ด

คุณสามารถประสานซ็อกเก็ต 2x5 บน Nyboard เพื่อเสียบ Raspberry Pi PI 3A+ เป็นแบบที่ดีที่สุดสำหรับ มิติของ Nyboard

Nybble

Bittle

หลังจากที่คุณประสานบนซ็อกเก็ต คุณจะไม่สามารถติดตั้งฝาหลังด้านหลังของ Bittle ได้

  • Ascii: ใช้ 2 ไบต์เพื่อเก็บอักขระ Ascii '6' และ '5'

  • Binary: ใช้ 1 byte เพื่อจัดเก็บค่า 65 ซึ่งเปรียบเสมือนกับตัวอักษร Ascii 'A'

ถ้าเป็นค่า -113 แบบ Ascii string จะใช้พื้นที่หน่วยความจำ 4 bytes แต่จะเหลือเพียง 1 byte เมื่อเข้ารหัสแบบ binary โดยภายในจะไม่สามารถแสดงผลเป็นตัวอักษรได้ แต่ยังคงเก็บค่าได้เป็นจำนวนเต็ม 1 byte

1. Config Raspberry Pi serial port

In Pi's terminal, type sudo raspi-config

ในตัวเลือก Interface ให้ค้นหา Serial แล้วปิดการเข้าสู่ระบบ shell ผ่านทางซีเรียลและเปิดใช้งานอินเทอร์เฟซซีเรียลเพื่อใช้พอร์ต UART หลัก:

  1. Run raspi-config with sudo privilege: sudo raspi-config.

  2. Find Interface Options -> Serial Port.

  3. At the option Would you like a login shell to be accessible over serial? select 'No'.

  4. At the option Would you like the serial port hardware to be enabled? select 'Yes'.

  5. Exit raspi-config and reboot for changes to take effect.

ถ้าคุณเชื่อมต่อ Pi เข้ากับช่อง 2x5 ของ NyBoard แล้ว พอร์ตซีเรียลของพวกเขาควรจะเชื่อมต่อโดยอัตโนมัติที่แรงดัน 3.3V อย่างไรก็ตามหากไม่ได้เชื่อมต่อแบบนี้ คุณควรใช้หลอดสายขนาดเล็กเพื่อเชื่อมต่อ Rx และ Tx ของชิป AI ของคุณกับ Tx และ Rx ของ NyBoard โดยให้แรงดันตรงกัน

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 OS

  • disable 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.

ถ้าคุณต้องการรันโปรแกรมเป็นคำสั่ง bash คุณต้องทำให้โปรแกรมสามารถรันได้:

chmod +x ardSerial.py

คุณอาจจะต้องเปลี่ยน path ที่ถูกต้องของ Python binary บนบรรทัดแรก:

#!/user/bin/python

3. Use ardSerial.py as the commander of robot

NyBoard มีพอร์ตซีเรียลเดียวเท่านั้น หากต้องการควบคุม Bittle ด้วยพอร์ตซีเรียลของ Raspberry Pi คุณจะต้องถอดอะแดปเตอร์ USB ออกก่อน

พิมพ์ ./ardSerial.py <args> เทียบเท่ากับการพิมพ์ ใน Arduino's serial monitor โดยตัวอย่างเช่น ./ardSerial.py kcrF หมายความว่า "ทำการเคลื่อนที่ด้วยทักษะคลานไปข้างหน้า".

การทำงานของ ardSerial.py และการแยกวิเคราะห์ใน OpenCat.ino ต้องการการปรับปรุงเพิ่มเติมเพื่อรองรับคำสั่งซีเรียลทั้งหมดในโปรโตคอล

For Nybble:

การเชื่อมต่อกับ Pi อาจทำให้ความสามารถในการเคลื่อนไหวลดลง! จำเป็นต้องใช้แบตเตอรี่ที่มีกำลังมากขึ้น

เมื่อเชื่อมต่อกับ Pi แล้ว Nybble อาจจะมีความสามารถในการเคลื่อนไหวที่ลดลง โดยเฉพาะการเคลื่อนไหวที่มีความเข้มข้น เช่นการเดินเหยียบ (โทเคน isktr) ระบบจะถูกจ่ายไฟด้วยแบตเตอรี่ 14500 สองเลเยอร์ คุณอาจจะคิดหาวิธีการจ่ายไฟที่ดีกว่า เช่น การใช้แบตเตอรี่ 7.4 ลิโพแบตเตอรี่สูงสุด หรือ 2S-18650 มีมากมายข้อควรพิจารณาในการร่วมมือซอฟต์แวร์และฮาร์ดแวร์เพื่อให้ได้ประสิทธิภาพที่สมดุลกัน ด้วยตัวขนาดเล็กของ Nybble นั้น จะดีกว่าใช้เป็นแพลตฟอร์มสำหรับเริ่มต้นกรอบการสื่อสารและต้นไม้พฤติกรรมมากกว่าเป็นสัตว์แข่งขัน

chapter 5 🔌 Connect Wires

โดยปกติแล้วการใช้ ในการเชื่อมต่อกับหุ่นยนต์จะต้องเห็นพอร์ทแค่อันเดียวหากไม่ได้เชื่อมต่อกับสิ่งอื่น

Parameters: kbalance เป็น บ่งบอกถึงสกิลของหุ่นยนต์

สำหรับคำอธิบายของคำสั่งอื่น ๆ บนพอร์ตซีเรียลโปรต์ โปรดอ้างอิงตามเอกสาร . นี้

ชิ้นส่วนสีแดง สามารถใช้ 3D print ได้

ดังที่แสดงใน แสดงว่าอาร์ดูโนไอดีเอสเป็นตัวกลางที่รองรับโทเค็นทั้งหมดที่ถูกเข้ารหัสเป็นตัวอักษร ASCII char string เพื่อให้มนุษย์สามารถอ่านได้ ในขณะที่คอมพิวเตอร์หลัก (เช่น RasPi) รองรับคำสั่งเพิ่มเติมที่เข้ารหัสเป็น binary string เพื่อให้การเข้ารหัสมีประสิทธิภาพมากขึ้น ตัวอย่างเช่น เมื่อเข้ารหัสมุม 65 องศา:

แน่นอนว่าการเข้ารหัสแบบไบนารีจะมีประสิทธิภาพมากกว่าการเข้ารหัสแบบสตริง Ascii อย่างไรก็ตาม ข้อความที่ถูกส่งไปจะไม่สามารถอ่านได้โดยตรงโดยมนุษย์ ใน OpenCat repository ฉันได้ใส่สคริปต์ Python ที่เรียกว่า ที่สามารถจัดการการสื่อสารซีเรียลระหว่าง NyBoard และ Pi ได้ง่ายดาย

You also need to DISABLE the to avoid repeating reset signals sent by Pi's GPIO 4.

ถ้าคุณใช้ระบบ Linux ทั่วไป หลังจากเชื่อมต่ออุปกรณ์แบบ uploader เข้ากับคอมพิวเตอร์ของคุณ คุณจะเห็น "ttyUSB#" ในรายการพอร์ตซีเรียล แต่อาจมีข้อผิดพลาดของพอร์ตซีเรียลเมื่อทำการอัปโหลด คุณจะต้องให้สิทธิ์การเชื่อมต่อพอร์ตซีเรียลก่อน โปรดไปที่ลิงค์นี้และทำตามคำแนะนำ:

2. Change the permission of

import network
import time
import webrepl

def do_connect():
    
    # WiFi SSID and Password
    wifi_ssid = "YOUR SSID"             # YOUR WiFi SSID
    wifi_password = "YOUR PASSWORD"     # YOUR WiFi PASSWORD

    # Wireless config : Station mode
    station = network.WLAN(network.STA_IF)
    station.active(True)

    # Continually try to connect to WiFi access point
    while not station.isconnected():
    
        # Try to connect to WiFi access point
        print("Connecting...")
        station.connect(wifi_ssid, wifi_password)
        time.sleep(10)

    # Display connection details
    print("Connected!")
    print("My IP Address:", station.ifconfig()[0])
    

if __name__ == "__main__":
    do_connect()
    webrepl.start()
Connected!
My IP Address: 192.168.xxx.xxx
WebREPL daemon started on ws://192.168.xxx.xxx:8266
Started webrepl in normal mode
***\serialMaster>python3 ardSerial.py kbalance
***\serialMaster>python3 ardSerial.py
__main__ - INFO - port[0] is COM11
__main__ - INFO - port[1] is COM5
__main__ - INFO - port[2] is COM10
Waiting for the robot to booting up
Waiting for the robot to booting up
['b', '\n* Start *\nBittle\nReady!\np\n']
Adding COM5
['b', '\n* Start *\nBittle\nReady!\np\n']
Adding COM11
__main__ - INFO - Connect to usb serial port:
__main__ - INFO - COM5
__main__ - INFO - COM11
Kbalance        # Command to control the robot to stand normally
m 0 -30 0 30    # Command to control the robot head to swing left and right
***\serialMaster>python3 example.py
for task in testSchedule:
    wrapper(task)
KERNEL=="ttyS0", SYMLINK+="serial0" GROUP="tty" MODE="0660"
KERNEL=="ttyAMA0", SYMLINK+="serial1" GROUP="tty" MODE="0660"
sudo chgrp -h tty /dev/serial0
sudo chgrp -h tty /dev/serial1
sudo adduser $USER tty
sudo adduser $USER dialout
sudo chmod g+r /dev/ttyS0
sudo chmod g+r /dev/ttyAMA0
The official document
USB adapter
serial command
Serial Commands
Pi standoff
serial protocol
ardSerial.py
1-wire interface of Pi
A good tutorial on the Pi Serial
https://playground.arduino.cc/Linux/All/#Permission
ardSerial.py

ROS

ROS Interface

Using ROS on Raspberry Pi

ในปัจจุบัน แนะนำให้ติดตั้ง ROS โดยใช้ Docker

sudo apt-get update && sudo apt-get upgrade
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker pi
# test installation
docker run hello-world
  • prepare workspace

mkdir -p workspace/src
cd workspace/src
git clone https://github.com/PetoiCamp/ros_opencat
cd ros_opencat
git submodule init && git submodule update
cd ../../..
  • run the container

docker run -v path/to/workspace:/workspace \
-it --rm --privileged --network host --name ros ros:noetic-robot
  • source files and build inside the container

cd /workspace
source /opt/ros/noetic/setup.bash
catkin_makbase
source devel/setup.bash
rosrun opencat_examples opencat_examples_serial

Using ROS for remote control

ROS ถูกออกแบบมาเพื่อให้เหมาะสมกับการคำนวณแบบกระจาย ต่อไปนี้เป็นตัวอย่างง่ายๆ เกี่ยวกับวิธีการเรียกใช้โหนดบนเครื่องคอมพิวเตอร์ต่างกัน

  • on host machine (usually more powerful than Raspberry Pi)

# launch server
roscore
  • run service node on Raspberry Pi

export ROS_MASTER_URI=http://<Host_IP>:11311/
rosrun opencat_server opencat_service_node
  • send command from host

rosrun opencat_examples opencat_examples_client_cpp

Examples

  • using serial library

rosrun opencat_examples opencat_examples_serial
  • using ROS service

# start core
roscore
# start service server
rosrun opencat_server opencat_service_node
# examples using oppencat ros service in C++
rosrun opencat_examples opencat_examples_client_cpp
# examples using opencat ros service in python
rosrun opencat_examples opencat_examples_client_py

NyBoard V1_1

Update:

NyBoard V1_1 เป็นเวอร์ชันที่อัปเกรดมาจาก V1 โดยมุ่งเน้นไปที่ปัญหาขาดแคลนของ ATMEGA328P-MU ในเครือข่ายการจัดหาวัสดุอุปกรณ์ของเรา

  1. แทนที่ ATMEGA328P-MU (QFN32=) ด้วย ATMEGA328P-AU (TQFP32)

  2. นำ 7 ดวง WS2812 LED ออกเพื่อเพิ่มพื้นที่บนบอร์ด

  3. เพิ่ม LED สีเขียวที่ต่อกับพอร์ต D10 และมีฟังก์ชัน PWM

  4. ไม่มีการเปลี่ยนแปลงสำหรับ socket และการกำหนดขาต่อจาก V1_0 โปรแกรมบูตและโค้ด OpenCat ยังคงเข้ากันได้อย่างเต็มที่

Overview

บอร์ด NyBoard V1 เป็นเวอร์ชันที่อัพเกรดขึ้นมาจากการรับความคิดเห็นจากผู้ใช้งานกับ NyBoard V0 โดยยังคงรองรับการใช้งานกับเวอร์ชันก่อนหน้า แต่มีการออกแบบใหม่เพื่อทำให้ใช้งานง่ายขึ้น

  • NyBoard V1 ยังใช้ Atmel ATMega328P เป็นชิปหลัก แต่เปลี่ยนความถี่ให้เป็น 16MHz โดยไม่ต้องเร่งความถี่ไปยัง 20MHz ตอนนี้บอร์ดเป็นเวอร์ชันที่เข้ากันได้อย่างเต็มที่กับ Arduino Uno จึงทำให้ผู้ใช้ใหม่ที่ไม่เคยใช้ Arduino มาก่อนสะดวกในการใช้งาน

  • NyBoard V1 ยังสามารถขับได้ถึง 16 ช่อง PWM ด้วย PCA9685 โดยเรียงลำดับขาแตกต่างจากเดิม แต่ไม่จำเป็นต้องอ่านหมายเลขดัชนีบนบอร์ดเพราะการเชื่อมต่อขานี้ถูกจัดการในซอฟต์แวร์อย่างถูกต้อง

  • เซ็นเซอร์การเคลื่อนไหว 6 แกนของ MPU6050 ออกแบบมาบน PCB แทนที่จะเป็นโมดูลแยกต่างหากที่ติดตั้งเหนือบอร์ด มันสนับสนุน DMP (Digital Motion Processor) ซึ่งสามารถคำนวณข้อมูลการเคลื่อนไหวได้โดยตรงและยังมีข้อมูลแบบดิบสำหรับผสมผสานและแยกสัญญาณเองได้

  • NyBoard V1 ยังคงใช้ EEPROM 8KB onboard I2C เพื่อบันทึกค่าคงที่สำหรับทักษะต่าง ๆ

  • ระบบไฟฟ้าได้รับการออกแบบใหม่เพื่อให้ได้กำลังไฟที่เสถียรมากขึ้น โครงสร้างของอุปกรณ์

  • ตั้งแต่วันที่ 1 มกราคม 2021 เราเริ่มรวมดองเกิลบลูทูธอย่างเป็นทางการเพื่อการอัปโหลดและสื่อสารไร้สาย ค่าเริ่มต้นสำหรับอัตราการสื่อสารทั้งหมดจะถูกตั้งค่าไว้ที่ 115200

  • ปุ่มรีเซ็ตอยู่ใกล้เข้าถึงมากขึ้นที่ด้านหลังของบอร์ด

  • เราได้เพิ่ม 4 ช่องต่อ Grove เพื่อเป็นการเชื่อมต่อแบบ plug-and-play กับโมดูลขยายของ Seeed Studio โดยยังคงให้แผงวงจรมาตรฐานที่มีรูเข็มขัดขนาด 2.54 มม. เช่นเดิม

  • สายสัญญาณสำหรับแบตเตอรี่ที่ใช้ต่อกับแผงวงจรเป็นสายแบบ anti-reverse ซึ่งจะช่วยป้องกันการเสียหายจากการต่อผิดขั้ว

Logic diagram of the controller

The configuration of NyBoard V1_0 is shown as below:

Introduction to the onboard components

Main controller

NyBoard V1_0 ใช้ Atmel ATMega328P-AU เป็นชิปหลัก เหมือนกับ MCU ของ Arduino Nano (UNO Compatible)

ATMega328P ทำงานที่ความถี่ 16MHz และมีแหล่งจ่ายไฟ 5V มี SRAM 2KB, Flash 32KB และ on-chip EEPROM 1KB ด้วย bootloader เดียวกับ Arduino Uno คุณสามารถอัพโหลดสคริปต์ผ่านพอร์ตซีเรียลได้เลย

LED(NEW!)

ได้ทำการเปลี่ยน WS2812 ที่เป็น LED RGB แบบต่อเซียงกันเป็น LED เดียวสีเขียวเท่านั้น สามารถใช้คำสั่งควบคุม GPIO ของ Arduino ได้อย่างง่ายดาย

I2C switch

ชิปหลักทำงานที่แรงดัน 5V ในขณะที่อุปกรณ์เสริมอื่น ๆ ทำงานในระดับตรรกะ 3.3V เราใช้ PCA9306 เพื่อแปลงบัส I2C ของ ATMega328P ให้เป็น 3.3V นอกจากนี้เรายังเพิ่มสวิทช์บนบัส I2C ซึ่งจะช่วยเปลี่ยน I2C master ของอุปกรณ์เสริมบนบอร์ดได้ โดยสามารถหมุนสวิทช์ไปที่ "Arduino" หรือ "Raspberry Pi" เพื่อเปลี่ยน I2C master ของอุปกรณ์บนบอร์ดได้

6-Axis IMU MPU6050

MPU6050 ถูกนำมาใช้งานอย่างแพร่หลายในโปรเจค DIY หลายๆ โปรเจค เพื่อใช้ได้รับข้อมูลสถานะการเคลื่อนไหวของอุปกรณ์ โดยเซ็นเซอร์นี้สามารถตรวจจับสถานะการเคลื่อนไหว 3 แกนและการเคลื่อนที่ของ 3 แกนทางมุมได้ นอกจากนี้ยังมี DMP ในตัวเซ็นเซอร์ เพื่อทำการคำนวณสถานะการเคลื่อนไหวได้โดยตรงโดยไม่ต้องใช้ทรัพยากรความสามารถในการคำนวณของคอนโทรลเลอร์หลักของบอร์ดเพิ่มเติม

บน NyBoard V1_0 ที่อยู่ I2C ของ MPU6050 คือ 0x68 และหมุนเวียน ของ MPU6050 ถูกเชื่อมต่อกับพอร์ต PD2 ของ ATMega328P (หรือพอร์ต D2 ของ Arduino Uno) โดยใช้ Interrupt pin

มีหลายไลบรารีสำหรับ MPU6050 ที่มีอยู่แล้วและเราใช้ I2CDev/6050DMP ใน NyBoard V1_0 อย่างไรก็ตาม คุณยังสามารถใช้เวอร์ชันอื่น ๆ ได้ด้วย

Name

Author

Feature

I2Cdev

jrowberg

built-in DMP

Adafruit MPU6050

Adafruit

standard MPU6050 library

Kalman Filter

TKJ Electronics

with Kalman filter

PCA9685 and the PWM servo ports

PCA9685 แบ่งออกเป็น 16 ช่อง PWM ที่มีความละเอียด 12 บิตด้วยคำสั่งจากพอร์ต I2C โดยมีที่อยู่ตั้งค่าไว้ที่ 0x40 บนบอร์ด มีหมายเลขช่อง PWM ทั้งหมด 16 ช่องพิมพ์บน PCB อยู่แล้ว แต่คุณไม่จำเป็นต้องอ่านหมายเลขนี้เนื่องจากการแมปพินได้ถูกตั้งค่าเป็นอัตโนมัติผ่านซอฟต์แวร์ แบบจับตามกลุ่มของขาเชื่อมต่อเหมือนเดิมกับรุ่นก่อนหน้า ในการต่อเซอร์โวต้องตรวจสอบทิศทางของขาเซอร์โว ซึ่งมักมี 3 ขา คือ PWM, ไฟ (2S) และ GND (อีกชื่อหนึ่งคือแบตเตอรี่) ขา GND ควรเชื่อมต่อกับสายสีดำของเซอร์โว

บน NyBoard V1_0 พลังงานไฟฟ้าของเซอร์โวต่อกับแบตเตอรี่ไอออน 2S โดยตรง โดยเราออกแบบเซอร์โวของเราให้เข้ากันได้กับแหล่งจ่ายไฟ 8.4V แบบปกติ ซึ่งเซอร์โวปกติทำงานที่แรงดันไฟฟ้า 6V คุณไม่ควรเชื่อมต่อเซอร์โว 9g ปกติเช่น SG90 โดยตรงกับบอร์ด

เราใช้ไลบรารี่ Adafruit PWM Servo Driver Library สำหรับ PCA9685

EEPROM

เราใช้หน่วยความจำในตัวชิป AT24C64 ที่ติดตั้งบนบอร์ดเพื่อเก็บข้อมูลทักษะการเคลื่อนไหว มันมีที่อยู่ I2C เป็น 0x54 ตารางค้นหาของทักษะถูกบันทึกไว้ในหน่วยความจำ EEPROM ในตัวชิป ATMega328P ขนาด 1KB โดยเราใช้ไลบรารี <EEPROM.h> ดังนั้นคุณควรใส่ใจกับความแตกต่างของพวกเขาเมื่อพัฒนาโค้ดใหม่

Passive buzzer

เราใช้ขา PD5 (หรือ D5 ของ Arduino UNO) เพื่อขับเสียงบัสเซอร์ และกระแสไฟจะถูกขยายโดย MOS 2N7002

Infrared receiver

เราใช้ VS1838B เป็นตัวรับสัญญาณอินฟราเรด ที่เชื่อมต่อกับ PD4 (หรือ D4 บน Arduino Uno) โดยใช้ไลบรารี IRremote ของ Arduino และรีโมทที่เข้ารหัสในรูปแบบ NEC คุณสามารถปิดใช้งานโปรโตคอลอื่นๆ ใน IRremote.h เพื่อประหยัดพื้นที่หน่วยความจำแฟลชได้ถึง 10%

Voltage detector

หลอด LED 2 ดวงในโลโก้ของ Petoi แสดงสถานะการเปิดเครื่องของบอร์ด ดวงตาซ้ายสีน้ำเงินแสดงสถานะของชิปต่างๆ ดวงตาขวาสีเหลืองแสดงสถานะของพลังงานสำหรับเซอร์โว การเชื่อมต่อกับแบตเตอรี่ ทั้ง 2 ดวงจะติดขึ้น แต่ถ้า NyBoard ถูกเชื่อมต่อกับ USB downloader ดวงตาสีน้ำเงินเท่านั้นที่จะติดขึ้น

มีช่องรับแบตเตอรี่ป้องกันการกลับด้าน และผลลัพธ์การเชื่อมต่อของแบตเตอรี่ถูกเชื่อมต่อกับ ADC7 (หรือ A7 ของ Arduino Uno) และไม่ได้เกี่ยวข้องกับขาอื่นๆบนบอร์ด ADC7 จะเก็บรวบรวมแรงดันไฟฟ้าที่แบตเตอรี่ผ่านตัวหารแรงดัน และแรงดันที่อ่านได้จะเป็นประมาณ 2 เท่าของค่าที่แสดงออกมา ระดับแรงดันที่ปลอดภัยของแบตเตอรี่อยู่ในช่วงต่ำกว่า 10V

คุณควรชาร์จแบตเตอรี่ทันทีเมื่อแบตเตอรี่ต่ำกว่า 7.4V

Grove sockets

เราใช้ตัวจับสายปลั๊กแบบ Grove เพื่อให้สะดวกในการเสียบและใช้งาน มีปลั๊กแบบนี้ทั้งหมด 3 ชนิด:

Grove Socket

Pin Number

Function

G1

I2C: SCL, SDA

I2C with 3.3V logic signal

G2

A2, A3

Analog input; 0-5V

G3

PD8, PD9

Digital I/O; 0-5V

G4

PD6, PD7

Digital I/O; 0-5V

Power system

ชิปหลักถูกจ่ายไฟโดย Low-dropout (LDO) linear regulator เพื่อลดเสียงรบกวนและเพิ่มความเสถียรภาพ โดยใช้ LM1117-5V และ XC6206P-3.3V เพื่อจ่ายไฟ 5V และ 3.3V โดยที่ LDO ของแต่ละแรงดันเชื่อมต่อต่อเนื่องกันเพื่อเพิ่มประสิทธิภาพ

มีไดโอดอยู่ระหว่างแบตเตอรี่และ LM1117-5V เพื่อป้องกันการเชื่อมต่อผิดพลาด และมีฟิวส์ที่ฟื้นตัวเอง (6V 500mA) บน USB uploader เพื่อจำกัดกระแสและป้องกันพอร์ต USB

Raspberry Pi ใช้พลังงานมากกว่านี้ ดังนั้นเราเลือก TPS565201 DC-DC เพื่อให้ผลลัพธ์ไฟฟ้าเป็น 5V 3A สูงสุดถึง 5A และมีการป้องกันอุณหภูมิ/กระแส/แรงดันสูง หากชิปส่งออกพลังงานเกิน 4A และอุณหภูมิเกิน 100 องศาเซลเซียส จะตัดการจ่ายไฟไปจนกว่าอุณหภูมิจะกลับสู่ปกติ

เซอร์โวขับเคลื่อนด้วยแบตเตอรี่ Li-ion 2S โดยตรง ต้องระวังไม่ให้เกิดการสัมผัสสั้นกันระหว่างพลังงานหรือขาต่อบน NyBoard

ตัวอัปโหลดเฟิร์มแวร์

คู่มือนี้สำหรับผู้เริ่มต้น ช่วยให้คุณเริ่มต้นใช้งานหุ่นยนต์ได้ง่ายขึ้น (Nybble / Bittle )

หมายเลขเวอร์ชันของบอร์ดอยู่ที่นี่

กดสวิตช์ I2C (SW2) ไปที่ฝั่ง "Arduino"

สวิตช์ I2C เปลี่ยนเป็นมาสเตอร์ I2C (ไจโร/มาตรความเร่ง, ไดรเวอร์เซอร์โว, EEPROM ภายนอก) ตามค่าเริ่มต้น “Arduino” NyBoard ใช้ ATmega328P แบบออนบอร์ดเป็นชิปหลัก ใน “RPi” NyBoard ใช้ชิปภายนอกที่เชื่อมต่อผ่านพอร์ต I2C (SDA, SCL) เป็นชิปหลัก เลือก "Arduino" เสมอ แต่ถ้ารู้วิธีเชื่อมต่ออุปกรณ์ I2C จากชิปภายนอกสามารถเปลี่ยนโหมดได้

หมายเหตุ:

  • บางครั้ง หากคุณไม่สามารถผ่านขั้นตอนการบูทเครื่องได้ เช่น พิมพ์ Init IMU\r\n ซ้ำๆ อาจจะมีการกดสวิตช์ไปที่ฝั่ง "RPi" โดยไม่ได้ตั้งใจ

  • ก่อนอัปโหลดเฟิร์มแวร์ โปรดตรวจสอบว่าไม่ได้เชื่อมต่ออุปกรณ์ I2C ใดๆ กับอินเทอร์เฟซ I2C ของเมนบอร์ด มิฉะนั้น การอัพโหลดเฟิร์มแวร์จะล้มเหลว ตำแหน่งของอินเทอร์เฟซ I2C แสดงอยู่ด้านล่าง (ในช่องสีแดง):

อัปโหลดเฟิร์มแวร์สำหรับ NyBoard ด้วยแอป Petoi Desktop

อาจจะมีปัญหาเรื่องความเข้ากันได้ของแพลตฟอร์ม OS กับคอมพิวเตอร์เครื่องอื่น

แต่ยังสามารถรันได้โดยตรงผ่านเทอร์มินัล:

  1. ไปที่ OpenCat/pyUI/ ในเทอร์มินัล

  2. ติดตั้ง pyserial, pillow สำหรับ python . สร้างสภาพแวดล้อมใหม่และพิมพ์ pip3 install pyserial pillow

  3. รัน python3 UI.py

สำหรับ NyBoard การอัปโหลดเฟิร์มแวร์ส่วนใหญ่จะเรียกแอปพลิเคชัน avrdude เพื่ออัปโหลดไฟล์เฟิร์มแวร์สำหรับเมนบอร์ด

การลง avrdude ใน Linux OS

สำหรับผู้ใช้ระบบ Linux นอกจากขั้นตอนข้างต้นแล้ว คุณต้องทำตามขั้นตอนต่อไปนี้ด้วย:

1. ติดตั้ง avrdude

  • Fedora : dnf install avrdude

  • CentOS : yum install avrdude

  • Debian / Ubuntu : apt install avrdude

2. แก้ไขตัวแปร avrdudeconfPath ใน FirmwareUploader.py

  • Fedora / CentOS : avrdudeconfPath = '/etc/avrdude/'

  • Debian / Ubuntu : avrdudeconfPath = '/etc/'

เชื่อมต่อตัวอัปโหลด USB

ตรวจสอบการเชื่อมต่อของ serial ports:

หลังจากเชื่อมต่อตัวอัปโหลด USB อย่างถูกต้องแล้ว ให้เปิด PetoiDesktopApp (สำหรับ Windows: UI.exe / สำหรับ Mac: Petoi Desktop App) แล้วเลือกรุ่นและภาษา

Menu bar in Petoi Desktop APP

"Italian", "Français", "日语" แปลเสร็จเรียบร้อยแล้ว. คุณสามารถมีส่วนร่วมในที่โค้ด GitHub ของเรา: OpenCat/pyUIC/translate.py

คลิกปุ่ม "Firmware Uploader" เพื่อเปิดอินเทอร์เฟซ Firmware Uploader:

เลือกตัวเลือกที่ถูกต้องเพื่ออัปโหลดเฟิร์มแวร์ล่าสุดสำหรับ NyBoard

ซอฟต์แวร์ 1.0 จะทำงานไม่ถูกต้องกับ Joint Calibrator, Skill Composer และ API อื่นๆ ใช้เฉพาะเมื่อคุณต้องการใช้ CodeCraft (อินเทอร์เฟซการเข้ารหัสแบบกราฟิกโดย TinkerGen ซึ่งเป็นพันธมิตรของเรา)

ไม่มีความสัมพันธ์ระหว่างเวอร์ชันของบอร์ด (ฮาร์ดแวร์) และเวอร์ชันรหัส (ซอฟต์แวร์)

ขั้นตอนการอัพโหลด

หลังจากคลิกปุ่ม "อัปโหลด" กระบวนการอัปโหลดจะเริ่มขึ้นทันที แถบสถานะด้านล่างจะแสดงความคืบหน้าปัจจุบันตามเวลาจริง รวมถึงผลลัพธ์ในการรัน

หลังจากอัปโหลดเฟิร์มแวร์ Parameters สำเร็จแล้ว บอร์ดจะเริ่มรันโปรแกรมการกำหนดค่าด้วยตัวเอง หน้าต่างข้อความบางหน้าต่างจะปรากฏขึ้นตามลำดับเพื่อให้คุณยืนยันหรือยกเลิก:

  • Reset joint offsets? (Y/N)

เลือก "是(Y)" โปรแกรมจะรีเซ็ตพารามิเตอร์การสอบเทียบเซอร์โวทั้งหมดเป็นศูนย์ และแถบสถานะจะอัปเดตกระบวนการที่เกี่ยวข้องและผลลัพธ์ตามเวลาจริง

เลือก "否(N)" โปรแกรมจะข้ามขั้นตอนนี้ไป

สำหรับซอฟต์แวร์เวอร์ชัน 1.0 จะมีหน้าต่างข้อความเตือน "Update Instincts? (Y/N)" ปรากฏขึ้นดังนี้:

เลือก "是(Y)" โปรแกรมจะรีเซ็ตพารามิเตอร์การสอบเทียบเซอร์โวทั้งหมดเป็นศูนย์ และแถบสถานะจะอัปเดตกระบวนการที่เกี่ยวข้องและผลลัพธ์ตามเวลาจริง

เลือก "否(N)" โปรแกรมจะข้ามขั้นตอนนี้ไป

หากคุณอัปโหลดซอฟต์แวร์เวอร์ชั่นนี้เป็นครั้งแรก อย่าลืมเลือก "是(Y)"!

สำหรับซอฟต์แวร์เวอร์ชัน 2.0 ตัวเลือกนี้จะถูกประมวลผลโดยอัตโนมัติเป็น Y

  • Calibrate IMU? (Y/N)

เลือก "是(Y)" โปรแกรมจะปรับเทียบไจโรสโคป (IMU) และแถบสถานะจะอัปเดตกระบวนการที่เกี่ยวข้องและผลลัพธ์ตามเวลาจริง

เลือก "否(N)" โปรแกรมจะข้ามขั้นตอนนี้ไป

หมายเหตุ:

  1. ตรวจสอบให้แน่ใจว่าเมนบอร์ดอยู่ในตำแหน่งแนวนอนก่อนคลิกปุ่ม "是(Y)"

  2. เมื่ออัปโหลดเฟิร์มแวร์เวอร์ชันนี้เป็นครั้งแรก อย่าลืมคลิกปุ่ม "是(Y)"!

เมื่อทำตามขั้นตอนทั้งหมดเสร็จสิ้น หน้าต่างข้อความจะปรากฏขึ้นว่า "Parameter initialization complete!" คุณต้องกดยืนยันเพื่อขั้นตอนถัดไป

หลังจากการอัปโหลดเสร็จสิ้น แถบสถานะจะอัปเดตผลลัพธ์ที่เกี่ยวข้อง เช่น การอัปโหลดเฟิร์มแวร์สำเร็จหรือล้มเหลว หากการอัปโหลดสำเร็จ จะมีหน้าต่างข้อความ "การอัปโหลดเฟิร์มแวร์เสร็จสมบูรณ์!" จะปรากฏขึ้นพร้อมกัน

หมายเหตุ:

  1. เมื่อคุณเปิดซอฟต์แวร์และอัปโหลดเฟิร์มแวร์เป็นครั้งแรก โปรแกรมจะอัปโหลดเฟิร์มแวร์ "พารามิเตอร์" ก่อน แล้วจึงอัปโหลดเฟิร์มแวร์ "ฟังก์ชันหลัก" หากคุณอัปโหลดซ้ำหลังจากอัปโหลดสำเร็จ โปรแกรมจะอัปโหลดเฉพาะเฟิร์มแวร์ "ฟังก์ชันหลัก" ตราบใดที่คุณแก้ไขตัวเลือก "โหมด" เท่านั้น

  2. หาก NyBoard ไม่ได้เชื่อมต่อกับแบตเตอรี่และเปิดอยู่ คุณจะได้ยินเสียงท่วงทำนองลดหลั่นซ้ำๆ ซึ่งแสดงว่าแบตเตอรี่เหลือน้อยหรือไม่ได้เชื่อมต่อ คุณต้องเชื่อมต่อแบตเตอรี่และเปิดเครื่อง

หากคุณมีประสบการณ์ในการเขียนโปรแกรม Arduino IDE โปรดดูที่ Upload Sketch For NyBoard

มี ให้นักพัฒนาเชื่อมต่อกับ environment.ได้อย่างสะดวกสบาย แนะนำให้ใช้ ROS ร่วมกับ .

install docker on Raspberry Pi ()

run examples (see for more)

Voltagereal=ADCreading1024×5.0×2Voltage_{real}=\frac{ADC_{reading}}{1024} \times 5.0 \times2 Voltagereal​=1024ADCreading​​×5.0×2

** ดาวน์โหลดเวอร์ชันล่าสุดของ . **

Petoi Desktop App ทำงานได้ทั้งบน Nybble และ Bittle ซึ่งควบคุมโดย NyBoard ที่ใช้ ATmega328P หรือ BiBoard ที่ใช้ ESP32 สามารถดูเอกสารรายละเอียดเพิ่มเติมได้ที่ หรือ .

ดาวน์โหลดเวอร์ชันล่าสุดของ .

สำหรับขั้นตอนเฉพาะ โปรดดูที่ ในโมดูลตัวอัปโหลด USB

Options
Values
Note

ROS wrapper
ROS
Raspberry Pi
ref
Examples

Software version

1.0

2.0 (default)

The 1.0 version เป็นรุ่นเก่า

Board version

NyBoard_V1_0 (default) NyBoard_V1_1 NyBoard_V1_2

Product

Bittle (default) Nybble

Mode

Standard (default) RandomMind Voice Camera

บางโหมดมีเฉพาะในผลิตภัณฑ์เฉพาะเท่านั้น

Serial port

The most recent

คุณอาจต้องค้นหาผ่านการลองผิดลองถูก

1.GPIO port

Operate the GPIO port of BiBoard

ไม่มีพอร์ต GPIO แยกต่างหากบน BiBoard แต่พอร์ตซีเรียลแบบมัลติเพล็กซ์ 2 (พิน 16, 17) หรือพิน PWM ของอินเทอร์เฟซเซอร์โว PWM ที่ไม่ได้ใช้สามารถใช้เป็นพอร์ต GPIO ได้ พอร์ต GPIO นั้นค่อนข้างใช้งานง่าย หลังจากกำหนดค่าโหมดอินพุตและเอาต์พุตแล้ว การใช้งานจะเหมือนกับ Arduino UNO ทุกประการ คุณสามารถใช้โปรแกรมควบคุม IO ของ Arduino UNO อะไรก็ได้ เพียงแค่เปลี่ยนจำนวนของ IO

/* In this demo, we use TX2, RX2 as general purpose IO
*   TX2 : IO17
*   RX2 : IO16
*/

void setup() {
  // initialize digital pin 16 & 17 as an output.
  pinMode(16, OUTPUT);
  pinMode(17, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    
  digitalWrite(16, HIGH);            // GPIO 16 & 17 HIGH
  digitalWrite(17, HIGH);
  delay(1000);                       // wait for a second

  digitalWrite(16, LOW);             // GPIO 16 & 17 LOW
  digitalWrite(17, LOW);
  delay(1000);                       // wait for a second
}

Petoi Desktop APP
NyBoard V1_0
NyBoard V1_1
Petoi Desktop APP
Connect NyBoard section
Bittle
Bittle

การเรียกใช้ MicroPython บน ESP8266

หลังจากอัพโหลดแล้ว MicroPython firmware บน ESP8266 เราสามารถใช้มันในการรันสคริปต์ MicroPython ได้

1. Run the script directly

เราสามารถดำเนินการรันสคริปต์ MicroPython ได้โดยตรงในตัวแปร interpreter ของ MicroPython

# Simple script:
print("Hello MicroPython")

2. Use the .py file to run the script

คุณสามารถเขียนสคริปต์ Python ง่าย ๆ เพื่อสั่งให้ไฟ LED สีแดงกระพริบได้ดังนี้:

from machine import Pin
import time

# GPIO LED IO2
def blink():
    
    led = machine.Pin(2, machine.Pin.OUT)     # Pin 2 ,Output mode
    
    while(True):			# loop
        led.on()			# light on LED
        time.sleep(1)		# delay 1s
        led.off()			# light off LED
        time.sleep(1)		# delay 1s

if __name__ == "__main__":
    blink()

กดปุ่มเริ่มต้นสีเขียวบนแถบเครื่องมือ แล้วสคริปต์จะถูกส่งไปยังโมดูล WiFi ผ่านพอร์ตซีเรียล แล้วจึงรันหลังจากถูกตีความโดยตัวแปล MicroPython ซึ่งถูกติดตั้งไว้บน ESP8266 ในกรณีที่สคริปต์เป็นลูปไม่สิ้นสุด เมื่อต้องการหยุดการทำงาน ให้กดปุ่มหยุดสีแดงเพื่อหยุดการแบ่งเบาะแสและรีเซ็ตระบบ

3. Upload the .py file to the ESP8266

เราสามารถคลิกที่ View -> File เพื่อเปิดแถบเครื่องมือไฟล์ และไฟล์จะปรากฏทางด้านซ้ายของ Thonny โดยส่วนบนคือไดเรกทอรีของเครื่องมือจำลองและส่วนล่างคือไฟล์ที่เก็บอยู่ในอุปกรณ์ MicroPython โดยค่าเริ่มต้นจะมีไฟล์ boot.py เพียงไฟล์เดียว โปรดอย่าลบไฟล์นี้ เพราะเป็นไฟล์เริ่มต้นของอุปกรณ์ MicroPython

เราบันทึกสคริปต์เป็นชื่อ blink.py และบันทึกไว้บนเครื่องคอมพิวเตอร์ จากนั้นคลิกขวาที่ไฟล์และเลือก Upload to / :

เลือก MicroPython device ในหน้าต่าง:

มีไฟล์blink.py อยู่บนอุปกรณ์แล้ว ดังนั้นไฟล์ได้ถูกบันทึกบนอุปกรณ์แล้ว

4. Write a script to let robot perform actions sequentially

ESP8266 สามารถส่งคำสั่งไปยัง NyBoard ผ่านพอร์ตซีเรียลได้ โดยเราเพียงแค่เขียนสคริปต์ส่งพอร์ตซีเรียลง่าย ๆ เพื่อส่งคำสั่งพอร์ตซีเรียลไปยัง NyBoard แล้วหุ่นยนต์ก็สามารถดำเนินการทำตามคำสั่งตามลำดับได้

from machine import UART
import time

uart = UART(0, baudrate=115200,timeout=5)

# walk
def walk(time_ms):
    print("walk")
    uart.write("kwkF")      # walk cmd
    time.sleep_ms(time_ms)  # keep time
    uart.write("d")         # stop
    time.sleep_ms(1500)
    
# backward
def back(time_ms):
    print("back")
    uart.write("kbk")
    time.sleep_ms(time_ms)
    uart.write("d")
    time.sleep_ms(1500)

# stop
def stop():
    uart.write("d")
    
def initConnection():
    connected = False
    while True:
        uart.write("d")
        for t in range(30):
            uos.dupterm(None, 1)        # disable REPL on UART(0), detach the REPL from UART0
            time.sleep_ms(5)            #delay is a must
            result = uart.read(1)
            uos.dupterm(uart, 1)        # enable REPL on UART(0), reattach REPL

            if result != None:
#                 uart.write(result)    # for debug
                if result == b"d":

                    connected = True
                    break
            time.sleep_ms(10)

        if connected:
            break

    uart.write("b22 4 24 4 26 4")
 

def actSeq():
    initConnection()
    time.sleep_ms(2000)
    walk(3000)
    back(3000)
    uart.write("m0 90")
    time.sleep_ms(3000)
    uart.write("i8 -20 9 -60")
    time.sleep_ms(2000)
    uart.write("b26 4 24 4 20 4")
    time.sleep_ms(1000)
    uart.write("d")
    uos.dupterm(None, 1)        # disable REPL on UART(0), detach the REPL from UART0

    
if __name__ == "__main__":
    actSeq()
    

เมื่อฟังก์ชั่น actSeq() ถูกเรียกใช้งาน มันจะส่งออกชุดคำสั่งผ่านพอร์ตซีเรียลไปยัง NyBoard ผ่านบอร์ด WiFi และใช้ serial monitor เพื่อดูผลลัพธ์ ดังนี้ (สำหรับความสะดวกในการอ่าน โปรดใช้การตั้งค่า automatic frame break ของตัวดีบักเกอร์พอร์ตซีเรียล เพื่อให้มีการขึ้นบรรทัดใหม่อัตโนมัติ)

5. Power on and run automatically

หลังจากที่เราได้ debug การทำงานของ sequence action เรียบร้อยแล้ว โดยการเชื่อมต่อ ESP8266 กับ NyBoard แล้วโปรแกรมดังกล่าวจะไม่สามารถรันได้เนื่องจากฟังก์ชั่น actSeq() ไม่ได้ทำงาน ดังนั้นเราต้องการให้โปรแกรมรันโดยอัตโนมัติหลังจากมีการเปิดเครื่อง ซึ่งมีวิธีการได้แก่ 2 วิธีดังนี้:

  • กรุณาเปลี่ยนชื่อไฟล์เป็น "main.py" และบันทึกลงบนอุปกรณ์ (แนะนำ)

  • แก้ไข Boot.py

รีโมทคอนโทรล

สามารถควบคุม Nybble / Bittle ผ่านรีโมทคอนโทรลได้อย่างง่าย

1. การเตรียมการ

รีโมทคุยข้อมูลผ่าน Infrared ทำให้ไม่ต้องจับคู่ โปรดตรวจสอบว่าได้ถอดแผ่นฉนวนพลาสติกออกแล้วเพื่อให้ถ่านสามารถจ่ายไฟเข้าไปสู่ตัวรีโมท และหากทดสอบเบื้องต้นโดยการชี้ตัวส่งสัญญาณของรีโมท (Infrared Transmitter) ไปที่ตัวรับสัญญาณ(Infrared Receiver)ที่ด้านหลังหุ่นยนต์เมื่อใช้งาน หากหุ่นยนต์ไม่ตอบสนอง คุณสามารถใช้กล้องของโทรศัพท์เพื่อตรวจสอบเครื่องส่งสัญญาณได้ หากไม่กะพริบเมื่อคลิกปุ่ม คุณต้องเปลี่ยนแบตเตอรี่ หากไฟกะพริบ แสดงว่าโปรแกรมบนหุ่นยนต์ไม่ได้กำหนดค่าอย่างถูกต้อง

2. คีย์แมพ

ตำแหน่งของปุ่มนั้นสำคัญมาก แม้ว่าสัญลัษณ์ต่างๆจะช่วยให้จดจำ function ต่างๆได้ แต่จจะเป็นการดีกว่าถ้าที่จะกำหนดสัญลักษณ์ที่เกี่ยวข้องกับตำแหน่งเพื่อให้สามารถอ้างอิงถึงคีย์ต่างๆได้ เช่น K00 สำหรับแถวที่ 1 และคอลัมน์ที่ 1 และ K32 สำหรับแถวที่ 4 และคอลัมน์ที่ 3

ตัวย่อสำหรับคำจำกัดความของคีย์สามารถลดการใช้ SRAM ได้เนื่องจากปุ่มของรีโมตจริงมีจำกัด คุณจึงเปลี่ยนคำจำกัดความได้เพื่อความสะดวก

คีย์แมพต่อไปนี้เป็นเพียงภาพประกอบเท่านั้น ตรวจสอบคำสั่งใน OpenCat/src/infrared.h สำหรับความหมายของคีย์แต่ละคีย์สามารถปรับแต่งได้ใน #define KXX

เรายังสร้างแผงควบคุมระยะไกลแบบกำหนดเองสำหรับแบทช์ในอนาคตอีกด้วย ผู้ใช้ก่อนหน้านี้สามารถดาวน์โหลดไฟล์การออกแบบและพิมพ์บนกระดาษ A4

3. ตรวจสอบฟีเจอร์การเคลื่อนไหว

  • Rest จะเป็นการสั่งหุ่นยนต์หมอบลงและปิดการทำงานของเซอร์โวเป็นคำสั่งคลิ๊กที่ปลอดภัยหากหุ่นยนต์ทำอะไรแปลกๆ

  • Balance คือท่ายืนที่สมดุล คุณสามารถปรับหุ่นยนต์จากด้านข้างและหุ่นยนต์จะพยายามบาลานซ์ คุณสามารถทดสอบความสามารถในการทรงตัวบนกระดานได้ การทรงตัวจะเปิดใช้งานในท่าทางและการเดินส่วนใหญ่.

  • การกด F/L/R จะทำให้หุ่นยนต์เคลื่อนที่ไปข้างหน้า/ซ้าย/ขวา

  • B จะทำให้หุ่นยนต์เคลื่อนที่ถอยหลัง

  • Calibrate ทำให้หุ่นยนต์อยู่ในท่าการคาลิเบรตและปิดการทำงานของไจโร

  • Stepping หุ่นยนต์ย่ำอยู่กับที่จุดเดิม

  • Crawl/walk/trot คือท่าที่สลับและใช้ร่วมกับปุ่มในการบังคับทิศทางของหุ่นยนต์ได้ได้

  • ปุ่มถัดจาก trot คือท่าทางหรือทักษะอื่นๆ ที่ตั้งไว้ล่วงหน้า

  • Gyro จะเปิด/ปิดไจโรเพื่อการทรงตัว การปิดไจโรสามารถเร่งความเร็วและทำให้การเดินช้าลงอย่างมีเสถียรภาพ แต่ไม่แนะนำให้เดินเร็วๆ เช่น วิ่งเหยาะๆ สิทธิ์ในตัวเองจะถูกปิดใช้งานเนื่องจากหุ่นยนต์ไม่รู้ว่าถูกพลิกอีกต่อไป

  • พื้นผิวที่แตกต่างกันมีแรงเสียดทานต่างกันและจะส่งผลต่อประสิทธิภาพการเดิน การเดินบนพื้นลาดเหมาะสำหรับหุ่นยนต์ขาสั้นทำให้การนี้มันสามารถคลานได้ด้วยคำสั่ง (command kcr) สำหรับภูมิประเทศที่เดินลำบาก

  • สามารถดึงก้อนแบตเตอรี่ลงและเลื่อนไปตามทิศทางที่ยาวขึ้นของส่วนท้อง ซึ่งจะปรับจุดศูนย์กลางมวลซึ่งเป็นสิ่งสำคัญมากสำหรับการเดิน

  • เมื่อหุ่นยนต์กำลังเดิน คุณสามารถปล่อยให้หุ่นยนต์ปีนขึ้น/ลงทางลาดชันเล็กน้อย (<10 องศา)

  • หากหุ่นยนต์ยังคงส่งเสียงบี๊บหลังจากที่คุณเชื่อมต่อตัวอัปโหลด USB โดยมีตัวเลขพิมพ์อยู่บนจอภาพซีเรียล แสดงว่ามีการเรียกใช้งานสัญญาณเตือนแรงดันไฟฟ้าต่ำ คุณต้องจ่ายพลังงานให้กับเมนบอร์ดด้วยแบตเตอรี่เพื่อให้ผ่านเกณฑ์

  • เซอร์โวได้รับการออกแบบให้ขับเคลื่อนด้วยเฟืองภายใน หลีกเลี่ยงการหมุนเซอร์โวจากภายนอกเร็วเกินไป

  • อย่าให้หุ่นยนต์วิ่งนานจนเกินไป มันจะทำให้อุปกรณ์อิเล็กทรอนิกส์ร้อนเกินไปและลดอายุการใช้งานของเซอร์โว

  • หากคุณรู้สึกว่ามีบางอย่างผิดปกติกับหุ่นยนต์ ให้กดปุ่มรีเซ็ตบนบอร์ดเพื่อเริ่มโปรแกรมใหม่

  • จงใจดีราวกับว่าคุณกำลังเล่นกับลูกแมว/ลูกสุนัขจริงๆ (^=◕ᴥ◕=^)

การคาลิเบรทด้วย Arduino IDE

การคาลิเบรทเป็นสิ่งสำคัญในการทำงานของหุ่นยนต์

หุ่นยนต์ที่ประกอบไว้ล่วงหน้าจะติดตั้งขาไว้อย่างถูกต้อง แต่ไม่มีการคาลิเบรทแบบละเอียด

การเข้าสู่โหมดการ calibrate ต้องมีการเตรียมการดังต่อไปนี้:

1. วงจรเซอร์โวทั้งหมดเชื่อมต่อกับเมนบอร์ด

2. แบตเตอรี่ชาร์จเต็มแล้ว

หากคุณกำลังสร้างหุ่นยนต์ด้วยชุดที่ยังไม่ได้ประกอบ อย่าติดตั้งส่วนประกอบส่วนหัวและส่วนขาจนกว่าจะได้รับการ calibrate คุณจะต้องติดตั้งแบตเตอรี่และกดปุ่มบนแบตเตอรี่ค้างไว้เพื่อจ่ายไฟให้กับหุ่นยนต์

การ calibrate มี 4 ขั้นตอน:

1.เขียนค่าคงที่ไปยัง Nyboard (สำหรับเฟิร์มแวร์ 1.0 เท่านั้น)

2.เปิดหุ่นยนต์ด้วยแบตเตอรี่ ปล่อยให้เซอร์โวหมุนได้อย่างอิสระจนถึงมุมศูนย์/สถานะการ calibration

3. แนบส่วนต่าง ๆ ของร่างกายเข้ากับเซอร์โว

4. ปรับออฟเซ็ตอย่างละเอียดบน serial monitor

1. Write constants

ขั้นตอนนี้ใช้สำหรับเฟิร์มแวร์ 1.0 เท่านั้น

1.1. มีค่าคงที่ 3 ประเภทที่จะบันทึกลงใน NyBoard

  1. Assembly-related เช่น การแม็ปข้อต่อ ทิศทางการหมุน และพินเซ็นเซอร์ ค่อนข้างคงที่และส่วนใหญ่กำหนดไว้ใน OpenCat.h และเก็บไว้ใช้กับหุ่นยนต์ในอนาคต

  2. พารามิเตอร์ที่เกี่ยวข้องกับการ Calibration เช่น MPU6050 offsets และการแก้ไขข้อต่อ มีการวัดตามเวลาจริงและบันทึกไว้ใน onboard EEPROM ต้องตั้งค่าเพียงครั้งเดียว

  3. ข้อมูลที่เกี่ยวข้องกับทักษะ เช่น ท่าทาง การเดิน และพฤติกรรมที่ตั้งโปรแกรมไว้ล่วงหน้า ส่วนใหญ่กำหนดไว้ใน InstinctNybble.h / InstinctBittle.h คุณสามารถเพิ่มทักษะที่กำหนดเองได้เช่นกัน

1.2. Upload and run WriteInstinct.ino

บทบาทของ WriteInstinct.ino คือการเขียนค่าคงที่ลงบนบอร์ดหรือ I2C EEPROM และบันทึกค่าการ calibration จะถูกเขียนทับโดย OpenCat.ino ในภายหลัง

คุณต้องเปลี่ยน * on#define NyBoard_V*_* ใน OpenCat.h เพื่อให้ตรงกับเวอร์ชันของ NyBoard หมายเลขเวอร์ชันสามารถพบได้บนเมนบอร์ดใกล้กับโลโก้บริษัท

ก่อนอัปโหลด sketch ตรวจสอบให้แน่ใจว่าได้ปิดหน้าต่างที่เปิดอยู่ทั้งหมดของ serial monitor มิฉะนั้น serial port อาจถูกใช้งานและ sketch จะไม่ถูกอัปโหลด

คุณต้องหมุนสวิตช์เลื่อนบน NyBoard ไปยัง Arduino แทน RPi!

หลังจากที่คุณอัปโหลด WriteInstinct.ino ผ่าน Arduino IDE ให้เปิด serial monitor

ตรวจสอบให้แน่ใจว่าตั้งค่า serial monito เป็น baud rate 115200 และ no line ending

คุณจะเห็นคำถามหลายข้อ:

Reset all joint calibration? (Y/n)

หากคุณไม่เคย calibrate ข้อต่อ หรือหากคุณต้องการ calibrate เซอร์โวใหม่โดยเริ่มต้นใหม่ ให้พิมพ์ 'Y' กับคำถาม

Do you need to update Instincts? (Y/n)

หากคุณได้แก้ไข Instinct.h ไม่ว่าด้วยวิธีใดก็ตาม คุณควรพิมพ์ 'Y' แม้ว่าจะไม่จำเป็นเสมอไปเมื่อคุณมีความเข้าใจ เกี่ยวกับการจัดการหน่วยความจำแล้ว

Calibrate MPU? (Y/n)

หากคุณไม่เคย calibrate MPU6050 เช่น gyro/accelerometer sensor ให้พิมพ์ 'Y'

บางครั้งโปรแกรมอาจหยุดทำงานในขั้นตอนการเชื่อมต่อ คุณสามารถปิด serial monitor แล้วเปิดใหม่อีกครั้ง หรือกดปุ่มรีเซ็ตบน NyBoard เพื่อรีสตาร์ทโปรแกรม

1.3. Upload OpenCat.ino

คุณต้องอัปโหลด OpenCat.ino เพื่อบันทึกค่าคงที่ล่าสุดและเปิดใช้งานฟังก์ชันสาธิต

2 Enter calibration mode

ตรวจสอบตำแหน่งและทิศทางของเซอร์โวทั้งหมด คุณต้องเสียบเซอร์โวและแบตเตอรี่ภายนอกเข้ากับ NyBoard เพื่อปรับเทียบอย่างถูกต้อง ก่อนที่เราจะติดตั้งชุดประกอบขา เพลาขาออกของเซอร์โวควรอยู่ที่ศูนย์ (ไปที่ตำแหน่งที่เป็นกลางและหยุด)

พิมพ์ 'c' ใน serial monitor เพื่อเข้าสู่โหมดการ calibration ขึ้นอยู่กับทิศทางของเพลาเริ่มต้น บางตัวอาจเดินทางในมุมที่ใหญ่ขึ้นจนกระทั่งหยุดที่จุดกึ่งกลาง จะมีเสียงรบกวนมาจากระบบเกียร์ของเซอร์โว คุณจะเห็นตารางการ calibration ดังต่อไปนี้:

แถวแรกคือ index ของข้อต่อ แถวที่สองคือออฟเซ็ตการ calibration:

ค่าเริ่มต้นคือ "-1" หรือ "0" และควรเปลี่ยนภายหลังการ calibration

เซอร์โวกำลังใช้ potentiometer ใน feedback loop เพื่อควบคุมตำแหน่ง เมื่อตำแหน่งคงที่ พวกเขามักจะสั่นรอบมุมเป้าหมาย อาการสั่นคล้ายพาร์กินสันจะเกิดขึ้นหลังจากใช้งานไปช่วงสั้นๆ จะไม่มีผลกระทบมากนักระหว่างการเคลื่อนไหวต่อเนื่อง เซอร์โวที่ดีกว่าไม่มีปัญหาเหล่านี้อาจมีราคาสูงกว่า 10 เท่า ดังนั้นการเปลี่ยนยูนิตที่จึงเป็นคำตอบที่คุ้มค่ากว่า

3 The rationale for calibration

3.1 เข้าใจสถานะศูนย์และระบบพิกัด

หลังจากพิมพ์ 'c' ใน serial monitor โดยเซอร์โวทั้งหมดหมุนไปที่มุมศูนย์ ตอนนี้ติดส่วนหัว หาง และขาที่เตรียมไว้ในส่วนก่อนหน้าเข้ากับลำตัว โดยทั่วไปจะตั้งฉากกับโครงร่างที่เชื่อมโยงกัน ท่าเทียบมาตรฐานแสดงไว้ด้านล่าง:

หากคุณกำลังสร้างหุ่นยนต์จากชุดอุปกรณ์ ให้ติดตั้งส่วนประกอบที่เกี่ยวข้องกับเซอร์โวตามภาพด้านบน และพยายามตรวจสอบให้แน่ใจว่าชิ้นส่วนเหล่านี้ตั้งฉากกัน (ขาท่อนบนตั้งฉากกับลำตัว และขาท่อนล่างตั้งฉากกับ ขาท่อนบน) โปรดดูบทที่เกี่ยวข้องในคู่มือผู้ใช้สำหรับรายละเอียด:

  • Nybble

หมายเหตุ: ใส่ส่วนประกอบที่เกี่ยวข้องกับเซอร์โวโดยตรงในเพลาขาออกของเซอร์โว ห้ามหมุนเพลาขาออกในระหว่างขั้นตอนนี้

การหมุนแขนขาทวนเข็มนาฬิกาจากสถานะศูนย์จะเป็นค่าบวก (เหมือนกับในพิกัดเชิงขั้ว) เมื่อมองจากด้านซ้ายของตัวหุ่นยนต์ การหมุนทวนเข็มนาฬิกาของข้อต่อถูกกำหนดให้เป็นทิศทางบวก

ยกเว้นอย่างเดียวคือมุมเอียงสำหรับหัวของ Nybble เป็นเรื่องปกติที่จะพูดว่า head up เป็นผลมาจากการหมุนตามเข็มนาฬิกา

แต่จากด้านขวาของตัวหุ่นยนต์ ทิศทางการหมุนที่เป็นบวกและลบนั้นตรงกันข้ามกัน

3.2 ช่วงมุมที่ไม่ต่อเนื่อง

หากเราพิจารณาเพลาเซอร์โวอย่างใกล้ชิด เราจะเห็นว่ามีจำนวนฟันจำนวนหนึ่ง มีไว้สำหรับติดแขนเซอร์โว และเพื่อหลีกเลี่ยงการเลื่อนไปตามทิศทางการหมุน ในตัวอย่างเซอร์โวของเรา เฟืองแบ่ง 360 องศาออกเป็น 25 ส่วน แต่ละส่วนมี 14.4 องศา (ออฟเซ็ต -7.2~7.2 องศา) นั่นหมายความว่าเราไม่สามารถติดตั้งในแนวตั้งฉากได้อย่างสมบูรณ์แบบเสมอไป

4 การ calibration อย่างละเอียดโดยใช้ serial monitor

4.1 คำสั่งควบคุมข้อต่อ

ตัวอย่างเช่น :

  • c8 6 หมายถึงให้เซอร์โวตัวที่ 8 มีออฟเซ็ต 6 องศา

  • c0 -4 หมายถึงการให้เซอร์โวตัวที่ 0 (ส่วนหัว) ชดเชย -4 องศา

ความละเอียดของการแก้ไขคือ 1 องศา ไม่ใช้ทศนิยม

หากคุณพบว่าค่าออฟเซ็ตมีค่ามากกว่า 9 แสดงว่าคุณไม่ได้ติดแขนขาที่ใกล้กับสถานะศูนย์ของมันมากที่สุด ซึ่งจะส่งผลให้ช่วงของเซอร์โวที่เข้าถึงได้ลดลงในด้านใดด้านหนึ่ง ถอดแขนขาออกแล้วหมุนด้วยฟันซี่เดียว มันจะส่งผลให้เกิดออฟเซ็ตมีขนาดเล็กลง

ตัวอย่างเช่น หากคุณต้องใช้ -9 เป็นค่าการ calibration ให้ถอดขาออก หมุนด้วยฟันซี่เดียวแล้วติดกลับเข้าไปใหม่ ค่าการ calibration ใหม่ควรอยู่ที่ประมาณ 5 หลีกเลี่ยงการหมุนแกนเซอร์โวระหว่างการปรับนี้

ค้นหาค่าออฟเซ็ตที่ดีที่สุดที่สามารถนำแขนขาไปสู่สถานะศูนย์ได้ เป็นกระบวนการลองผิดลองถูก

หลังจากการ calibration อย่าลืมพิมพ์ 's' เพื่อบันทึกค่าออฟเซ็ต มิฉะนั้นจะถูกลืมเมื่อออกจากสถานะการ calibration คุณยังสามารถบันทึกทุกครั้งหลังจากที่คุณทำการ calibration เซอร์โวตัวเดียวเสร็จแล้ว

4.2 Use ‘L’ shaped joint tuner

การสังเกตจะเปลี่ยนมุมมองต่างๆ นั่นเป็นเหตุผลที่เราต้องการอ่านโดยตรงเหนือไม้บรรทัดอ้างอิงเมื่อทำการวัดความยาว

สิ่งสำคัญอย่างยิ่งคือคุณต้องมีมุมมองที่ขนานกันเมื่อปรับเทียบ Bittle ใช้จูนเนอร์ข้อต่อรูปตัว 'L' เป็นข้อมูลอ้างอิงแบบขนานเพื่อหลีกเลี่ยงข้อผิดพลาดในการอ่าน วางปลายบนจูนเนอร์ให้ตรงกับกึ่งกลางของสกรูที่ข้อต่อไหล่และข้อเข่า และรูเล็กๆ ที่ปลายเท้า ดูตามแกนร่วมของศูนย์ สำหรับขาแต่ละข้าง ให้ปรับเทียบเซอร์โวไหล่ (หมายเลข 811) ก่อน จากนั้นจึงปรับเซอร์โวเข่า (หมายเลข 1215) เมื่อปรับเทียบข้อเข่า ให้ใช้ช่องสามเหลี่ยมที่ตรงกันทั้งบนตัวปรับจูนและด้ามเพื่อให้แน่ใจว่าจัดแนวขนานกัน

Nybble

Bittle

4.3 การทดสอบและการตรวจสอบความถูกต้อง

หลังจากการ calibration พิมพ์ ‘d’ หรือ ‘kbalance’ เพื่อตรวจสอบการ calibration มันจะส่งผลให้ Bittle / Nybble ขยับแขนขาอย่างสมมาตรระหว่างสถานะพักและสถานะยืน

คุณอาจต้องทำการ calibration สองถึงสามรอบเพื่อให้ได้สถานะที่เหมาะสมที่สุด

ยกตัวอย่าง Bittle ดังนี้:

4.4 Center of mass

พยายามทำความเข้าใจว่าหุ่นยนต์รักษาสมดุลได้อย่างไรแม้ในขณะเดิน หากคุณกำลังเพิ่มส่วนประกอบใหม่ให้กับหุ่นยนต์ ให้พยายามอย่างเต็มที่เพื่อกระจายน้ำหนักให้สมดุลกับกระดูกสันหลัง คุณอาจต้องเลื่อนที่ใส่แบตเตอรี่ไปมาเพื่อหาจุดที่ดีที่สุดสำหรับการปรับสมดุล เนื่องจากแบตเตอรี่มีน้ำหนักมากกว่าที่ด้านหน้า คุณจึงสามารถใส่แบตเตอรี่กลับด้านเพื่อเลื่อนจุดศูนย์กลางมวลไปทางด้านหลังได้มากขึ้น

คุณอาจต้อง calibrate ใหม่หากมีการเปลี่ยนแปลงจุดศูนย์กลางมวล

โปรดอย่าบังคับให้หุ่นยนต์เพิ่มของหนัก ซึ่งอาจทำให้เซอร์โวติดขัดได้

6.Gyro IMU(MPU6050)

MPU6050 เป็นไจโรสโคป 6 แกนที่ใช้กันแพร่หลายมากที่สุด ซึ่งไม่เพียงวัดความเร็วเชิงมุม 3 แกนและการเร่งความเร็ว 3 แกนได้แม่นยำมากขึ้น แต่ยังใช้ตัวประมวลผลการเคลื่อนไหวแบบดิจิตอล (DMP) ในตัวสำหรับการคำนวณฟิวชั่นทัศนคติตามฮาร์ดแวร์ มือใหม่จึงใช้งานได้สะดวกมาก ด้วยเหตุนี้ เราจึงใช้ไจโรสโคป MPU6050

มีการสาธิต MPU6050 มากมายบน Arduino UNO ที่มีชื่อเสียงที่สุดคือไลบรารี I2Cdev และ MPU6050DMP ของ jrowberg:

ขออภัย ไลบรารีนี้ไม่สามารถเรียกใช้โดยตรงบน BiBoard ที่ใช้ ESP32 เราพบไลบรารีที่มีบน Github ซึ่งใช้งานง่าย ไลบรารีนี้เพิ่มคำจำกัดความของ PGMSpace สำหรับซีรีส์ ARM และ ESP เพิ่มฟังก์ชันการปรับเทียบ และลบฟังก์ชันการประมวลผลเกิน FIFO (เพื่อนๆ ที่สนใจสามารถใช้ Beyond Compare สำหรับการเปรียบเทียบโค้ดได้) ไลบรารีประกอบด้วย I2Cdev และ MPU6050 ที่อยู่และแพ็คเกจที่บีบอัดมีดังนี้:

หลังจากการดาวน์โหลดเสร็จสิ้น ให้สร้างโฟลเดอร์ MPU6050 ภายใต้ Documents/Arduino/library และคัดลอกไฟล์ไลบรารีในแพ็คเกจที่บีบอัดลงไป ไลบรารีของ MPU6050 ที่แก้ไขนี้ยังเข้ากันได้กับ ARM และ AVR ดังนั้นหากคุณมีไลบรารี I2Cdev และ MPU6050 ดั้งเดิมในคอมพิวเตอร์ของคุณ คุณสามารถลบออกได้

เราสามารถใช้การตัวอย่าง MPU6050_DMP6 อย่างเป็นทางการ

ตรวจสอบให้แน่ใจว่าคุณได้อัปโหลดเฟิร์มแวร์ฟังก์ชันหลักของ OpenCat ก่อนทำการคาลิเบรท

3. เชื่อมต่ออะแดปเตอร์ และสื่อสารตามปกติ

ตรรกะเบื้องหลังการ สามารถพบได้ใน OpenCat forum หลักการเหมือนกันสำหรับ Nybble และ Bittle

คำสั่งสำหรับการ calibration แบบละเอียด (อ้างอิงจาก ) มีรูปแบบเป็น cIndex Offset. โปรดสังเกตว่ามีช่องว่างระหว่าง cIndex และ Offset หมายเลขข้อต่อของหุ่นยนต์แสดงในภาพด้านล่าง:

Index

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Offset

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

-1

5.EEPROM (Electrically Erasable Programmable read only memory)

การใช้งาน EEPROM นั้นเหมือนกับ Arduino UNO มีสองการทำงาน: อ่านและเขียน

Read:

  • I2C address of EEPROM

  • The internal address of EEPROM (the address for storing data)

  • Read data

Write:

  • I2C address of EEPROM

  • The internal address of EEPROM (the address for storing data)

  • Write data

ในการสาธิต BiBoard ที่อยู่ของ EEPROM บนบัส I2C คือ 0x54 และความจุคือ 8192Bytes (64Kbit) เราเขียนค่าทั้งหมด 16 ค่าตามลำดับตั้งแต่ 0 ถึง 15 ใน EEPROM จากแอดเดรสแรก จากนั้นจึงอ่านเพื่อเปรียบเทียบ ในทางทฤษฎี ข้อมูลที่เขียนใน EEPROM และข้อมูลที่อ่านจากที่อยู่ที่เกี่ยวข้องควรเหมือนกัน

ในการทดสอบโรงงานของ NyBoard เราใช้วิธีนี้เช่นกัน แต่จะซับซ้อนกว่า เราจะใช้รายการคงที่เพื่อเติม EEPROM และอ่านเพื่อเปรียบเทียบ

#include <Wire.h>

#define EEPROM_ADDRESS 0x54
#define EEPROM_CAPACITY 8192       // 64Kbit
#define EEPROM_TESTBYTES 16

// write 1 byte EEPROM by address
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data ) 
{
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.write(data);
  Wire.endTransmission();
 
  delay(5);
}

// read 1 byte EEPROM by address
byte readEEPROM(int deviceaddress, unsigned int eeaddress ) 
{
  byte rdata = 0xFF;
 
  Wire.beginTransmission(deviceaddress);
  Wire.write((int)(eeaddress >> 8));   // MSB
  Wire.write((int)(eeaddress & 0xFF)); // LSB
  Wire.endTransmission();
 
  Wire.requestFrom(deviceaddress,1);
 
  if (Wire.available()) 
    rdata = Wire.read();
  return rdata;
}

void testI2CEEPROM(){

    byte tmpData = 0;

    Serial.println("EEPROM Testing...");
    
    // write EEPROM from 0 to EEPROM_TESTBYTES
    for(int i = 0; i < EEPROM_TESTBYTES; i++){
        writeEEPROM(EEPROM_ADDRESS, i, i % 256);
        delay(1);
    }

    Serial.println();
    
    // read from 0 to EEPROM_TESTBYTES
    for(int i = 0; i < EEPROM_TESTBYTES; i++){
        tmpData =  (int)readEEPROM(EEPROM_ADDRESS, i);
        Serial.print(tmpData);
        Serial.print("\t");
    }
}


void setup(){

    Serial.begin(115200);
    Wire.begin();
    
    testI2CEEPROM();
}

void loop(){
  
}

หมายเหตุ: การดำเนินการ EEPROM โดยเฉพาะการดำเนินการเขียน โดยทั่วไปจะไม่ใส่ลงในลูป () แม้ว่า EEPROM จะทนทานต่อการลบ (100,000 ครั้ง) หากมีการเขียนบล็อคบางบล็อกในลูปบ่อยๆ จะทำให้ EEPROM ทำงานผิดปกติ

11.Bluetooth low energy (BLE) serial port pass-through

พอร์ตอนุกรม Bluetooth Low Energy (BLE, Bluetooth Low Energy) ใช้กันอย่างแพร่หลาย บนแพลตฟอร์ม iOS ของ Apple Classic Bluetooth ต้องมีใบรับรอง MFi เพื่อเชื่อมต่อกับอุปกรณ์ iOS ของ Apple อุปกรณ์บลูทูธพลังงานต่ำไม่มีข้อจำกัดนี้

โปรโตคอลสแต็คและหลักการของบลูทูธพลังงานต่ำจะไม่ถูกทำซ้ำที่นี่ มีบทความและวิดีโอที่เกี่ยวข้องมากมาย กล่าวโดยย่อ บริการบลูทูธมีให้ในรูปแบบของโปรไฟล์ และมีอักขระ N ตัวที่มี ID อิสระ (UUID) อยู่ใต้โปรไฟล์ของแต่ละบริการ อักขระแต่ละตัวมีสิทธิ์ต่างกัน (อ่าน เขียน แจ้ง ระบุ) หลังจากที่ผู้ใช้กำหนดอักขระและรวมเข้ากับสิทธิ์แล้ว ก็สามารถให้บริการที่สมบูรณ์ได้

BLE pass-through คืออะไร คือเพื่อสร้างบริการ BLE และมีอักขระ 2 ตัวอยู่ใต้โปรไฟล์นี้

#define SERVICE_UUID           "6E400001-B5A3-F393-E0A9-E50E24DCCA9E" // UART service UUID
#define CHARACTERISTIC_UUID_RX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"

หนึ่งอันสำหรับ TX (ส่งข้อมูล) และอีกอันสำหรับ RX (รับข้อมูล) สำหรับสิ่งนี้พวกเขามีสิทธิ์ต่างกัน รหัสต่อไปนี้คือการสร้างบริการและอักขระใหม่:

  // Create the BLE Service
  BLEService *pService = pServer->createService(SERVICE_UUID);
  
  // Create a BLE Characteristic
  pTxCharacteristic = pService->createCharacteristic(
										CHARACTERISTIC_UUID_TX,
										BLECharacteristic::PROPERTY_NOTIFY
									);
                      
  pTxCharacteristic->addDescriptor(new BLE2902());

  BLECharacteristic * pRxCharacteristic = pService->createCharacteristic(
											 CHARACTERISTIC_UUID_RX,
											BLECharacteristic::PROPERTY_WRITE
										);

ถัดไปคือฟังก์ชันการเรียกกลับสองฟังก์ชัน ซึ่งจะดำเนินการเมื่อมีการเชื่อมต่อและเมื่อมีการเขียนอักขระ RX:

class MyServerCallbacks: public BLEServerCallbacks {
    void onConnect(BLEServer* pServer) {
      deviceConnected = true;
    };

    void onDisconnect(BLEServer* pServer) {
      deviceConnected = false;
    }
};

class MyCallbacks: public BLECharacteristicCallbacks {
    void onWrite(BLECharacteristic *pCharacteristic) {
      std::string rxValue = pCharacteristic->getValue();

      if (rxValue.length() > 0) {
        Serial.println("*********");
        Serial.print("Received Value: ");
        for (int i = 0; i < rxValue.length(); i++)
          Serial.print(rxValue[i]);

        Serial.println();
        Serial.println("*********");
      }
    }
};

สุดท้าย ลูปหลักคือตัวควบคุมการเชื่อมต่อ ซึ่งจะกำหนดว่ามีการเชื่อมต่อหรือไม่และขาดการเชื่อมต่อหรือไม่

    if (deviceConnected) {
        pTxCharacteristic->setValue(&txValue, 1);
        pTxCharacteristic->notify();
        txValue++;
		    delay(10); // bluetooth stack will go into congestion, if too many packets are sent
	  }
    
    // disconnecting
    if (!deviceConnected && oldDeviceConnected) {
        delay(500); // give the bluetooth stack the chance to get things ready
        pServer->startAdvertising(); // restart advertising
        Serial.println("start advertising");
        oldDeviceConnected = deviceConnected;
    }
    // connecting
    if (deviceConnected && !oldDeviceConnected) {
		// do stuff here on connecting
        oldDeviceConnected = deviceConnected;
    }

สำหรับโค้ดที่สมบูรณ์ ดูตัวอย่างไลบรารีอย่างเป็นทางการ: ble_uart และเครื่องมือดีบั๊กสามารถใช้ LightBlue ได้

10.Classic Bluetooth serial port SPP

โค้ดตัวอย่างส่วนใหญ่แสดงให้เห็นถึงการส่งต่อข้อมูลร่วมกันระหว่างพอร์ตอนุกรม Bluetooth และพอร์ตอนุกรม ซึ่งได้มาจากการตัวอย่าง อย่างเป็นทางการของ ESP32 ซึ่งเรียบง่ายและเข้าใจได้ง่าย คำอธิบายจึงอธิบายแนวคิดที่ปรากฏในโค้ดเป็นหลัก

1. Bluetooth protocol

ในปัจจุบัน โปรโตคอล Bluetooth หลักแบ่งออกเป็นสองประเภท ได้แก่ Bluetooth แบบดั้งเดิม (HS/BR/EDR) ตาม RFCOMM และ Bluetooth พลังงานต่ำ (BLE) ตาม GATT

Bluetooth แบบดั้งเดิมนั้นเร็วกว่าและมีโปรโตคอลแอปพลิเคชันเฉพาะมากมาย เช่น A2DP ที่เน้นเสียง, พอร์ตอนุกรม Bluetooth SPP เป็นต้น อย่างไรก็ตาม การใช้พลังงานสูง และการเข้าถึงอุปกรณ์ Apple ต้องใช้ชิป MFi (Made For iOS) และการรับรอง

Bluetooth Low Energy (BLE) สามารถกำหนดโปรไฟล์ GATT ต่างๆ ได้ด้วยตัวเอง และยังมีโปรไฟล์ที่ใช้กันทั่วไป (เช่น ข้อมูลอุปกรณ์ แบตเตอรี่ ฯลฯ) มีการใช้พลังงานต่ำและใช้กันอย่างแพร่หลาย สามารถใช้กับอุปกรณ์ Apple ข้อเสียคือช้ากว่าบลูทูธแบบเดิม บลูทูธพลังงานต่ำส่วนใหญ่จะใช้กับอุปกรณ์ที่มีปริมาณข้อมูลน้อยแต่ไวต่อการใช้พลังงาน เช่น สร้อยข้อมือ/นาฬิกาอัจฉริยะ/บีคอน

2. Classic Bluetooth serial port (SPP)

การสาธิตนี้ใช้โปรโตคอล SPP ตามบลูทูธแบบดั้งเดิม ซึ่งมาพร้อมกับโปรโตคอลพอร์ตอนุกรมทั้งหมด เมื่อคอมพิวเตอร์หรือโทรศัพท์ Android เชื่อมต่อและจับคู่ หมายเลขพอร์ตอนุกรมจะถูกสร้างขึ้นโดยอัตโนมัติในระบบสำหรับการสื่อสาร และประสบการณ์การใช้งานจะไม่แตกต่างจากพอร์ตอนุกรมแบบมีสายทั่วไปมากนัก

//This example code is in the Public Domain (or CC0 licensed, at your option.)
//By Evandro Copercini - 2018
//
//This example creates a bridge between Serial and Classical Bluetooth (SPP)
//and also demonstrate that SerialBT have the same functionalities of a normal Serial

#include "BluetoothSerial.h"

#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif

BluetoothSerial SerialBT;

void setup() {
  Serial.begin(115200);
  SerialBT.begin("BTSPP_Test");          //Bluetooth device name
  Serial.println("The device started,");
  Serial.println("Now you can pair it with bluetooth!");
}

void loop() {
  if (Serial.available()) {
    SerialBT.write(Serial.read());
  }
  if (SerialBT.available()) {
    Serial.write(SerialBT.read());
  }
  delay(20);
}

พอร์ตอนุกรมบลูทูธพลังงานต่ำจะแสดงให้เห็นในบทถัดไป โดยพื้นฐานแล้ว เป็นโปรไฟล์ที่กำหนดค่าด้วยพอร์ตอนุกรมและต้องการ การสนับสนุนของโฮสต์ซอฟต์แวร์

Demo Applications

3.Analog-digital converter

Application of ADC which is variable gain on BiBoard (ESP32)

คำสั่งแนะนำของ ADC บน BiBoard

พิน 34, 35, 36 และ 39 ของโมดูล ESP32 รองรับอินพุตเท่านั้น เรากำหนดค่าให้เป็นพอร์ตอินพุตแบบอะนาล็อกบน BiBoard ซึ่งทำให้สะดวกสำหรับนักพัฒนาในการเชื่อมต่อเซ็นเซอร์เท้า 4 ตัว

การใช้งานตัวแปลงสัญญาณอนาล็อกเป็นดิจิตอล (ADC) บน BiBoard นั้นเหมือนกับ Arduino UNO พื้นฐาน แต่ความแม่นยำนั้นสูงกว่า (12 บิต UNO คือ 10 บิต) และมีการเพิ่มตัวขยายสัญญาณที่ตั้งโปรแกรมได้เพื่อให้ ADC ทำงานในช่วงที่ดีที่สุด

เมื่อป้อนสัญญาณแรงดันไฟฟ้า 1V หากใช้การเข้าถึง 12 บิตตามการกำหนดค่าปกติ แรงดันอ้างอิงจะเท่ากับแรงดันแหล่งจ่ายไฟ (3.3V): เอาต์พุตที่สอดคล้องกันคือ 0~1241 ส่วนใหญ่ของช่วง ADC จะเสียเปล่า ทำให้ได้ข้อมูลที่ไม่ถูกต้อง เมื่อเรากำหนดค่าอัตราขยายที่ตั้งโปรแกรมได้ เราสามารถทำให้สัญญาณอินพุต 1V เติมเต็มช่วง ADC เกือบทั้งหมด และความแม่นยำและความละเอียดจะดีขึ้นอย่างมาก

การสาธิตนี้ใช้ 4 อินพุต กำหนดค่าตามลำดับเป็น: อัตราขยายเดซิเบล 0/2.5/6/11 ควรสังเกตว่าการกำหนดค่าเริ่มต้นของ ESP32 Arduino คืออัตราขยาย 11 เดซิเบล

เราใช้ "analogSetPinAttenuation(PIN_NAME, attenuation)" เพื่อกำหนดค่าอัตราขยายของพินอินพุตเดี่ยว หรือใช้ "analogSetAttenuation(attenuation)" เพื่อกำหนดค่าอัตราขยายของพินอินพุตแบบอะนาล็อกทั้งหมด

// Ain 34 - 0dB Gain - ADC_0db
analogSetPinAttenuation(34, ADC_0db);

// Ain 35 - 2.5dB Gain - ADC_2_5db
analogSetPinAttenuation(35, ADC_2_5db);

// Ain 36 - 6dB Gain - ADC_6db
analogSetPinAttenuation(36, ADC_6db);

// Ain 39 - 11dB Gain - ADC_11db    (default)
analogSetPinAttenuation(39, ADC_11db);

ในการทดสอบจริง เมื่อป้อนแรงดันไฟฟ้ามาตรฐาน 1V ค่า ADC จะเป็น: 3850/2890/2025/1050 ในการผลิตในอนาคต ช่วง ADC สามารถเปลี่ยนแปลงได้โดยการเปลี่ยนอัตราขยายของ ADC โดยไม่ต้องเปลี่ยนแหล่งจ่ายแรงดันอ้างอิง

Main function firmware
USB adapter
logic behind calibration
serial protocol

NyBoard V1_0

Overview

NyBoard V1 เป็นเวอร์ชันที่ได้รับการอัพเกรดโดยพิจารณาจากความคิดเห็นของผู้ใช้ใน NyBoard V0 โดยเป็นเวอร์ชันที่สามารถใช้งานร่วมกับเวอร์ชันก่อนหน้าได้ แต่มีการออกแบบใหม่เพื่อทำให้ใช้งานได้ง่ายขึ้น.

  • บอร์ด NyBoard V1 ยังใช้ Atmel ATMega328P เป็นชิปหลักอยู่เหมือนเดิม แต่มีการเปลี่ยนความถี่จาก 20MHz เป็น 16MHz และเป็นเวอร์ชั่นที่เข้ากันได้กับ Arduino Uno ทำให้ง่ายต่อการใช้งานสำหรับผู้ใช้งานใหม่ของ Arduino

  • NyBoard V1 ยังคงใช้ PCA9685 เพื่อให้มีการขับเคลื่อน PWM 16 ช่องเช่นเดิม โดยลำดับของพินถูกเปลี่ยนแปลง แต่คุณไม่ต้องอ่านดัชนีบนบอร์ดเพราะมีการจัดการลำดับของพินด้วยซอฟต์แวร์แล้ว

  • เดิมทีบอร์ดใช้โมดูล 6-axis motion sensor MPU6050 ในรูปแบบของโมดูลแยกต่างหากที่ถูกเชื่อมต่อบนบอร์ด แต่บอร์ดรุ่นนี้ได้ทำการออกแบบเป็นส่วนหนึ่งของ PCB เองแล้ว มีการรองรับ DMP (Digital Motion Processor) ซึ่งช่วยในการคำนวณข้อมูลการเคลื่อนไหว และยังสามารถให้ข้อมูลแบบ raw data สำหรับใช้งาน fusion และ filtering algorithms ของเราเองได้อีกด้วย

  • NyBoard V1 ยังคงใช้บอร์ดหน่วยความจำภายใน 8KB I2C EEPROM เพื่อบันทึกค่าคงที่สำหรับฝีมือการทำงาน

  • ระบบจ่ายไฟได้รับการออกแบบใหม่เพื่อให้ได้แหล่งจ่ายไฟที่เสถียรมากขึ้น โครงสร้างสำหรับอุปกรณ์รอบข้างได้รับการปรับปรุงให้เหมาะสมมากยิ่งขึ้นด้วย

  • ตั้งแต่วันที่ 1 มกราคม 2021 เราเริ่มเพิ่มพอร์ต Bluetooth อย่างเป็นทางการเพื่อให้สามารถอัปโหลดและสื่อสารไร้สายได้ ค่าเริ่มต้นของ Baud rate สำหรับพอร์ตสื่อสารทั้งหมดถูกตั้งค่าไว้ที่ 115200

  • ปุ่มรีเซ็ตเป็นส่วนสำคัญของบอร์ด และใน NyBoard V1 นั้น ปุ่มรีเซ็ตได้รับการพัฒนาเพื่อทำให้ง่ายต่อการเข้าถึงมากยิ่งขึ้นโดยการวางอยู่ที่ด้านหลังของบอร์ด

  • เราเพิ่มพอร์ต Grove 4 ช่องเพื่อให้ใช้งานง่ายกับโมดูลขยาย Seeed Studio โดยไม่ต้องใช้สายเสียบเพิ่มเติม ในขณะเดียวกันยังมีพอร์ตหลักที่ผ่านมาตลอดอยู่เหมือนเดิมที่ขนาด 2.54 มม.

  • เราได้เพิ่ม WS2812 RGB LEDs จำนวน 7 ดวงลงบนบอร์ดเป็นรูปแบบออกพอร์ทและตัวบ่งชี้สถานะอีกหนึ่งรูปแบบ

  • ช่องต่อแบตเตอรี่ปัจจุบันเป็นแบบ anti-reverse ครับ

Logic diagram of the controller

The configuration of NyBoard V1_0 is shown as below:

Introduction to the onboard components

Main controller

NyBoard V1_0 ใช้ Atmel ATMega328P-MUR เป็นตัวควบคุมหลัก โดยเราได้นำเอาเวอร์ชันขนาดเล็กของมัน QFN32 เพื่อให้เหมาะสมกับการเลือกตำแหน่งและมีความเข้ากันได้กับ TQFP32 ตามปกติเลย

ATMega328P ทำงานที่ความถี่ 16MHz ด้วยแหล่งจ่ายไฟ 5V มีหน่วยความจำ RAM 2KB, Flash 32KB และ on-chip EEPROM 1KB ด้วย bootloader เดียวกับ Arduino Uno คุณสามารถอัพโหลดสคริปต์ผ่านพอร์ตซีเรียลได้เช่นกัน

I2C switch

ชิปหลักทำงานที่แรงดัน 5V ในขณะที่อุปกรณ์รอบตัวทำงานที่ระดับตรรกะของแรงดัน 3.3V โดยเราใช้ PCA9306 เพื่อแปลงบัส I2C ของ ATMega328P เป็นระดับตรรกะ 3.3V และเราได้เพิ่มสวิตช์ I2C บนบัส โดยที่เราสามารถสลับเปลี่ยนตัวควบคุมบัส I2C ของอุปกรณ์บนบอร์ดได้ โดยการเลือก "Arduino" หรือ "Raspberry Pi"

6-Axis IMU MPU6050

MPU6050 เป็นเซ็นเซอร์ที่ใช้กันอย่างแพร่หลายในโปรเจกต์ DIY ต่างๆ เพื่อไว้ใช้ในการรับรู้สถานะการเคลื่อนไหวของอุปกรณ์ โดยตรวจจับการเคลื่อนที่และการหมุนของอุปกรณ์ รวมถึงมี DMP ที่คำนวณสถานะได้โดยตรงโดยไม่ต้องใช้ทรัพยากรของตัวควบคุมหลักของบอร์ดเอง

บน NyBoard V1_0 ที่มีที่อยู่ I2C คือ 0x68 พอร์ตแตกรับ (interrupt pin) เชื่อมต่อกับพอร์ต PD2 ของ ATMega328P (หรือพอร์ต D2 ของ Arduino Uno)

มีหลายไลบรารี่สำหรับใช้กับ MPU6050 และเราใช้ I2CDev/6050DMP ในปัจจุบัน แต่คุณสามารถใช้เวอร์ชันอื่นได้ดังนี้:

PCA9685 and the PWM servo ports

PCA9685 แยกสัญญาณ PWM 16 ช่อง 12 บิตด้วยคำสั่งจากพอร์ต I2C ด้วยที่อยู่ 0x40 บนบอร์ด บนบอร์ดมีหมายเลขดัชนี PWM 16 หมายเลข ที่แสดงอยู่บน PCB แต่คุณไม่จำเป็นต้องอ่านเลขดัชนีเหล่านี้ เนื่องจากการแมพพินจะทำในซอฟต์แวร์แทน แบบต่อสายก็เหมือนเดิม แต่ต้องตรวจสอบทิศทางของพินเซอร์โว หากเป็นเซอร์โวปกติจะมีพินสัญญาณ PWM พลังงาน (2S) และอีกหนึ่งพินเป็น GND และควรเชื่อม GND กับสายสีดำของเซอร์โว

บนบอร์ด NyBoard V1_0 พ่วงพลังงานให้กับโดยตรงกับแบตเตอรี่ Li-ion 2S ของเรา โดยเราออกแบบเซอร์โวของเราให้เข้ากันได้กับแหล่งจ่ายไฟ 8.4V ซึ่งเป็นค่ามาตรฐานของเรา แต่เซอร์โวขนาด 9g ปกติที่เป็น SG90 ที่ทำงานที่แรงดันไฟฟ้า 6V จะไม่ควรถูกเชื่อมต่อโดยตรงกับบอร์ด

เราใช้ไลบรารี Adafruit PWM Servo Driver Library สำหรับ PCA9685

EEPROM

เราบันทึกทักษะการเคลื่อนไหวด้วยหน่วยความจำ I2C EEPROM AT24C64 ขนาด 8KB ซึ่งมีที่อยู่ในสัญญาณ I2C เป็น 0x54 โดยตารางค้นหาของทักษะถูกบันทึกไว้ในหน่วยความจำภายในขนาด 1KB ของ ATMega328P โดยใช้ไลบรารี <EEPROM.h> คุณต้องสังเกตเอาไว้ว่ามีความแตกต่างกันเมื่อพัฒนาโค้ดใหม่ๆ

Passive buzzer

เสียงเตือน (buzzer) ถูกขับเคลื่อนโดย PD5 (หรือ D5 ของ Arduino UNO) และกระแสได้ถูกขยายด้วย MOS ยี่ห้อ 2N7002

Infrared receiver

เราใช้ VS1838B เป็นตัวรับสัญญาณอินฟราเรด ต่อกับขา PD4 (หรือ D4 บน Arduino Uno) โดยใช้ไลบรารี IRremote ของ Arduino โปรโตคอลที่เราใช้เป็นรูปแบบ NEC คุณสามารถปิดใช้งานโปรโตคอลอื่นเพื่อประหยัดพื้นที่ Flash (ประมาณ 10%) ในไฟล์ IRremote.h ได้

Voltage detector

ไฟ LED สองดวงในโลโก้ Petoi แสดงสถานะการเปิดใช้งานของบอร์ด ดวงตาทางซ้ายสีน้ำเงินแสดงสถานะของชิปต่างๆในเบอร์ด ดวงตาทางขวาสีเหลืองแสดงสถานะของแหล่งจ่ายพลังงานสำหรับเซอร์โว เมื่อ NyBoard ต่อกับแบตเตอรี่แล้ว ทั้งสอง LED จะติด แต่เมื่อ NyBoard ถูกจ่ายพลังงานจากดาวน์โหลด USB จะมีแค่ LED สีน้ำเงินติดอย่างเดียว

มีแหล่งจ่ายไฟชนิด Anti-Reverse สำหรับแบตเตอรี่อยู่บนบอร์ด และแบตเตอรี่มีการเชื่อมต่อไปยัง ADC7 (หรือ A7 ของ Arduino Uno) และไม่ได้เชื่อมต่อกับขาว่างอื่นๆ โดย ADC7 จะรับค่าแรงดันจากแบตเตอรี่ผ่านตัวหารแรงดัน และค่าแรงดันจริงๆ จะมีค่าประมาณ 2 เท่าของค่าที่อ่านได้ ช่วงแรงดันของแบตเตอรี่ที่ถือว่าปลอดภัยคือต่ำกว่า 10V

คุณควรชาร์จแบตเตอรี่ทันทีเมื่อแบตเตอรี่ต่ำกว่า 7.4V

WS2812 RGB LED

เราเพิ่ม WS2812 RGB LEDs 7 ดวง (หรือ NeoPixel) บนบอร์ด NyBoard ด้วย หมายเลขพินคือ D10 พวกเขาถูกจ่ายไฟโดยชิป DC-DC 5V สำหรับ Raspberry Pi และเป็นอิสระจากเครือข่าย 5V ของ ATMega328P ดังนั้นคุณต้องเสียบแบตเตอรี่เพื่อจ่ายไฟให้กับ LED

Grove sockets

เราได้ใช้ช่องเสียบ Grove เพื่อให้การเชื่อมต่อง่ายดาย มีช่องเสียบประเภทต่าง ๆ ดังนี้:

Power system

NyBoard มีการจ่ายไฟหลักโดยใช้ตัวควบคุมไฟเลี้ยงแบบ Low-dropout (LDO) linear regulators เพื่อลดเสียงรบกวนและเพิ่มความเสถียรภาพ โดยใช้ LM1117-5V และ XC6206P-3.3V เพื่อจ่ายไฟเลี้ยงให้กับชิป 5V และ 3.3V โดย LDO 3.3V จะถูกเชื่อมต่อตามลำดับหลังจาก LDO 5V เพื่อเพิ่มประสิทธิภาพในการใช้พลังงาน

มีไดโอดอยู่ระหว่างแบตเตอรี่กับ LM1117-5V เพื่อป้องกันความเสียหายจากการเชื่อมต่อผิดพลาด นอกจากนี้ยังมีฟิวส์ที่สามารถฟื้นตัวเองได้ (6V 500mA) บนตัวอัพโหลด USB เพื่อจำกัดกระแสและป้องกันพอร์ต USB

Raspberry Pi ใช้พลังงานมากกว่าจึงเลือกใช้ TPS565201 DC-DC เพื่อให้ไฟเลี้ยงออกแรงดัน 5V และกระแสไฟ 3A และสามารถให้กระแสสูงสุด 5A พร้อมมีการป้องกันอุณหภูมิ/กระแส/แรงดันสูง ๆ โดยจะตัดไฟเมื่อชิปมีการออกแรงดัน >4A และอุณหภูมิเกิน 100 องศาเซลเซียสจนกว่าอุณหภูมิจะกลับสู่ปกติ โดย WS2812 RGB LEDs ยังถูกจ่ายไฟด้วยแหล่งนี้เช่นกัน

Servo จะได้รับพลังงานจากแบตเตอรี่ Li-ion 2S โดยตรง แต่จำเป็นต้องระวังการสัมผัสไฟหรือพินบน NyBoard ไม่ให้สัมผัสกัน

Last updated: Jan 13, 2021

การใช้โปรโตคอล ESP-NOW

Petoi Group Control Solution

1. การแนะนำฟังก์ชัน

ESP-NOW เป็นโปรโตคอลการสื่อสารไร้สายอีกอย่างหนึ่งที่ถูกพัฒนาโดย Espressif ซึ่งทำให้อุปกรณ์หลายตัวสามารถสื่อสารกันได้โดยไม่ต้องใช้ Wi-Fi หรือใช้ Wi-Fi ได้ตามต้องการ โปรโตคอลนี้คล้ายกับการเชื่อมต่อไร้สาย 2.4GHz แบบพลังงานต่ำที่พบได้บ่อยในเม้าส์ไร้สาย โดยอุปกรณ์จะถูกเชื่อมต่อกันก่อนที่จะสื่อสารกันได้ หลังจากการเชื่อมต่อแล้ว การเชื่อมต่อระหว่างอุปกรณ์จะเป็นต่อเนื่องแบบ peer-to-peer และไม่ต้องมีการสร้าง handshake protocol โดยเป็นเทคโนโลยีการสื่อสารที่เร็วและมีการส่งข้อมูลแบบสั้นๆ โดยไม่ต้องมีการเชื่อมต่อ ซึ่งช่วยให้คอนโทรลเลอร์พลังงานต่ำสามารถควบคุมอุปกรณ์อัจฉริยะได้โดยตรงโดยไม่ต้องเชื่อมต่อกับเราเตอร์ นี่เหมาะสำหรับสถานการณ์เช่นไฟอัจฉริยะ การควบคุมระยะไกล และการส่งข้อมูลเซ็นเซอร์กลับมา

หลังจากใช้การสื่อสาร ESP-NOW ถ้ามีอุปกรณ์บางตัวสูญเสียพลังงานโดยไม่ได้ปิดเสียงเชื่อมต่อกับอุปกรณ์ที่เหลือไว้ ให้เริ่มต้นอุปกรณ์นั้นใหม่ ก็จะเชื่อมต่อกับโหนดที่เหลืออยู่โดยอัตโนมัติเพื่อดำเนินการสื่อสารต่อไป

โหมดการสื่อสารที่รองรับโดย ESP-NOW มีดังนี้:

  • one-to-one communication

  • one-to-many communication

  • many-to-one communication

  • many-to-many communication

ESP-NOW รองรับคุณสมบัติดังนี้:

  • การเข้ารหัสแพคเก็ตแบบยูนิแคสต์หรือการสื่อสารแบบยูนิแคสต์โดยไม่มีการเข้ารหัสแพคเก็ต

  • การใช้งานผสมระหว่างอุปกรณ์ที่มีการเข้ารหัสจับคู่และอุปกรณ์ที่ไม่มีการเข้ารหัสจับคู่

  • สามารถบรรทุกข้อมูล payload ได้สูงสุดถึง 250 ไบต์

  • รองรับการตั้งค่าฟังก์ชันการส่งแบบ callback เพื่อแจ้งให้ชั้นแอปพลิเคชันทราบเมื่อการส่งแฟรมไม่สำเร็จหรือสำเร็จ

ต่อไปนี้เป็นข้อ จำกัด ของ ESP-NOW:

  • ไม่รองรับการส่ง Broadcast packet ชั่วคราว;

  • มีข้อจำกัดในการใช้กับอุปกรณ์ที่เป็นคู่ระหว่างการเข้ารหัส

    • ในโหมด Station รองรับคู่ระหว่างการเข้ารหัสได้สูงสุด 10 อุปกรณ์;

    • ในโหมด SoftAP หรือ SoftAP + Station mixed mode รองรับคู่ระหว่างการเข้ารหัสได้สูงสุด 6 อุปกรณ์;

    • จำนวนอุปกรณ์ที่เป็นคู่ระหว่างการเข้ารหัสไม่เกิน 20 อุปกรณ์ทั้งหมด;

  • ขนาดของข้อมูล payload สามารถรับได้สูงสุด 250 ไบต์.

การควบคุมกลุ่ม Petoi สามารถใช้ฟังก์ชันการสื่อสาร ESP-NOW ของ ESP8266 ได้

2. Setup for ESP-NOW

2.1 Hardware setup

ในกรณีนี้ เตรียมอุปกรณ์ 2 ตัวของ Bittle (ที่มี ESP8266 ติดตั้งอยู่) และคอมพิวเตอร์ที่เชื่อมต่อกับ ESP8266 1 ตัว

ข้อมูลต่อไปนี้เกี่ยวกับการอัปโหลดโปรแกรมและการเรียกรูปแบบ MAC ของโมดูลในรูปภาพ

2.2 Software setup

เปิดโปรแกรม Thonny และใช้ USB uploader เพื่อเชื่อมต่อโมดูล ESP8266 แล้วป้อนคำสั่งต่อไปนี้ใน shell interface:

หากมีการแจ้งเตือนข้อผิดพลาดเช่น "ไม่พบโมดูล espnow" แปลว่ามีปัญหาในการอัพโหลดเฟิร์มแวร์ ในขณะที่หากไม่มีการแจ้งเตือน แปลว่าการอัพโหลดเฟิร์มแวร์เสร็จสมบูรณ์

ถ้าหลังจากเขียนเฟิร์มแวร์ ESP-NOW แล้วไม่มีสัญลักษณ์ >>> ของ Python ปรากฏในอินเทอร์เฟซเชลล์ หมายความว่าการเขียนเฟิร์มแวร์ล้มเหลว คุณสามารถลองใช้เครื่องมือเผาไฟแบบ Flash ชื่อ NodeMCU-PyFlasher.exe และการตั้งค่าการเผาไฟแสดงในภาพด้านล่าง:

3. Code introduction

โค้ดควบคุมกลุ่มถูกแบ่งเป็น 3 ส่วน:

  • Query the MAC address of the module

  • Transmitter program

  • receiver program

3.1 Query the MAC address of the module

หมายเลข MAC คือหมายเลขที่ใช้ในการยืนยันตำแหน่งของอุปกรณ์เครือข่าย และรับผิดชอบในชั้นที่สอง (data link layer) ของโมเดลเครือข่าย OSI หมายเลข MAC ยังเรียกว่าที่อยู่ฟิสิกส์ (physical address) และที่อยู่ฮาร์ดแวร์ (hardware address) มันถูกเขียนลงบนหน่วยความจำที่ไม่สูญเสีย (เช่น EEPROM) ของการ์ดเครือข่ายเมื่อผู้ผลิตอุปกรณ์เครือข่ายผลิตอุปกรณ์นั้นๆ ขึ้นมา

ที่อยู่ MAC เป็นที่อยู่ที่ใช้สำหรับยืนยันตำแหน่งของอุปกรณ์เครือข่าย และรับผิดชอบด้านชั้นที่สอง (data link layer) ของโมเดลเครือข่าย OSI ที่อยู่ MAC ยังเรียกว่าที่อยู่ฟิสิกส์และที่อยู่ฮาร์ดแวร์ จะถูกเขียนลงในหน่วยความจำที่ไม่สูญเสีย (เช่น EEPROM) ของการ์ดเครือข่ายเมื่อมันถูกผลิตโดยผู้ผลิตอุปกรณ์เครือข่าย

ความยาวของที่อยู่ MAC คือ 48 บิต (6 ไบต์) ซึ่งมักแสดงเป็น 12 ตัวเลขฐานสิบหก 3 ไบต์แรกแทนหมายเลขอุปกรณ์ซีเรียลของผู้ผลิตฮาร์ดแวร์เครือข่ายที่ได้รับมอบหมายโดย IEEE (สถาบันวิทยาการและอิเล็กทรอนิกส์) และ 3 ไบต์สุดท้ายแทนหมายเลขอุปกรณ์เครือข่ายบางอย่าง (เช่นการ์ดเครือข่าย) ที่ผลิตโดยผู้ผลิต

เพียงแค่คุณไม่เปลี่ยนที่อยู่ MAC ของคุณ ที่อยู่ MAC จะเป็นเอกลักษณ์ในโลก ด้วยภาพการมองเห็น ที่อยู่ MAC เหมือนหมายเลขบัตรประชาชนบนบัตรประชาชน เป็นเอกลักษณ์

วิธีที่ง่ายที่สุดในการใช้ ESPNOW คือการส่งข้อมูลด้วย MAC address โดยเราจะใช้โปรแกรมเล็ก ๆ เพื่อสอบถาม MAC address ของโมดูล

หลังจากการรันโปรแกรมใน Thonny เสร็จสิ้น โปรแกรมจะแสดง MAC address บน terminal ออกมา ในขณะนี้ คุณสามารถใช้สติ๊กเกอร์สำหรับเขียน MAC address ของโมดูลแล้ววางไว้บนโมดูลได้เลย

3.2 Transmitter program

โปรแกรมส่งประกอบด้วยส่วนต่อไปนี้:

  • Enable the WiFi function of the module

  • Configure the ESP-NOW protocol and enable it

  • Add a node (peer) that needs to communicate

  • Send a message

โค้ดที่เป็นตัวอย่างเฉพาะ:

3.3 Receiver program

โปรแกรมตัวรับประกอบด้วยส่วนต่อไปนี้:

  • Enable the WiFi function of the module

  • Configure the ESP-NOW protocol and enable it

  • Add a node (peer) that needs to communicate

  • Receive and decode the message, and send commands to NyBoard through the serial port

โค้ดที่เป็นตัวอย่างเฉพาะ:

โค้ดนี้ถูกแพ็กเก็ตไว้ในฟังก์ชันที่ชื่อว่า espnow_rx() เพื่อความสะดวกในการเริ่มโปรแกรมโดยอัตโนมัติหลังจากเปิดเครื่องขึ้นมา

มีวิธีสองวิธีในการเรียกใช้โปรแกรมโดยอัตโนมัติหลังจากเปิดเครื่อง:

  • Rename the code file to main.py;

  • Modify the boot.py ;

สำหรับผู้เริ่มต้นเราแนะนำอันแรก

3.4 Communication-Command Converter

การเขียนการแปลงคำสั่งผ่านทางซีเรียลที่ส่งมาจะทำให้โปรแกรมซับซ้อนและยากต่อการบำรุงรักษา ดังนั้นเราสามารถสร้างฟังก์ชันใหม่เพื่อทำการแปลงคำสั่งและส่งออกคำสั่งได้ โดยจะทำการเก็บคำสั่งที่รับเข้ามาเป็นตัวเลขเดียวกันกับคำสั่งที่ส่งออกไปยังฝั่งอีกข้าง ที่เขียนเป็นฟังก์ชันใหม่ ตั้งชื่อว่า“instruction_handle()” เพื่อแปลงข้อความที่ได้รับเป็นตัวเลขและส่งออกข้อความตามรูปแบบของคำสั่งที่ต้องการ

ติดตั้งโปรแกรม Thonny บนคอมพิวเตอร์เพื่อให้สะดวกในการดีบั๊ก MicroPython ของโมดูล ESP8266 โดยใช้โปรโตคอล ESP-NOW ต้องใช้เฟิร์มแวร์ MicroPython เฉพาะ (ดูที่ ). เนื่องจากเวอร์ชันธรรมดาของฟิวเจอร์เซ็ต MicroPython สำหรับ 8266 จะแจ้งเตือนว่าไม่พบไลบรารี

Name

Author

Feature

I2Cdev

jrowberg

built-in DMP

Adafruit MPU6050

Adafruit

standard MPU6050 library

Kalman Filter

TKJ Electronics

with Kalman filter

Voltagereal=ADCreading1024×5.0×2Voltage_{real}=\frac{ADC_{reading}}{1024} \times 5.0 \times2 Voltagereal​=1024ADCreading​​×5.0×2

Grove Socket

Pin Number

Function

G1

I2C: SCL, SDA

I2C with 3.3V logic signal

G2

A2, A3

Analog input; 0-5V

G3

PD8, PD9

Digital I/O; 0-5V

G4

PD6, PD7

Digital I/O; 0-5V

import espnow
import ubinascii
import network

wlan_sta = network.WLAN(network.STA_IF)
wlan_sta.active(True)
wlan_mac = wlan_sta.config('mac')
print(ubinascii.hexlify(wlan_mac).decode())Pythonp
import network
import espnow
import time

sta = network.WLAN(network.STA_IF)    # Enable station mode for ESP
sta.active(True)
sta.disconnect()        # Disconnect from last connected WiFi SSID

e = espnow.ESPNow()     # Enable ESP-NOW
e.active(True)

peer1 = b'\xe8\x68\xe7\x4e\xbb\x19'   # MAC address of peer1's wifi interface
e.add_peer(peer1)                     # add peer1 (receiver1)

peer2 = b'\x60\x01\x94\x5a\x9c\xf0'   # MAC address of peer2's wifi interface
e.add_peer(peer2)                     # add peer2 (receiver2)

print("Starting...")            # Send to all peers

e.send(peer1, "walk", True)     # send commands to pear 1
e.send(peer2, "walk", True)     # send commands to pear 2
time.sleep_ms(2000)
e.send(peer1, "walk", True)
e.send(peer2, "back", True)
time.sleep_ms(2000)
import network
import espnow
from machine import UART

def espnow_rx():
    #config UART
    uart = UART(0, baudrate=115200)

    # A WLAN interface must be active to send()/recv()
    sta = network.WLAN(network.STA_IF)
    sta.active(True)
    sta.disconnect()                # Disconnect from last connected WiFi SSID

    e = espnow.ESPNow()                  # Enable ESP-NOW
    e.active(True)

    peer = b'\x5c\xcf\x7f\xf0\x06\xda'   # MAC address of peer's wifi interface
    e.add_peer(peer)                     # Sender's MAC registration

    while True:
        host, msg = e.recv()
        if msg:                          # wait for message
            if msg == b'walk':           # decode message and translate
                uart.write("kwkF")       # to the NyBoard's command
            elif msg == b'back':
                uart.write('kbk')
            elif msg == b'stop':
                uart.write('d')

if __name__ == "__main__":
    espnow_rx()
    

2.Serial port

มีพอร์ตซีเรียล 2 พอร์ตซึ่งแยกจากกันบนช่องส่วนขยาย 2 ช่อง (P16, P17) บน BiBoard

พอร์ตซีเรียล 1 บน P16 สามารถเชื่อมต่อกับตัวดาวน์โหลด USB และอุปกรณ์ซีเรียลภายนอกได้ โปรดอย่าใช้ตัวดาวน์โหลดและอุปกรณ์ซีเรียลภายนอกพร้อมกัน การแบ่งแรงดันพอร์ตซีเรียลจะนำไปสู่ข้อผิดพลาดในการสื่อสาร

ในการสาธิต Arduino นั้น Serial แทนพอร์ตซีเรียล 0 Serial1 แทนพอร์ตซีเรียล 1 Serial และ Serial1 นั้นส่งถึงกัน

/* In this demo, we use Serial and Serial1 
*  Serial and Serial1 send to each other 
*/

void setup() {
  // initialize both serial ports:
  Serial.begin(115200);
  Serial1.begin(115200);
}

void loop() {
  // read from port 1, send to port 0:
  if (Serial1.available()) {
    int inByte = Serial1.read();
    Serial.write(inByte);
  }

  // read from port 0, send to port 1:
  if (Serial.available()) {
    int inByte = Serial.read();
    Serial1.write(inByte);
  }
}

4.Digital-Analog Converter

The usage of DAC

วัตถุประสงค์ของ DAC นั้นตรงกันข้ามกับของ ADC DAC แปลงสัญญาณดิจิทัลเป็นสัญญาณอะนาล็อกสำหรับเอาต์พุต

จำเพลงเมื่อเปิด NyBoard ได้ไหม กำลังใช้ PWM เพื่อสร้างเสียงเพลงซึ่งใช้การสลับความเร็วสูงเพื่อปรับรอบการทำงานเป็นแรงดันเอาต์พุต

เมื่อเปรียบเทียบกับ PWM แล้ว DAC จะส่งแรงดันออกโดยตรงโดยไม่ต้องคำนวณรอบการทำงาน ESP32 รวม DAC 8 บิต 2 แชนเนลที่มีค่า 0-255 ช่วงแรงดันไฟฟ้าคือ 0-3.3V ดังนั้นสูตรการคำนวณแรงดันเอาต์พุตของ DAC จึงเป็นดังนี้:

DAC=(int)TargetV/3.3V∗255DAC=(int)TargetV/3.3V∗255DAC=(int)TargetV/3.3V∗255

The demo is as follows:

#define DAC1 25 

void setup() {  
}

void loop() {
  
  // 8bit DAC, 255 = 3.3V, 0 = 0.0V 
  for(int i = 0; i < 255; i++){
    dacWrite(DAC1, i);
    delay(10);
  }
}

Github

สกิลคอมโพสเซอร์

Skill Composer เป็นเครื่องมือพัฒนาทักษะที่พัฒนาเป็นพิเศษโดย Petoi สำหรับหุ่นยนต์ (Bittle, Nybble) เครื่องมือที่ดีเป็นสิ่งที่จำเป็นสำหรับความสำเร็จของงาน

บทเกริ่นนำ ของอินเทอร์เฟซ

หุ่นยนต์ต้องใช้พลังงานจากแบตเตอรี่และใช้เฟิร์มแวร์ OpenCat 2.0 เพื่อให้ Petoi Desktop App รู้จัก ก่อนเปิดซอฟต์แวร์ โปรดติดตั้งแบตเตอรี่และกดปุ่มบนแบตเตอรี่ค้างไว้เพื่อเปิด Nybble / Bittle

อินเทอร์เฟซของสกิลคอมโพสเซอร์

Nybble

Bittle

หมายเหตุ: ปุ่มส่วนใหญ่บนอินเทอร์เฟซมีคำแนะนำการใช้งานหากเลื่อนเมาส์ไปด้านบนของเครื่องมือนั้นๆ

ตัวเลือกในเมนู

  • โมเดล

    • Nybble

    • Bittle

    Nybble cat และ Bittle มีข้อต่อขาหลังที่แตกต่างกัน ข้อมูลสกิลของทั้งสองตัวไม่สามารถใช้แทนกันได้ เลือกรุ่นที่ถูกต้องก่อนใช้งาน สกิลคอมโพสเซอร์ มิฉะนั้น ข้อต่อบางส่วนอาจขัดแย้งกับร่างกายของหุ่นยนต์

  • ภาษา

  • ประโยชน์

    เราจะเพิ่มแกดเจ็ตขนาดเล็กลงในแท็บยูทิลิตี้ต่อไป ขณะนี้เรามีตัวเลือกสีตาสำหรับเซ็นเซอร์อัลตราโซนิกของแมว Nybble พร้อมไฟ LED ในตัว

การเชื่อมต่อและการหมุนหมายเลขสถานะ

พอร์ท / เชื่อมต่อ

หมายเหตุ: แอปเดสก์ท็อปจะคอยฟังพอร์ตอนุกรมและส่งสัญญาณจับมือไปยังอุปกรณ์ที่เพิ่มใหม่ หากอุปกรณ์ตอบสนองด้วยสัญญาณที่กำหนดไว้ล่วงหน้า อุปกรณ์นั้นจะรับรู้เป็นอุปกรณ์ Petoi และเพิ่มลงในเมนูแบบเลื่อนลง

เซอร์โว

ข้อต่อของหุ่นยนต์จะคงตำแหน่งเมื่อออกแรง คุณไม่ควรหมุนด้วยมือ การปิดจะทำให้คุณสามารถหมุนข้อต่อของหุ่นยนต์ได้อย่างอิสระ การจัดตำแหน่งหุ่นยนต์อย่างรวดเร็วเพื่อวางแผนจุดศูนย์กลางมวลเพื่อการทรงตัวจะเป็นประโยชน์

ไจโร

หุ่นยนต์มีไจโรสโคปเพื่อตรวจจับมุมและการเคลื่อนไหวของร่างกาย ใช้สำหรับการทรงตัวและการม้วนกลับ การปิดสามารถหลีกเลี่ยงปฏิกิริยาที่ไม่คาดคิดเมื่อหมุนหุ่นยนต์

แรนด้อม

ท่าที่ตั้งค่าไว้

มีท่าคงที่ที่กำหนดไว้ล่วงหน้าสองสามท่าเพื่อย้ายข้อต่อของหุ่นยนต์ไปยังตำแหน่งเฉพาะ คุณสามารถใช้เป็นจุดเริ่มต้นในการสร้างลำดับการเคลื่อนไหวของคุณ เรามักจะเริ่มด้วยท่า "ทรงตัว" โดยให้หุ่นยนต์ยืนบนขาทั้งสี่ข้าง

สามารถสลับไปมาระหว่างท่าทางต่างๆ และสังเกตว่าแถบเลื่อนในในหน้าต่างปรับข้อต่ออัปเดตอย่างไรเพื่อแสดงเห็นการเปลี่ยนแปลงในมุมองศาของข้อต่อ

Joint Controller

แถบเลื่อนมุมสามารถแสดงมุมข้อต่อปัจจุบันของหุ่นยนต์ สามารถหมุนข้อต่อของหุ่นยนต์กลับด้านได้หากคุณเปลี่ยนค่า คุณสามารถลากแถบเลื่อนเพื่อปรับมุมกว้าง หรือคลิกด้านบนหรือด้านล่างแถบเลื่อนเพื่อปรับแบบละเอียด (ทีละ 1 องศา) ข้อต่อบางอันจะมีระยะการเข้าถึงที่เล็กกว่าตัวเลื่อน พยายามใช้มุมระหว่าง -125 ถึง 125 องศา การส่งมุมที่ใหญ่ขึ้นจะเพิ่มเวลาตอบสนองกับหุ่นยนต์

แถบเลื่อนสอดคล้องกับข้อต่อของหุ่นยนต์ หากคุณมองลงไปที่หุ่นยนต์โดยให้ส่วนหัวชี้ไปข้างหน้าข้อต่อที่อยู่ใกล้กับร่างกายจะอยู่ใกล้กับศูนย์กลางของแผง ข้อต่อของหุ่นยนต์สามารถเข้ากับร่างกายของคุณเองและกลายเป็นอวตารของคุณได้

หมายเหตุ: แถบเลื่อนบางตัวที่มีพื้นหลังสีเหลืองอ่อนจะปิดใช้งานสำหรับข้อต่อที่ไม่มีในบางรุ่นเช่น Bittle ไม่มีเหมือน Nybble

คุณสามารถควบคุมหลายข้อต่อได้โดยคลิกปุ่มหมุนหมายเลข "+" หรือ "-" บนแถบเลื่อนแต่ละตัว แถบเลื่อนทั้งหมดที่มีการกด "+" จะเปลี่ยนโดย increaments เดียวกัน แถบเลื่อนที่กดปุ่ม "-" จะเปลี่ยนตามค่าลบ ปุ่มสามารถเปิดปิดได้ คลิกปุ่ม "Unbind All" เพื่อปลดข้อต่อทั้งหมดพร้อมกัน

คุณยังสามารถควบคุมข้อต่อทั้งตัวของหุ่นยนต์ได้ด้วยแถบเลื่อนที่แผงตรงกลาง คุณสามารถปรับแถบเลื่อนกลางเหล่านี้เพื่อปรับการวางแนวและการแปลโดยรวมของหุ่นยนต์ ท่า "สมดุล" ที่เป็นกลางสามารถสร้างผลลัพธ์ที่ดีกว่าท่าเอียงอื่น ๆ

Global Orientation and Translation
Effect

Pitch

ปรับมุมเอียง

Roll

ปรับมุมม้วน

Spinal

เคลื่อนไปตามทิศทางหุ่นยนต์

Height

ยกหรือลดร่างกายของหุ่นยนต์

Skill Editor

ฟังก์ชันก่อนหน้านี้สามารถแก้ไขท่าทางเดียวได้ Skill Editor เป็นตัวกำหนดตารางเวลาแอนิเมชั่นสต็อปโมชั่น คุณสามารถเพิ่ม ลบ และแทรกเฟรมของท่าทางต่างๆ และทำให้หุ่นยนต์เคลื่อนไหวได้อย่างต่อเนื่องและราบรื่น

ในแต่ละเฟรมมีแถวของตัวมันเองโดยแถวแรกบนสุดจะเป็นแถบเมนูบอกว่าทำอะไรเราสามารถแอดเฟรมแล้วปรับค่าได้

การทำงานขั้นพื้นฐาน

การเปิดใช้งานเฟรม

สามารถคลิก "=" (ปุ่มที่ 2 ของแต่ละเฟรม) เพื่อเปิดใช้งานเฟรมที่เกี่ยวข้องและย้ายหุ่นยนต์ไปยังท่าทางของเฟรม เฟรมจะเก็บการแก้ไขใหม่ทั้งหมดของคุณในท่าทางปัจจุบันของหุ่นยนต์ สัญลักษณ์ "=" จะเป็นตัวหนา และปุ่มจะใหญ่ขึ้น หากเฟรมปัจจุบันถูกแก้ไข สัญลักษณ์ "=" จะกลายเป็นเครื่องหมายตกใจสีแดง "!" คุณสามารถคลิกปุ่มนี้เพื่อบันทึกการแก้ไขของคุณ มิฉะนั้น การแก้ไขปัจจุบันจะถูกยกเลิกหากคุณคลิกปุ่ม "="ของเฟรมอื่นๆ

การเพิ่มเฟรม

คุณสามารถคลิกปุ่ม "v" (ปุ่มที่ 9 ของแต่ละเฟรม) เพื่อเพิ่มเฟรมหลังจากเฟรมปัจจุบันและเปิดใช้งาน กรอบใหม่จะเหมือนกับของเฟรมที่เปิดใช้งานก่อนหน้า

หมายเหตุ: เฟรมใหม่ไม่จำเป็นต้องคัดลอกเฟรมโดยการกดปุ่ม "v"

แทรกเฟรม

ไม่จำเป็นต้องเพิ่มเฟรมใหม่หลังจากเฟรมสุดท้ายเสมอไป คุณสามารถคลิกปุ่ม "v" (ปุ่มที่ 9 ของแต่ละเฟรม) oเฟรมระหว่างกลางใด ๆ เพื่อแทรกเฟรมใหม่ด้านล่างโดยการกดปุ่ม "v" . เฟรมใหม่มีข้อมูลที่เหมือนกันกับเฟรมที่เปิดใช้งานก่อนหน้า

สะท้อนเฟรม

สามารถคลิกปุ่ม ">|<" เพื่อให้เฟรมนี้เหมือนกับเฟรมท่าทางของเฟรมที่เปิดใช้งานไปแล้ว

ลบเฟรม

สามารถคลิกที่ปุ่ม "<" (ปุ่มที่ 8 ของแต่ละเฟรม) เพื่อลบเฟรมปัจจุบันโดยกดปุ่มค้างไว้เฟรมต่อไปนี้ทั้งหมดจะเลื่อนขึ้น ถ้า เฟรมที่เปิดใช้งานถูกลบ เฟรมก่อนหน้าจะเปิดใช้งาน เฟรมที่เปิด เป็นเฟรมแรกและถูกลบ เฟรมถัดไปจะถูกเปิดใช้งาน

เพิ่มคำอธิบายสำหรับแต่ละเฟรม

บางครั้งอาจจะลืมสิ่งที่ต้องการให้แต่ละเฟรมทำงานมีการแก้ไขเฟรมหลายครั้ง และการสลับไปมายังแต่ละเฟรมอาจใช้เวลานาน เราให้บริการ "Note" (ปุ่มที่ 7 ของแต่ละเฟรม)ซึ่งคุณสามารถเพิ่มคีย์เวิร์ดสั้นๆ เพื่อระบุความหมายของเฟรมได้ ตามค่าเริ่มต้น ชื่อท่าแบบสุ่มจะถูกเพิ่มเข้าไปในเฟรมเมื่อสร้างขึ้น

การผูกติดข้อต่อและแก้ไขแบบส่งผ่าน

หากมุมของข้อต่อเหมือนกันในเฟรมปัจจุบันและเฟรมถัดไป การแก้ไขและบันทึกมุมจะอัปเดตมุมในเฟรมต่อไปนี้ด้วยจนกว่ามุมจะแตกต่างกัน ตัวอย่างเช่น หากมุมร่วมของ 8 เป็น 4,4,4,4,6,7 ในทุกเฟรม การเปลี่ยนมุมในเฟรมที่สองเป็น 8 จะอัปเดตลำดับเป็น 4,8,8,8,6,7

เล่นสกิลตามลำดับ

นอกเหนือจากการคลิกด้วยตนเองที่ปุ่ม "=" (ปุ่มที่ 2 ของแต่ละเฟรม)หากต้องการดูท่าเดียว คุณสามารถคลิก "Play" ปุ่มเริ่มแสดงท่าตามลำดับเริ่มจากเฟรมที่เปิดใช้งานทั้งหมด ในระหว่างการเล่นสามารถกดปุ่ม "Stop" เพื่อหยุดการเล่นสกิลกลางคันได้

ส่งออกสกิล

หลังจากคลิกไปที่ปุ่ม "Export" คุณสามารถเลือกตำแหน่งและชื่อไฟล์ในการบันทึกสกิล เฟรมที่กำลังดำเนินการทั้งหมดในรายการเฟรมจะถูกส่งออก) เป็นไฟล์ข้อความ คุณสามารถยกเลิกการบันทึกเพื่อข้ามได้ แอปเดสก์ท็อปจะยังคงส่งทักษะไปยังหุ่นยนต์เพื่อประสิทธิภาพแบบเรียลไทม์ และคุณสามารถเรียกใช้ทักษะที่ส่งล่าสุดด้วยโทเค็นซีเรียล"T". โดยสองวิธีต่อไปนี้

เนื้อหาของไฟล์ข้อความที่ส่งออก (.txt) สามารถคัดลอกและวางลงในไฟล์ Instinct**.h เพื่อใช้เป็นอาร์เรย์ทักษะได้

นำเข้าสกิล

หลังจากที่คลิกปุ่ม "Import"คุณจะเห็นหน้าต่างเด้งขึ้นมามันอนุญาตให้คุณก๊อปปี้และวางสกิลดาต้าอารเ์เรย์ใน text editor หรือ นำเข้าสกิลที่มีอยู่แล้วจากการสร้างโดยคนอื่นได้คุณสามารถดูตัวอย่างได้ที่OpenCat/src/InstinctBittle.h or InstinctNybble.h. รูปแบบสกิลที่สมบูรณ์ควรประกอบด้วยคู่"{ }" และมีตัวเลขระหว่างกลาง. เฉพาะรายการแรกเท่านั้นที่จะถูกนำเข้าหากมีอาร์เรย์สกิลหลายรายการ ควรตรวจสอบก่อนนำเข้า

รีเซ็ตตัวแก้ไขสกิล

คุณสามารถใช้ปุ่ม "Restart" เพื่อล้างแผงตัวแก้ไขสกิลและเริ่มต้นใหม่

การดำเนินการขั้นสูง

ตั้งค่า Action Frame Loops

หากคุณป้อน -1 ในช่อง ทำซ้ำ เฟรมจะดำเนินการวนซ้ำจะวนซ้ำตลอดไป เว้นแต่คุณจะกดปุ่มรีเซ็ตบนกระดานหลักของหุ่นยนต์

กำหนดความเร็วในการเคลื่อนที่

1,2,4,8,12,16,32,48,max

หมายเหตุ:

  • คุณยังสามารถป้อนค่าจำนวนเต็มในช่วง 0~125 (0 หมายถึง สูงสุด) ในกล่องตัวเลือก

  • คลิกปุ่ม "Play" ใน "Skill Editor" คุณไม่สามารถมองเห็นเอฟเฟกต์ความเร็วในการวิ่งที่แท้จริงของการกระทำได้ หลังจากคลิกปุ่ม "ส่งออก" คุณจะเห็นเอฟเฟกต์ความเร็วจริง

  • การเคลื่อนที่ด้วยความเร็วสูงสุดเป็นเวลานานจะทำให้เซอร์โวเสียหายได้ ดังนั้นจึงแนะนำโดยทั่วไปว่าอย่าตั้งค่าเป็น "สูงสุด"

  • เมื่อเปิดปุ่ม "Gyro" ในพื้นที่ "หน้าปัดสถานะ" (สีตัวอักษรเป็นสีเขียว) หลังจากปรับค่ามุมร่วมในเฟรมหรือความเร็วในการทำงานของเฟรม สามารถกด เล่น เพื่อดูเอฟเฟกต์การดีบัก หรือส่งออกพฤติกรรมการกระทำ หุ่นยนต์จะพยายามรักษาสมดุลร่างกายของตนเองตามเวลาจริง ดังนั้นอาจเห็นได้ว่าเมื่อหุ่นยนต์ทำการกระทำที่กำหนดไว้ล่วงหน้า (โดยเฉพาะเมื่อทำการกระทำที่ค่อนข้างรุนแรง) ร่างกายของมันจะสั่นไปมา และมาหรือแม้แต่พลิกคว่ำ และหุ่นยนต์จะฟื้นตัวโดยอัตโนมัติ การดำเนินการอาจรบกวนขั้นตอนการทำงานเดิมของคุณ ดังนั้น ขอแนะนำให้คุณคลิกปุ่ม "Gyro" เมื่อออกแบบการทำงานเพื่อปิดไจโรสโคป (สีตัวอักษรเปลี่ยนเป็นสีแดง) และหุ่นยนต์จะไม่ดำเนินการป้อนกลับสมดุลตามเวลาจริง เมื่อคุณต้องการเปิดไจโรสโคป ให้คลิกปุ่ม "ไจโร" อีกครั้ง

ตั้งค่าการหน่วงเวลา

มีให้เลือก 17 แบบ: 0,50,100,200,300,400,500,600,700,800,900,1000,2000,3000,4000,5000,6000.

แน่นอน คุณยังสามารถป้อนค่าจำนวนเต็มในช่วง 0~6000 ในช่องตัวเลือก "Delay" หน่วยเป็นมิลลิวินาที (ms)

ตั้งค่าทริกเกอร์และมุม

ตัวเลือก "ทริกเกอร์" (ปุ่มที่ 4 ของเฟรม) ในเฟรมใช้เพื่อกำหนดทิศทางการหมุนของร่างกายเมื่อหุ่นยนต์สั่งงานเฟรมถัดไป มีตัวเลือกการตั้งค่า 5 แบบต่อไปนี้:

  • None หมายความว่าไม่มีทริกเกอร์และตั้งค่าเงื่อนไขมุมแล้ว

  • Pitch หมายถึงตัวหุ่นยนต์หมุนทำให้จมูกลง

  • -Pitch หมายถึงตัวหุ่นยนต์หมุนทำให้จมูกสูงขึ้น

  • Roll หมายความว่าตัวหุ่นยนต์จะกลิ้งไปทางด้านซ้าย (ทวนเข็มนาฬิกาเมื่อมองจากหาง)

  • -Roll หมายถึง ตัวหุ่นยนต์จะกลิ้งไปทางด้านขวา (ตามเข็มนาฬิกาเมื่อมองจากหาง)

ตัวเลือก "มุม" (ปุ่มที่ 5 ของเฟรม) ถูกกำหนดโดยอ้างอิงถึงมุมของระบบพิกัดเชิงขั้ว ดังที่แสดงในรูปด้านบน เมื่อร่างกายอยู่ในแนวนอน มุมของแกนพิกัดเชิงขั้วคือ 0 องศา หากแกนพิกัดเชิงขั้วหมุนทวนเข็มนาฬิกา มุมจะเป็นบวกและค่อยๆ เพิ่มขึ้น ช่วงการตั้งค่ามุมคือค่าจำนวนเต็มระหว่าง-125~125.

เมื่อมีการตั้งค่าทริกเกอร์และมุมเฉพาะในกรอบการทำงาน กรอบการทำงานถัดไปจะถูกเรียกใช้เมื่อหุ่นยนต์หมุนเหนือมุมสั่งงานในทิศทางของทริกเกอร์เท่านั้น หากมีการตั้งค่าการหน่วงเวลาในกรอบการทำงานนี้ด้วย จะมีการเลื่อนเวลาเพิ่มเติมหลังจากตรงตามเงื่อนไขทริกเกอร์ก่อนที่จะย้ายไปยังเฟรมถัดไป

เมื่อสร้างการกระทำที่เกี่ยวข้องกับการหมุนตัวหุ่นยนต์ (เช่น การตีลังกากลับหลัง การออกกำลังกายแบบยกน้ำหนักสูง ฯลฯ) จำเป็นอย่างยิ่งที่จะต้องกระตุ้นการเคลื่อนไหวในมุมของร่างกายที่แน่นอน ซึ่งจังหวะเวลานั้นยากแก่การประเมิน และอาจเปลี่ยนแปลงในระหว่าง การเคลื่อนไหว เราสามารถใช้ไจโรสโคปเพื่อตรวจสอบมุมการหมุนของตัวหุ่นยนต์แบบเรียลไทม์ เพื่อให้หุ่นยนต์สั่งงานเซอร์โวร่วมในเวลาที่แน่นอนของเหตุการณ์สั่งงาน

ส่งออกท่าทางที่เรียนรู้(มิเรอร์)

ตัวเลือกพฤติกรรมและการเดิน

เมื่อนำเข้าอาร์เรย์ทักษะที่สร้างไว้ล่วงหน้า แอปเดสก์ท็อปจะเลือกตัวเลือก "พฤติกรรม/การเดิน" โดยอัตโนมัติตามรูปแบบข้อมูล เฟรมจะถูกโหลดลงในโปรแกรมแก้ไขเฟรม และหุ่นยนต์จะย้ายไปยังตำแหน่งของเฟรมแรกโดยอัตโนมัติ

แอปเดสก์ท็อปจะรอให้หุ่นยนต์ส่งคืนโทเค็นการยืนยันหลังจากส่งคำสั่ง อาจค้างหากโปรแกรมของหุ่นยนต์หยุดทำงานหรือขาดการเชื่อมต่อ คุณไม่จำเป็นต้องปิดแอปเดสก์ท็อปและสูญเสียเฟรมการกระทำที่ไม่ได้บันทึก แต่กดปุ่ม "รีเซ็ต" บนกระดานหลักของหุ่นยนต์เพื่อหยุดการวนรอบการรอของแอป หากโปรแกรมยังไม่ตอบสนอง คุณสามารถคลิกปุ่มท่าทางในพื้นที่ "ท่าทางที่ตั้งไว้ล่วงหน้า" หรือลองเชื่อมต่อหุ่นยนต์อีกครั้งโดยใช้ปุ่ม "เชื่อมต่อ/ฟัง"

การควบคุมหุ่นยนต์หลายตัวพร้อมกัน

  • USB

ก่อนอื่นให้เชื่อมต่อตัวอัปโหลด USB เข้ากับแผงวงจรหลักของหุ่นยนต์ จากนั้นใช้สายเคเบิลข้อมูลเพื่อเชื่อมต่อกับอินเทอร์เฟซ USB ของคอมพิวเตอร์

  • Bluetooth

ขั้นแรกให้เสียบโมดูล Bluetooth เข้ากับบอร์ดหลักของหุ่นยนต์ (ไม่จำเป็นต้องใช้บอร์ดที่ใช้ ESP32) จับคู่บอร์ดกับอินเทอร์เฟซการตั้งค่า Bluetooth ของคอมพิวเตอร์ แอปเดสก์ท็อปจะตรวจจับว่ามีการเชื่อมต่อพอร์ตอนุกรมใหม่หรือไม่ เมื่อเชื่อมต่อพอร์ตอนุกรมหลายพอร์ตสำเร็จ ปุ่มตัวเลือกพอร์ตอนุกรมในพื้นที่ "State Dials" จะเปลี่ยนเป็น "All" คลิกรายการแบบเลื่อนลงเพื่อดูพอร์ตอนุกรมทั้งหมดที่เชื่อมต่อสำเร็จ หุ่นยนต์ทั้งหมดจะถูกซิงโครไนซ์แบบเรียลไทม์ด้วยวิธีนี้ คุณยังสามารถเลือกพอร์ตอนุกรมใดก็ได้เพื่อควบคุมหุ่นยนต์ที่เกี่ยวข้อง

หากคุณถอดปลั๊กซีเรียลพอร์ต USB บนคอมพิวเตอร์ (หรือเลือกที่จะตัดการเชื่อมต่อโมดูล Bluetooth ในอินเทอร์เฟซการตั้งค่า Bluetooth) พอร์ตอนุกรมที่เกี่ยวข้องจะถูกลบออกจากรายการแบบหล่นลงตามเวลาจริง

หากคุณถอดปลั๊กซีเรียลพอร์ต USB ทั้งหมด (ตัดการเชื่อมต่อโมดูลบลูทูธทั้งหมด) ปุ่มตัวเลือกพอร์ตอนุกรมจะแสดงเป็น "ไม่มี" และปุ่มด้านซ้ายจะแสดงขึ้น "Listening". แอปเดสก์ท็อปยังคงตรวจพบโดยอัตโนมัติว่ามีการเชื่อมต่อพอร์ตหรือไม่ เมื่อหุ่นยนต์เชื่อมต่อกับคอมพิวเตอร์อีกครั้งผ่านพอร์ต ปุ่มทางด้านซ้ายของเมนูแบบเลื่อนลงจะแสดงขึ้น "Connected". ชื่อพอร์ตที่สอดคล้องกันจะแสดงอยู่ในปุ่มตัวเลือกพอร์ตอนุกรม

หากคุณต้องการให้แอปเดสก์ท็อปหยุดตรวจหาการเชื่อมต่อแบบซีเรียล คุณสามารถคลิกปุ่ม"Connected" / ปุ่ม "Listening" ข้อความในปุ่มจะเปลี่ยนเป็น "Connect"และการเชื่อมต่อแบบพอร์ตทั้งหมดจะถูกตัดการเชื่อมต่อ คลิกปุ่ม "Connect" อีกครั้งเพื่อรีสตาร์ทฟังก์ชันการตรวจจับแบบเรียลไทม์

15.The usage of Wi-Fi OTA(Over-The-Air)

The Arduino demo of ESP32 provides the function of OTA (updating/uploading a new program to ESP32 using Wi-Fi)

1. What is OTA?

การกำหนดค่าของ BiBoard ของเราคือ 16MB Flash และพาร์ติชันเฉพาะมีดังนี้:

OTA ดำเนินการพื้นที่ข้อมูล OTA เป็นหลัก ได้แก่ พื้นที่ APP1 และ APP2 หลักการคือ:

  • BiBoard เรียกใช้เฟิร์มแวร์ด้วยฟังก์ชัน OTA ในขณะนี้ การบูตชี้ไปที่พื้นที่ APP1

  • คำสั่ง OTA ถูกส่งไปยัง ESP32 ผ่าน Wi-Fi และไฟล์ไบนารีของโปรแกรมอัปเกรดจะถูกถ่ายโอนไปยังพื้นที่ APP2

  • หากการส่ง APP2 เสร็จสิ้นและการตรวจสอบยืนยันสำเร็จ ข้อมูล OTA จะชี้ไปที่พื้นที่ APP2 และครั้งต่อไปที่เริ่มต้นจากพื้นที่เฟิร์มแวร์ที่อัปเดตแล้ว (APP2) ข้อมูล APP1 จะถูกเก็บไว้ ครั้งต่อไป OTA จะเขียนไปยังพื้นที่ APP1 เพื่อเขียนทับเฟิร์มแวร์เก่า

  • หากการส่ง APP2 ไม่เสร็จสมบูรณ์เนื่องจากข้อผิดพลาดในการส่งเครือข่าย เนื่องจาก APP2 ไม่ผ่านการตรวจสอบ ข้อมูล OTA จะไม่ชี้ไปที่พื้นที่ APP2 โปรแกรมในพื้นที่ APP1 จะยังคงทำงานหลังจากเริ่มต้นการรีเซ็ต และพื้นที่ APP2 ที่เสียหายจะถูกลบและเขียนทับอย่างสมบูรณ์ระหว่าง OTA ถัดไป

OTA operation in Arduino program

ในการสาธิต ก่อนอื่นให้กำหนดค่า WiFi และกำหนดค่าโหมด WiFi เป็น STA (สถานี โหมดสถานีฐาน) เปิดใช้งานฟังก์ชัน WiFi และป้อนรหัสผ่านบัญชี "WiFi.begin(ssid, password);"

  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();

เมื่อเชื่อมต่อ Wi-Fi สำเร็จ ที่อยู่ IP จะถูกพิมพ์ผ่านพอร์ตอนุกรม หากการเชื่อมต่อผิดพลาด ESP32 จะรีสตาร์ท

ในการสาธิต คุณสามารถกำหนดค่าหมายเลขพอร์ต คีย์ OTA หรือแฮชของคีย์ และพื้นที่และประเภทของ OTA (ระบุโดยค่าเริ่มต้น)

  // Port defaults to 3232
  // ArduinoOTA.setPort(3232);

  // Hostname defaults to esp3232-[MAC]
  // ArduinoOTA.setHostname("myesp32");

  // No authentication by default
  // ArduinoOTA.setPassword("admin");

  // Password can be set with it's md5 value as well
  // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
  // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");

ต่อไปนี้เป็นข้อมูลโค้ดบางส่วนที่คล้ายกับฟังก์ชันการโทรกลับ ซึ่งใช้ในการตัดสินสถานะของแต่ละขั้นตอนของ OTA

  ArduinoOTA
    .onStart([]() {
      String type;
      if (ArduinoOTA.getCommand() == U_FLASH)
        type = "sketch";
      else // U_SPIFFS
        type = "filesystem";

      // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
      Serial.println("Start updating " + type);
    })
    .onEnd([]() {
      Serial.println("\nEnd");
    })
    .onProgress([](unsigned int progress, unsigned int total) {
      Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
    })
    .onError([](ota_error_t error) {
      Serial.printf("Error[%u]: ", error);
      if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
      else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
      else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
      else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
      else if (error == OTA_END_ERROR) Serial.println("End Failed");
    });

  ArduinoOTA.begin();

หลังจากกำหนดค่าตามการสาธิต ให้เรียก "ArduinoOTA.handle();" ในฟังก์ชันลูป ฟังก์ชัน analogWrite ต่อไปนี้ใช้เพื่อแยกแยะผลกระทบของการอัพเดตเฟิร์มแวร์ต่างๆ (โดยการเปลี่ยนค่า)

void loop() {
  ArduinoOTA.handle();
  analogWrite(2, 127);    // test OTA firmware
}

ครั้งแรกที่คุณใช้พอร์ตอนุกรมเพื่อดาวน์โหลด เครื่องมือไพธอน "esptool" จะถูกเรียก คุณสามารถใช้ OTA ได้หลังจากการดาวน์โหลดเสร็จสิ้น ในตัวเลือกพอร์ต คุณจะพบพอร์ตพิเศษตามที่อยู่ IP ซึ่งเป็นที่อยู่ OTA

เลือกที่อยู่นี้ มุมขวาล่างคือที่อยู่ IP ของ ESP32 Dev Module บน BiBoard ของคุณ (192.168.1.178)

ในเวลาเดียวกัน คำเตือนจะปรากฏขึ้น: "ไม่รองรับการมอนิเตอร์แบบอนุกรมบนพอร์ตเครือข่าย เช่น 192.168.1.178 สำหรับโมดูล ESP32 Dev ในล่าสุดนี้"

ESP32 OTA ของ Arduino เหมาะสำหรับการอัปเดตโปรแกรมเท่านั้น และไม่สามารถทำงานดีบักพอร์ตอนุกรมได้ หากคุณต้องการดีบัก BiBoard โปรดเชื่อมต่ออินเทอร์เฟซ USB-C

ดาวน์โหลดโปรแกรม ดังรูป

Introduction

หุ่นยนต์ Nyboard v1 ใช้ Controller Atmel ATMEGA328P ซึ่งรองรับแค่ Serial port เท่านั้น โดยมีการแยก Serial port ของหุ่น Nyboard ให้รองรับหลายๆ Module โดย Pin ของ Serial port สามารถต่อกับ Arduino Pro Mini 6 Pin โดยรายละเอียดของ Pin ต่างๆแสดงอยู่ในตารางด้านล่าง

Pin No.

Name

Usage

1

DTR

Modem signal DTR, reset NyBoard after serial download finished.

2

RX

ATMEGA328P RX (receive)

3

TX

ATMEGA328P TX (send)

4

5V

5V power for MCU and chips

5

GND

Ground

6

GND

Ground

default serial baud rate คือ 115200 bps

หุ่น Nyboard V1 มี communication module 3 แบบ

13.Add hardware partition configuration option in Arduino IDE

หน่วยความจำแฟลชของบอร์ด ESP32 มี 16M และช่วงของที่อยู่จัดเก็บที่แสดงเป็นเลขฐานสิบหกคือ: 0x0-0x01000000

นี่คือตารางพาร์ติชันที่ระบบกำหนดค่าไว้ ดังแสดงในรูปด้านล่าง:

ตำแหน่งที่เก็บไฟล์ตารางพาร์ติชันนี้บนคอมพิวเตอร์:

C:\Users\{YourUserName}\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.*\tools\partitions\large_spiffs_16MB.csv

สามารถเห็นได้จากตารางพาร์ติชันด้านบน: พื้นที่ APP0 และพื้นที่ APP1 มีพื้นที่ 4.5M พื้นที่ข้อมูลคือ SPIFFS ขนาด 6.9M

แต่ใน Arduino IDE การกำหนดค่านี้ไม่รวมอยู่ในตัวเลือกการกำหนดค่าพาร์ติชันฮาร์ดแวร์ของโมดูล ESP32 Dev:

เราจำเป็นต้องเพิ่มการกำหนดค่านี้ในโมดูล ESP32 Dev

เปิดไฟล์การกำหนดค่าบอร์ดพัฒนา:

C:\Users\{YourUserName}\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.*\boards.txt

ค้นหาชื่อของบอร์ดพัฒนา: esp32.name=ESP32 Dev Module ดังแสดงในรูปด้านล่าง:

บรรทัดข้อความในการกำหนดค่าพาร์ติชัน ESP32 Dev Module ในไฟล์กำหนดค่า:

esp32.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728

เพิ่มข้อความ 3 บรรทัดต่อไปนี้ใต้บรรทัดนี้:

esp32.menu.PartitionScheme.large_spiffs=BiBoard V0(4.5 MB APP with OTA /6.9 MB SPIFFS)
esp32.menu.PartitionScheme.large_spiffs.build.partitions=large_spiffs_16MB
esp32.menu.PartitionScheme.large_spiffs.upload.maximum_size=4685824

ต่อไปนี้จะอธิบายความหมายของข้อความสามบรรทัด:

esp32.menu.PartitionScheme.large_spiffs=BiBoard V0(4.5 MB APP with OTA /6.9 MB SPIFFS)

ชื่อของการกำหนดค่าพาร์ติชัน ESP32 เราตั้งชื่อว่า BiBoard V0 (4.5M APP พร้อม OTA /6.9 MB SPIFFS) หรือสามารถแทนที่ด้วยชื่ออื่นที่คุณคุ้นเคย

esp32.menu.PartitionScheme.large_spiffs.build.partitions=large_spiffs_16MB

ข้อมูลไฟล์การกำหนดค่าพาร์ติชัน นคือไฟล์ large_spiffs_16MB.csv คุณยังสามารถเขียนไฟล์พาร์ติชั่นเพื่อปรับขนาดไฟล์ของแอพและพื้นที่ข้อมูล

esp32.menu.PartitionScheme.large_spiffs.upload.maximum_size=4685824

ข้อความบรรทัดนี้ระบุว่าขนาดโปรแกรมอัปโหลดสูงสุดคือ 4685824 ไบต์

ลองรวบรวมโปรแกรมอย่างง่ายเพื่อทดสอบว่าการตั้งค่าข้างต้นสำเร็จหรือไม่

เปิด Arduino IDE อีกครั้ง เราจะเห็นว่า BiBoard เพิ่งกำหนดค่า:

หลังจากคอมไพล์โปรแกรมแล้วจะได้ผลลัพธ์ดังรูปด้านล่าง

การคอมไพล์เสร็จสมบูรณ์ โดยใช้ Flash ขนาด 213KB (4%) และขนาดสูงสุดที่ใช้งานได้คือ 4,685,824 ไบต์

ในข้อนี้ “4685824 ไบต์” ถูกระบุในบรรทัดที่สามของข้อความที่เพิ่งเพิ่มไปยังไฟล์กำหนดค่า

ถึงตอนนี้ คุณได้ทำการกำหนดค่าบอร์ดพัฒนาที่มีพื้นที่หน่วยความจำแฟลชที่ใหญ่ที่สุดใน Arduino IDE เรียบร้อยแล้ว

7.Infrared remote control

BiBoard ติดตั้งเซ็นเซอร์อินฟราเรดซึ่งเชื่อมต่อกับพินที่ 23 การใช้อินฟราเรดนั้นเหมือนกับที่ใช้ใน Arduino UNO ที่ใช้ AVR

ก่อนอื่นให้ดาวน์โหลดไลบรารี IRremote เวอร์ชัน 2.6.1 คุณต้องเลือกเวอร์ชัน 2.6.1 ด้วยตนเอง เนื่องจากโค้ดที่เกี่ยวข้องกับอินฟราเรดมีการเปลี่ยนแปลงในเวอร์ชันหลังๆ หากคุณใช้เวอร์ชัน 3.X คำสั่งจะไม่ถูกแปล เพื่อให้เข้ากันได้กับผลิตภัณฑ์ก่อนหน้าของเรา เราตัดสินใจใช้เวอร์ชัน 2.6.1 หลังจากการทดสอบ

เมื่อใช้ NyBoard เพื่อให้แน่ใจว่าสามารถคอมไพล์โค้ดได้อย่างราบรื่น เราจำเป็นต้องลบโค้ดที่ไม่จำเป็นในไลบรารี IRremote นั่นคือ ลบตัวเข้ารหัส/ตัวถอดรหัสที่เราไม่ได้ใช้ และเก็บเฉพาะ NEC_DECODER ซึ่งก็คือ ตัวถอดรหัสสัญญาณ 38KHz ในรูปแบบ NEC

เนื่องจากความจุของหน่วยความจำแฟลชของ BiBoard นั้น “มหาศาล” เราจึงไม่จำเป็นต้องลบโค้ดที่ไม่จำเป็นในไลบรารี IRremote

สุดท้ายมีการแนบตัวอย่างซึ่งรับสัญญาณอินฟราเรดและพิมพ์ผ่านพอร์ตซีเรียล คุณยังสามารถใช้การตัวอย่าง อย่างเป็นทางการสำหรับการทดสอบ

#include <Arduino.h>
#include <IRremote.h>

int RECV_PIN = 23;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup() {
  Serial.begin(115200);
  irrecv.enableIRIn();
  Serial.println("IR Receiver ready");
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    Serial.print(" - ");
    irrecv.resume(); // Receive the next value
  }
  delay(300);
}

WiFi ESP8266

WiFi module ESP8266

Introduction

โมดูลนี้ใช้ ESP-WROOM-02D ซึ่งเป็นโมดูลทางการของ ESP8266EX มี QSPI Flash 4MB โมดูลได้รับการรับรองด้วย FCC ในสหรัฐอเมริกา CE-RED ในยุโรป TELEC ในญี่ปุ่นและ KC ในเกาหลีใต้

โมดูลนี้เปิดโอกาสให้ผู้ใช้เขียนโปรแกรมเองได้ ไม่ใช่โมดูลส่งข้อมูลโปร่งแสง (transparent transmission module) ง่ายๆ อย่างเดียว

Module Functions

โมดูลรวมวงจรดาวน์โหลดอัตโนมัติและโมดูลสื่อสารอยู่ในโมดูลนี้ วงจรดาวน์โหลดอัตโนมัติหมายถึงการแนะนำอย่างเป็นทางการในการใช้ 2 ตัวขับแบบ S8050 เพื่อรับสัญญาณ RTS และ DTR จาก downloader แบบ CH340C และเรียกใช้ลำดับการดาวน์โหลด

Assembly

เชื่อมต่อกับ NyBoard:

อัปโหลดสคริปต์ผ่าน USB downloader:

Development Environment Settings

เราใช้ Arduino เป็นสถานที่พัฒนาโปรแกรม (Development Environment)

2.1 Add ESP8266 source to the board manager

จากนั้นเปิด "Board Manager" และกรอก ESP8266 หรือ 8266 เพื่อค้นหาแพ็กเกจสนับสนุนบอร์ด:

ดาวน์โหลด package ESP8266 โดย ESP8266 Community ครับ

Configuration of the Module

หลังจากดาวน์โหลด package แล้ว เราเลือก ESP8266 Board (เวอร์ชันปัจจุบัน: 2.74) -> Generic ESP8266 Module.

ขั้นตอนต่อไปคือการตั้งค่าพารามิเตอร์ดังนี้:

Parameters

Settings

Builtin Led

2

Upload Speed

921600(Auto-negotiation during downloading, 115200 is too slow)

CPU Frequency

160MHz

Flash Size

4MB

Reset Method

DTR reset

lwIP variant

V2 Lower memory

Erase Flash

Only sketch

Download Test

หลังจากที่เราตั้งค่าเสร็จแล้ว เราใช้โปรแกรม "Blink" ของ Arduino เพื่อทดสอบโมดูล ESP8266

เปิดโปรเจกต์ Blink และทำการกำหนดค่าบอร์ดพัฒนา จากนั้นเสียบโมดูลลงในอินเตอร์เฟสการแก้ไขข้อผิดพลาดของโมดูลสื่อสารแบบ USB และดาวน์โหลดตัวอย่าง Blink

เมื่อเทียบกับ Arduino UNO จะมีเวลาในการคอมไพล์ที่นานขึ้นเล็กน้อย หลังจาก Linking เสร็จแล้ว ความคืบหน้าในการดาวน์โหลดจะแสดงเป็นเปอร์เซ็นต์:

"โค้ด Blink" ใช้พื้นที่แฟลชขนาด 257KB และ SRAM ขนาด 26.8KB

Download WiFi Firmware

ไฟล์โปรเจ็กต์ประกอบด้วย 3 ไฟล์:

  • ESP8266WiFiController.ino: โค้ดสคริปต์อาดูโน่ที่มีโค้ดเซิร์ฟเวอร์สำหรับคอนโทรล

  • mainpage.h: หน้าต้อนรับ (html) อยู่ในรูปแบบ char array

  • actionpage.h: หน้าควบคุมการทำงาน (html) อยู่ในรูปแบบ char array

โปรดใส่ไฟล์เหล่านี้ลงในโฟลเดอร์ชื่อ "ESP8266WiFiController" แล้วเปิดไฟล์ ino และดาวน์โหลดไปยังโมดูล WiFi ESP8266

How to Use

หลังจากโปรแกรมถูกดาวน์โหลดลงในโมดูล WiFi แล้ว เราขอแนะนำให้ทดลองรันโปรแกรมด้วย USB downloader เพื่อให้สามารถเช็คผลลัพธ์ที่ออกมาจากโปรแกรมได้ผ่าน Arduino serial monitor อย่างแม่นยำ

เปิดแอปสแกน WiFi ของสมาร์ทโฟนของคุณแล้วค้นหาจุดเข้าถึงที่มีชื่อว่า "Bittle-AP" ที่ไม่ได้เข้ารหัสข้อมูล แล้วเชื่อมต่อกับมัน

ถ้าสมาร์ทโฟนของคุณตั้งค่าการเชื่อมต่อเครือข่ายโดยอัตโนมัติ จะตัดการเชื่อมต่อของ "Bittle-AP" เนื่องจากไม่มีการเชื่อมต่ออินเทอร์เน็ต สมาร์ทโฟนของคุณอาจเชื่อมต่อกับ Wi-Fi ที่มีการเชื่อมต่ออินเทอร์เน็ต หรือแม้แต่ใช้ข้อมูลเคลื่อนที่ของคุณด้วย

แอพของคุณอาจกระโดดไปยังหน้า "WiFiManager" โดยอัตโนมัติเมื่อเชื่อมต่อกับ "Bittle-AP"

หากไม่ได้รับการเชื่อมต่อกับ "Bittle-AP" โดยอัตโนมัติ โปรดเปิดเบราว์เซอร์ของคุณแล้วป้อน 192.168.4.1 เพื่อเข้าสู่หน้าการกำหนดค่าการเชื่อมต่อ WiFi ด้วยตัวเอง

ที่หน้าเว็บไซต์ WiFiManager, โมดูลไร้สายของ Bittle จะค้นหา SSID ของ WiFi ที่อยู่ใกล้เคียงทั้งหมดและแสดงผลให้เห็น หลังจากคลิกที่ SSID ของ WiFi ของคุณและใส่รหัสผ่าน Bittle จะเชื่อมต่อกับเครือข่ายนี้ก่อน

เมื่อ Bittle เชื่อมต่อกับ WiFi ได้สำเร็จ มันจะพิมพ์ที่อยู่ IP ที่ได้รับจาก DHCP ผ่านพอร์ตช่องต่อออกแสดงผล คุณยังสามารถกำหนดที่อยู่ IP คงที่ใน Arduino ได้เช่นกัน

กรอกที่อยู่ไอพีของโมดูล WiFi เพื่อควบคุม Bittle ผ่าน WiFi ได้แล้ว!

About the Sample Code

โค้ดตัวอย่างเป็นตัวอย่างเว็บเซิร์ฟเวอร์ที่เรียบง่าย ประกอบด้วย 2 หน้า HTML โดยจะเก็บไว้ใน 2 ไฟล์ส่วนหัวในรูปแบบของค่าคงที่ข้อความ (string constants) เพื่อลดการเรียกใช้ฟังก์ชั่น client.print อย่างต่อเนื่อง

3.1 Set Up the WiFi Networks

ก่อนที่เราจะเริ่มต้นเว็บเซิร์ฟเวอร์ของเรา เราควรตั้งค่า WiFi เพื่อเชื่อมต่อกับเครือข่าย LAN (Local Area Network) ของคุณ ในอดีตเราใช้การป้อนชื่อและรหัสผ่าน WiFi ในโปรแกรม แต่มันไม่สะดวกเมื่อเราต้องเปลี่ยนแวดวงเครือข่าย

เราใช้ไลบรารี WiFi manager เพื่อกำหนดค่าข้อมูล WiFi ผ่านเว็บไซต์

  // WiFiManager
  WiFiManager wifiManager;

  // Start WiFi manager, default gateway IP is 192.168.4.1
  wifiManager.autoConnect("Bittle-AP");

3.2 Web server

สร้างเว็บเซิร์ฟเวอร์ใหม่และกำหนดพอร์ต 80 (พอร์ตเซิร์ฟเวอร์ HTTP ที่ใช้งานมาก)

ESP8266WebServer server(80);

3.3 Configure 3 HTTP service handler

ฟังก์ชันการตอบกลับ HTTP ใช้สำหรับการจัดการคำขอ HTTP ที่เข้ามา

void handleMainPage() {
 //Serial.println("GET /");
 server.send(200, "text/html", mainpage);
}
void handleActionPage() {
 //Serial.println("GET /actionpage");
 server.send(200, "text/html", actionpage);
}

ฟังก์ชัน handleMainPage และ handleActionPage จะตอบกลับสถานะ 200 (OK) และรหัส HTML เพื่อให้กับเบราว์เซอร์ของคุณ (client) ที่ส่ง HTTP requests เข้ามา.

void handleAction(){
  String argname = server.arg("name");

  if(argname == "gyro"){              // gyro switch
    Serial.print("g");
  }
…

ฟังก์ชั่น HandleAction ต่างจาก HandleMainPage และ HandleActionPage นิดหน่อย โดยเป็นการประมวลผลคำขอ HTTP ที่มีการส่งพารามิเตอร์ โดยเมื่อพารามิเตอร์เป็น "gyro" ฟังก์ชั่นจะส่งคำสั่งไปยังพอร์ตซีเรียลของโมดูล WiFi ("g" เปิดการใช้งาน IMU) เพื่อให้ Bittle ของเราดำเนินการตามคำสั่งนั้นๆ

พารามิเตอร์ "gyro" นี้สร้างและส่งผ่านอย่างไร เนื่องจากเราส่งคำขอ HTTP พร้อมค่าไปยังเซิร์ฟเวอร์:

http://IP address or DomainName/action?name=gyro

เซิร์ฟเวอร์แยกวิเคราะห์พารามิเตอร์การดำเนินการตามฟังก์ชันและแก้ไขว่าชื่อคือ "gyro"

เราสามารถพิมพ์ URL นี้โดยตรงในเบราว์เซอร์และดำเนินการด้วยคีย์บอร์ดได้เลย วิธีที่พบบ่อยกว่าคือการเพิ่มลิงก์ไปยังปุ่ม "Walk" ในหน้าเว็บเพจ ActionPage โดยเมื่อกดปุ่ม gyro URL ด้านบนจะถูกส่งไปยังโฮสต์

การกำหนดปุ่ม Walk ที่สมบูรณ์ครบวงจรดังนี้:

<button style="width: 25%" onclick="location.href='/action?name=gyro'">GyroOn/Off</button>

หลังจากแยกวิเคราะห์พารามิเตอร์ "name" แล้ว เราจะส่ง actionpage อีกครั้ง

server.send(200, "text/html", actionpage);

เราผูกเมธอดผู้จัดการกับ URL ที่สอดคล้องกัน

server.on("/", handleMainPage);
server.on("/actionpage", handleActionPage);
server.on("/action", handleAction);

3.4 Start the Web Server

server.begin();
Serial.println("HTTP server started");

3.5 Handle Client Requests

void loop(void){
 server.handleClient();
}

More Ways Playing the WiFi Module

เมื่อเทียบกับ ATMega328P บน NyBoard ESP8266 มีทรัพยากรด้านฮาร์ดแวร์และซอฟต์แวร์มากกว่า คุณสามารถทำการทดลองได้มากขึ้นด้วยมัน

Connect your Bittle to IoT platforms with HTTP restful APIs.

MQTT and node-red.

OTA with WiFi.

Make ESP8266 a strong co-processor for NyBoard for motion data fusion.

14.Play MP3

มีตัวอย่างชื่อ testMP3 ในไดเร็กทอรีไฟล์ "OpenCatEsp32/ModuleTests" หน้าที่หลักของตัวอย่างนี้คือการเล่นไฟล์ .mp3 ที่จัดเก็บไว้ในระบบไฟล์ SPIFFS ผู้ใช้สามารถเลือกเล่นไฟล์ .mp3 ต่างๆ ได้โดยการป้อนตัวเลข 0~6 (หมายเลขดัชนีไฟล์ .mp3) ในจอภาพอนุกรม

หมายเหตุ:

  • Arduino IDE 2.0 ไม่สามารถเพิ่มตัวเลือกการกำหนดค่า large_spiffs_16MB (4.5MB APP with OTA/6.93MB SPIFFS) ได้ในขณะนี้

แน่นอน คุณยังสามารถใช้ VS Code + PlatformIO เพื่ออัปโหลดไฟล์ร่างและ .mp3 สำหรับรายละเอียด โปรดดูเอกสารต่อไปนี้:

ก่อนอัปโหลดไฟล์ร่างและ .mp3 โปรดย้ายโฟลเดอร์ "data" ไปยังไดเร็กทอรีรูท(root)ของโปรเจ็กต์ จัดเก็บไฟล์โค้ดในไดเร็กทอรี "src" และกำหนดค่าตัวเลือกพาร์ติชัน "board_build.partitions" ใน platformio.ini ใน ไดเร็กทอรีรูทของโปรเจ็กต์ดังแสดงในรูปต่อไปนี้:

USB Uploader (CH340C or CH343G)

ใช้ module CH340C USB bridge Window 10, Linux และ macOS all drive-free โดย Specific interface แสดงดังภาพดังนี้

NyBoard download interface: ในการเชื่อต่อกับ NyBoard ต้อง dowload program firmware หุ่นยนต์ เพื่อใช้ในการ communication กับ computer ผ่าน Serial port

Communication module debugging interface: ใช้เชื่อมต่อโมดูล Bluetooth หรือ WiFi และอัพเดทโปรแกรมโมดูล และ debug พารามิเตอร์ต่างๆ โดยเพื่อหลีกเลี่ยงการใช้สาย Dupont ที่อาจจะซับซ้อน การเรียงลำดับขาจะต่างกับขาดาวน์โหลดของ NyBoard โดยขา TX/RX จะถูกสลับกันและขา GND จะกลายเป็นขา RTS สำหรับรายละเอียดเพิ่มเติมเกี่ยวกับวิธีใช้ Debugging Interface ของโมดูลการสื่อสาร โปรดดูต่อไปในบทที่เกี่ยวข้อง

ไม่ควรเสียบ NyBoard และโมดูลอื่นๆ (WiFi หรือ Bluetooth) พร้อมกัน! นั่นจะทำให้พอร์ตซีเรียลถูกบล็อค.

Connect NyBoard

เสียบขา 6 ขา (H1) ของ USB uploader เข้ากับช่อง Uploader ของ NyBoard แล้วใช้สาย USB data ที่มากับอุปกรณ์ นำหนึ่งข้างเสียบเข้ากับพอร์ต MicroUSB ของโมดูล USB upload และอีกข้างเสียบเข้ากับพอร์ต USB ของคอมพิวเตอร์

คลิกขวาที่ "This PC" บนหน้าจอ desktop ของ Windows แล้วคลิก "Manage" ด้วยปุ่มเม้าส์ซ้าย (แนะนำให้ใช้วิธีนี้ แต่คุณสามารถดำเนินการใน browser ได้เช่นกัน) ดังรูปด้านล่าง จากนั้นเลือก "Device Manager" ในหน้า "Computer Management" เพื่อตรวจสอบพอร์ตซีเรียลที่เชื่อมต่อ:

เปิดโปรแกรม Arduino IDE หรือ Desktop App Firmware Uploader แล้วเลือกพอร์ต COM ที่เชื่อมต่อกับ NyBoard เพื่อทำการอัพโหลด Firmware และใช้ Serial monitor เพื่อสื่อสารกับบอร์ดได้เช่นกัน

ตัวอัพโหลดมี LED 3 ดวง: ไฟเลี้ยง, Tx, และ Rx หลังจากการเชื่อมต่อแล้ว หลอดไฟ Tx และ Rx ควรจะกระพริบเป็นเวลา 1 วินาทีเพื่อแสดงการสื่อสารเริ่มต้น แล้วจะดับลง เหลือเพียงหลอดไฟแสดงสถานะไฟเลี้ยงเท่านั้น คุณสามารถหาพอร์ตใหม่ใต้ Tool->Port ได้

  • “/dev/cu.usbserial-xxxxxxxx” (Mac)

  • “COM#” (Windows)

  • “ttyUSB#” (Linux)

สำหรับ Linux เมื่อเชื่อมต่ออัปโหลดเพื่อนับความสำเร็จ คุณจะเห็น "ttyUSB #" ในรายการพอร์ตซีเรียล แต่คุณอาจได้รับข้อผิดพลาดพอร์ตซีเรียลในขณะที่กำลังอัปโหลด คุณต้องการให้สิทธิ์กับพอร์ตซีเรียล โปรดไปที่ลิงค์นี้และดำเนินการตามคำแนะนำ:

ถ้าไฟ Tx และ Rx ยังค้างอยู่ หมายความว่ามีปัญหากับการสื่อสารผ่านพอร์ต USB โดยทั่วไปเป็นเพราะการป้องกันไฟล้นกระแสจากคอมพิวเตอร์ของคุณ หากคุณไม่ได้เชื่อมต่อ NyBoard กับแหล่งจ่ายไฟภายนอกและเซอร์โวเคลื่อนที่ทั้งหมดเคลื่อนที่พร้อมกัน

The Drivers

ถ้าคุณไม่สามารถหาพอร์ตซีเรียลหลังจากเชื่อมต่อกับคอมพิวเตอร์ของคุณได้ คุณอาจจะต้องติดตั้งไดรเวอร์สำหรับชิป CH340

For ChromeOS:

  1. Plug the Bittle USB adapter into the robot and the Chromebook.

  2. Set the Chromebook Linux VM to recognize the USB port

Settings => Advanced => Developers => Linux development environment => Manage USB devices => USB Serial (turn on)

หมายเหตุ: ขั้นตอนที่ 4 จะต้องทำซ้ำทุกครั้งเมื่อมีการเชื่อมต่อ USB อีกครั้งหรือมีการเปิดเครื่องใหม่

Ultrasonic Sensor

Function introduction

RUS-04 is a new module that integrates RGB LED and ultrasonic ranging. Only one GPIO is needed to operate the ultrasonic transceiver, and while the ultrasonic probe is measuring the distance, the left and right probes can emit 7 colorful lights.

Hardware setup

Connecting to the NyBoard with wire as shown in the following picture:

Software setup

Currently only supports the product Nybble, the software version 2.0, the mode can choose "Ultrasonic" or "RandomMind_Ultrasonic".

Use the latest OpenCat code to finish the setup. As shown below:

If you have already uploaded the latest OpenCat code to make Nybble walk, you only need to uncomment the #define ULTRASONIC at the beginning of OpenCat.ino then upload the code.

Ultrasonic module code realization function: According to the different distances monitored by the ultrasonic module in real-time, the probe inside the ultrasonic module lights up with lights of different colors, and Nybble will make different action responses at the same time.

The demo video is as follows:

คู่มือเริ่มต้นใช้งาน BiBoard ฉบับรวบลัด

1. บทนำ

BiBoard เป็นบอร์ดควบคุมหุ่นยนต์สุนัขที่ใช้ ESP32 พัฒนาโดย Petoi LLC ไม่เหมือนกับ NyBoard สำหรับผู้ใช้ทั่วไปและผู้ชื่นชอบหุ่นยนต์ BiBoard มุ่งเน้นไปที่นักพัฒนาและผู้เชี่ยวชาญเป็นหลัก โปรเซสเซอร์ประสิทธิภาพสูง หน่วยความจำและพื้นที่เก็บข้อมูลขนาดใหญ่ขึ้น การเชื่อมต่อไร้สาย และฟังก์ชั่นเสียงรวมอยู่ด้วย

2. โมดูลและฟังก์ชัน

การแบ่งฟังก์ชันสำหรับ BiBoard แสดงอยู่ด้านล่าง:

บล็อกไดอะแกรมสำหรับ BiBoard แสดงไว้ด้านล่าง:

3. รายละเอียดโมดูล:

3.1 Power

มี 2 วิธีในการจ่ายไฟให้กับ BiBoard: USB 5V และช่องเสียบแบตเตอรี่ 7.4V

เมื่อใช้พลังงานจาก USB จะไม่มีเอาต์พุตพลังงานสำหรับส่วนขยาย DC-DC 5V และเซอร์โว

เมื่อใช้พลังงานแบตเตอรี่ที่ 7.4V (สูงสุด: 8.4V) จะจ่ายทั้งเซอร์โวและส่วนไฟ 5V คุณสามารถใช้ 5V จ่ายไฟให้กับ Raspberry Pi

3.2 โมดูลบนบอร์ด

3.2.1 ตั้งค่าสภาพแวดล้อมการพัฒนา ESP32

หมายเหตุ:

  • Arduino IDE 2.0 ไม่สามารถเพิ่มตัวเลือกการกำหนดค่า large_spiffs_16MB (4.5MB APP with OTA/6.93MB SPIFFS) ได้ในขณะนี้

    • ใน Arduino IDE 1.8.* เขียนด้วยภาษาจาวา และ Arduino IDE 2.0 เขียนด้วยภาษาอื่น (TypeScript + Golang) ดังนั้นปลั๊กอินอัปโหลดก่อนหน้านี้จึงไม่สามารถใช้ใน Arduino IDE 2.0 ได้ ขณะนี้ยังไม่รองรับปลั๊กอินอัปโหลดไฟล์ Arduino IDE 2.0 SPIFFS

เปิด "Preferences" ใน Arduino เพิ่ม URL ของบอร์ดพัฒนา ESP32:

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

บันทึกแล้วออก

เปิด “Boards Manager...” และรอการอัปเดตจากลิงก์สนับสนุนบอร์ดภายนอก ค้นหา “esp32” และดาวน์โหลดแพ็คเกจสนับสนุนล่าสุด

หลังจากแสดง “INSTALLED” แสดงว่าแพ็คเกจสนับสนุนบอร์ด BiBoard เสร็จสิ้น

3.2.2 USB Downloader

ไม่มีวงจร USB ใน ESP32 ดังนั้นเราจึงใช้สะพาน USB CP2102 ตามคำแนะนำอย่างเป็นทางการ ดาวน์โหลดสูงสุดคือ 921600 โดยสะพานเชื่อมต่อกับ serial1 ของ ESP32

เราใช้พอร์ต USB Type-C ตัวต้านทาน 2 ตัว CC1 และ CC2 ถูกเพิ่มเป็นตัวระบุ

เราลองใช้วงจรดาวน์โหลดอัตโนมัติที่ออกแบบโดย ESP และ NodeMCU แต่ไม่มีวงจรใดทำงานได้อย่างสมบูรณ์ ดังนั้นเราจึงแก้ไขวงจรโดยเพิ่มทรานซิสเตอร์ตัวที่สามและขยายตัวเก็บประจุ

ทรานซิสเตอร์จะรับสัญญาณโมเด็มอนุกรมมาตรฐาน DTR และ RTS และทริกเกอร์ลำดับเวลาเฉพาะที่บังคับให้ ESP32 เข้าสู่โหมดดาวน์โหลด จากนั้นรีบูต รายละเอียดของวงจรดาวน์โหลดอัตโนมัติแสดงไว้ด้านล่าง

3.2.3 IMU

เราใช้ Invensense MPU6050 ซึ่งเป็น IMU ที่ใช้กันอย่างแพร่หลาย ที่อยู่ I2C ของมันคือ 0x68 และการขัดจังหวะของ DMP เชื่อมต่อกับ IO26 ของ ESP32

ด้วยความช่วยเหลือของไลบรารี MPU6050 DMP ของ Jrowberg คุณสามารถรับสถานะการเคลื่อนไหวของ Bittle ได้อย่างง่ายดาย ไลบรารี MPU6050 ของ Jrowberg ต้องถูกแก้ไขเพื่อปรับให้เข้ากับ ESP32 ชนิดข้อมูลของ “int8” และ “PGMSpace” ควรได้รับการกำหนดไว้ล่วงหน้าแทน 8-bit AVR macros เราขอเสนอไลบรารีที่แก้ไขแล้วของ MPU6050 คุณสามารถเปลี่ยนไลบรารีเดิมเพื่อให้ทั้งบอร์ด AVR และบอร์ด ESP ทำงานได้ตามปกติ

3.2.4 EEPROM

บน BiBoard มี EEPROM 64Kbit คุณสามารถใช้ EEPROM อ่านและเขียนโปรแกรมที่ใช้กับ Arduino UNO ได้โดยตรง คุณสามารถใช้เพื่อเก็บข้อมูลการตั้งค่าเริ่มต้น นอกจากนี้ยังมีตัวอย่างโปรแกรมชื่อ “EEPROM” ในแพ็คเกจสนับสนุน ESP32 นี่ไม่ใช่โปรแกรมสาธิตของ I2C EEPROM นี่คือการสาธิต EEPROM จำลองโดยหน่วยความจำแฟลช QSPI ของ ESP32

3.2.5 DAC and audio applications

เราใช้เอาต์พุต DAC และ class-D แอมพลิฟายเออร์ แทน PWM buzzer เพื่อทำให้ Bittle สดใสยิ่งขึ้น คุณสามารถใช้ 3 วิธีในการขับโมดูลเสียง:

  1. ใช้ฟังก์ชัน "Tone()" ของ Arduino

  2. ใช้ฟังก์ชัน “dacWrite()” ของ ESP32 เหมือน “analogWrite()” ของ Arduino โดยคุณภาพข้อมูลที่โดย DAC นั้นดีกว่า PWM

  3. ใช้ไลบรารีถอดรหัส MP3 ของ ESP ที่พัฒนาโดย XTronical คุณสามารถเล่นไฟล์ MP3 ได้ คุณควรกำหนดค่าระบบไฟล์เช่น SPIFFS หรือ FAT ในแฟลชก่อนที่คุณจะใช้ตัวถอดรหัส MP3 นี้

3.2.6 IR modules

เซ็นเซอร์ IR บน Nyboard และ BiBoard เหมือนกัน คุณจึงสามารถใช้ sketch จาก Nyboard ได้โดยตรง แฟลชของ BiBoard มีขนาดใหญ่พอ ดังนั้นคุณจึงไม่ต้องปิดใช้งาน macros ใน IRremote.h

4. Servo sockets

มีช่องเซอร์โว PWM 12 ช่องบน BiBoard และหมายเลขพินจะถูกทำเครื่องหมายไว้ใกล้กับช่อง เราเปลี่ยนทิศทางของช่องเซอร์โว PWM 90 องศาเนื่องจากขนาดของโมดูล ESP32 คุณควรต่อสายไฟก่อนขันสกรูตรงที่ยึดสายไฟบนบอร์ด BiBoard

5. Extension sockets

มีช่องเสียบส่วนขยาย 3 ช่องบน BiBoard ที่มีเครื่องหมาย P15, P16 และ P17

5.1 Analog input sockets(P15)

ช่องนี้ใช้สำหรับส่วนขยายอินพุตแบบอะนาล็อก คุณสามารถลองเชื่อมต่อเซ็นเซอร์แรงกดที่เท้าที่ช่องนี้ได้

5.2 Bus extension sockets(P16)

ช่องนี้ใช้สำหรับส่วนขยายบัสของ ESP32

5.3 Raspberry Pi interface (P17)

คุณสามารถใช้อินเทอร์เฟซนี้เพื่อเชื่อมต่อกับ Raspberry Pi ได้ แต่คุณไม่สามารถต่อเชื่อม Raspberry Pi เหนือ BiBoard ได้โดยตรง คุณต้องใช้สายไฟหรืออะแดปเตอร์แทน

MU Camera

Function introduction

MU Vision Sensor is an intelligent vision sensor that can recognize many kinds of objects with a deep-learning algorithm inside. For example, it can detect color blocks, balls, the human body, and cards. Its detect result can be transmitted through UART or I2C interface. MU is compact, has low power consumption, processes all algorithms locally, and can be widely used in intelligent toys, AI+STEAM lessons, creators, and other products or fields.

Software setup

Currently only supports the product Bittle, software version 2.0, please select "Camera" for the mode.

2. Use the latest OpenCat code to finish the setup.

If you have already uploaded the latest OpenCat code to make Bittle walk, you only need to uncomment the #define CAMERA at the beginning of OpenCat.ino then upload the code.

Hardware setup

After uploading the firmware, switching the dial switches on the MU Vision Sensor and connecting to the NyBoard with wire as shown in the following picture:

Note: The position of the left and right switches (left: down and up; right: down and down) must be dialed to the position shown in the figure.

Fix the end connected to the camera to the robot's head (included in Bittle's mouth).

If the MU Vision Sensor has not been able to identify the target object, please press the reset button on the camera, then press the reset button on the main board.

The demo video is as follows:

** ดาวน์โหลดเวอร์ชันล่าสุดของ . **

เปิด (สำหรับ Windows: UI.exe / สำหรับ Mac: Petoi Desktop App) คลิกปุ่ม "สกิลคอมโพสเซอร์" และเปิดอินเทอร์เฟซของ สกิลคอมโพสเซอร์

ขณะนี้มีภาษา English, 中文, and Italian. คุณสามารถมีส่วนช่วยในอัพเดทภาษาได้ที่ .

เชื่อมต่อหุ่นยนต์กับคอมพิวเตอร์ของคุณผ่านทาง หรือ จากนั้นเปิดแอปเดสก์ท็อปนี้ ควรตรวจจับและเชื่อมต่อกับหุ่นยนต์โดยอัตโนมัติ พอร์ตอนุกรมของหุ่นยนต์จะปรากฏในเมนูแบบเลื่อนลงต่อไปนี้ ปุ่มควรเปลี่ยนจาก "Listening" เพื่อ "Connected" หากหุ่นยนต์ไม่สามารถเชื่อมต่อได้ในครั้งแรก คุณสามารถคลิก "Listening" สำหรับการปลดการเชื่อมต่อพอร์ตทั้งหมด จากนั้นกดปุ่ม "Connect" อีกครั้ง

ในโหมดทดลองบางโหมดเช่น (e.g. )หุ่นยนต์จะเคลื่อนที่แบบสุ่ม ปุ่มนี้สามารถสลับการเปิด/ปิดพฤติกรรมได้

เปิด , และพิมพ์ "T" ใน serial command

เปิด , ใช้ "" ฟังก์ชั่น, และพิมพ์ "T" ในโค้ดบ๊อก

หากคุณต้องการเฟรมแอคชั่นต่อเนื่องใน เพื่อรันลูปจำนวนหลายครั้งคุณต้องใส่จำนวนลูปที่ต้องการวนซ้ำก่อนคุณสามารถใส่จำนวนลูป, คุณสามารถใส่การ วนซ้ำ ในช่องด้านบน (ทางด้านซ้ายของ Set"),จากนั้นใช้ปุ่มซ้ายของเมาส์เพื่อเลือกเลข(ช่องแรกของเฟรมที่ 1 ) ของเฟรมแรกและสองเฟรมสุดท้ายของเฟรมการกระทำต่อเนื่องที่ต้องการให้เกิดการเคลื่อนไหวเป็นซ้ำ (ปุ่มหมายเลขจะปรากฏในสถานะเลือกไปแล้ว) ดังแสดงในรูปต่อไปนี้:

ใน , คุณสามารถกำหนดความเร็วในการวิ่งของแต่ละเฟรมของการกระทำ (ช่องที่สามของแต่ละเฟรม),มีให้คุณเลือก 9 แบบดังนี้ (เพิ่มความเร็วรอบวิ่งตามลำดับค่าตัวเลข):

ใน ตัวเลือก "Delay" (ปุ่มที่ 6 ของแต่ละเฟรม) แต่ละเฟรมสามารถที่จะระบุระยะเวลาที่หุ่นยนต์เล่นอนิเมชั่นก่อนที่เฟรมถัดไปจะทำงานหลังจากเฟรมนี้ทำงานเสร็จสิ้น

เมื่อเส่งออกเฟรมแอคชั่น หากคุณต้องการมิเรอร์เฟรมแอคชั่นทั้งหมด (ข้อต่อด้านซ้ายและด้านขวาของหุ่นยนต์จะสลับกันราวกับเห็นในกระจก) ขั้นแรกให้คลิกปุ่ม "" และคลิกปุ่ม "" หากคุณต้องการยกเลิกการส่งออกที่ทำมิเรอร์ คุณสามารถยกเลิกการเลือกได้กดปุ่ม "MirrorAll" อีกครั้ง

ก่อนการส่งออกแอคชั่นเฟรมให้เลือกตัวเลือก "Behavior/Gait" ใน "" ซึ่งเป็น "Behavior"หลังจากนั้นคลิกส่งออก ""โปรแกรมจะทำงานบนหุ่นยนต์และสอดแทรกระหว่าเฟรมเหล่านี้โดยอัตโนมัติเพื่อให้หุ่นยนต์เคลื่อนไหวได้อย่างราบรื่น และเฟรมทั้งหมดจะดำเนินการเพียงรอบเดียว

หากเลือก "Gait" ก่อนที่จะคลิกปุ่มส่งออก ""หุ่นยนต์จะดำเนินการต่อในลูปและแต่ละเฟรมของการดำเนินการจะทำงานด้วยความเร็วสูงสุด จะไม่มีการเพิ่มการแก้ไขระหว่างเฟรมการดำเนินการ การเคลื่อนไหวอาจรุนแรงมาก ดังนั้นจึงขอแนะนำให้ผู้เริ่มต้นใช้ตัวเลือก "พฤติกรรม" เพื่อพัฒนาทักษะใหม่เสมอ

แอพเดสก์ท็อปรองรับการเชื่อมต่อของหุ่นยนต์หลายตัวผ่าน (และผ่าน )เพื่อให้เกิดการควบคุมหุ่นยนต์หลายตัวพร้อมกัน แอปสามารถจดจำพอร์ตอนุกรมเป็นหุ่นยนต์ได้หลังจากทำการเชื่อมต่อทางกายภาพแล้วเท่านั้น หลังจากเปิดหุ่นยนต์ตามปกติแล้ว:

dual mode(EDR & BLE)JDY-23

ESP8266

URL:. ให้วาง URL ลงในการตั้งค่าเพิ่มเติมของบอร์ดพัฒนาใน Arduino preferences.

Project URL:

ก่อนคอมไพล์ตัวอย่าง (, development board esp32 2.0.*, library , ).

หลังจากคอมไพล์แล้ว ให้ใช้ปลั๊กอินอัปโหลดไฟล์ SPIFFS ล่าสุดเพื่ออัปโหลดไฟล์ .mp3 ไปยังพาร์ติชันระบบไฟล์ SPIFFS ของ BiBoard สำหรับรายละเอียด โปรดดูบทที่ .

ปลั๊กอินอัปโหลดไฟล์ ใน Arduino IDE 1.8.* เขียนด้วยภาษาจาวา และ Arduino IDE 2.0 เขียนด้วยภาษาอื่น (TypeScript + Golang) ดังนั้นปลั๊กอินอัปโหลดก่อนหน้านี้จึงไม่สามารถใช้ใน Arduino IDE 2.0 ได้ ขณะนี้ยังไม่รองรับปลั๊กอินอัปโหลดไฟล์ Arduino IDE 2.0 SPIFFS

ดังนั้นขอแนะนำให้คุณติดตั้งและใช้ ชั่วคราวเพื่ออัปโหลดไฟล์ร่างและ .mp3

Download the Arduino IDE(e.g. 1.8.19) for Linux from

Install it on the Chromebook. Please refer to the video at

Attach the ultrasonic sensor to .

You can use the within the Petoi Desktop App to finish the configuration.

You can also use for the most freedom to upload and modify the codes.

If you are not sure, you need to finish the to ensure everything is configured correctly, then upload the code in the Ultrasonic mode.

If the Ultrasonic code is uploaded correctly, you can see success messages printed on the of Arduino IDE. As shown below:

ปลั๊กอินอัปโหลดไฟล์

ดังนั้นขอแนะนำให้คุณติดตั้งและใช้ . เป็นการชั่วคราว

URL:

You can use the within the Petoi Desktop App to finish the configuration.

You can also use for the most freedom to upload and modify the codes.

First, download and install the into your Arduino IDE.

If you are not sure, you need to finish the to ensure everything is configured correctly, then upload the code in the camera mode.

If the camera code is uploaded correctly, Bittle maintains a squat position basically, you can see success messages printed on the of Arduino IDE. When the MU Vision Sensor recognizes a target, the two LEDs will turn blue, and Bittle's head can follow the target and swing left and right. The demo code will auto-switch the target between a yellow tennis ball and a human body if it fails to find any object.

For more details, please refer to .

Petoi Desktop APP
Petoi Desktop App
translation script
USB uploader
Bluetooth settings
RandomMind mode
the serial monitor
the mobile app
Customized buttons
serial ports
the Bluetooth communication module
USB uploader
Bluetooth
WiFi module
http://arduino.esp8266.com/stable/package_esp8266com_index.json
https://github.com/PetoiCamp/OpenCat/tree/main/ModuleTests/ESP8266WiFiController
the action frame list
the action frame list
the action frame list
the action frame list
the action frame list
MirrorAll
Export
Skill Editor
Export
Export
Chapter 2
Chapter 3.2.1
File System SPIFFS
SPIFFS file upload plugin
Arduino IDE 1.8.* IDE
Getting Started with VS Code and PlatformIO IDE for ESP32 and ESP8266 (Windows, Mac OS X, Linux Ubuntu)
ESP32 with VS Code and PlatformIO: Upload Files to Filesystem (SPIFFS)
https://playground.arduino.cc/Linux/All/#Permission
Mac
Windows
https://github.com/arduino/Arduino/releases/download/1.8.19/arduino-1.8.19.tar.xz
https://www.youtube.com/watch?v=2cve6n4LZqI
Nybble's eye
Firmware Uploader
Arduino IDE
upload process for the standard mode
serial monitor
SPIFFS file upload plugin
Arduino IDE 1.8.* IDE
https://www.xtronical.com/basics/audio/dacs-on-esp32/
Firmware Uploader
Arduino IDE
MU camera library
upload process for the standard mode
serial monitor
the Technical Support Document
Arduino IDE 1.8.*
ESP8266Audio 1.9.7
partition configuration BiBoard V0
download, install and configure the software environment
Bittle

Gesture Sensor

Function introduction

The sensor features advanced gesture detection, proximity detection and digital ambient light sensing. Gesture detection can accurately sense "up, down, left and right" and more complex movements.

Software setup

2. Upload the demo sketch (gesture.ino)

Of course, you can also compile and upload your own sketch for the gesture sensor.

Hardware setup

After uploading the the demo sketch, connecting to the NyBoard with wire as shown in the following picture:

For specific use, the end connected to the sensor can be fixed on the robot's head (included in Bittle's mouth or attached to the top of Nybble's head), of course, you can also use your creativity according to actual needs.

The demo code

PIR Motion Sensor

Function introduction

This sensor allows you to detect the movement of animals, usually the movement of humans within its detection range. Just connect it to the NyBoard and program it, and when anyone moves within its detection range, the sensor will output a high potential on its SIG pin.

Hardware setup

Connecting to the NyBoard with wire as shown in the following picture:

For specific use, the end connected to the sensor can be fixed on the robot's head (included in Bittle's mouth or attached to the top of Nybble's head), of course, you can also use your creativity according to actual needs.

Software setup

The demo code

Touch Sensor

Function introduction

The sensor contains two touch parts (left and right) and can detect changes in capacitance when a finger approaches. This means that the touch sensor will output a high level whether your finger touches lightly or presses hard. You can realize the function you want by judging the detected value (1 for high level, 0 for low level).

Hardware setup

Connecting to the NyBoard with wire as shown in the following picture:

For specific use, the end connected to the sensor can be fixed on the robot's head (included in Bittle's mouth, or attached to the top of Nybble's head), of course, you can also use your creativity according to actual needs.

Software setup

The demo code

Introduction

The head of Bittle is designed to be a clip to hold extensible modules. We compiled a sensor pack with some popular modules, but its contents may change in the future. You can also wire other add-ons thanks to the rich contents of the Arduino and Raspberry Pi communities.

You can also purchase the following third-party sensors (such as Seeed studio):

8.PWM(Pulse Width Modulation)

1. การแนะนำฟังก์ชัน PWM บน BiBoard (ESP32)

ESP32 ที่ใช้โดย BiBoard นั้นแตกต่างจาก 328P ที่ใช้โดย UNO เนื่องจาก PWM ของ ESP32 ใช้เมทริกซ์บัส จึงสามารถใช้กับพินที่ไม่ได้ระบุได้

PWM ของ ESP32 เรียกว่าตัวควบคุม LED (LEDC) ตัวควบคุม LED PWM ส่วนใหญ่จะใช้เพื่อควบคุม LED และยังสามารถสร้างสัญญาณ PWM สำหรับการควบคุมอุปกรณ์อื่นๆ ตัวควบคุมมีตัวจับเวลา 8 ตัว ซึ่งสอดคล้องกับช่องความเร็วสูง 8 ช่อง และช่องความเร็วต่ำ 8 ช่อง รวมเป็น 16 ช่อง

เมื่อเปรียบเทียบกับ UNO ให้ใช้ "analogWrite()" โดยตรงเพื่อป้อนอัตราส่วนทำงานระหว่าง 0-255 การควบคุม PWM ของ ESP32 บน BiBoard นั้นยุ่งยากกว่า พารามิเตอร์ที่ต้องควบคุมมีดังนี้:

  1. การเลือกช่อง PWM ด้วยตนเอง (0-15) ยังช่วยเพิ่มความยืดหยุ่นในการใช้พิน

  2. จำนวนบิตของรูปคลื่น PWM จะกำหนดความละเอียดของรอบการทำงานของรูปคลื่น PWM จำนวนบิตยิ่งมาก ความแม่นยำยิ่งสูง

  3. ความถี่ของรูปคลื่น PWM จะกำหนดความเร็วของรูปคลื่น PWM ยิ่งความถี่สูง ความเร็วยิ่งเร็วขึ้น

ความถี่ของรูปคลื่น PWM และจำนวนบิตนั้นสัมพันธ์กัน ยิ่งจำนวนบิตมาก ความถี่ยิ่งต่ำ ตัวอย่างต่อไปนี้ยกมาจากคู่มือการเขียนโปรแกรม ESP32:

ตัวอย่างเช่น เมื่อความถี่ PWM คือ 5 kHz ความละเอียดรอบการทำงานสูงสุดจะเป็น 13 บิต ซึ่งหมายความว่ารอบการทำงานสามารถเป็นค่าใดก็ได้ระหว่าง 0 ถึง 100% โดยมีความละเอียด ~0.012% (2 ** 13 = 8192 ระดับความสว่าง LED แบบแยกส่วน)

สามารถใช้ตัวควบคุม LED PWM เพื่อสร้างสัญญาณความถี่สูง ซึ่งเพียงพอที่จะส่งสัญญาณนาฬิกาไปยังอุปกรณ์อื่นๆ เช่น โมดูลกล้องดิจิทัล ที่นี่ความถี่สูงสุดสามารถเป็น 40 MHz และความละเอียดรอบการทำงานคือ 1 บิต กล่าวอีกนัยหนึ่ง รอบการทำงานจะคงที่ที่ 50% และไม่สามารถปรับเปลี่ยนได้

API คอนโทรลเลอร์ LED PWM สามารถรายงานข้อผิดพลาดเมื่อความถี่ที่ตั้งไว้และความละเอียดรอบการทำงานเกินช่วงฮาร์ดแวร์ของคอนโทรลเลอร์ LED PWM ตัวอย่างเช่น หากคุณพยายามตั้งค่าความถี่เป็น 20 MHz และความละเอียดรอบการทำงานเป็น 3 บิต ข้อผิดพลาดจะถูกรายงานบนจอภาพพอร์ตซีเรียล

2. Configure the PWM frequency on BiBoard in Arduinoin Arduino

ดังที่แสดงไว้ด้านบน เราจำเป็นต้องกำหนดค่าช่องสัญญาณ ความถี่ และจำนวนบิต และเลือกพินเอาต์พุต

ขั้นตอนที่ 1: กำหนดค่าตัวควบคุม PWM

const int freq = 5000; // PWM frequency
const int ledcChannel = 0; // ledc channel, 0-15
const int resolution = 8; // resolution of PWM,8bit(0~255)
ledcSetup(ledcChannel, freq, resolution);

ขั้นตอนที่ 2: กำหนดค่าพินเอาต์พุต PWM

ledcAttachPin(ledPin, ledcChannel);

ขั้นตอนที่ 3: เอาต์พุตรูปคลื่น PWM

ledcWrite(ledcChannel, dutyCycle);

ในการสาธิต เราเลือก IO2 เป็นพินเอาต์พุต เชื่อมต่อ IO2 เข้ากับ LED และคุณสามารถสังเกตเอฟเฟกต์ของไฟ LED กระพริบช้าๆได้

3. Complete code:

/* In this demo, we show how to use PWM in BiBoard(ESP32)
* It's different from the Arduino UNO based on the ATMega328P
*/

// define the PWM pin
const int ledPin = 2;  // 16 corresponds to GPIO16

// setting PWM properties
const int freq = 5000;          // PWM frequency
const int ledcChannel = 0;      // ledc channel, in ESP32 there're 16 ledc(PWM) channels
const int resolution = 8;       // resolution of PWM
 
void setup(){
  // configure ledc functionalitites
  // channels 0-15, resolution 1-16 bits, freq limits depend on resolution
  // ledcSetup(uint8_t channel, uint32_t freq, uint8_t resolution_bits);
  ledcSetup(ledcChannel, freq, resolution);     
  
  // attach the channel to the GPIO to be controlled
  ledcAttachPin(ledPin, ledcChannel);
}
 
void loop(){
  // increase the LED brightness
  for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){   
    // changing the LED brightness with PWM
    ledcWrite(ledcChannel, dutyCycle);
    delay(15);
  }

  // decrease the LED brightness
  for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--){
    // changing the LED brightness with PWM
    ledcWrite(ledcChannel, dutyCycle);   
    delay(15);
  }
}

12.File system SPIFFS

ESP32 File System SPIFFS Configuration Guide

1. Why use a file system

บน BiBoard (ESP32) นอกเหนือจากพื้นที่โปรแกรมปกติและพื้นที่บูตแล้ว เราใช้ระบบไฟล์ในพาร์ติชัน Flash

บทบาทของระบบไฟล์ที่มีพาร์ติชันอิสระมีดังนี้:

  • บันทึกข้อมูลตามที่อยู่ที่ระบุ และจะไม่ถูกลบเนื่องจากการอัปเดตซ้ำ (เช่น ข้อมูลการคาลิเบต ข้อมูลการเดิน

  • ไม่จำเป็นต้องใช้การ์ด SD ภายนอก ช่วยประหยัดทรัพยากรฮาร์ดแวร์

ระบบไฟล์ทั่วไป ได้แก่ Windows NTFS, exFAT และระบบไฟล์บันทึกของ Linux Ext และ XFS แต่ในเขตข้อมูลที่ฝังตัว ระบบไฟล์ขนาดใหญ่เหล่านี้มีขนาดใหญ่เกินไป เราใช้ SPIFFS (ระบบไฟล์แฟลช SPI) ที่มีน้ำหนักเบา ซึ่งเป็นระบบไฟล์แบบฝังสำหรับอุปกรณ์แฟลช SPI NOR และฟังก์ชันสนับสนุน เช่น การปรับระดับการสึกหรอและการตรวจสอบความสอดคล้องกันของระบบไฟล์

เนื่องจากน้ำหนักเบา คุณลักษณะที่ใหญ่ที่สุดของ SPIFFS คือไม่รองรับไดเร็กทอรีแบบต้นไม้ กล่าวคือ ไฟล์ทั้งหมดจะถูกจัดเก็บไว้ในเลเยอร์เดียวกัน SPIFFS ที่ให้บริการโดย ESP32 มีคุณสมบัติดังต่อไปนี้:

  • ปัจจุบัน SPIFFS ไม่รองรับไดเร็กทอรี แต่สร้างโครงสร้างแบบเรียบ หาก SPIFFS ติดตั้งอยู่ใต้ /spiffs การสร้างไฟล์ด้วยเส้นทาง /spiffs/tmp/myfile.txt จะสร้างไฟล์ชื่อ /tmp/myfile.txt ใน SPIFFS แทนที่จะเป็น myfile.txt ในไดเร็กทอรี /spiffs/tmp

  • ไม่ใช่สแต็คแบบเรียลไทม์ การดำเนินการเขียนรายการหนึ่งอาจใช้เวลานานกว่าการดำเนินการอื่นมาก

  • สำหรับตอนนี้ มันไม่ได้ตรวจหาหรือจัดการกับบล็อกที่ไม่ดี

2. Install the Arduino ESP32 file system uploader

คุณสามารถสร้าง/บันทึกและลบไฟล์ด้วยโค้ด Arduino ของคุณเอง แต่การดำเนินการนั้นยุ่งยาก คุณต้องใส่ข้อมูลหรือไฟล์ไบนารีลงใน Arduino Sketch และสร้างไฟล์โดยเรียกใช้โปรแกรม

อย่างไรก็ตาม มีเครื่องมือที่มีประโยชน์มากที่สามารถอัปโหลดไฟล์จากคอมพิวเตอร์ไปยังระบบไฟล์ได้โดยตรง แม้ว่าจะยุ่งยากกว่าการ "ลากและวาง" สำเนาของ "ที่เก็บข้อมูลแบบถอดได้" เล็กน้อย ไม่ว่าจะเป็นไฟล์เสียง MP3 หรือไฟล์เว็บ HTML ทั้งหมดก็สามารถอัปโหลดไปยังหน่วยความจำแฟลชได้อย่างง่ายดาย มาเรียนรู้วิธีใช้ปลั๊กอินนี้กัน

3. Install ESP32 file upload plugin

3.1 Preparing the Environment

โปรดติดตั้ง Arduino IDE (เวอร์ชัน: 1.8.* ) และชุดสนับสนุน ESP32 ของ Arduino IDE (โปรดดูบทที่ 3.2.1 ของคู่มือการเริ่มต้นฉบับย่อของ BiBoard)

3.2 Download the ESP32FS plugin

ดาวน์โหลดแพ็คเกจบีบอัดของปลั๊กอิน ESP32FS ได้ที่:

ไปที่ไดเรกทอรี "Arduino" และเปิดโฟลเดอร์ "tools"

C:\Users\{YourUserName}\Documents\Arduino\tools

คลายซิปโฟลเดอร์ .zip ที่ดาวน์โหลดมาไปยังโฟลเดอร์ Tools คุณควรมีโครงสร้างโฟลเดอร์ที่คล้ายกัน:

C:\Users\{YourUserName}\Documents\Arduino\tools\ESP32FS\tool\esp32fs.jar

สุดท้ายให้รีสตาร์ท Arduino IDE

หากต้องการตรวจสอบว่าติดตั้งปลั๊กอินสำเร็จหรือไม่ ให้เปิด Arduino IDE เลือกบอร์ดพัฒนา ESP32 ของคุณ (ESP32 Dev Module) ไปที่ "Tools" จากนั้นตรวจสอบว่ามีตัวเลือก "ESP32 Sketch Data Upload" หรือไม่

4. Upload files using the file system uploader

หากต้องการอัปโหลดไฟล์ไปยังระบบไฟล์ ESP32 ให้ทำตามขั้นตอนด้านล่าง:

  • สร้างโครงการ Arduino (เช่น Test.ino) และบันทึก

  • หากต้องการเปิดไดเร็กทอรีโครงการ คุณสามารถใช้ตัวเลือก "Sketch - Show Sketch Folder"

  • ภายในโฟลเดอร์นี้ ให้สร้างโฟลเดอร์ใหม่ชื่อ "data"

  • ในโฟลเดอร์ "data" คุณควรใส่ไฟล์ที่คุณต้องการบันทึกลงในระบบไฟล์ SPIFFS เช่น สร้างไฟล์ .txt ที่มีข้อความชื่อ "test_example" ดังต่อไปนี้:

  • โปรดคลิก "Tools - ESP32 Sketch Data Upload" ใน Arduino IDE

เมื่อคุณเห็นข้อความแจ้ง "SPIFFS Image Uploaded" แสดงว่าไฟล์ได้รับการอัปโหลดไปยังพาร์ติชัน SPIFFS เรียบร้อยแล้ว

5. Demo of how to use the file system

วอย่างของระบบไฟล์ SPIFFS_Test.ino(C:\Users\{YourUserName}\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.*\libraries\SPIFFS\examples\SPIFFS_Test))มาจาก ESP32 อย่างเป็นทางการ โดยไม่ต้องดัดแปลง โค้ดนี้ใช้การดำเนินการพื้นฐานของ "การเพิ่ม การลบ การแก้ไข และการตรวจสอบ" และจัดเตรียมโปรแกรมทดสอบ SPI flash IO

หากจำเป็น ขอแนะนำให้ใช้โค้ดของตัวอย่างโดยตรงเพื่อใช้งาน ESP32 SPIFFS

OpenCat Imitation Tutorial

Let the robot be your Avatar!

In this tutorial, we will introduce how to use the Ailia in python language to implement an OpenCat robot to imitate various human body movements.

To clone or download the code from the GitHub repository, you can clone the code with the following command:

1. Run on a regular computer (Mac/Linux)

Requirements

  • Python 3.6 and later

  1. Open the Anaconda Prompt (Windows) or the Terminal (Linux / macOS) and enter the following commands to create and activate a virtual environment (the environment name is "venv", and can also be customized to other names): conda create --name venv conda activate venv

  2. Use the USB uploader or Bluetooth module to connect the robot and power it on. The computer needs to be connected to a camera device.

  3. Run the following command to start the OpenCat Imitation program:

You can execute run.sh within OpenCat-Imitation/ with your shell command directly. It wraps up the above commands.

2. Run on the Jetson Nano 2GB Developer kit

You may want to run the demo on a Jetson Nano to experiment with some GPU features.

The developer kit uses a microSD card as a boot device and for main storage. It’s important to have a card that’s fast and large enough for your projects; the minimum requirement is a 32GB UHS-1 card. Many projects with Jetson Nano 2GB Developer Kit will utilize swap space on the MicroSD Card due to only 2GB physical memory. For this reason, we recommend 64GB or larger microSD cards. High-endurance microSD cards are also recommended.

2. Use a network cable to connect the Jetson Nano development board to a router or other computer hosts so that it can access the Internet.

pip install -r requirements.txt

4. Install the relevant python library files using the following command:

To connect the USB uploader, you need to use the following command:

sudo usermod -a -G dialout $USER to increase user rights.

Skill Creation

Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.

Preparation

Understand the code

All skill arrays of the robot are defined in the Instinct***.h file.

  • Nybble: InstinctNybble.h

  • Bittle: InstinctBittle.h

Here is an abbreviated example of an Instinct***.h file:

Data structure

The meaning of the data structure of the skill array is shown in the figure below:

Total # of Frames

Expected Body Orientation

The 2nd and 3rd elements in the skill array represent the expected value of the body direction, that is, the inclination angle of the robot's body when performing skill actions, corresponding to the body's roll angle (Roll) and pitch angle (Pitch) respectively. When the robot is performing a skill action, if the body tilt deviates from the expected value, the balance algorithm will make some adjustments to the angle value of the relevant leg servos to keep the body tilt as close as possible to the expected value.

The pitch angle (Pitch) and roll angle (Roll) of the robot shown in the figure above are both at 0 degrees. In the picture on the left, the robot body rotates counterclockwise from the 0-degree position around the center point, and the pitch angle is positive; when it rotates clockwise, the pitch angle is negative. In the picture on the right, the robot body rotates counterclockwise from the 0-degree position around the center point, and the roll angle is positive; when it rotates clockwise, the roll angle is negative.

Take a look at the following sample code, standing:

Sitting:

The 2nd and 3rd elements in the array represent the expected value of the body direction (corresponding to the roll angle and pitch angle of the body), and the unit is degree.

When the gyroscope is activated, Bittle's body is slightly rotated, and when the body tilts away from the expected value of the body direction, the balance algorithm will keep the body in this posture as much as possible.

Indexed Joint Angles

The index numbers of the servo are shown in the figure below:

Please control the rotation angle range of the joint servo between [-125~125]. For the leg servo, when viewed from the left side of the robot, the leg rotates counterclockwise from the 0 degree position around the joint center point (the screw fixing position) , the angle is a positive value; clockwise rotation, the angle is a negative value; viewed from the right side of the robot, the leg rotation angle is mirror-symmetrical to the left side (rotating clockwise from the 0 degree position around the joint center point, the angle is a positive value; Rotate counterclockwise, the angle is negative). For the robot's neck servo, looking down from the top of the robot's head, the neck rotates counterclockwise from the position of 0 degrees around the joint center point (the position where the screw is fixed), and the angle is a positive value; when it rotates clockwise, the angle is a negative value.

For the Nybble head servo (No. 1 servo) observed on the right side of the robot, the head rotates counterclockwise from the 0-degree position around the joint center point (screw fixed position), and the angle is positive; when it rotates clockwise, the angle is negative.

For the Nybble tail servo (No. 2 servo) facing the tail and looking down, the tail rotates counterclockwise from the 0-degree position around the center point (screw fixing position), and the angle is positive; when it rotates clockwise, the angle is negative.

Each action frame in the skill array contains the rotation angle values of multiple servos.

In the above data structure figure, the rest action frame contains 16 joint servo angle values, and the corresponding servo index numbers are arranged from small to large starting from 0.

Each action frame in the crF (crawling forward) contains 8 joint servo angle values, and the corresponding servo index numbers are arranged from small to large starting from 8.

Angle ratio

The 4th element in the skill array represents the angle ratio. The angle ratio value can be increased when it is necessary to store angle values outside the range of -128 to 127. For example, if the angle ratio is set to 2, the angle value of all joint servos in the skill array multiplied by 2 is the actual rotation angle of the servo.

Take a look at the following example skill array rc (return to standing after being on all fours):

The 4th element (2) in the array represents the angle ratio. This means that the actual angle value of all joint rotations is equal to the angle value of each joint in the array (starting from the 8th element) multiplied by this angle ratio.

Posture array

The posture array contains only one action frame. Taking Bittle as an example, find the zero posture array in InstinctBittle.h:

Modify some of the joint servo angle values:

Save the modification and upload the main function program OpenCat.ino to the Bittle mainboard. After the upload is complete, click the button (7, 3) on the IR remote to see the modified zero skill, and the new posture is shown in the figure below:

The first element (1) in the array represents the total number of frames of the skill, and 1 means it is a posture skill.

The 4th element (1) in the array represents the angle ratio. This means that all index joint angles below are actual angles (because each of them is multiplied by 1).

The 5th to 20th elements in the array represent the respective angle values of the 16 joints in the current frame.

For Bittle, the 5th element in the array (70, corresponding to the No.0 servo) means that the servo on Bittle's neck rotates 70 degrees counterclockwise. Bittle's head turned to the left side of the body.

The 13th element in the array (-60, corresponding to No.8 servo) indicates that Bittle's left front thigh rotates 60 degrees clockwise around the joint center point.

The 17th element in the array (60, corresponding to No.12 servo) indicates that Bittle's left front calf rotates 60 degrees counterclockwise around the center of the joint.

The other joint angles remain unchanged at 0 degrees.

Gait array

The gait array contains multiple coherent action frames, and these action frames are executed repeatedly in a sequential cycle, unless the robot receives a new skill command, it will stop executing. For example, the bk(draw back) gait array is defined as follows:

The 1st element in the array (35) means the skill has 35 action frames. Starting from the second line of data, each line is an action frame, which contains the angle values of 8 joint servos, and the corresponding servo index numbers are arranged from small to large starting from 8 (a total of 35 lines).

For gait skills, each action frame in the future may contain 12 joint servo angle values, and the corresponding servo index numbers will be arranged from small to large starting from 4, depending on the number of leg servos participating in the movement.

Behavior array

The behavior array also contains multiple coherent action frames, and all the action frames are only executed for one round in order, but some of the continuous action frames can be executed multiple times in a loop. For example, the pu(push-up) behavior array is defined as follows:

This data structure contains more information than pose and gait:

The meanings of the 4 elements in line 1 are as mentioned above, and the first element (total number of frames) is a negative number, indicating that this skill is a behavior.

The 3 elements in line 2 indicate the loop structure contained in this behavior: start frame, end frame, and loop times:

6, 7, 3 in the example means that this behavior is executed 3 times from the 7th frame to the 8th frame (the frame index number starts from 0). The motion sequence of the entire behavior is performed in one round, rather than in a continuous loop-like gait.

Each action frame contains 20 elements. The first 16 elements represent the angles of the joint servos as mentioned above, and the corresponding servo index numbers are arranged from small to large starting from 0. The last 4 elements have the following meanings:

  1. The 1st represents the speed factor. The default speed factor is 4, which can be changed to an integer from 1 (slow) to 127 (fast). Units are degrees per step. If set to 0, the servo will rotate to the target angle at maximum speed (about 0.07 seconds/60 degrees). Values greater than 10 are not recommended unless you understand the risks.

  2. The 2nd represents the delay time. The default delay is 0. The range that can be set is 0 to 127, and the unit is 50 milliseconds (if it is set to 2, the actual delay is 100 milliseconds).

  3. The 3rd represents the trigger axis. It is used to set the body rotation direction when the robot triggers the next frame of action. There are the following 5 setting options:

    • 0 means there is no trigger axis and the trigger angle condition setting

    • 1 means positive pitch, the robot body is bent forward and rotated in the downward direction

    • -1 means negative pitch, the robot body rotates backwards

    • 2 indicates positive roll, the robot rolls to its left side

    • -2 means negative roll, the robot rolls to its right side

Note:

  • The trigger axis and trigger angle need to be used together: only when the robot completes the frame of motion and rotates in accordance with the set body rotation direction to exceed the trigger angle, the next frame of motion will be triggered. If the trigger axis is set to 0, the trigger angle is meaningless. Therefore, when the trigger axis is set to 0, the trigger angle is generally also set to 0.

  • If a delay time is also set in the action frame, then when the robot runs this action frame, it must not only meet the trigger conditions set by the trigger axis and trigger angle but also reach the delay setting time before triggering the next frame of action.

Skill storage type

The erasing and writing times of EEPROM are limited (1,000,000 times). In order to minimize write operations, two skills are defined: Instinct and Newbility. Their addresses are stored in the built-in EEPROM (1KB) of the chip (ATmega328P) as a lookup table, but the data of the main body exists in different storage units:

  • I2C EEPROM (8KB) memory Instincts. Instincts are fixed skills (or occasional fine-tuning), which can be thought of as "muscle memory".

  • Flash (shares 32KB storage space with Arduino program code) Storage Newbilities. Newbilities refer to user-defined skills (possibly modified, added, or deleted). They will not be written into the static EERPOM but uploaded to the flash memory (Flash) together with the Arduino program code. Their addresses are assigned in real-time when the code is executed, and this value rarely changes as long as the total number of skills (including all instincts and newbilities) remains the same.

The specific sample code is as follows:

Add a suffix to each skill array name in the character pointer array skillNameWithType, "N" means Newbility, and "I" means Instinct.

const char* progmemPointer[] = {crF, pu, rest, zero, }; This part of the code is active when uploading the configuration mode sketch. It contains data and pointers for all abilities.

const char* progmemPointer[] = {zero}; This part of the code is active when uploading the major functionalities sketch. Since the instincts are already saved in the external I2C EEPROM, their data is omitted here to save space. If you only need to adjust the actions of existing new skills (such as zero), you don't need to re-upload the configuration mode sketch.

Create new skills

Debug the skills

The following two methods can be used when authoring or debugging skill actions:

You are also welcome to share your new skills by sending merge requests to this folder.

Add skill array

Add Instinct

To add a new skill(testI) array ending with I, you need to add the skill array variable name (test) to the first branch of the sample code macro judgment. The specific code modification is as follows:

Add Newbility

To add a new skill(testN) array ending with N, you need to add the skill array variable name (test) to both branches of the sample code macro judgment. The specific code modification is as follows:

After adding the skill array In the Instinct***.h file, for NyBoard, use the data cable to connect the USB uploader and the computer, use the Arduino IDE to upload the configuration mode sketch, open the serial monitor when the serial port prompts the following content:

Intelligent

Light Sensor

Function introduction

The sensor integrates two photoresistors (depending on the light intensity adjustment resistance) to detect the light intensity. The photoresistor is a special resistance that uses the photoconductive effect, and its resistance is directly related to the intensity of the incident light. When the light intensity increases, the resistance decreases; when the light intensity decreases, the resistance increases. The output signal is an analog value, the brighter the brightness, the larger the value. You can realize the function you want by judging the value of the detected light intensity, such as the function of a robot tracing light.

Hardware setup

Connecting to the NyBoard with wire as shown in the following picture:

For specific use, the end connected to the sensor can be fixed on the robot's head (included in Bittle's mouth, or attached to the top of Nybble's head), of course, you can also use your creativity according to actual needs.

Software setup

The demo code

FAQ(Frequently Asked Questions)

Arduino IDE

Cannot upload sketch, sync error.

The error that occurs when uploading the sketch is shown below:

This "not in sync error" indicates a bad connection between your computer and your robot. It could be:

Usually, it can be fixed by the following checks:

  1. Use the USB cable with the data function(the one included in the kit is good).

  2. Select the correct board (Arduino Uno) and serial port

  3. Connect the board and the programmer in the right pin order

Software

What do different sounds from the board mean?

Why there are two calibration stages?

There are two calibration steps for different components.

Because the controller board has limited resources, we divide the program into two stages.

In the first stage, we upload the program and large data to the onboard EEPROM (hard disk) and use the remaining programming space to calibrate the IMU, a sensor that measures the body orientation. The board should be leveled and untouched during the (IMU) calibration.

In the second stage, we upload the standard functional code. For the first-time configuration, we need to enter the (joint) calibration state and attach the legs in the right direction.

If you use the Arduino IDE to set up the board, you will handle those stages explicitly. The Petoi Desktop App can finish the two-stage uploading in the background. The smartphone app can work only with an already configured board. Its (joint) calibration is only for attaching the legs.

When using the smartphone app, I found that Bittle was walking very slowly.

When using the smartphone app, Bittle cannot turn back up now.

Bittle doesn't walk very stable.

  • Remove the rubber toe covers

If to buy the preassembled bittle does it still have to be calibrated?

If to buy the main board alone, do you have to buy a separate software program to make it work?

Could Python be used to control the robot?

You can use python to control the robot. The scripts can work either on your computer and connects to the robot wired or wirelessly.

Can your little robot (Bittle / Nybble) function on its own? Or, it only works with the commands I give it? Also, can it learn?

Hardware

How can I easily install the springs into the upper legs of Bittle?

I can't find the toe covers. What are the toe covers for?

The toe covers are for special experiments that require more friction. They are not required for regular walking and performance. We have removed them from the standard kit recently and you may order them as optional accessories.

Some frame structures are broken. Where can I get replacement parts?

Where can I get the bone shown in Bittle's picture?

Does it come with a battery or do you have to buy a lithium battery?

Both Bittle kit and pre-assembled Bittle include one Lithium battery with a built-in charging circuit. You may add more spare batteries.

Does Rasberry Pi require any additional components?

You can solder the 2x5 socket on the NyBoard and then mount the Rasberry Pi on the NyBoard.

How to debug the servo?

Resources and links

Driver for CH340 USB uploader

Can I use Codecraft/block-based coding with the basic Bittle package or do I need to purchase add-on components/modules?

Install the latest version of the Arduino_APDS9960 library using the

This demo sketch (gesture.ino) implements real-time printing of various directional gestures (up, down, left, and right) made by the user in front of the gesture sensor in the .

You can use the to upload the demo code (test_Touch_Reflection_PIR.ino) or compile and upload your own code.

This demo sketch (test_Touch_Reflection_PIR.ino) implements real-time printing of sensor detection results in the - when anyone moves within its detection range, print 1; otherwise, print 0.

The demo code is in the OpenCat code repository on GitHub (specific path: OpenCat/ModuleTests/test_Touch_Reflection_PIR). You can visit our GitHub code repository to download the complete code, as shown in the following figure:

You can use the to upload the demo code (doubleTouch.ino) or compile and upload your own code.

This demo sketch (doubleTouch.ino) implements real-time printing of the detection values of D6 and D7 pins in the :

You can find the demo codes of these modules in our GitHub repository. They should be in the folder if you download the whole OpenCat repository.

(Applicable to Nybble)

The loudness and light level modules can generate for the corresponding signals and should be connected to the analog Grove socket.

The touch, reflection, PIR sensors can generate digital 1 or 0 as a switch signal. So they should be connected to the digital Grove socket. In the , we use the fourth socket with D6 and D7.

The , , and module should be connected to the I2C Grove socket.

It is recommended to install the IDE. For the specific installation method, please refer to the following link:

Follow to install the Ailia SDK, it will be used for pose detection. The guide mainly includes the following steps: download and install the ailia SDK and the related python library files. When downloading the Ailia SDK, you need to enter the correct email address to receive the download link address and license file. The free license is valid for only one month. The SDK is about 2GB, so it takes time to download. Move the downloaded license file (AILIA.lic) to the directory where bootstrap.py is located ({ailia sdk directory}/python), and then follow the steps to continue installing the Ailia SDK. cd {ailia sdk directory}/python python3 bootstrap.py pip3 install . Download the from this page () to the directory where bootstrap.py is located before running the following command: pip install -r requirements.txt. It may take 30 minutes.

Please refer to to record the system image file () into the microSD card and complete the system initialization.

The system image file link in the user guide () points to JetPack 4.6.1, download and burn it to a microSD card After that, system initialization may fail when the Jetson Nano is started. So we recommend using the earlier version: JetPack 4.6.

3. Clone or download the code from , and install the Ailia SDK according to , the specific method is the same as the above step 3 in Run on the host computer, but NO need to execute the statement:

5. Connect the camera and complete its configuration by referring to .

Please refer to the technical documentation to complete the setup if you use a USB camera to complete the setup.

6. Start the program, please refer to step 4 and 5 of .

Now the OpenCat imitation program can run on the Jetson Nano development board. You can refer to other relevant technical documents to improve the program's performance, such as .

Familiar with upload the firmware (Chapter 3 of the / User Manual), the assembly process (Chapter 4 of the / User Manual) and calibrate the servo (Chapter 6 of the /User Manual). Use an IR remote to verify that the following functions work as expected.

Press the button on 's 2nd row, 2nd column (as shown in the picture below). Later it will be expressed by (2, 2). You can also connect a USB adapter and enter the serial command "kbalance" in . The robot will stand up.

Press the (7, 3) button on . You can also connect a USB adapter and enter the serial command "kzero" in . All the servos of the robot are turned to the 0-degree position, which is the "Zero" skill (as shown in the figure below).

The 1st element in the skill array indicates the total number of all action frames contained in the skill. If there is a minus sign (-) before the value, it means that the skill is a .

In the above data structure figure, the rest is a . It has only 1 action frame (1 row of data).

the crF (Crawl forward) is a . It contains 36 action frames (36 rows of data).

The 4th represents the trigger angle. Angle values have the same positive and negative meanings as . Trigger angle setting range: an integer value between -125 and 125.

Control the robot to make actions by Python scripts. For details, please refer to the .

Use in the Desktop App to control the robot to do actions, and then use the "" function to copy and paste the contents of the debugged skill array to the Instinct***.h file for use. Please refer to the for the specific format.

This is a good starting point if you want to develop a customized gait. If you are going to do some inverse kinematics calculation, you may use the following key dimensions to build your model:

The "SkillLibrary" folder in is a collection of new skills that OpenCat robots can perform, which can be used for your reference.

Another direction is to set up a simulation for Bittle then test the model in reality. You may use this for Bittle to set up an NVIDIA Omniverse simulation.

After inputting 'Y' or 'n', all instinct arrays will be stored in the I2C EEPROM at one time, and the index addresses of all skills will also be generated and stored in the built-in EERPOM of the chip, and then upload the major functionalities sketch. For the specific operation process, please refer to in uploading the sketch for NyBoard.

When verifying the skill action, you can open and call through the serial port command with 'k' token. For example, "ksit" can be transformed into a sitting posture by Bittle.

By adding some (such as a gesture sensor), it can help the robot to better perceive the environment and even make decisions. By accumulating these automatic behaviors and designing a decision tree, robot's fully automatic intelligent operation is finally realized!

You can use the to upload the demo code (doubleLight.ino) or compile and upload your own code.

This demo sketch (doubleLight.ino) implements real-time printing of the analog values of the two analog pins (A2 and A3) in the . You can also use the serial plotter to view the two analog pins (A2 and A3) more intuitively. The waveform graph generated by the analog value of the pin output along the time axis.

A wrong between your uploader and the robot

Your computer doesn't have a driver for the

You didn't before pressing the upload button

The uploader unit is defective. In this case, you can request a replacement from us at

Install

The above steps are covered in the .

Of course, you can also refer to the solution in the :

Sound type
Occasion
Explaination

Try turning off the Gyro in the , as shown in the following picture:

Try turning on the Gyro in the , as shown in the following picture:

Make sure you the joints with the included L-shaped tuner and understand the references

will make slow gaits more stable

Yes, you still need to use the desktop app or smartphone app or Arduino IDE .

Our main board is specifically designed for our robots. The code is free to download on .

It follows your instructions via the infrared remote, smartphone app, or desktop app. It can also do random behaviors if you upload the random mode. Best of all, the program is open source on GitHub and you can refer to to create new skills for the robot.

Please check out post discussing installing springs with varies tools.

You may contact support@petoi.com. Show the picture of the broken pieces and explain how they broke. You may find the or get a replacement directly from us.

The little bone is included in the box and it is not being sold separately. You may download its 3D-printable file at:

Read more at

[1].

[2].

[3].

Mac:

Windows:

Bittle can be programmed with a Scratch-like web-based IDE . You may find some complementary materials: and .

Note that CodeCraft hasn't provided support for our 2.0 version. But you may roll back to the supported version within CodeCraft or through .

You don't need to buy add-on components to use the basic functions in Codecraft. However, several extension functions require . If you are comfortable with coding with Arduino, you can have a much wider selection of third-party components.

Arduino IDE
serial monitor
Arduino IDE
serial monitor
https://github.com/PetoiCamp/OpenCat
Arduino IDE
serial monitor
ModuleTests
analog readings
demo code
intelligent camera
gesture
OLED
Save HTML and CSS files to build a web server
Save images, audio and other files
Chapter 3.2.1
git clone https://github.com/PetoiCamp/OpenCat-Imitation
cd {your file directory}/OpenCat-Imitation/
# set python import path
export PYTHONPATH=$PWD:$PWD/serialMaster
python opencat_imitation/imitation.py -v0
sudo apt install python3-pip
sudo apt install python3-matplotlib
sudo apt install python3-scipy
pip3 install cython
pip3 install numpy
sudo apt install nvidia-jetpack
pip3 install dataclasses
pip3 install pyserial
//a short version of Instinct***.h as example
const char rest[] PROGMEM = { 
1, 0, 0, 1,
  -30, -80, -45,   0,  -3,  -3,   3,   3,  75,  75,  75,  75, -55, -55, -55, -55,};
const char zero[] PROGMEM = { 
1, 0, 0, 1,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,};

const char crF[] PROGMEM = { 
36, 0, -3, 1,
  61,  68,  54,  61, -26, -39, -13, -26,
  66,  61,  58,  55, -26, -39, -13, -26,
  ...
  51,  81,  45,  72, -25, -37, -12, -25,
  55,  76,  49,  68, -26, -38, -13, -26,
  60,  70,  53,  62, -26, -39, -13, -26,
};

const char pu[] PROGMEM = { 
-8, 0, -15, 1,
 6, 7, 3, 
    0,   0,   0,   0,   0,   0,   0,   0,  30,  30,  30,  30,  30,  30,  30,  30,	 5, 0,
   15,   0,   0,   0,   0,   0,   0,   0,  30,  35,  40,  29,  50,  15,  15,  15,	 5, 0,
   30,   0,   0,   0,   0,   0,   0,   0,  27,  35,  40,  60,  50,  15,  20,  45,	 5, 0,
   15,   0,   0,   0,   0,   0,   0,   0,  45,  35,  40,  60,  25,  20,  20,  60,	 5, 0,
    0,   0,   0,   0,   0,   0,   0,   0,  50,  35,  75,  60,  20,  30,  20,  60,	 6, 0,
  -15,   0,   0,   0,   0,   0,   0,   0,  60,  60,  70,  70,  15,  15,  60,  60,	 6, 0,
    0,   0,   0,   0,   0,   0,   0,   0,  30,  30,  95,  95,  60,  60,  60,  60,	 6, 1,
   30,   0,   0,   0,   0,   0,   0,   0,  75,  70,  80,  80, -50, -50,  60,  60,	 8, 0,
};

const char* skillNameWithType[] = {"crFI", "puI", "restI", "zeroN",};
#if !defined(MAIN_SKETCH) || !defined(I2C_EEPROM)
const char* progmemPointer[] = {crF, pu, rest, zero, };
#else
const char* progmemPointer[] = {zero};
#endif
const char balance[] PROGMEM = { 
1, 0, 0, 1,
    0,   0,   0,   0,   0,   0,   0,   0,  30,  30,  30,  30,  30,  30,  30,  30,};C
const char sit[] PROGMEM = { 
1, 0, -30, 1,
    0,   0, -45,   0,  -5,  -5,  20,  20,  45,  45, 105, 105,  45,  45, -45, -45,};
const char rc[] PROGMEM = { 
-3, 0, 0, 2,
 0, 0, 0, 
    0,   0,   0,   0,   0,   0,   0,   0, -88, -43,  67,  87,  42, -35,  42,  42,	15, 0, 0, 0,
    0,   0,   0,   0,   0,   0,   0,   0, -83, -88,  87,  42,  42,  42,  42, -40,	15, 0, 0, 0,
   -8, -20, -11,   0,  -1,  -1,   0,   0,  18,  18,  18,  18, -14, -14, -14, -14,	10, 0, 0, 0,
};
const char zero[] PROGMEM = { 
1, 0, 0, 1,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,};
const char zero[] PROGMEM = { 
1, 0, 0, 1,
70, 0, 0, 0, 0, 0, 0, 0, -60, 0, 0, 0, 60, 0, 0, 0,};
const char bk[] PROGMEM = {
  35, 0, 0, 1,
  46,  54,  46,  54,  -5, -23,  -5, -23,
  43,  58,  43,  58,  -5, -24,  -5, -24,
  ......
  52,  43,  52,  43,  -5, -21,  -5, -21,
  50,  48,  50,  48,  -5, -22,  -5, -22,
  47,  53,  47,  53,  -5, -23,  -5, -23,
};
const char pu[] PROGMEM = { 
-8, 0, -15, 1,
 6, 7, 3, 
    0,   0,   0,   0,   0,   0,   0,   0,  30,  30,  30,  30,  30,  30,  30,  30,	 5, 0, 0, 0,
   15,   0,   0,   0,   0,   0,   0,   0,  30,  35,  40,  29,  50,  15,  15,  15,	 5, 0, 0, 0,
   30,   0,   0,   0,   0,   0,   0,   0,  27,  35,  40,  60,  50,  15,  20,  45,	 5, 0, 0, 0,
   15,   0,   0,   0,   0,   0,   0,   0,  45,  35,  40,  60,  25,  20,  20,  60,	 5, 0, 0, 0,
    0,   0,   0,   0,   0,   0,   0,   0,  50,  35,  75,  60,  20,  30,  20,  60,	 6, 0, 0, 0,
  -15,   0,   0,   0,   0,   0,   0,   0,  60,  60,  70,  70,  15,  15,  60,  60,	 6, 0, 0, 0,
    0,   0,   0,   0,   0,   0,   0,   0,  30,  30,  95,  95,  60,  60,  60,  60,	 6, 1, 0, 0,
   30,   0,   0,   0,   0,   0,   0,   0,  75,  70,  80,  80, -50, -50,  60,  60,	 8, 0, 0, 0,
};
const char* skillNameWithType[] = {"crFI", "puI", "restI", "zeroN",};
#if !defined(MAIN_SKETCH) || !defined(I2C_EEPROM)
const char* progmemPointer[] = {crF, pu, rest, zero, };
#else
const char* progmemPointer[] = {zero};
#endif
const char* skillNameWithType[] = {"crFI", "puI", "restI", "zeroN", "testI"};
#if !defined(MAIN_SKETCH) || !defined(I2C_EEPROM)
const char* progmemPointer[] = {crF, pu, rest, zero, test};
#else
const char* progmemPointer[] = {zero};
#endif
const char* skillNameWithType[] = {"crFI", "puI", "restI", "zeroN", "testN"};
#if !defined(MAIN_SKETCH) || !defined(I2C_EEPROM)
const char* progmemPointer[] = {crF, pu, rest, zero, test};
#else
const char* progmemPointer[] = {zero, test};
#endif
Reset joint offsets? (Y/n):
Nybble Cat User Manual

Short melody

Power on or reboot

The program starts successfully

Short beep

During use

The program receives a command

Repetitive short melody

During use and pausing the movements

The battery is low or unconnected

Demo
Anaconda3
https://docs.anaconda.com/anaconda/install/
the guide
requirements.txt
https://github.com/axinc-ai/ailia-models
the user guide
JetPack 4.6
https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-2gb-devkit#write
GitHub
the guide
the relevant guide
the relevant technical documentation
Run on a regular computer
enabling openCV to support CUDA acceleration
Nybble
Bittle
Nybble
Bittle
Nybble
Bittle
the IR remote
the serial monitor
the IR remote
the serial monitor
serialMaster User Guide
GitHub repo
GitHub repo
Unified Robot Description Format (URDF) file
the relevant chapters
the serial monitor
extensible modules
Arduino IDE
serial monitor
physical connection
uploader
select the serial port
support@petoi.com
Doc Center
Arduino technical forum
mobile app
mobile app
calibrate
to fine-tune the joints
GitHub
the relevant technical documents
the forum
3D-printable files
Intelligent Camera Module
https://github.com/PetoiCamp/NonCodeFiles/blob/master/stl/Bittle_bone.stl
https://docs.petoi.com/api/raspberry-pi-serial-port-as-an-interface
Re-upload the firmware
Calibrate the PWM signal
Swap the pin definitions
http://www.wch-ic.com/download/CH341SER_MAC_ZIP.html
http://www.wch-ic.com/downloads/CH341SER_EXE.html
Codecraft
online help
curriculum
the desktop app
add-on components
behavior
posture
gait
body orientation expectations
the Skill Composer
Export the skill
data structure
the CH340 driver
Turning off the Gyro
Bittle Dog User Manual

Supporting Application and Software

Programming Language Support

3rd-party Open Source Projects

    • need to mount a Raspberry Pi

  • Please check out the following video for the app configuration to support controlling Bittle.

ESP8266 + Python Scripts Implement wireless crowd control

Setup environment

Script introduction

สำหรับ Python เวอร์ชัน 3.8 ขึ้นไป มีการเปลี่ยนแปลง Syntax ในการกำหนด Type ของตัวแปร สคริปต์นี้สามารถใช้งานได้แต่ต้อง comment และ uncomment หลายคำสั่งที่เกี่ยวข้องตามรุ่นของ Python ที่คุณได้ติดตั้งไว้ ตัวอย่างเช่นสคริปต์ด้านล่างนี้รองรับ Python เวอร์ชันต่ำกว่า 3.8:

"""
In Python 3.8 and earlier, the name of the collection type is
capitalized, and the type is imported from the 'typing' module
"""
# from typing import Union, Optional             # for Python 3.9+
from typing import Union, Dict, List, Optional   # for Python 3.7

แอปสคริปต์นี้สามารถควบคุมหุ่นยนต์ได้เพียงหนึ่งตัว หรือควบคุมหลายตัวพร้อมกันได้ โดยสามารถทำได้โดยการแก้ไขคำสั่งต่อไปนี้ใน example.py:

# ip = "192.168.0.108"                     # for only one robot
ip = ["192.168.0.110", "192.168.0.108"]    # for multiple robots

How to Use

cmds = [
        Command.sit, Command.balance, Command.stepping, Command.pee,
        Command.stop
    ]

Dual Mode Bluetooth

Introduction

โมดูล Bluetooth เป็นโมดูลสื่อสารโปร่งใสมาตรฐานซึ่งส่งข้อมูลพอร์ตซีเรียลไปยังอุปกรณ์ที่เชื่อมต่อกับ Bluetooth

Connection with NyBoard

การเชื่อมต่อระหว่างโมดูลบลูทูธและ NyBoard แสดงในภาพด้านล่าง คุณจะต้องเสียบโมดูลบลูทูธเข้ากับช่อง 6 ขาบน NyBoard โดยให้ใส่ในทิศทางที่ถูกต้อง หลังจากเชื่อมต่อแบตเตอรี่กับ NyBoard ให้กดปุ่มบนแบตเตอรี่ค้างไว้เพื่อเปิดใช้งานหุ่นยนต์ หลอด LED บนโมดูลบลูทูธจะกระพริบแสดงว่ากำลังรอการเชื่อมต่อ

Connect the dongle with your phone

คุณต้องเชื่อมต่อดองเกิลภายในแอป Petoi เพื่อใช้งาน ไม่ใช่ผ่านการตั้งค่าบลูทูธของโทรศัพท์ของคุณ บางโทรศัพท์อาจต้องให้สิทธิ์ในการเข้าถึงบลูทูธและบริการตำแหน่งสำหรับแอปด้วย

Connect the dongle with your computer

ในการตั้งค่า Bluetooth ของระบบของคุณ ค้นหาชื่ออุปกรณ์ Bluetooth ที่เริ่มต้นด้วย Petoi หรือ Bittle และเชื่อมต่อ รหัส PIN สำหรับการจับคู่คือ "0000" หรือ "1234" หลังจากที่การจับคู่สำเร็จ ระบบจะกำหนดชื่อพอร์ตซีเรียลโปรต์ให้.

เมื่ออยู่บน Mac ให้ไปที่ System Preference -> Bluetooth ค้นหาชื่ออุปกรณ์ที่เริ่มต้นด้วย Petoi หรือ Bittle แล้วเชื่อมต่อกับอุปกรณ์นั้นได้เลยค่ะ

บนระบบ Windows ให้เพิ่มอุปกรณ์ Bluetooth ในการตั้งค่าระบบดังนี้

สำหรับผู้ใช้ Win10 ระบบจะกำหนด COM port ขาเข้าและขาออกให้กับบลูทูธ โปรดใช้ COM port ขาออก ("outgoing") และสำหรับรายละเอียดเพิ่มเติมโปรดดูใน "More Bluetooth options" ของ Win10 ดังรูปภาพต่อไปนี้:

หลังจากนั้น คุณสามารถเลือกพอร์ตนั้นได้ในเมนู Tools->Port ใน Arduino IDE โดยใช้วิธีเดียวกับกับ USB Uploader หลังจากเปิด Serial Monitor โปรดเลือก: No line ending และอัตราการสั่งโอนข้อมูล (baud rate) ตั้งไว้ที่ 115200.

การเชื่อมต่อ Bluetooth กับคอมพิวเตอร์อาจขาดหายได้บ้างครั้ง การเปิดอ่านข้อมูลผ่านซีเรียลมอนิเตอร์อาจช่วยให้การเชื่อมต่อมีความเสถียรขึ้น แต่โปรดทราบว่าการเปิดซีเรียลมอนิเตอร์จะเก็บพอร์ตไว้และบล็อกแอปพลิเคชันอื่นที่ต้องการเชื่อมต่อด้วยด้วย

Configure the Bluetooth module

ถ้าคุณต้องการกำหนดค่าโมดูลบลูทูธโปรดอ้างอิงไปที่ "JDY-23 AT Command List" ใส่โมดูลบลูทูธเข้ากับอินเตอร์เดบั๊กของแอดาพเตอร์ USB เช่นที่แสดงในรูปด้านล่าง:

คำสั่งที่ใช้งานบ่อยแสดงด้านล่างนี้:

Usage

Command

Demo

Check BT module version

AT+VER

AT+VER

>+VER=JDY-23A-V2.21,Bluetooth V3.0+BLE

(BT module version infomation)

Check BT broadcast name

AT+NAME

AT+NAME

>+NAME=BITTLE

Change BT broadcast name

AT+NAME(名字)

AT+NAMEPiggy

>+OK

AT+NAME

>+NAME=Piggy

Check serial baud rate

AT+BAUD

AT+BAUD

>+BAUD=8 (8 = 115200, 7=57600)

Change serial baud rate

AT+BAUD

AT+BAUD7

>+OK (Set serial monitor to 57600)

AT+BAUD

>+BAUD=7

เมื่อคุณใช้เทอร์มินัลซีเรียลเช่น "Arduino serial monitor" เพื่อตั้งค่า JDY-23 ด้วยคำสั่ง AT คุณต้องตั้งค่า "NL และ CR" และอัตราการส่งข้อมูล (baud rate) ต้องตั้งเป็น 115200 หรือโมดูล JDY-23 จะไม่รับรู้คำสั่ง AT ใดๆที่คุณส่งเข้ามา

ถ้าคุณเป็นนักพัฒนา คุณสามารถใช้ Lightblue หรือเครื่องมืออื่นๆ เพื่อเชื่อมต่อกับบริการ BLE ของ dongle ได้

Light sensor
Touch sensor
Gesture sensor
PIR motion sensor
MU vision sensor
Ultrasonic sensor
Grove - Sound Sensor/ Noise Detector
Grove - Light Sensor v1.2 - LS06-S phototransistor
Grove - Touch Sensor
Grove - Infrared Reflective Sensor v1.2
Grove - mini PIR motion sensor
Grove - Gesture Sensor for Arduino (PAJ7620U2)
Grove - OLED Display 0.96" (SSD1315)

Coding can be done in C-style language with the .

Bittle can be programmed with a Scratch-like web-based IDE . You may find some complementary materials: and .

Note that Codecraft doesn't support OpenCat 2.0. You'd need to use instead.

- a web interface to control Opencat-based robots

by the author leukipp

can control a few open source Robots, including Bittle.

โปรดอ้างอิงคำแนะนำของ และใช้ เพื่อเปิดโปรแกรมตัวอย่าง (ESP8266WiFiController.ino) เพื่ออัปโหลดเฟิร์มแวร์ควบคุม WiFi สำหรับโมดูล ESP8266

Install Python3, and download to control the robot.

อ้างอิงถึง ให้กำหนด IP address ของโมดูล ESP8266 ผ่าน WiFi และนำมาต่อกับบอร์ดหลักของหุ่นยนต์ หลังจากนั้นเมื่อเปิดเครื่องหุ่นยนต์แล้ว คุณสามารถใช้ python เพื่อรันสคริปต์ example.py เพื่อควบคุมหุ่นยนต์ได้ผ่านวิธีไร้สาย คุณสามารถปรับแต่งคำสั่งในสคริปต์ต่อไปนี้ (แก้ไขเนื้อหาของ list) ตามความต้องการจริงของคุณ เพื่อให้หุ่นยนต์ทำการแสดงพฤติกรรมต่างๆ ได้:

สำหรับคำสั่งการกระทำที่รองรับในปัจจุบันโปรดดูที่ไฟล์โค้ด actions.h(in ).

คุณสามารถอัพโหลดเฟิร์มแวร์หรือควบคุมการเคลื่อนไหวของหุ่นยนต์ผ่านการเชื่อมต่อบลูทูธได้ และคุณยังสามารถควบคุมหุ่นยนต์ผ่านแอปพลิเคชัน . บนสมาร์ทโฟนได้อีกด้วย และเราได้รวมโมดูลบลูทูธอย่างเป็นทางการของเราไว้ในชุดหุ่นยนต์มาตรฐานดังแสดงด้านล่าง:

ขั้นตอนการติดตั้งที่ละเอียดมากขึ้นสามารถพบได้ในส่วนของ .

Arduino IDE
Python API for sending serial commands
Codecraft
online help
curriculum
OpenCat 1.0
Inverse Kinematic Model OpenCat
a discussion thread
OpenCatWeb
a discussion thread
The Code & Robots iOS app
WiFi ESP8266
Arduino IDE
the Python scripts
the instruction
ESP8266WiFiController
Petoi
mobile app
Teach Nybble push-ups with one hand

Programmable Puppet Character

You may check a more detailed tutorial in the following post.

LogoRobot Dog Tutorial: Bittle vs Gummy Bear on HalloweenHackster.io
chapter 6 📐 Calibration
30MB
app-release-v1.0.5-17-1.apk.zip
archive
We keep updating the newest version here
29MB
Petoi-1.0.2.apk.zip
archive
The latest stable version in case of compatibility issues
2MB
newPanel.pdf
pdf
121KB
mpu6050-master.zip
archive
mpu6050-master.zip
21KB
gesture.zip
archive
571B
doubleTouch.zip
archive
602B
doubleLight.zip
archive
4MB
code & robots configuration.mp4
Calibration Interface
Calibration Interface
Bittle
USB serial port number
Bluetooth serial port number
Model
Language
Help
Main interface
Firmware Uploader interface
Nybble
Bittle
Align the upper leg first
Pay attention to the reference edges for the lower leg
Top side
Bottom side
23% of flash is used on UNO
Only 4% of flash is used on BiBoard
Nybble
Bittle
Device Manager
Key Settings of LED PWM Controller's API
Download ESP32 SPIFFS file system upload plug-in for Arduino IDE
"data" folder in the project directory
Create test sample file with Notepad
The SPIFFS image has been uploaded to the ESP32 board
Data structure
https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050
https://github.com/ElectronicCats/mpu6050/tree/master/src

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.

//#include "InstinctBittle.h" //activate the correct header file according to your model 
#include "InstinctNybble.h" 

1. NyBoard

1.1 Read the user manual

Find the version information for your board on NyBoard. As shown below:

Nybble

Bittle

Take NyBoard V1_0 as an example, as shown in the following figure:

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.

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

2.1. Install through the library manager

  • 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.

#define DECODE_RC5           0
#define SEND_RC5             0

#define DECODE_RC6           0
#define SEND_RC6             0

#define DECODE_NEC           1
#define SEND_NEC             0

#define DECODE_SONY          0
#define SEND_SONY            0

...
set zeros all the way down the list 
...

#define DECODE_HASH          1 // special decoder for all protocols

2.2 Install by adding .ZIP library

2.3. Add NyBoard support to Arduino IDE

With NyBoard V1_*, you can simply choose Arduino Uno.

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:

  1. Open the Preferences... panel

  2. 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.

  3. 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)

  4. Open the Boards Manager... window with the Tools -> Board: XXXX -> Boards Manager... menu item.

  5. In the Filter your search... field, type NyBoard

  6. Select the entry and click on Install

  7. Click on the Close button

  8. 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\

Linux

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.

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
## --------------------------------------------------
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
## --------------------------------------------------

code block in the Arduino Pro or Pro Mini section as below. 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
## --------------------------------------------------

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).

  • 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.

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).

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.

If you cannot find the serial port after connecting to your computer, you may need to install the driver for the CH340 chip.

2.6. Connect Bluetooth uploader (optional)

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.

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

  • 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.

For Linux machines, you may see the error message like "permission denied".

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:

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

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.

  • 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.

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:

  1. Run raspi-config with sudo privilege: sudo raspi-config.

  2. Find Interface Options -> Serial Port.

  3. At the option Would you like a login shell to be accessible over serial? select 'No'.

  4. At the option Would you like the serial port hardware to be enabled? select 'Yes'.

  5. Exit raspi-config and reboot for changes to take effect.

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 OS

  • disable 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):

KERNEL=="ttyS0", SYMLINK+="serial0" GROUP="tty" MODE="0660"
KERNEL=="ttyAMA0", SYMLINK+="serial1" GROUP="tty" MODE="0660"
  • reload your udev rules: sudo udevadm control --reload-rules && sudo udevadm trigger

  • change the group of the new serial devices:

sudo chgrp -h tty /dev/serial0
sudo chgrp -h tty /dev/serial1
  • The devices are now under the tty group. Need to add the user to the tty group and dialout group:

sudo adduser $USER tty
sudo adduser $USER dialout
  • update the permissions for group read on the devices:

sudo chmod g+r /dev/ttyS0
sudo chmod g+r /dev/ttyAMA0
  • reboot

Or just create a script that will do this automatically.

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

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.

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.

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.

Find the version info on NyBoard. Read the user manual for , , , or (a light revision) accordingly.

Find the version info on NyBoard. Read the user manual for or (a light revision) accordingly.

NyBoard V1_0 Top side
NyBoard V1_0 Bottom side

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 . 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+).

You will need the newest 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:​​ ). 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 code from GitHub after Jan 3, 2022, you can skip all the following libraries.

Go to the library manager of Arduino IDE (instruction: ), search and install

Go to , 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.​

Automatic method (many thanks to !)

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 .

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:

You can download my file, or:

● Download and put it in your Arduino folder ./bootloaders/atmega/. You should see other bootloaders with the .hex suffix in the same folder.

●

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 !

​

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:

It’s possible to program and communicate with Bittle wirelessly. You can even control Nybble / Bittle with a or from there!

We include our official 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.

For the specific connection method, please refer to of the Dual-Mode Bluetooth module.

Download the 1.0 ​OpenCat repository from GitHub:

NyBoard V0_*
NyBoard V1_*

The red can be 3D printed.

As shown in the , 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:

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 that can handle the serial communication between NyBoard and Pi.

You also need to DISABLE the to avoid repeating reset signals sent by Pi's GPIO 4.

4.2. Change the permission of

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 for the detailed connection instruction.

Read this to find batteries that work on Nybble.

NyBoard V0_1
NyBoard V0_2
NyBoard V1_0
NyBoard V1_1
NyBoard V1_0
NyBoard V1_1
forum post
Arduino IDE
https://stackoverflow.com/questions/16752806/how-do-i-remove-a-library-from-the-arduino-environment
OpenCat(sw 1.0)
https://www.arduino.cc/en/Guide/Libraries
jrowberg/i2cdevlib: I2C device library collection for AVR/Arduino or other C++-based MCUs
A-Ron
https://www.arduino.cc
https://www.arduino.cc/en/Main/Software
boards.txt
ATmega328_20MHz.hex
What is a bootloader?
Arduino as ISP
https://playground.arduino.cc/Linux/All/#Permission
Mac
Windows
smartphone APP
web API
Bluetooth dongle
the corresponding chapter
https://github.com/PetoiCamp/OpenCat/tree/1.0
Pi standoff
serial protocol
ardSerial.py
1-wire interface of Pi
A good tutorial on the Pi Serial
ardSerial.py
here
forum
post
Quick Software Setup Guide
https://github.com/me-no-dev/arduino-esp32fs-plugin/releases