Compare commits

...

3 Commits

Author SHA1 Message Date
16b569c49d docs 2025-04-23 13:27:51 +02:00
f5c2e0d7a6 images 2025-04-23 13:13:05 +02:00
5333816f44 docs update 2025-04-23 13:07:24 +02:00
3 changed files with 61 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

View File

@@ -29,7 +29,10 @@ Starting the project we used last years prototype as our starting point.
(Our robot already strapped with an Ultrasonic and a Time of flight sensor)
Dylan and I wanted to do the coding and electronics of the robot and Patrick and Irja took the designing and building part of the robot.
We realized quickly that we only had 2 ports left over because all other where in use by the arduino motor drive hat. These 2 ports that where left over where the I2C port SDA and SCL. So I thought let's use ToF sensors since you can hook up multiple on I2C. After some digging in the datasheet I found out that wouldn't work because whenever you assign a I2C address to a VL53X1L it would forget it next power cycle. So I thought: what if I used a multiplexer connected to all the XSHUT pins of the ToF sensor to turn them on one by one and assign them each their own I2C address on startup.
We realized quickly that we only had 2 ports left over because all other where in use by the arduino motor drive hat. These 2 ports that where left over where the I2C port SDA and SCL.
![alt text](image-14.jpg)
So I thought let's use ToF sensors since you can hook up multiple on I2C. After some digging in the datasheet I found out that wouldn't work because whenever you assign a I2C address to a VL53X1L it would forget it next power cycle. So I thought: what if I used a multiplexer connected to all the XSHUT pins of the ToF sensor to turn them on one by one and assign them each their own I2C address on startup.
![alt text](image-11.jpg)
Luckily we had the I2C multiplexer [PA9555](https://www.nxp.com/docs/en/data-sheet/PCA9555.pdf). So I used I2C for everything because I had limited pins. So I started designing a circuit.
@@ -500,4 +503,60 @@ So the main MCU would do all the thinking and readings from the sensors and the
}
```
So now I could send commands to the motors over Serial and see the motors spin in realtime. The command is structured like this. `1,500` Where 1 is the motor number and 500 is the speed of the motor. So like this I could control every motor separately.
So now I could send commands to the motors over Serial and see the motors spin in realtime. The command is structured like this. `1,500` Where 1 is the motor number and 500 is the speed of the motor. So like this I could control every motor separately.
## Using an ESPC6
Since we couldn't use the Arduino for any logic stuff we needed something else to talk to the arduino that's where the ESP came in to play. I only attached the Esp Tx to the Rx of the arduino because these 2 mcu's work on different logic levels and I was concerned that the arduino may fry the the ESP if it send anything back.
//TODO: add more docs
## Getting ultrasonic sensors to work (Again)
On the last day I tried to connect everything together. I first started out with one ultrasonic sensor but I noticed I wasn't getting any data from it. So I started debugging and only running the code necessary to get the sensor running but that also didn't work
??? Code
```cpp
int trigPin = D4; // Trigger
int echoPin = D9; // Echo
long duration, cm, inches;
void setup() {
//Serial Port begin
Serial.begin(9600);
//Define inputs and outputs
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
// The sensor is triggered by a HIGH pulse of 10 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
digitalWrite(trigPin, LOW);
delayMicroseconds(5);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read the signal from the sensor: a HIGH pulse whose
// duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
duration = pulseIn(echoPin, HIGH);
// Convert the time into a distance
cm = (duration/2) / 29.1; // Divide by 29.1 or multiply by 0.0343
inches = (duration/2) / 74; // Divide by 74 or multiply by 0.0135
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(250);
}
```
I double, triple checked every connection and grabbed new wires in case that was the issue. After a while a directly connected it to the mcu but that also didn't work and then I gave up.
![alt text](image-13.jpg)
After going to Henk and reading the datasheet he said I needed to use 5 volts instead of 3.3 volts
When I changed that connection it worked.