My Projects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
arduino:Spin-Scan [2018/04/17 22:47] – tonyarduino:Spin-Scan [2026/10/15 23:37] (current) – tony
Line 1: Line 1:
 <html><p style="text-align:right;">Published  2 Apr 2018</p></html> <html><p style="text-align:right;">Published  2 Apr 2018</p></html>
-<html><center><b><font size="6">Making 360 degree GIF Photos</font></b></center></html>+<html><p style="text-align:center"><b><font size="6">Making 360° GIF Photos</font></b></p></html>
 \\ \\
  
-{{ :arduino:spin-scan:pc231605.jpg?200|Original camera setup to manually produce 360 degree animation.}}I wanted to automate the creation of 360 degree animated GIF photos.  The obvious way to do it appeared to be to use an Arduino board to control a stepper motor and synchronize the camera.  I had previously created such animations by manually moving the camera and taking many photos, then manually aligning the images and stitching them together to get a more or less smooth animation.  But this requires a subject that stays still as it takes a lot of time, and the images inevitably are slightly out of alignment. +I wanted to automate the creation of 360° animated GIF photos.  This sort of thing has been done many times in various ways by many people, so I am re-inventing the wheel here, but I don't have their solution to hand.  The obvious way to do it appeared to be to use an Arduino board to control a stepper motor and synchronize the camera.  I had previously created such animations by manually moving the camera and taking many photos, then manually aligning the images and stitching them together to get a more or less smooth animation.  But this requires a subject that stays still as it takes a lot of time, and the images inevitably are slightly out of alignment.\\ 
-\\ \\ \\ \\ \\+{{ arduino:spin-scan:pc231605b.png?400 |Original camera setup to manually produce 360° animation.}} 
 +\\
  
 Doing it the hard way, the first animation shows the raw frames jerking about, and the second shows the manually aligned frames giving a smoother animation: Doing it the hard way, the first animation shows the raw frames jerking about, and the second shows the manually aligned frames giving a smoother animation:
 <HTML> <HTML>
-  <center><div style="margin-right: auto; margin-left: auto;">+  <div style="margin-right: auto; margin-left: auto;">
      <a href="/dokuwiki/_detail/arduino/spin-scan/pc235692h1.gif" class="media"><img width="48%" src="/dokuwiki/_media/arduino/spin-scan/pc235692h1.gif" class="media" title="Beetle with pseudo-scorpion attached'" alt="Beetle with pseudo-scorpion attached" /></a> <a href="/dokuwiki/_detail/arduino/spin-scan/pc235692h2.gif" class="media"><img width="48%" src="/dokuwiki/_media/arduino/spin-scan/pc235692h2.gif" class="media" title="Beetle with pseudo-scorpion attached'" alt="Beetle with pseudo-scorpion attached" /></a>      <a href="/dokuwiki/_detail/arduino/spin-scan/pc235692h1.gif" class="media"><img width="48%" src="/dokuwiki/_media/arduino/spin-scan/pc235692h1.gif" class="media" title="Beetle with pseudo-scorpion attached'" alt="Beetle with pseudo-scorpion attached" /></a> <a href="/dokuwiki/_detail/arduino/spin-scan/pc235692h2.gif" class="media"><img width="48%" src="/dokuwiki/_media/arduino/spin-scan/pc235692h2.gif" class="media" title="Beetle with pseudo-scorpion attached'" alt="Beetle with pseudo-scorpion attached" /></a>
-   </div></center>+   </div>
 </HTML> </HTML>
 +\\ \\
 Finished result, trimmed manually adjusted frames: Finished result, trimmed manually adjusted frames:
 <HTML> <HTML>
-  <center><div class="shadows">+  <div class="shadows" style="text-align:center">
       <a href="/dokuwiki/_detail/arduino/spin-scan/pc235692h.gif" class="media"><img width="90%" src="/dokuwiki/_media/arduino/spin-scan/pc235692h.gif" class="media" title="Beetle with pseudo-scorpion attached'" alt="Beetle with pseudo-scorpion attached" /></a>       <a href="/dokuwiki/_detail/arduino/spin-scan/pc235692h.gif" class="media"><img width="90%" src="/dokuwiki/_media/arduino/spin-scan/pc235692h.gif" class="media" title="Beetle with pseudo-scorpion attached'" alt="Beetle with pseudo-scorpion attached" /></a>
      <div class="container">      <div class="container">
-      <p>Animation created by trying to move a camera around the subject at a fixed distance.</p>+      Animation created by trying to move a camera around the subject at a fixed distance.
     </div>     </div>
-  </div></center>+  </div>
 </HTML> </HTML>
-(Published: [[http://naturewatch.org.nz/observations/9240245|Naturewatch]]) 
    
 ===== Overview ===== ===== Overview =====
Line 32: Line 32:
 ===== Hardware configuration ===== ===== Hardware configuration =====
  
-  * Arduino Uno clone (duinotech UNO classic r3, p/n XC-4410)+I had a choice of a number of  recycled stepper motors, and settled on using a [[:electronic:actuator:stepper:msaf200b51]], a Sankyo Mitsubishi flat motor with 1.8º/step (200 steps per revolution) and runs off a 12V power supply.  Its low profile, and lack of any protruding shaft from underneath meant it could just sit on the desk while testing.
  
-  * LCD keypad shield clone (duinotech 2 x 16 LCD Controller, p/n XC-4454)+{{arduino:spin-scan:spinscan2.png?800|Fritzing connection illustration of Arduino, LCD, Stepper controller, stepper motor}}\\ 
 +The hardware setup consisting of the Arduino UNO with LCD shield, stepper motor controller, stepper motor, and an infrared LED for controlling the shutter on the camera.
  
-  * Stepper Motor controller (duinotech L298N based, Dual Stepper Motor Controller, p/n XC-4492)+===== Parts list ===== 
 +  * Arduino Uno clone (duinotech UNO classic r3, p/n [[:electronic:boards:arduino:xc4410|XC4410]]) 
 +  * LCD keypad shield clone (duinotech 2 x 16 LCD Controller, p/n [[:electronic:boards:shield:xc4454|XC4454]]) 
 +  * Stepper Motor controller (duinotech {{:electronic:datasheet:stmicroelectronics:ds_l298.pdf|L298N}} based, Dual Stepper Motor Controller, p/n [[:electronic/boards/xc4492|XC4492]]) 
 +  * [[:electronic:actuator:stepper:msaf200b51|MSAF200B51]], a Sankyo Mitsubishi stepper motor
  
-I had a choice of a number of  recycled stepper motors, and settled on using a [[:electronic:stepper:msaf200b51]], a Sankyo Mitsubishi flat motor with 1.8º/step (200 steps per revolution) and runs off a 12V power supply.  Its low profile, and lack of any protruding shaft from underneath meant it could just sit on the desk while testing.+{{arduino:spin-scan:p4188738a.jpg?640|Arduino, LCD, Stepper controller, stepper motor}}\\ 
 +The implementation with a rubber disk on the end of the stepper motor shaft as a platform for mounting subjects.  The green and white wires to the left go to the 12V power supply for the motor, the rest is powered through the USB port connected to the Arduino)
  
-{{arduino:spin-scan:p4188738a.jpg?640 |Arduino, LCD, Stepper controller, stepper motor}} +===== The program code =====
-\\ \\ \\ The hardware setup consisting of the Arduino UNO with LCD shield, stepper motor controller, stepper motor (with rubber disk on the end of its shaft as a platform for mounting subjects), and an infrared LED for controlling the shutter on the camera (the green and white wires to the left go to the 12V power supply for the motor, the rest is powered from the USB port)+
  
-<html><br style="clear: both;" /></html>+As mentioned, I started with Shapespear's [[https://cdn.instructables.com/ORIG/F59/07PC/IJUCSTEF/F5907PCIJUCSTEF.zip|3D scanner firmware]], which was a great base as I had no experience with Arduinos at this point and his code did most of what I wanted.  My code is basically the same, but I have removed the manual step-and-take-exposure button function and added a post-exposure delay selection option instead.  The other minor change is that I don't use the motor enable/disable controls.
  
-===== The programs =====+The program has the stepper motor and camera-type set within the code, I assume it will be used in a fairly dedicated mode.  So it would need to be recompiled and re-downloaded to use it with alternative devices ((the Arduino IDE uses the term "upload" for sending the code to the Arduino board, but in my terminology one downloads from the larger machine to the smaller machine - eg you download from the internet to your PC)).
  
-As mentioned, I started with Shapespear's [[https://cdn.instructables.com/ORIG/F59/07PC/IJUCSTEF/F5907PCIJUCSTEF.zip|3D scanner firmware]], which was a great base as I had no experience with Arduinos at this point and his code did most of what I wanted.+If you are using the code with a different motor, that has a different number of steps per rotation, you will need to adapt "stepsPerRevolution" and "stepChoices" \\ 
 +<code> 
 +int stepsPerRevolution = 200; 
 +int stepChoices [] = {25, 40, 50, 66, 100, 200}; 
 +</code> 
 +If your stepsPerRevolution divided by a stepChoice produces a fraction then it won't rotate an exact complete revolution on that setting (eg the "66"  
 +above will actually result in it only completing 356.4º).   If a stepChoice is greater than stepsPerRevolution, then it will be trying to step by less than one step, and result in no movement.
  
-As mentioned in the comments to his [[http://www.instructables.com/id/Build-a-DIY-Desktop-3d-Scanner-With-Infinite-Resol/|instructables page]], there were a few strange things with delay timings have no effect : this turns out to be a problem of not understanding the order in which expressions are evaluated in the C programming language - easily solved by adding a few brackets around arithmetic expressions!+^There are 6 push-button switches on the LCD shield :^^ 
 +|  **Select**|Start/stop scanner| 
 +|  **Left**|Cycle through post shutter delay times| 
 +|  **Up**|Cycle through options for the number of exposures per revolution| 
 +|  **Down**|Step one unit counter-clockwise without triggering camera| 
 +|  **Right**|Step one unit clockwise without triggering camera| 
 +|  **Reset**|Reset scanner| 
 + 
 +To operate, select the number of steps to take, and change the delay option that determines how long it waits after triggering the shutter, before taking the next step.  Then press 'select' to start the scan. 
 + 
 +Some of the delay options here are quite long (6000 mS = 6 seconds) for situations where the camera might take a long time to take and save the image - eg for a camera that can do internal focus-stacking and combines multiple, rapidly taken, shots each time the shutter is triggered. 
 + 
 +The scan can be paused at any stage by pressing 'select' to pause and then 'select' again to resume.  While paused all the buttons can be operated and you can then resume, but if you change the number of steps it will reset the exposure count before continuing. 
 + 
 +The reset button stops and resets everything as though it has just been powered on. 
 + 
 +All these functions except "Up" (cycle through exposure count options) are live, even during a stepping run, so that you can tweak things while a scan is in progress. 
 + 
 +I might update the code so that the manual step options are just step one stepper motor step, rather in units of stepsPerRevolution/stepChoices, as that would be more useful for aligning the photographic subject exactly where I want it. 
 + 
 +Here is my modified version of Shapespear's code so far :\\ 
 +{{arduino:spin-scan:scanner_firmware-2.ino}}\\ 
 +and you would need :\\ 
 +{{arduino:spin-scan:multicameraircontrol.cpp}} and\\ 
 +{{arduino:spin-scan:multicameraircontrol.h}}\\
  
 ===== The results ===== ===== The results =====
Line 56: Line 91:
  
 <HTML> <HTML>
-<center><div class="shadows">+<div class="shadows" style="text-align:center">
     <a href="/dokuwiki/_detail/arduino/spin-scan/p1010032-066h.gif" class="media"><img width="90%" src="/dokuwiki/_media/arduino/spin-scan/p1010032-066h.gif" class="media" title="Animated dead longhorn beetle'" alt="Animated dead longhorn beetle" /></a>     <a href="/dokuwiki/_detail/arduino/spin-scan/p1010032-066h.gif" class="media"><img width="90%" src="/dokuwiki/_media/arduino/spin-scan/p1010032-066h.gif" class="media" title="Animated dead longhorn beetle'" alt="Animated dead longhorn beetle" /></a>
   <div class="container">   <div class="container">
-    <p>Animation of a dead longhorn beetle found outside our house.</p>+    Animation showing a dead longhorn beetle found outside our house.
   </div>   </div>
-</div></center>+</div>
 </HTML> </HTML>
  
 <HTML> <HTML>
-<center><div class="shadows">+<div class="shadows" style="text-align:center">
   <a href="/dokuwiki/_detail/arduino/spin-scan/pc310001-066h.gif" class="media"><img width="90%" src="/dokuwiki/_media/arduino/spin-scan/pc310001-066h.gif" class="media" title="Animation chiton 'valve'" alt="Animation chiton 'valve'" /></a>   <a href="/dokuwiki/_detail/arduino/spin-scan/pc310001-066h.gif" class="media"><img width="90%" src="/dokuwiki/_media/arduino/spin-scan/pc310001-066h.gif" class="media" title="Animation chiton 'valve'" alt="Animation chiton 'valve'" /></a>
  <div class="container">  <div class="container">
-    <p>Animation of a 'valve' (plate) from a chiton shell.</p>+    Animation showing a 'valve' (plate) from a chiton shell.
   </div>   </div>
-</div></center>+</div>
 </HTML> </HTML>
  
Line 77: Line 112:
 I have further work to do to setup good lighting and methods of mounting photographic subjects to give the best results.  Also it would be useful to package this up in a portable form so the I can photograph subjects in the field. I have further work to do to setup good lighting and methods of mounting photographic subjects to give the best results.  Also it would be useful to package this up in a portable form so the I can photograph subjects in the field.
  
-The setup would also work fine for operating a microscope camera, the stepper could be connected to adjust the microscope up and down to move the focus and take multiple photos that are then combined with focus-stacking software to produce sharp macro photos.+The setup would also work fine for operating a microscope camera, the stepper would be connected to adjust the microscope up and down to move the focus and take multiple photos that are then combined with focus-stacking software to produce sharp macro photos. 
 + 
 +At the moment the exposures taken are stored in the camera, and have to be downloaded.  An enhancement would be controlling the camera via USB (eg [[http://chdk.wikia.com/wiki/CHDK|CHDK software]]) and extracting the photos as they're taken.
  
 ====== References and Additional Resources ====== ====== References and Additional Resources ======
Line 86: Line 123:
   * [[http://www.doc-diy.net/photo/remote_pinout/|Camera remote release pinout list]].   * [[http://www.doc-diy.net/photo/remote_pinout/|Camera remote release pinout list]].
  
-\\ +<html><small>If any referenced page no longer exists, try looking for its URL on <a href="http://archive.org">http://archive.org</a>.</small></html>
-\\ +
-<html><center><hr size="7" width="90%"></center></html> +
-\\ +
-<html><center><small><p>If any referenced page no longer exists, try looking for its URL on <a href="http://archive.org">http://archive.org</a>.</p></small></center></html> +
-  +
-\\+
 \\ \\
 ---- ----
 +<html><div style="width: 80%; text-align:center">&nbsp;</html>[[:start|Home Page]]<html>&nbsp;&nbsp;&nbsp;</html>[[:about|About this Site]]<html>&nbsp;&nbsp;&nbsp;</html>[[:copyright|Copyright Questions]]<html>&nbsp;&nbsp;&nbsp;</html>[[:contact|Contact Us]]<html></div></html>\\
 \\ \\
-<html>&nbsp;&nbsp;&nbsp;</html>[[:start|Home Page]]<html>&nbsp;&nbsp;&nbsp;</html>[[:about|About this Site]]<html>&nbsp;&nbsp;&nbsp;</html>[[:copyright|Copyright Questions]]<html>&nbsp;&nbsp;&nbsp;</html>[[:contact|Contact Us]]+