Sunday, 27 July 2014

My NodeBots Melbourne Experience

I'd been looking forward to NodeBots all week, and although I wasn't quite at the not being able to sleep stage, there was absolutely no chance that I'd wake up late on Saturday. The day was definitely not a disappointment!

Myself and a bunch of other people waited patiently outside the The Village @ NAB (an awesome space by the way) until the friendly security staff would let us in the doors a little before 10am. The checkin process was easy, and before we new it @dtbolger and I had our Robo Hacker Kits and were checking out all the wires, plastic pieces, and electronics (including an arduino nano) we had. I don't know about everyone else, but I had absolutely no idea to where to start.

Luckily, by the time I got to that point @ajfisher gave a very nice intro to the day, and then Hadi gave a great presentation on getting started with electronics which I found very useful.

I then went back to my laptop and cloned the simplebot repository locally and quickly realised I had no idea how to perform the "Flashing my arduino" step. One of the experienced mentors helped us out by pointing us at the Arduino app (which we already had installed). The steps that were required were:
  1. Open Arduino
  2. Menu -> File -> Open
  3. Browse to the simplebot repo that you cloned earlier and select the file SimpleBotFirmata/SimpleBotFirmata.ino
  4. Click Open
  5. Menu -> Tools -> Board -> Arduino Nano (I had 2 options and had to select the w/ ATmega328)
  6. Plug the Arduino into your USB port if you haven't already
  7. Menu -> Tools -> Serial Port -> /dev/tty.usbserial.XXXX
  8. Click the Tick button in your SimpleBotFirmata Arduino window
  9. Click the Right Arrow button right beside the Tick button once the compile is completed
In order to test that it all worked, I plugged in all the wires according to the example located within the simplebot repo at ./examples/wiring/basic_wiring_bb.png, and then opened a terminal window to ./examples and ran "npm install" followed by "node simplebot.js".

The first thing I noticed that one of my servos worked and the other didn't. After a bit of head scratching, I found that I had plugged the servos into the pins d8 and d9, yet in the simplebot.js file I was referring to pins d9 and d10:
var left_wheel = new five.Servo({ pin: 9, type: 'continuous' }).to(LSTOPVAL);
var right_wheel = new five.Servo({ pin: 10, type: 'continuous' }).to(RSTOPVAL);
So I moved the wiring on the breadboard so I was connected to pins 9 and 10 and everything worked perfectly! Needless to say, I was pretty excited at this point, now I just had to strap the simplebot together and get it running all over the floor.

The next thing that confused me was how to hook the wheels up to the servo. What was needed was to cut 4 lengths (15-20cm) from the wire included in your kit, and thread them around another bit of plastic and the wheel (similar to threading a button), until it looks something like:
I set up the rest of the board until it looked like so:
I plugged in the battery pack, attached the wheels, and I was off and racing. One thing I'd recommend, is that you attach the nub/dome thing at the front (underneath the base at the bottom end of previous picture) before sticking the breadboard to the base. I didn't, and my breadboard was partially covering the hole I needed to use to screw the nub/dome to the base board.

I extended my bot slightly by using the ultrasonic sensor to stop the simplebot if it got closer than 20cm to an object. I also added an emergency retreat that would cause the bot to back away if it was closer than 5cm to anything. This was a bit of fun, but meant that my simplebot was terrible at soccer as it kept running away from the ball :-D


No comments:

Post a Comment