A USB driven turntable

A USB driven turntable

A while ago, we were challenged to build a motorized turntable of the kind used by photographers to take pictures of objects from all angles. The idea was obviously to control the position of the table with Yoctopuce modules. It was a rather ambitious project as there was more mechanics than electronics in it, but we nevertheless took up the challenge...

The mechanical part

The challenge required us to use as a mechanical basis a turntable produced by the French company FANTASTIC Motors. This table is formed by two fat steel disks, with a 12cm diameter, which rotate relative to each other. Inside, there is a large gear wheel driving one of the disks. This tiny thing supports weights up to 150Kg. However, it wasn't designed to be driven, its normal use is to rotate objects displayed behind glass.

top view  bottom view
The mechanical basis of the turntable

We started by removing the motor and the original gearbox which aren't all that reliable, from what we heard. Instead, we used a largely reduced motor, as we wanted to be able to make the table turn very slowly. Pictures of objects on turntables are often taken with a flash, and the flash needs time to charge again in between two pictures. For the power supply, turning the table, even fully loaded, requires only a few hundreds of mA, quite a joke for the Yocto-Motor-DC.

The new motor besides the original one
The new motor besides the original one

To know the position of the table, we put an angular sensor on its central axis. This sensor, working thanks to a Hall effect, has an accuracy of the order of 0.1░. It has a 4-20mA output and it is therefore easy to read it with a Yocto-4-20mA-Rx.

The angle sensor
The angle sensor

The Yocto-Motor-DC and the Yocto-4-20mA-Rx are connected to a Micro-USB-Hub. We chose a 5V power supply voltage, so we can use the same 250VAC to 5V converter to power both the motor and the Micro-USB-Hub. This enables us to use the turntable at the end of a very long USB cable.

The installation diagram
The installation diagram

To keep the motor, the sensor, and the turntable together, we printed an custom support. We put everything into an aluminum box, into which we had drilled the needed openings. We added a small fan to ventilate the box content and prevent a potential overheat in case of intensive use. We therefore end up with an easily movable box that we only need to connect to the mains and to a computer to operate.

The mechanical part The electronic part
The completed turntable
 You only need to connect the mains and USB

The software part

At first sight, we might suppose the software part to be obvious: We only need to turn the motor on and to read the angle sensor value in a loop. But that would be a mistake. Let's imagine that you have a task to perform and that your boss calls you every minute to check how far along you are. Most likely, you are going to spend more time on the phone than actually working. It's better if you call your boss to inform him/her of significant advances in your work. This reasoning can also be applied to Yoctopuce modules: if you question them in a loop which is too fast, they are going to spend more time answering than actually working. The turntable control software was therefore written using the API callbacks, without ever doing a single get. It's the position sensor that leads the way, not the the control software.

There is the second technical difficulty. As the turntable is able to rotate very heavy loads, it is imperative to avoid brutally varying its speed, otherwise it might damage the driving system gears because of inertia. A brutal stop of a rotating 100Kg load might be a killer.

The idea is to create a class to which we ask to turn the table with a constant speed and to call a user defined callback every X degrees. This callback is typically used to drive a camera. Here is a typical use example of this class. Note that we used Python. It's probably not the best language to work in real time, but it was imposed.

def TakeAPictureCallback(angle):
    photorelay.pulse(200)  # takes a picture
    # stops the table after a full rotation
    photocount += 1
    if (photocount >=36): turntable.setPower(0,None,0)

# creating the TurnTable object controlling the table
turntable =  TurnTable()
# starts the table at 30%  and calls TakeAPictureCallback every  10░
# waits until the table stops

So we created a class taking advantage of "TimedCallback" and of "valueCallBack". The position sensor calls a TimedCallback 5 times per second and is used to progressively adjust the speed of the turntable depending on what it is currently doing: accelerating, slowing down, stopping, ... Here is the skeleton of the said callback:

def _powerCompute(self,func,data):
    position =  data.get_averageValue()

    if  self._mode == self._MoveMode.ABSPOSITION:
        # position mode:  Progressively adjusts the speed
        # so that it falls to zero at the correct position

    if  self._mode == self._MoveMode.SPEEDCTRL:
        # speed control mode: Progressively adjusts the speed
        # until the required value

    if  self._mode == self._MoveMode.STOPPING:
        # stopping the system: progressively diminishing
        # the speed until zero

Meanwhile, the valueCallBack is called each time the position sensor value changes significantly: in practice, about every 0.1 degree. This callback checks if a pre-computed position is reached and, if so, calls the user callback and computes the next position.

def _PositionChangeCallBack(self,fct,sposition):
  if self._positionCallback is None : return
  position = float(sposition)

  if self._powertarget>0 and position>=self._positionCallbackNext:
    self._positionCallbackNext = self._positionCallbackNext \
    + self._positionCallbackPeriod

  if self._powertarget<0 and position<self._positionCallbackNext:
    self._positionCallbackNext = self._positionCallbackNext \
    - self._positionCallbackPeriod

The last difficulty is linked to the fact that we had to put the motor right next to the angle sensor. This sensor is based on the Hall effect. In short, there is a magnet rotating inside it. and the sensor measures the magnetic field of this magnet to determine the position. But it so happens that the motor also contains permanent magnets and these magnets slightly perturb the sensor. We observed differences from -4 to +2░ between the measures and the actual positions. As this perturbation essentially depends on the table angle, we added a function to compensate for this measurement error.

The observed measurement error (in blue) and the function used to compensate it (in red)
The observed measurement error (in blue) and the function used to compensate it (in red)

Here we are, we more or less surveyed all the issues. We created a device which enables us to automatically take a series of pictures of an object, that we can next put together to make nice 360░ animations such as this one:

A fun way to present Yoctopuce products :-)
A fun way to present Yoctopuce products :-)

Note that animated GIF is not necessarily the most subtle way to create these animations :-) As a conclusion, here is a short video showing the turntable while in use.


Add a comment 2 comments
Back to blog

1 - naddame Tuesday,october 13,2015 17H20

I programmed the code that turn the table and recover events in a custom callback but it does not work perfectly

Can you provide a full program or link to TurnTable.py.


2 - martinm (Yocto-Team)Tuesday,october 13,2015 17H46

Sure! Just contact the Yoctopuce support.

Yoctopuce, get your stuff connected.