Monday, February 15, 2021

Encoders

 If I hope to be able to locate my robot, I need some sort of sensor, for it to know where it is. When I bought the chassis I decided to get something with encoders. 

Magnetic encoders work by sensing a change in magnetic field as a disk attached to the motor rotates. The type that I have is called a 2 phase encoder. 

 

 

 One ring represents signal A and the other represents signal B. Based on the positions of the rings the logic of the signals will tell me if my robot's wheels are going backward or forward.

The problem is that I have 4 motors, and each of them has an encoder. I am already using 3 wires per motor, just to drive them. And with the encoders I will need another 2 wires per motor. 

I can use the analog pins as digital inputs, but I am still a bit short. My hope was to use pins 0 and 1, but they are ties to the serial communications. So basically I can either talk to my raspberry pi or I can have these two pins. Great... 

Since I don't want to buy another bigger arduino, I found another solution. I can use a shift register! This device would allow me to power 8 pins as digital output, while only using 3 on my arduino. Luckily I have a 74HC595 chip laying around.

The pins that are driven by the shift register will technically react slower, but the delay is so small that it shouldn't be noticeable.

So next time I will need to figure out how to use that, put some of the motor pins on there, and plug the encoder into the digital pins that are now available.

Other than this minor hickup, I have gotten all of the encoders to report data. This is amazing news. With this done, I can start getting into ROS more and using the data from the encoders to control the robot.

Speaking of which, I have managed to get basic serial communication to happen between the raspberry pi and the arduino, I wrote a simple script, where the arduino spits out the position of the wheel and the raspberry pi can read it. Currently I am controlling the raspberry by via ssh, so I can read the output on my nice computer screen.

No comments:

Post a Comment

NEW Project Autonomous underwater vehicle!

  I have been more and more interested in Autonomous Underwater Vehicles and ocean exploration. I live on the coast with direct access to th...