Automated Docking Using IR.
by kiran_sreekumar in Circuits > Raspberry Pi
738 Views, 1 Favorites, 0 Comments
Automated Docking Using IR.
I've been working on a remotely driven vehicle for a while (Naah.. I did it a year back but found time to put it here now :P). Controlling the robot over the internet meant an unavoidable delay. I made a dock/charging station for it to park for recharging its battery. However, it was proving really difficult to do it manually, with the delay. The bigger picture when I started working on the project was assisted driving. But being an electronics enthusiast (and lazy to start with AI back then), I thought it'll be fun to do it with some good old circuitry and a dark magic algorithm.
What's covered in this Instructable are:
Part A: The Transmitter : An IR transmitter that produces IR signals flickering at 5KHz. This will be part of a charging dock for the “Telebot” project, acting as a beacon system to aid in aligning the robot with the dock during the auto-docking process. The design utilizes a 555 timer in astable configuration to drive an array of 5mm IR LEDs which are to be placed at the center of the charger.
Part B: The Receiver : The design is for 2 receivers which are to be placed at the front and the back of the machine respectively. The system will look for the 5KHz signal sent from the dock and will signal the Raspberry Pi when detected (perfectly aligned).
PS: I'm unable to share the 500000IQ docking station design or a video of it working cos I designed it for a company. Sike!
Supplies
For the Transmitter:
- 555 timer IC 1
- 5MM IR LEDs 6
- RESISTORS 56ohm 2
- RESISTOR 1K ohm 1
- RESISTOR 10K ohm 1
- RESISTOR 470ohm 1
- IRLZ44N Mosfet 1
- CAPACITOR 103 2
- RMC MALE 2PIN 2.54 2
- RMC FEMALE 2PIN 2.54 1
For the Receiver:
- LM324N OP AMP IC 1
- 5MM IR RECEIVER DIODE 6
- RESISTOR 4.7K 4
- RESISTOR 470K 2
- 10K POT(MULTIPLE WINDING) 2
- CAPACITOR 100uF 25V 2
- CAPACITOR 104 2
- RMC MALE 2PIN 2.54 2
- RMC FEMALE 6PIN 2.54 2
- 3D PRINTED LED HOUSING 2
Part A: the Transmitter
Let's start with the transmitter.The idea here is fairly simple, we need an IR-Led arrangement that can transmit in all directions from which the vehicle can approach the dock for charging. So, this part is for the charging dock.
Setup the Emitter LED Array
I made a simple setup for the 6 IR LEDs, held together by the magical power of solder alone, for testing. You could always make print a proper holder for it. Never bothered because this kindof worked for me. Note that i have used two resistors in parallel to avoid heating. O1 and O2 are the inputs.
The Driving Circuit
Note: C=103, R1=1k, R2=10k
P1: i/p from the power supply (12v) P2 :o/p to the LED array
“O1” and “O2” are the black and the red wires respectively, of a two pin female RMC (P2). This will be the output to the LED array, which we wired up in the previous step.
This is a fairly straight forward square wave generator using 555 timer. I soldered it on a small piece of PCB. I've used a MOSFET for driving the current that we need. It is also better to add a pull-down resistor to the gate of the MOSFET. I'll update with a proper PCB layout later. This works flawlessly though.
Putting It Together
- Place the LED array at the center of the dock (where you want the vehicle to approach)
- connect the driver circuit to the led array and then connect power to the driver circuit. (with a female rmc from power supply)
- ideally place the driver somewhere inside the charger casing.
Part B: the Receiver
This is the part that goes on the mobile robot, to receive the signals. Ideally we need to be able to detect the charging station from the front as well as the back of the robot (cos why not). Therefore, we need to make two sets of receiver LED arrays and one circuit to read the two signals.
The tricky part here was avoiding the ambient light changes and changing intensity of beacon signal (with distance) , from affecting out readings.
The Receiving LED Array
I ended up using 3 receiver LEDs per receiver array cos I'm rich (cries in poverty). Simply put, 1 LED to read the signal, another one to read ambient light and yet another one to sense the scale/magnitude of both (to control sensitivity). It's definitely more complicated than that, but this is one way to understand it.
I 3D printed two housings for the arrays so that they fit nicely on the robot (front and back). I directly used the LED pins to connect to a 6 pin female RMC coming from the magic circuit. (It was convenient. I'm not lazy).
- Push in 3 IR-receivers each, into the two 3D printed housings as shown in the image. Take care to align the pins and take care of the polarity of the LEDs as shown in the diagrams above. I also used some foam to hold the LEDs in place , whilst making it light proof from behind.
- the RMC shown in the image is from the magic circuit.
The Magic Circuit
This is the crux of this project. And yes, I haven't made a proper PCB design file. But here's an amazing hand drawing.
P11 through P16 are the wires from first RMC (array at the front of robot) and p21 through P26 are wires from second RMC (array at the back of robot)
This looks overly complicated. I really will upload a design file soon.
It needs to be powered by a 5v source and the "output to reader" RMC is where the output is read. the two pins here are for front and back sensors. Pardon my sketching skills.
Testing
once its all wired up, connect the two output pins to any two GPIO pins of the RPi.
My setup was an RPi zero and I used an i2c based GPIO extender (mcp23017). You can replace the first part of the code with normal GPIO pin assignment.
Here's a simple test code for initial testing sessions.
Test code:
from lib_mcp23017 import MCP23017
import time
import RPi.GPIO as GPIO
fpin=0 #pin for the front array
bpin=1 #pin for the back array
#the part below is for the i2c pin extender
print("")
if GPIO.RPI_REVISION > 0:
from smbus import SMBus
i2cbus = SMBus(1) # SMBus(0) or SMBus(1) depending board revision
resetPin=0
else:
i2cbus = GPIO.I2C()
resetPin = 0
GPIO2 = MCP23017(GPIO, i2cbus, 0x20, resetPin)
if not GPIO2.found:
print ("MCP23017 on %s not detected, or not reset properly" % hex(GPIO2.addr))
GPIO2.setup(fpin, GPIO.IN)
GPIO2.setup(bpin, GPIO.IN)
#test code begins here. Ctr+z to break
while 1:
k=5 #tweak this
inpf=1 #initiate both as triggered (on)
inpb=1
while k: #we look for 5 consecutive non zero readings
if GPIO2.input(fpin)==0:
inpf=0
if GPIO2.input(bpin)==0:
inpb=0
k-=1
# time.sleep(0.1)
if inpf:
print ("front triggered!!!!!")
elif inpb:
print("back triggered")
else:
print("nil")
# time.sleep(1)
Automatic Parking
The rest is algo black magic. You can find the code on my GitHub.
https://github.com/EvilChang/ir_beacon/upload/main
Worship Me
Just kidding. Anyway, it's my first post here. I hope someone finds this helpful. Please feel free to shoot any doubts. I'm planning to be active here.
Well then... Cheers!