Wednesday, April 25, 2012

WALTR - Update

Project WALTR (Wireless, Apple II, Logo, Turtle, Robot)

WALTR is a Parallax Scribbler 2 (S2) robot that takes in direct action or interpreted Logo movement commands via a serial connection and executes them. Although I designed WALTR to be run from an Apple II computer any computer with a serial port and a Logo software package that supports serial communications can be used. WALTR can still be used as a Logo robot even without its pen lifter and Bluetooth enhancements.




Overview of how it works (once the S2 robot is programmed up):-

WALTR in Logo mode.

- Start up your favourite Logo software package. (Only a few Logo software packages are supported at the moment. Each package will most likely need a different WALTR.LOGO file)
- Load in the file WALTR.LOGO. (This file opens the serial port and overrides the turtle graphics commands. Each turtle graphics command will perform its original function as well as outputting the correct serial protocol information to the serial port.)
- Type in the Logo commands or load in and execute your favourite turtle graphics file.
- WALTR listens to the serial port and waits for a command. When a command is received eg "$70 $00 $C8 $13" WALTR will execute it. ($70 or "F" = forward command, $00 and $C8 make up the distance of 200 units and $13 = command termination.)

WALTR in Direct mode.

- Open a terminal program like HyperTerminal or Parallax-Serial-Terminal.exe. (Currently all devices are set to communicate using 9600 baud, no parity, 8 data bits and 1 stop bit)
- Type "2" to turn WALTR into Direct mode. (Typing "1" will revert it back into Logo mode.)
- Type the required command ie "a" (forward), "z" (back), "," (left turn), "." (right turn), [space] (stop) etc.
- WALTR listens to the serial port and waits for a command. When a command is received WALTR will start and continue that command until a new one is received.


Logo control.

Each version of Logo contains different commands for interfacing with the serial port. Each version also has its own quirks and Logo commands that it does not support. Therefore the example files for each Logo version are different. These are the versions I have covered so far:-

  FMSLogo (free Windows package)

  Apple Logo II by LCSI [1984]
  Apple Logo by LCSI [1983]
  Terrapin Logo V1.0 [1981]

WALTR is not an interpreter so it does not accept Logo commands directly eg "FORWARD 200" instead it accepts interpreted commands in a specific format which you can find in the protocol specification document. Currently the communications are in one direction, that is, to the robot. The problem with this is that Logo does not check to see if WALTR has enough buffer space to hold the sent command. The current buffer of 8192 bytes should be good for about 2000 commands. At some stage I plan to modify the communications protocol so that Logo can be informed as to when the robot is ready to receive information. This will allow WALTR to process an unlimited amount of commands.

In regards to the Apple II Logo versions, these needed a bit of work to get them going. I prefer using Apple Logo II because it is ProDOS based which means I can run it from the hard drive. Apple Logo and Terrapin Logo need to be run from floppy disks. These last two packages are screen based hence they only send out 7bits instead of 8bits per character. The robot code ie WALTR_r01.spin needs to be modified. I have provided a constant in the declaration section called FORCE_7BIT_DATA. This needs to be set to to TRUE if using WALTR with Terrapin Logo V1.0 or LCSI's 1983 Apple Logo. Terrapin logo V1.0 is the oldest of the Logo packages and the most difficult to work with. It does not support command overrides so new commands were created ie TPD instead of PD for Pen Down, TFD instead of FD for forward etc. It also does not support sending out the ASCII character $0 so a work around was required for this. When working with Terrapin Logo V1.0 the parameter TERRAPIN_V1 needs to be set to TRUE.

I have included instruction files and Apple II "dsk" files with the examples.


Direct control.

Direct control allows real time control of the robot. Direct control starts a robot movement then just waits for the next command. The robot keeps performing the command until a new command is issued. This allows WALTR to be controlled from a keyboard, mobile phone etc. The easiest way to control WALTR is to open a terminal program and just send the keyboard keystrokes. Alternatively I have provided a simple program showing how the robot can be controlled on an Apple II using a joystick. Again this program is screen based so the declaration FORCE_7BIT_DATA needs to be set to TRUE in WALTR_r01.spin.


Bluetooth issues.

The cheap Bluetooth modules that I purchased are specified to operate at 5V however the signal lines are still only 3.3V. There is a voltage divider on the back board however from my calculations it only reduces the signal by about 0.1 of a volt, nowhere near close enough to the 3.3V needed. Technically I should place some resistors on the module's RX line to protect it, but looking at other people's projects, this mostly goes unimplemented. These cheap modules seem quite tolerant of the higher voltage.

These modules have not stacked up as well as I had expected. The firmware on the modules has been programmed to use power saving mode. This feature places the module into sleep mode if no data has been received after a given amount of time (this is somewhere in the vicinity of 15 to 30 seconds). I found that I was missing characters during the time the module was coming out of sleep mode. I tried to disable this feature as per the manual but it did not work. I contacted the module manufacturer and they informed me that disabling of the power saving mode has not been implemented. To get around this issue I programmed a heartbeat into the communications driver ie a dummy character sent every few seconds to keep the modules from going to sleep.

For now the module is working, be it in a not so desirable way. I could try reflashing the firmware or desoldering it from the back board and replacing it with an alternate unit however if I had my time again I would probably try purchasing a more refined product like the ones from Sparkfun.

Wiring to the Bluetooth module was cleaned up and the Bluetooth module plug was hot glued to the robot's top casing. It's a nice clean fit and since the module is only attached by the plug I can easily replace it if required.




Serial to Bluetooth (for the Apple II).

I built a transparent container for the serial to Bluetooth module and constructed a plug that allows me to source 5V externally from the Apple II. The plug is just a straight through male to female DE-9 with the ground and 5V signals brought out. The plug gets attached to the Apple II's game port. The construction of the custom moulded plug allowed me to try a new product that I have had my eye on. The product is called Sugru. It's like Play-Doh but it sets hard after a day or so. Initially I thought that the product would set like concrete but I discovered that in fact it turns hard and has a rubbery feel to it like an eraser. That's not a bad thing. It makes it easy to trim with a hobby knife.


Custom moulded plug. Before and after adding Sugru.


Serial to Bluetooth converter attached to the Apple IIe and to the Apple IIgs.


Pen lifter.

I was lucky enough that several people have already constructed pen lifters for the S2 robot. It gave me plenty to think about. My inspiration came from these three implementations.
http://www.savagecircuits.com/forums/content.php?297-Episode-9-Pen-Lifter-for-Scribbler-Robots
http://forums.parallax.com/showthread.php?128367-S2-internal-Pen-Lifter-and-a-couple-questions-for-Phil
http://forums.parallax.com/showthread.php?138538-Advanced-S2-pen-lifter-kit

After doing some testing I found that just one paper clip bent in just the right way could be used to hold up the pen. I was able to get away with not having to modify the S2 casing. However since there is only a small gap of about 3mm to 4mm between the top and bottom sections it took me many attempts to get it just right. The current ring will support itself in the pen hole once the robot is put together but it takes some effort when joining the top and bottom sections.

The up and down movement is handled by a "NARO" sized servo motor. I wanted to build a container for the servo so that I could replace it if needed. I wasn't going to bother unless I could find a light weight and easy to construct solution. Sugru came to the rescue yet again. I was able to mould a casing and trim it after it hardened to get the end result, a perfect fitting glove. Adding to the servo holder a bent paper clip, some Velcro and an elastic strap makes it all hold together quite nicely. I am extremely happy with the result. Tuning the up and down positions is very easy. You can hear when the paper clip makes contact with the case. Small servo adjustments are required until this noise is reduced or eliminated.


The pen holder ring in this picture is one of the initial unsuccessful ones.



All the project files are contained here. https://docs.google.com/open?id=1-13822jXvuGfinGyO7wEAGmBtdWIGXIo

No comments: