Advertisement
Guest User

Untitled

a guest
Jan 25th, 2012
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' Macro focus rail driver
  2. ' Unipolar stepper (12V 1.8deg) connected to ULN2003A:
  3. '    green, white, red, brown -> Out1-Out4
  4. '    08m 2 -> ULN In2
  5. '    08m 1 -> ULN In3
  6. ' Out4 -> optocoupler for shutter triggering (tip+, sleave-)
  7. ' IR detector codes:
  8. '    CH+      back focus
  9. '    CH-      front focus
  10. '    NN       steps in one slide (in 0.01mm)
  11. '    AV/TV    the next slide will be continuous (any key to interrupt)
  12. '    Vol-     mark focus (front) and start moving focus back; mark focus end by any key
  13. '       slide to the front of the stack
  14. '    Power    start shooting
  15.  
  16. symbol slack = 5          ' how many micro steps to add when changing direction
  17. symbol steppause = 1   ' larger number will make it go slower
  18. '                                  - useful if you have a stepper with very few steps per revolution
  19.  
  20. symbol stepc     = b0
  21. symbol s    = b1
  22. symbol i    = b2
  23. symbol direction = b3
  24. symbol nsteps    = b4
  25. symbol nframes   = b5
  26. symbol nslide    = b6
  27. symbol j     = b7
  28. symbol irflag    = b8
  29. symbol olddir    = b9
  30. symbol contflag  = b10
  31.  
  32. high 1
  33. high 2
  34. low 4
  35.  
  36. '           (nsteps)
  37. eeprom 0, (20)
  38.  
  39. read 0, nsteps
  40.  
  41. contflag=0
  42.  
  43. main:
  44.     infrain2
  45.     if infra<10 then
  46.         infra=infra+1
  47.         infra=infra//10
  48.         nsteps=infra*10
  49.         pause 500
  50.         infrain2
  51.         infra=infra+1
  52.         infra=infra//10
  53.         nsteps=nsteps+infra
  54.         write 0, nsteps
  55.     elseif infra=37 then
  56.         contflag=1
  57.         pause 500
  58.         infrain2
  59.         pause 500
  60.     endif
  61.     select infra
  62.     case 17 ' front focus
  63.         direction=2
  64.         gosub slide
  65.     case 16 ' back focus
  66.         direction=0
  67.         gosub slide
  68.     case 19 ' Vol-  - mark focus start
  69.         nslide=0
  70.         irflag=0
  71.         pause 200
  72.         do
  73.             pause 200
  74.             direction=0
  75.             gosub slide
  76.             nslide=nslide+1
  77.             'pause 200
  78.         loop while irflag=0
  79.         pause 2000
  80.         for j=1 to nslide
  81.             direction=2
  82.             gosub slide
  83.         next j
  84.         gosub slide
  85.         direction=0
  86.         gosub slide
  87.     case 21 ' Power - start shooting run
  88.         gosub shoot
  89.         for j=1 to nslide
  90.             direction=0
  91.             gosub slide
  92.             gosub shoot
  93.         next j
  94.     endselect
  95.     'debug
  96.     pause 500
  97.     goto main
  98.  
  99. shoot:
  100.     pause 5000    
  101.     high 4  ' shoot
  102.     pause 400
  103.     low 4
  104.     pause 3000    ' wait before the next slide (exposure time)
  105.     return
  106.  
  107.    
  108. slide:
  109.     if direction<>olddir then   ' remove sprocket slack
  110.         for i=1 to slack
  111.             gosub onestep
  112.         next i
  113.     endif
  114.     irflag=0
  115. lup:
  116.     for i=1 to nsteps
  117.         gosub onestep
  118.         pause steppause
  119.     next i
  120.     if irflag=0 AND contflag=1 then goto lup
  121.     contflag=0
  122.     olddir=direction
  123.     return
  124.  
  125. onestep:
  126. '   s=direction*2
  127.     stepc=stepc+direction-1
  128.     let stepc=stepc // 4
  129.     lookup stepc, (%00000110, %00000100, %00000000, %00000010), s
  130.     let pins=s
  131.     if pin3=0 then
  132.         irflag=1
  133.     endif
  134.     'pause 1
  135.     return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement