15 March 2012

Moving in a Shape: Basics of Bluetooth

Well, I decided to do some work on bluetooth messaging so that I when it comes time to real swarm algorithms and such, I won't have to keep referencing guides and stuff for how to send and receive messages. So, I designed this little program that, on the master:
  1. Opens a bluetooth connection with the slave.
  2. Runs a designated shape path (triangle, square, decagon, etc);
  3. Sends the total degrees turned by the right wheel (total encoder reading)
  4. Quits the program.
Meanwhile, the slave:
  1. Receives the encoder rotations
  2. Runs through a loop that does the number of turns and straight runs = to the number of turns encountered by the master which is sent to the slave
  3. Disconnects from the master
  4. Quits
Here's a little video:

Note: I realize the shapes aren't perfectly normal, and that the slave ends up in a different orientation than the master. I realized what was going on after I taped this, and I didn't feel like doing it again, but I will explain why. After each turn/straight, I had the master and the slave wait for 50 milliseconds, but I forgot to state motors A & B should be = 0, so there was a minor rotation error. Because the slave had a battery on max charge, it rotated more through those 50 milliseconds than the slave did, which had a mere 6.2 volts of battery. And there you have. An explanation for the discrepancy.

Here are some pics, in case you want to see how the robots are built:

Later on, I'll make a post on my Projects tab for this project. Until next time, then.

No comments:

Post a Comment