MKET

Man Keeping an Eye on Things. Look closely and you will see his right eye opens as his head rises.

My sister’s latest sculpture is called “Man Keeping an Eye on Things” or MKET for short. It is a man in a rocking chair, who, when motion occurs within his view, raises his head and starts rocking. Relative to the Ghost Elevator sculpture, this was from my point of view simple to animate. The head motion is controlled by an RC type hobby servo. Often for something like this I’d use a Robotic servo, but there were none available small enough to fit. Standard RC servos tend to be somewhat problematic for this type of application since there is no way to tell where they are. Their position is set by sending a pulse train where the width of the pulses tells it where to go. So the problem you have is when things first power up, you don’t necessarily know where the current position is and if it’s not where you first tell it to go, it goes there as fast as it can which looks bad and may break things.

However, there are now so called “digital servos”. They are still intended to be controlled with a pulse train, but they have the advantage of being able to be pre-programed with multiple parameters, including a soft-start and operating speed. It also turns out, that the same digital protocol used to program them, can be used to operate them, bypassing the whole pulse train control protocol. The problem is, the digital protocol is, somewhat oddly, not documented, but it is not hard to reverse engineer. I used a Hitec “D” series servo and a quick search of the web turned up a post by someone who had reverse engineered the protocol (I was surprised I could find only one person who had done this). He also discovered that the protocol was the same as that for servos produced by Robotro, a Korean company who’s products do not seem to be available in the US. The manuals they produce are in Korean, but it turns out, because the language of programming is English, much of the most useful part of the manuals are largely in English, so they are quite useful.

The digital protocol used is a simple asynchronous serial one in which the servo is controlled simply by reading and writing registers in the servo. This is pretty much like typical robotic servos. They invert the standard polarity of the UART and since they use one line for send and receive there is a somewhat time sensitive turnaround from send to receive, but this is not hard to deal with.

Of course the Hitec servos do deviate from the documents from Robotro. The strangest deviation is that while the Hitec servos contain a current position register and a set position register, and the current position register behaves as documented, the new position register does not use the same scaling the current position register (as one would expect) and the scaling, while linear, makes no sense.

For this project, I once again chose to use a Cypress PSoC5 microcontroller. I used this since it allowed me to reuse a lot of code from the Ghost Elevator. Also it was actually very cost effective, since Cypress sells a dev board with this processor (actually two of them, one is used to program the other) for $10 and it would be hard to get any other board mounted processor for this price.

The programable logic in the PSoC allowed me to handle the inverted serial logic and send receive turn around timing in hardware without any external logic which was very nice.

The PSoC allows the logic required for serial communication to be programmed into the chip, requiring no external circuitry.

In the circuit above, you will see two inverters, which handle the fact that the servo is using inverted logic. The mux avoids having the UART readback what is being sent, which is nice. The timer handles pulling the RX/TX line high after a read request.

The rocking motion in MKET is done using a stepper motor with “locomotive drive” to convert rotary motion to approximately sinusoidal linear motion. Once again I used a Trinamic stepper controller since these provide very quiet stepper operation. The trick here, is that you want the stepper to stop when the rocking chair is in its neutral position, other wise it can end up looking odd and tends to move suddenly to its neutral position when power to the stepper is removed. To handle this, the motor is equipped with a Hall effect index sensor, which provides a pulse once every revolution to the PSoC. When you want to stop rocking, a timer triggered by the index pulse is enabled. When it times out, it asserts a limit input to the motor controller, which soft stops the motor. By setting the delay appropriately, you can ensure the motor stops reliably in the neutral position. While all of this could be done is software, once again the PSoC allows it to be done totally in hardware.

The stop timer, programmed into the PSoC, allows the motor to be reliably stopped in the desired position completely by hardware.

As with the Ghost Elevator, I once again used FreeRTOS to build the software. This allowed a good deal of software reuse and also results in a design which is easier to understand and easier to modify. This time I also took advantage of the Bootloader system provided by Cypress. This will allow the firmware to be changed over the USB port on the processor without any special programming hardware. While not too likely to ever be used, I had plenty of programming space available and it might be useful if the firmware ever needed to be changed in the field. I will probably retro fit the boot loader to the Ghost Elevator at some point as well.

The electronics and drive motor are all mounted on the bottom of the base.
The head drive servo is just visible above the cutout. The drive linkage can be seen near the back running up to the head.