summaryrefslogtreecommitdiff
path: root/debug
diff options
context:
space:
mode:
authorabel <abel.tim.t@gmail.com>2024-10-06 13:01:45 +0200
committerabel <abel.tim.t@gmail.com>2024-10-06 13:01:45 +0200
commit0e217de000f87bc134e6c3cfc2ca339220b195f6 (patch)
tree47ba45f7a1d38e5f8152cb63cc5368e1786db656 /debug
parentd816abac97cbec68cceb0707016ded09aaf670d4 (diff)
downloadrobotica-0e217de000f87bc134e6c3cfc2ca339220b195f6.tar.gz
robotica-0e217de000f87bc134e6c3cfc2ca339220b195f6.zip
dfgs
Diffstat (limited to 'debug')
-rw-r--r--debug/comm/deg_to_byte.py5
-rw-r--r--debug/comm/i2c/arduino_i2c_slave_1.py98
-rw-r--r--debug/comm/i2c/i2c_arduino_master/i2c_arduino_master.ino36
-rw-r--r--debug/comm/openmv_com.py13
-rw-r--r--debug/comm/seeed-teensy/readme.txt.txt3
-rw-r--r--debug/comm/seeed-teensy/seeed_uart/seeed_uart.ino9
-rw-r--r--debug/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino17
7 files changed, 29 insertions, 152 deletions
diff --git a/debug/comm/deg_to_byte.py b/debug/comm/deg_to_byte.py
deleted file mode 100644
index 196d4a5..0000000
--- a/debug/comm/deg_to_byte.py
+++ /dev/null
@@ -1,5 +0,0 @@
-deg = 40
-sbinary = format(deg, 'b')
-print(sbinary)
-binary = "".join(("01", sbinary))
-print(binary) \ No newline at end of file
diff --git a/debug/comm/i2c/arduino_i2c_slave_1.py b/debug/comm/i2c/arduino_i2c_slave_1.py
deleted file mode 100644
index 5957c5b..0000000
--- a/debug/comm/i2c/arduino_i2c_slave_1.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# This work is licensed under the MIT license.
-# Copyright (c) 2013-2023 OpenMV LLC. All rights reserved.
-# https://github.com/openmv/openmv/blob/master/LICENSE
-#
-# I2C with the Arduino as the master device and the OpenMV Cam as the slave.
-#
-# Please wire up your OpenMV Cam to your Arduino like this:
-#
-# OpenMV Cam Master I2C Data (P5) - Arduino Uno Data (A4)
-# OpenMV Cam Master I2C Clock (P4) - Arduino Uno Clock (A5)
-# OpenMV Cam Ground - Arduino Ground
-
-import pyb
-import ustruct
-
-text = "Hello World!\n"
-data = ustruct.pack("<%ds" % len(text), text)
-# Use "ustruct" to build data packets to send.
-# "<" puts the data in the struct in little endian order.
-# "%ds" puts a string in the data stream. E.g. "13s" for "Hello World!\n" (13 chars).
-# See https://docs.python.org/3/library/struct.html
-
-# READ ME!!!
-#
-# Please understand that when your OpenMV Cam is not the I2C master it may miss responding to
-# sending data as a I2C slave no matter if you call "i2c.send()" in an interrupt callback or in the
-# main loop below. When this happens the Arduino will get a NAK and have to try reading from the
-# OpenMV Cam again. Note that both the Arduino and OpenMV Cam I2C drivers are not good at getting
-# unstuck after encountering any I2C errors. On the OpenMV Cam and Arduino you can recover by
-# de-initing and then re-initing the I2C peripherals.
-
-# The hardware I2C bus for your OpenMV Cam is always I2C bus 2.
-bus = pyb.I2C(2, pyb.I2C.SLAVE, addr=0x12)
-bus.deinit() # Fully reset I2C device...
-bus = pyb.I2C(2, pyb.I2C.SLAVE, addr=0x12)
-print("Waiting for Arduino...")
-
-# Note that for sync up to work correctly the OpenMV Cam must be running this script before the
-# Arduino starts to poll the OpenMV Cam for data. Otherwise the I2C byte framing gets messed up,
-# and etc. So, keep the Arduino in reset until the OpenMV Cam is "Waiting for Arduino...".
-
-while True:
- try:
- bus.send(
- ustruct.pack("<h", len(data)), timeout=10000
- ) # Send the len first (16-bits).
- try:
- bus.send(data, timeout=10000) # Send the data second.
- print("Sent Data!") # Only reached on no error.
- except OSError as err:
- pass # Don't care about errors - so pass.
- # Note that there are 3 possible errors. A timeout error, a general purpose error, or
- # a busy error. The error codes are 116, 5, 16 respectively for "err.arg[0]".
- except OSError as err:
- pass # Don't care about errors - so pass.
- # Note that there are 3 possible errors. A timeout error, a general purpose error, or
- # a busy error. The error codes are 116, 5, 16 respectively for "err.arg[0]".
-
-###################################################################################################
-# Arduino Code
-###################################################################################################
-#
-# #include <Wire.h>
-# #define BAUD_RATE 19200
-# #define CHAR_BUF 128
-#
-# void setup() {
-# Serial.begin(BAUD_RATE);
-# Wire.begin();
-# delay(1000); // Give the OpenMV Cam time to bootup.
-# }
-#
-# void loop() {
-# int32_t temp = 0;
-# char buff[CHAR_BUF] = {0};
-#
-# Wire.requestFrom(0x12, 2);
-# if(Wire.available() == 2) { // got length?
-#
-# temp = Wire.read() | (Wire.read() << 8);
-# delay(1); // Give some setup time...
-#
-# Wire.requestFrom(0x12, temp);
-# if(Wire.available() == temp) { // got full message?
-#
-# temp = 0;
-# while(Wire.available()) buff[temp++] = Wire.read();
-#
-# } else {
-# while(Wire.available()) Wire.read(); // Toss garbage bytes.
-# }
-# } else {
-# while(Wire.available()) Wire.read(); // Toss garbage bytes.
-# }
-#
-# Serial.print(buff);
-# delay(1); // Don't loop to quickly.
-# }
diff --git a/debug/comm/i2c/i2c_arduino_master/i2c_arduino_master.ino b/debug/comm/i2c/i2c_arduino_master/i2c_arduino_master.ino
deleted file mode 100644
index ff960ed..0000000
--- a/debug/comm/i2c/i2c_arduino_master/i2c_arduino_master.ino
+++ /dev/null
@@ -1,36 +0,0 @@
-#include <Wire.h>
-#define BAUD_RATE 19200
-#define CHAR_BUF 128
-
-void setup() {
- Serial.begin(BAUD_RATE);
- Wire.begin();
- delay(1000); // Give the OpenMV Cam time to bootup.
-}
-
-void loop() {
- int32_t temp = 0;
- char buff[CHAR_BUF] = {0};
-
- Wire.requestFrom(0x12, 2);
- if(Wire.available() == 2) { // got length?
-
- temp = Wire.read() | (Wire.read() << 8);
- delay(1); // Give some setup time...
-
- Wire.requestFrom(0x12, temp);
- if(Wire.available() == temp) { // got full message?
-
- temp = 0;
- while(Wire.available()) buff[temp++] = Wire.read();
-
- } else {
- while(Wire.available()) Wire.read(); // Toss garbage bytes.
- }
- } else {
- while(Wire.available()) Wire.read(); // Toss garbage bytes.
- }
-
- Serial.print(buff);
- delay(1); // Don't loop to quickly.
-}
diff --git a/debug/comm/openmv_com.py b/debug/comm/openmv_com.py
deleted file mode 100644
index d5a3faf..0000000
--- a/debug/comm/openmv_com.py
+++ /dev/null
@@ -1,13 +0,0 @@
-import time
-from pyb import UART
-
-# UART 3, and baudrate.
-uart = UART(3, 19200, timeout_char=200)
-location = "40" #place to put the goal location
-while True:
- uart.write("s")
- uart.write(location)
- uart.write("e")
- if uart.any():
- print(uart.read())
- time.sleep_ms(1000)
diff --git a/debug/comm/seeed-teensy/readme.txt.txt b/debug/comm/seeed-teensy/readme.txt.txt
new file mode 100644
index 0000000..ef9f996
--- /dev/null
+++ b/debug/comm/seeed-teensy/readme.txt.txt
@@ -0,0 +1,3 @@
+serial communication between two Seeed Studio XIAO SAMD21 and one teensy.
+Teensy Serial 2 and 3 on read
+Seeed XIAO SAMD21 write a 8 values on Serial1 between 0-10000 (pulses from IR sensor) every 0,25 seconds. For example 100 pulses in 1 second = 00025
diff --git a/debug/comm/seeed-teensy/seeed_uart/seeed_uart.ino b/debug/comm/seeed-teensy/seeed_uart/seeed_uart.ino
new file mode 100644
index 0000000..32750de
--- /dev/null
+++ b/debug/comm/seeed-teensy/seeed_uart/seeed_uart.ino
@@ -0,0 +1,9 @@
+void setup() {
+ Serial1.begin(9600)
+
+}
+
+void loop() {
+ Serial1.println("/D:00025:/E");
+ delay(250);
+}
diff --git a/debug/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino b/debug/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino
new file mode 100644
index 0000000..684c199
--- /dev/null
+++ b/debug/comm/seeed-teensy/teensy_uard_read/teensy_uard_read.ino
@@ -0,0 +1,17 @@
+void setup() {
+ // Initialize Serial1 with a baud rate of 19200
+ Serial1.begin(9600);
+ Serial.begin(9600); // Initialize Serial for debugging
+}
+
+void loop() {
+ // Check if there is any data available to read from Serial1
+ if (Serial1.available()) {
+ // Read the most recent byte
+ byte byteRead = Serial1.read();
+ // Echo the value that was read
+ Serial1.write(byteRead);
+ // Print the received byte for debugging
+ Serial.print((char)byteRead);
+ }
+}