Wednesday, March 9, 2016

Modifications to a kids' electric scooter

Last summer my mother-in-law found an kids' electric scooter in the free section of a local thrift store. It was lacking a seat and a battery. Back then I quickly made a new seat by laminating sheets of polyethylene plastic together, and also hacked up a battery from my airplane lithium batteries and a DC-DC buck regulator. It was driven almost daily throughout the summer, until it had to be taken inside in the fall.

It was obviously not really designed to be an outside toy, as was evident from the decay of all the decal stickers from just one summer outside. We don't have the space play with it inside though, so it shall remain an outside toy. However, while I had it in for the winter I decided to clean the whole thing. It was already dirty from the thrift shop in addition to a summers worth of daily play. I took the whole thing to pieces and washed everything carefully. This made it look almost band new, but I also wanted to update some functionality.

The scooter originally just ran current through a foot pedal switch directly from the battery to the motor. This is quite hard for the transmission as there is a huge torque spike when the pedal is pressed. It also requires connecting and disconnecting quite large DC currents through an inductive load. This has left quite clear marks on the contact surfaces inside the pedal. Without any speed regulation, the scooter runs slow uphill and fast downhill. Finally, there is no reverse implemented, which together with the rather large turning radius causes problems in tight corners.

I wanted to address all of the problems through an electric speed controller. The speed controller can either limit the current through the motor to an acceptable level, or it can start the motor up more slowly. In both cases limiting the amount of torque through the transmission. Also proper driving of the motor ensures that current is continuous and hence no arcing will occur. Finally, implementing velocity feedback control allows the scooter to run at constant velocity.

I didn't want to add any sensors to read the motor velocity, so I had to do some reading on sensorless motor velocity feedback control. The main idea is that when the motor is turning without current flowing, the motor acts as a generator producing a voltage proportional to the velocity. The only downside is that in order to measure the velocity, we have to cut power to the motor and wait some time for the magnetic energy in the motor to dissipate. The time it takes for the energy to dissipate is also strongly dependent upon the velocity of the motor (which could be used as a secondary velocity measurement as well).

After some bread boarding of the technique I designed and etched a PCB to put everything on. To keep things simple I implemented the drive using a single N-channel MOSFET, while the reverse function is achieved through a DPDT relay. I went with a silicon diode for the freewheel diode instead of a Schottky one. This is a trade-off between efficiency and the time the motor takes to demagnetize. A Schottky diode would be more efficient, but it would take some time longer for the magnetic energy in the motor to dissipate than with a silicon diode. Also, I had silicon diodes capable of handling the current already lying around. The layout of the motor controller is shown in the figure below, while the schematic is available here.

Layout of the motor controller, view from the top side. Nothing special. Mixed through-hole and surface mount components. Footprint of the relay coil drive transistor is inverted... So don't use this layout directly. I had to bodge the part upside down, as I was too lazy to re-do the board.
These new features also needed new interfaces. As the electronics will be running even if the pedal is not pressed, a power switch needed to be installed. Although the electronics could be designed to be very very low power, just the concept of an ignition key is cool which my oldest son found very exciting.

My oldest son showing the position where he wants the ignition lock to be mounted.

The ignition lock in position.
As the scooter will have a new reverse feature, a switch is needed to choose the direction. The switch also includes an indicator light to show when the ignition is turned on.

Direction switch mounted. My son in the background supervising my work.
What was also lacking previously was any kind of fuse. This would not really be a problem if the only components in the system are a lead-acid battery and a motor, but with the buck converter and a lithium-ion battery there was a non-zero probability of an electrical fire. In fact, the lithium battery was never really meant to be anything else than a quick hack to get it going, but I never got into replacing it with something better suited. For this upgrade, however, I got a sealed lead-acid battery and added a 5A circuit breaker. 5A should be enough for normal operation, but also low enough to protect the battery and the wiring.

Connecting power wires. The black block at the back is the 5A circuit breaker. The reset button of the circuit breaker is accessible through the underside of the scooter.

A better view of the inside compartment, showing the speed controller board. The motor is just dangling from the wires for testing. The off-white part in the compartment is the gearbox to which the motor connects.

Flashing the software. The speed controller is seen dangling from the wires. The scooter is too large to comfortably fit in my hobby room, so all of this was done in the living room and on the dinner table.
Taking it for a test spin. Works great!
The biggest requests by my son still has are to get flashing lights and a police siren. So those will be up next. He also wants a speedometer, which I think I'll do some time later using a 128x64 graphics LCD module I've had waiting to be purposed for something.

Tuesday, March 8, 2016

Changing the color wheel on my DLP projector

One evening, just as we were about to turn off the projector, it made a horrible glass breaking sound and the picture went black and white. My first reaction was, that the lamp exploded, but realized a second later that the picture was still there. Only the colors were gone. Obviously it was the color wheel that had disintegrated. The reason for it failing is unclear, as the projector is mounted on a solid concrete wall isolating it from most vibrations.

I contacted the manufacturer to obtain a replacement part, as it is not sold as a standard replacement part. Their Finnish representative replied that they only sold the part together with servicing. They also said that it would cost 60e to do an estimate of the cost of repair. Ugh. I didn't want a service, I wanted the part. I would have happily paid 100 euros or more for the part. No wonder the Finnish economy is in crisis. I would have wanted to buy, but no-one wanted to sell.

So, since the official source didn't want to sell the part to me, I had to look at alternatives. Turns out there are very helpful eBay stores, which sell all sorts of parts for projectors. I found the correct part for about 30 euros and decided to pay some more for expedited shipping through DHL. So for about 70e all together, I got the part shipped to me.

I had checked online how the repair was done before ordering the part. The whole process is very trivial. The whole assembly is removed and the motor removed from the assembly. The new motor with the new color wheel is then put in and the assembly reattached.

The color wheel assembly. I had already removed the old motor and the glass shards from the old color wheel when I took this photo.

Second view of the color wheel assembly. I had already removed the old motor and the glass shards from the old color wheel when I took this photo.

The old motor. No pieces of the color wheel are left. It got completely destroyed.

New motor with the new color wheel attached.

New color wheel fitted in the color wheel assembly.

Sunday, February 21, 2016

Bluetooth adapter for UNI-T UT61E multimeter

This is a useful little project I did already quite some time ago. Since it may be of interest to some people I want to write something about it.

My UNI-T UT61E multimeter has a data out port, which can be used for data logging on a PC. The meter comes with a data cable to connect it to a RS232 port. This has two problems. RS232 ports on computers are quite difficult to come by these days, and even if you have an RS232 port, you have to have a cable connecting the meter to the PC. UNI-T sells a USB cable to get around the first problem, but you still are limited by the cable length.

For my own solution I wanted to go wireless using Bluetooth. I had a spare Bluetooth serial port module laying around, which was suitable for the job. First thing to do was to check how to interface the UT61E. I found the schematic of the RS232 cable at http://blog.avrnoob.com/2014/03/uni-t-ut61e-rs232-serial-interface.html. I've recreated the schematic here. The author of that other blog modified the RS232 cable to interface it with a USB low level serial adapter. I however wanted to use the cable unmodified.

Schematic of the UT61E RS232 adapter.
The data transfer from the UT61E is optoisolated using an IR led in the UT61E and a phototransistor in the adapter. The circuit in the adapter works as follows. If there is no light transmitted from the multimeter, D1 will not sink current. Q2 will thus be in cut-off and its collector will be pulled to -12V. No current thus flows on the base of Q1 and hence R3 pulls RxD to -12V. However, if light lands on D1, it will sink current through the base of Q2. Thus Q2 turns on and the voltage on its collector rises to near +12V. Q1 then acts as an emitter follower pulling RxD near +12V. On RS232 the logic levels are such that negative voltage is a 1 and positive voltage is a 0. Thus, when the UT61E wants to transmit a 1 it turns the IR off and when it wants to transmit a 0 it turns the IR on.

The bitrate at which the multimeter operates is rather slow at 19200 bps (actually 19230 bps to be exact). This allows a lower voltage than 12V to be used and still have the RxD swing quickly enough. In fact, connecting the -12V line (RTS) to GND and the +12V line (DTR) to 5V still produces good output.

Even if running at 5V, as described above, the RxD line still can't be directly fed into the Bluetooth module. Firstly, the module uses 3.3V logic and is not 5V tolerant. Secondly, the polarity is inverted to what the module is expecting. However, both of these problems can be solved using a simple level shifting inverter as shown in the schematic below.

Simple adapter to connect the UT61E serial cable to a Bluetooth module.




I had already made a carrier board for the Bluetooth module I used. These can now be bought online for cheap, and I wouldn't bother to roll my own anymore. I've omitted any details related to that carrier board. The main point is that the Bluetooth module is still removable so that it can be configured using a USB low level serial adapter.


Bluetooth UT61E interface. Top side.
Bluetooth UT61E interface. Bottom side.
The UT61E RS232 cable connects to the DE9 connector and power can be applied for instance from a 9V battery. I've used this about 10 meters away from the computer and have still read measurements without problems.

As a final note, the Bluetooth module I used didn't support the 7-O-1 framing that the UT61E uses. Luckily this frame is compatible with the more conventional 8-N-1 framing with the parity bit getting decoded as the last data bit. This extra bit can then be handled in software. The software I'm using to record data is a modified version of Steffen Vogel's dmmut61e. You can download my modified version here.