Project lab 8 - Bluetooth communication and more Distributor

Date: 11/06/2013
Duration of activity: 09:00-23:45 --> 14 hours and 45 minutes
Group members participating: Ole Rasmussen and Kasper Føns

1. Goal

The goal of this lab sessions is to:
  • Add the AxleSorter to the BeamCounter-Loader system.
  • Create a communication link between the different submodules using Bluetooth.
  • Build the distributor bridge.

2. Plan

Our plan is foe one of us to work on adding the AxleSorter to the system and code the communication layer, while another builds the platform and begins experimenting with moving on it.

3. Adding the AxleSorter

As described in project lab 7 we wanted to add the AxleSorter to the Loader-BeamCounter system. The AxleSorter and BeamCounter where originally run by two different NXTs. This is the hardware configurations:
  • BeamCounter
    • Two motors
    • Two NXT lightsensors
  • AxleSorter
    • One motor
    • Two RCX lightsensors
As can be seen from this one NXT should be enough. However, we were unsure if one NXT could sense both light sensors fast enough to register both beam holes and the time an axle was between the sensors. We tested it by running two threads with small timeouts and it worked fine. We therefore integrated the two NXT's into one, which we will call Sorter.

The combined system can be seen in Figure 1. The right NXT controls the AxleSorter and BeamCounter while the left NXT controls the loader subsystem.
Figure 1: Our system with BeamCounter and AxelSorter (now in one NXT called Sorter) and the Loader.

4. Communication system

We want to build a communication system with one master. From our lab report "Week 12 - Endcourse Projects" we found that an NXT can have three outgoing Bluetooth connections or one incoming. The loader will be the master and will handle all communication between modules. It should function like this:
  1. Connect to sorter and distributor
  2. Tell sorter and distributor to start up
  3. Keep running conveyor belt until brick is received
  4. Receive brick information from the Sorter
  5. Wait until distributor sends ready
  6. Eject the item into the distributor
  7. Give the distributor information about what brick it received
  8. Return to step 3

4.1 Setup

Before Bluetooth communication can be made, the NXT's need to have been paired together. We paired the loader with both the distributor and the sorter. When the distributor and sorter starts up, they will wait for the loader to connect to them. When a startup message is received the sorter will start its conveyor belt and the distributor will move to its initial position.

We created a class called Communicator which encapsulated the Bluetooth communication by allowing users to send or receive specific packets. One problem we had, was that we were sending an enum value (BrickType: Beam or Axle) back and forth between the systems by converting it to a string and back again. Apparently leJOS has not implemented the valueOf method on enums. That method is responsible for converting a string into the equivalent enum value. However, the leJOS implementation just threw a RuntimeException, so we had to implement our own string to enum conversion.

We made a test setup where the sorter would send an axle or a beam to the loader, which would receive a LegoDescription packet, eject the brick into the distributor which would be forwarded the LegoDescription and would then open the gate and release the item. We have reconstructed the test using our final system so that a video could be shown. The video is shown below.


5. Distributor Bridge

We need to construct the distributor bridge which the car controls and sits on top of the distributor platform. The platform needs to be as lightweight as possible, since it needs to be able to move, but it also needs to be robust, since the car on top of it is pretty heavy (one NXT, two motors and the distributor tray).

We used the experiment track developed in project lab 5 as a starting point. The car already fitted on top of it and it have already been tested. We needed to enable it to move as opposed to being stationary. The first thing we did was to add gears as wheels to the bridge, they can be seen in Figure 2. The larger gears have traction on the distributor platform while the smaller wheels are used to transfer motor power from one side to the other.

Figure 2: Our "wheels" for the distributor bridge. The axle that points outwards should somehow be connected to a motor. There is no gearing used, the gears are only used to transfer power from the left side to the right. The top picture shows the system from above while the bottom picture shows it from below.
We added such a "wheel" to both sides of our distributor bridge, one on each side. Our distributor car already uses two motors, one for driving its own wheels and one for controlling the car tray, which means only a single motor port is available for controlling the distributor bridge. We added a motor half-way on the bridge and assembled many axles into one large axle (as seen on Figure 3). Having two such long axles introduced a lot of clearance in the system and it made it very imprecise, not to mention that it didn't look well in action.

Figure 3: Very long axle assembled by many small axles and the red extension parts.
Instead of using the long extended axles we created our custom axles using beams. Figure 4 shows our custom beams attached to the motor on the distributor bridge. Figure 5 shows the bridge with two custom axles on top of the distributor platform together with the distributor car.

Figure 4: Custom axle constructed using Lego beams. This system was much more robust and reduced clearance considerably.
Figure 5: The complete distributor bridge with our custom axles. The car can control it using the motor in the middle. The platform is visible on the left side.

5.1 Toothed bricks on distributor platform

We tested the system by making the bridge go back and forth. We had used some larger toothed gears (to save on the few smaller ones that were left), but we found that sometimes the bridge would wobble on top of them. We believe this might be caused by the sheer weight that was coming from both the distributor car and bridge. Exchanging the toothed bricks solved the problem. See Figure 6 for what bricks we exchanged. 
Figure 6: Exchanging the toothed bricks that we used from one type to another. We had used the ones in the top of the figure to save the ones on the bottom, since there were few of them left.
We have now constructed all parts of the distributor system. What is left is the software. 

6. Conclusion

We have integrated the AxleSorter and BeamCounter into one, now called sorter and only used one NXT for it. We have completed the communication layer and used it in both the loader, sorter and distributor.
We have also completed work on the distributor bridge, completing all construction work on the distributor parts.

7. Next lab

We need to code the distributor such that it can deliver a Lego brick to the correct tray compartment. Since we are now done with the sorter and loader, we also have time to take a second look at the down-prioritized feeder subsystem.