4 drops of superglue result in high precision PT camera system

I am working on a pan tilt camera system that identifies approach for landing airplane in sky and automatically centers PT camera (see photo at bottom):
https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=252176&p=1562815#p1562815

Until today I always did it with small black brackets with two servos from aliexpress.

Recently I was very impressed on that 28BYJ-48 stepper motor has 4096(!) half steps per revolution (and did build high precision (3µm accuracy) linear actuator from it):

Today I received a box with 5 such stepper motors and 5 ULN2003 drivers.
Until today I had only one such stepper motor, and was not able to do what I did now.

4 drops of superglue are enough to create a high precision PT system!
Servos have range 0…180° with 180 steps (1 step/°).
28BYJ-48 has unlimited range and 4096 steps per 360° (11.3 steps/°).

1st drop of superglue between ground plate and bottom steper motor.
2nd drop to fixate 4 cables leaving upper stepper horizontally.
3rd drop to fixate upper 28BYJ-48 directly on motor shaft of bottom stepper motor.
4th drop to fixate Raspberry v1 camera on upper stepper motor shaft.

That’s all – I don’t know why I every used servos for PT camera system.

Below is sketch that did the demo video:

#include <AccelStepper.h>

// ULN2003
AccelStepper stepper(AccelStepper::HALF4WIRE, 2, 4, 3, 5);
AccelStepper stepper2(AccelStepper::HALF4WIRE, 8, 10, 9, 11);

int i=0;
int A[]={3072,1024,0};
int B[]={3072,1024,0};

void setup()
{  
  stepper.setMaxSpeed(800);
  stepper.setAcceleration(250);
  stepper2.setMaxSpeed(800);
  stepper2.setAcceleration(250);
  Serial.begin(9600);
  stepper.moveTo(512);
  stepper2.moveTo(512);
  stepper.runToPosition();
  stepper2.runToPosition();
}

void loop()
{
  if ((stepper.distanceToGo() == 0) &&
      (stepper2.distanceToGo() == 0))
  {
    if (i == sizeof(A)/sizeof(A[0]))  for(;;){}

    stepper.moveTo(A[i]);
    stepper2.moveTo(B[i++]);
  }
    
  stepper.run();
  stepper2.run();  
}

That’s fracking cool!

I did it, moved the 70mm lens from servo PT camera system to stepper PT system.
Upper stepper+lens weight is 36.4g+19.1g=55.5g – lower stepper and superglue have no problems to deal with this.

Used this sample script to make joystick connected to A0 and A1 move the camera.
Horizontal range restricted to -90*…90°, vertical from 0°…90° (for tracking airplane through roof window):

#include <AccelStepper.h>

// ULN2003
AccelStepper stepper(AccelStepper::HALF4WIRE, 2, 4, 3, 5);
AccelStepper stepper2(AccelStepper::HALF4WIRE, 8, 10, 9, 11);

void setup()
{  
  stepper.setMaxSpeed(800);
  stepper.setAcceleration(250);
  stepper2.setMaxSpeed(800);
  stepper2.setAcceleration(250);
}

void loop()
{
  stepper.moveTo((analogRead(A1)-512));
  stepper2.moveTo(-2*(analogRead(A0)-512));
    
  stepper.run();
  stepper2.run();  
}

To set a new 0-position for both stepper motors, use the joystick to move the camera to that position, and press reset button then.

Not earth-shatteringly robust of course, but works pretty well. Does the Pi camera board get damaged if you were to remove it from the motor for another use? I'd suspect it might.

MarkT:
Does the Pi camera board get damaged if you were to remove it from the motor for another use? I’d suspect it might.

No, it did get off sometimes by accident, and when I want to change.

I have already changed back for inhouse dev work on automatically centered at airplane recording.
My other code is plain C code on Raspberry, so I searched for a C library to control the servos from Raspberry.
I got simple sample code from Joan, maintainer of pigpio library.
That got me going and now I have my 1st demo controlling PT camera system from Raspberry:
pigpio C library with half-stepping for ULN2003 + 28BYJ-48 stepper motor? - Raspberry Pi Forums

I will develop the airplane center algorithm inhouse, that is main reason for changing back 70mm lens camera to normal v1 camera. Red ball at end of pendulum will play role of dark airplane before bright sky …
Based on all the code I have already, I would expect automatic centering of video on swinging red ball while recording video tomorrow (1920x1080@30fps and 640x480@90fps).

Until now photos/videos were not from the stepper PT system camera.
Before continuing I needed to check what the videos captured will look like.

I used the fast movement from before (delay 1ms between steps).
And new move tool for positioning:
https://www.raspberrypi.org/forums/viewtopic.php?f=33&t=256740&p=1565748#p1566020

This is command used:

$ L=200
$ while true
> do
> sudo ./move $L 0
> sudo ./move 0 $L
> sudo ./move -$L -$L
> sleep 1
> done

So first 200 half-steps left, then 200 half-steps down, finally back to start position.
200 steps is roughly 18°.

I did record 1920x1080@30fps video with this command:

$ raspivid -md 1 -w 1920 -h 1080 -p 22,50,960,540 --shutter 10000 -t 5000 -o tst.h264

Option "--shutter 10000" sets exposure to 1/100 second. It is needed to see clear frames:

I wanted to show the video here, and I wanted to be able to show details.
Therefore I slowed it down by factor 3.
Unfortunately the generated 1920x1080 animated .gif is 107MB in size.
So while creating the .gif I scaled down by factor 6 to 320x180, with only 3.5MB size:

I think the speed should suffice for tracking pendulum -- origianl speed is 3 times faster.
And it is far more than needed when tracking real airplane in sky.

Next step is to determine for pendulum, how many pixels in generated frame correspond to a single stepper motor step up, down, left and right.

Neat.

You might want to investigate constructing things with 1/8” Acrylic plastic sheets.

These can be easily cut, glued, and screwed together with brass inserts.

Acrylic would make your assembly more flexible and robust.

larryd:
Acrylic would make your assembly more flexible and robust.

Sure, but I have no experience with acrylic.

I do have a long history of connecting things by just superglueing them together.
And I have learned that superglued motor can withstand even heavy vibrations with high forces
[although sometimes big Lego wheel fixated with bullet on outrunner motor shaft escaped, see 90fps slowmo near camera hit :wink: ]:

I looked at aliexpress and amazon for "pan tilt bracket" and only found servo PT system brackets. Seems that no one else uses stepper motors as I do.

HermannSW:
Based on all the code I have already, I would expect automatic centering of video on swinging red ball while recording video tomorrow (1920x1080@30fps and 640x480@90fps).

That was a bit too optimistic, although I made huge progress.
Further development of airplane tracking will be posted in this posting and following:
https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=252176&p=1566603#p1566603
I will report back here if pendulum ball tracking works and show an automatically centered video.

I added a 2nd heuristic on top of 1st and get a smooth moving blue point in "airplane".
I slowed down 90fps video by factor 30 for easy inspection.
This is animation with graphical debugging, see posting for details:

P.S:
Stepper motor does not seem to loose any steps at 0.8ms/step speed, 10 far moving repeats:

I just learned in another thread that powering both 28BYJ-48 stepper motors directly from Arduino 5V rail with half-stepping (4096 steps per revolution) draws 2×200mA, while an USB powered Arduino Uno does provide 450mA on 5V rail. So doing what I did, powering stepper PT camera system compeletly from Arduino Uno is safe!

Btw, still work in progress, but stepper PT camera system now can automatically center on black ball with P only PID controller (animation speed is 0.25):
https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=252176&p=1568093#p1568093

While working on Raspberry Pi, I will use Arduino-PID-library for further PID controller work:

To be more precise on building instructions, this is the central superglue connection between the two 28BYJ-48 stepper motors [feels like the motor shaft was built for exactly that ;-)]:

The OpenScad file is based on RGriffoGoes’ thingverse OpenScad model of single 28BYJ-48 stepper motor.

My modified file is here:

You can open the OpenScad.net share link and press F4 to redraw as well.

I did complete the OpenScad modelling by adding Raspberry camera as well as wood base.
I learned how to pass an argument (angle) to "StepMotor28BYJ(-45)" module, the share link:
https://tinyurl.com/t7kyfug

Today I played with Raspberry HQ camera and C-mount 35mm lens. Both together do weigh 109g together, with the top stepper 19g that is 128g in total. I was not sure whether superglue would be strong enough and tried.

HQ camera comes with tripod mount, and I measured M6 with micrometer. So in addition to the two stepper motors I superglued a M6 screw:

And it really works — as long as the camera does not move too far to front or back, then steps get lost:

Have you tried counter balancing some of these to offset the weight ?

ballscrewbob:
Have you tried counter balancing some of these to offset the weight ?

No, thank you for that good idea!
That would really help for moving lens down.

For moving lens up there is less problems.
I just measured, and more than 12mm of M6x20 screw thread are not used.
So replacing M6x20 screw with M6x8 would bring everything closer to upper stepper motor shaft.
Then even 70° lens up should be possible:

That would be enough for capturing airplanes automatically centered
(on walk with dog I saw low flying airplane, and that reminded me on this project):

P.S:
The automatically centered airplane capturing project was planned as a pre-project for autonomous fast robot driving. I am much further with my raspcatbot project already, instead of real time locating airplane at sky, robot determines whether it is still on straight black line (sofar), processing 204 frames of ov7251 global shutter camera, and then does autonomous full stop from currently maximal seen 2.55m/s inhouse (robot can do 5m/s or 18km/h):

Until mounting 100g camera+lens onto stepper PT camera system on weekend, I was not aware that the Arduino code posted above produced jitter. The much less weight of the cameras I used before did not uncover that fact.

Today I just started the Arduino Uno with sketch from this posting above:

I did let the joystick alone, no movements.
The jitter (in the analog reads?) is really heavy, this is 0.5s real time animated .gif loop from Raspberry HQ camera mode4 (1012x760) video capture at 60fps (that mode can capture up to 120fps), scaled to 1/3rd size:

So today I created modified sketch with jitter filter.
Jitter remained with threshold 5, 10 and 15. No jitter with 20, sketch uses threshold=25 to be on safe side:

#include <AccelStepper.h>

// ULN2003
AccelStepper stepper(AccelStepper::HALF4WIRE, 2, 4, 3, 5);
AccelStepper stepper2(AccelStepper::HALF4WIRE, 8, 10, 9, 11);

#define thr 25

void setup()
{  
  stepper.setMaxSpeed(800);
  stepper.setAcceleration(250);
  stepper2.setMaxSpeed(800);
  stepper2.setAcceleration(250);
}

void loop()
{
  int x = 2*(analogRead(A1)-512);
  int y = -2*(analogRead(A0)-512);
  int cx = stepper.currentPosition();
  int cy = stepper2.currentPosition();

  if ((abs(x-cx) > thr) || (abs(y-cy) > thr))
  {
    stepper.moveTo(x);
    stepper2.moveTo(y);
  }
    
  stepper.run();
  stepper2.run();  
}

P.S:
Youtube video captured with new sketch:

P.P.S:
The 35mm lens is quite nice, this is 1:1 copy out from 12MP frame captured, the tower is 2.3km(!!) distant:

It is time to make use of PT stepper camera sytem for capturing images of moon with new 38$ 300mm lens:
https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=291432

New lens looks very similar to 70mm lense, already used with PT camera system:

HQ camera was used with PT camera system as well before:

I just measured, 35mm C-mount lens plus CStoC mount weight is 77.9g, while 300mm lens plus a CStoM12 adapter weight is 22.7g, that is 55g less weight.

In the posting pointed to above I have calculated that 80% of moon will cover full width (4056 pixel) of 12MP HQ camera photo, so moon can be viewed partially(!) only.