The magic package

Dealing with electronics, I sometimes order stuff which gets shipped directly from the Philippines, Malaysia or somewhere else on the Pacific rim. Generally they get shipped by air and often arrive in a few days. Recently I ordered something that was shipped from Malaysia. It sat there doing nothing for a week and then suddenly FedEx said it had been delivered. I went and looked at the front door; no package, no footsteps in the freshly fallen snow and furthermore, the delivery time was several hours in the future. Furthermore, when I looked at the tracking detail, it had been put on a truck for delivery in Malaysia and somehow that truck had evidently made it to Rochester, NY USA in a few hours and the package had been delivered. I finally called FedEx and it seems that while it said it had been delivered, it had actually been returned to the sender. Checking the next day, it still said delivered (to Rochester), but the tracking history showed a different story. It has now made it to Taiwan. But the tracking history is kind of amusing and indicates FedEx needs to do a bit of work on its tracking history system.

Looking at this, one could conclude that my package briefly quantum tunneled from Malaysia to Rochester and back. Hopefully it is now on its way to Rochester for real.

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.

DRO completed

The interface and PSoC enclosure. The boards are held in place by fingers coming down from the top cover.

Some time ago, I blogged about a digital readout (DRO) I was working on for my Sherline mill. Work on the Elevator project caused that to go on hold, but I finally got back to it and completed it. Mostly, I needed to design and 3D print a case for the interface board and PSoC KitProg. As you can see in the photos, that got done and the whole thing is now complete. I like it a lot as it is much easier to see than the original Sherline unit. Only thing I don’t like is the way the cord is attached at the display unit. I need to modify and reprint the display case so the cord has better strain relief.

The completed DRO. Having the display separate from the main electronics makes it easier to place the display in a convenient location.

Elevator status report

My sister picked up the remaining two elevator shafts in early November. Since then she has been busily finishing the whole set of three. I saw them over the Christmas holiday and they are looking great. There are just a few more artistic features she needs to finish. Once it is done, hopefully I’ll be able to get some pictures and a video posted here.

One down, two to go

A few weeks ago I delivered the first completed elevator to my sister and picked up two more to automate. With warmer weather arriving, progress on these has been a bit slow. Also, there was a diversion. I had purchased a multi-process welder to replace my MIG welder and I needed to fabricate a new cart for it, since the multi-process welder will accommodate two shielding gas cylinders at once (one for MIG, one for TIG) and most carts only handle only one cylinder. Anyhow, the cart is now done, so progress on the two remaining elevators should get a little quicker.

The MIG welder I gave to my sister, along with a quick welding lesson. She turned out to be a natural welder and was making good looking beads almost immediately. In case you are wondering, there is in fact a welded part in the elevator: the bracket that fastens the belts to the counter-weight was TIG welded together.

The completed two cylinder welding cart, with only one cylinder. Actually, it is not quite complete, since the handle is not done yet. The other benefit over the previous cart is that it will hold my plasma cutter.

Elevator in Action

The Ghost Elevator continues to come together. Everything but the stuff in the car is working. The video shows it in action. Only the center door has a pointer, but the pointer motor is actually working on all three doors. It is a bit hard to see the figure in the car since the light is not implemented yet.

More Elevator Progress

The circuit boards for the elevator electronics came in a few days ago. Actually it was the third set, the first two attempts having fatal errors (don’t ask). The third set had only a minor error easily fixed by adding a wire. The board is now installed in the frame and I am wiring things up, testing and bringing up code. The wiring is somewhat tedious since there are a lot of crimp terminals to install.

The elevator electronics installed in the frame of the shaft. The three 12 wire cables go to the three doors.

At this point, almost everything is working (most of the time) with the exception of the floor indicators, which I’m holding off on until I get everything else working well. There have been a few glitches. One was that it would periodically get a call to the first floor all on its own. This was due to the relatively long cable run to the first floor door resulting in the PWM to the door stepper motor coupling to the call signal. This was fixed with some digital filtering which could be implemented in the PSoC CPLD. I also had a stepper driver board fail and the first one I replaced it with seemed to be DOA. The next one has been working so far, but there may be a QC issue with this board. The other issue is the second floor door is sometimes getting stuck, so the mechanics need to be looked at. Overall, things are going reasonably well so far.

The Elevator is coming together

A couple of weeks ago my sister came to visit and brought one of the elevator shafts and cars along with more door assemblies. We spent the weekend retrofitting doors with the new mechanism, but there was not time to get the car operating in the shaft while she was here. My first idea for driving the car worked fine, but I realized it had a potential drawback. The car is being driven with a stepper motor and a “GT2” timing belt. While the belt is operating well below is rated operating tension, if it should break it would be a disaster since neither the car nor the counter weight has a brake. I decided it would be a really good idea to use a double belt system, so if a belt broke, the other would prevent a crash. Between coming up with a double belt system and wiring up doors, it was only today that I got the car operating again.

The video shows the car in action. The doors are not operating yet since I am waiting for the circuit boards for the controller to be fabricated.

CNC Holes

As mentioned in previous posts, the Miniature Elevator needs a lot of precisely located holes and I decided to commission my CNC mill to drill them. I show here a movie of the CNC mill in action drilling elevator door carriage plates. The plates have eight holes each, but there are three size holes and also a spot drill operation so there are three tool changes involved (four if you count the first set up). Ideally, the mill would have an auto tool changer and each plate would be placed on the mill and it would then drill all the the holes changing bits as required. I don’t have that, nor do I even have quick change tooling, so tool changes are a slow operation. So it is faster to set up the mill with one bit at a time and swap all the plates through it, since it is faster to swap a plate than change a bit. So in the movie you will see first the mill doing the spot drilling of eight holes and then you will see four of the holes being drilled. The plate then requires two more passes through the mill to drill two more pairs of holes. In all, with 18 doors and 8 holes per plate, there were 144 holes to drill.

CNC mill spot drilling then drilling four of eight holes in an aluminum carriage plate.

The finished product may not look like much, but remember there are 18 of them and the holes on each one are probably within a couple thousandths of an inch of where they should be.

A finished carriage plate.