Shop OBEX P1 Docs P2 Docs Learn Events
time control on image capture(Linescan sensor) — Parallax Forums

time control on image capture(Linescan sensor)

RokkiRokki Posts: 3
edited 2010-03-31 17:16 in Accessories
Hi,
Does any know what code you need to write in order to control the time interval between each image capture? Right now, I am using the code written on the manual such that the camera is only triggered when the lighting condition is dramatically changes, say I move the LED position. However, I want the camera to snap a picture every 2 second regardless of external environment. Has anyone done this before?

PS: I didn't OR XTRIG with the ACRBIN.

cheers

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-31 06:27
    You can do the timing between exposures in the foreground in PBASIC. (See the PAUSE command.) Another alternative is to connect a 0.5Hz oscillator (e.g. a 555) to the trigger pin, and set up the coprocessor script for triggered exposures.

    -Phil
  • RokkiRokki Posts: 3
    edited 2010-03-31 13:31
    Hi,
    thanks, I've tried to use 'PAUSE 100' command in the loop, so every 100ms, it should execute the ACRBIN command but it didn't. Here's the code I wrote:

    lft_edge VAR Byte
    rgt_edge VAR Byte
    max_dia VAR Byte

    OWOUT owio, 1, [noparse][[/noparse]SETEXP, 30]
    OWOUT owio, 0, [noparse][[/noparse]SETBIN, 128, 10, FIXED|LEVEL]

    DO
    PAUSE 100
    OWOUT owio, 0, [noparse][[/noparse]"<", ACQBIN, FNDNXT|FWD|BRTEDG]
    OWOUT owio, 0, [noparse][[/noparse]FNDNXT|BKWD|BRTEDG, ">"]
    GOSUB Ready
    OWOUT owio, 0, [noparse][[/noparse]DUMPADR, RESULTS + 5]
    OWIN owio, 2, [noparse][[/noparse]lft_edge, rgt_edge]
    IF (rgt_edge) THEN
    max_dia = rgt_edge - lft_edge + 1 MIN max_dia
    ELSEIF (max_dia) THEN
    DEBUG "Bagel diameter: ", DEC max_dia, CR
    max_dia = 0
    ENDIF
    DEBUG "exposure interval: ", DEC 100, CR
    LOOP[noparse][[/noparse]code]

    But the debug window gives me result of
    100
    100
    Bagel diameter: 50
    100
    100
    100
    100
    100
    Bagel diameter:180
    100
    Bagel diameter: 100
    ...

    These diameter value shows up only when I change the angle or move the position of my LED, not controlled by the software I wrote...

    thanks
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-03-31 15:34
    The program is dong what it's supposed to be doing. It's written to monitor the size of a bagel passing on a conveyor, recording the maximum diameter that it sees. Then, when the bagel has passed (i.e. when rgt_edge is zero and max_dia > 0) it spits out the value of max_dia.

    If you want it to send the value of every non-zero width it sees, do this:

    DO
      PAUSE 100
      OWOUT owio, 0, [noparse][[/noparse]"<", ACQBIN, FNDNXT|FWD|BRTEDG] 
      OWOUT owio, 0, [noparse][[/noparse]FNDNXT|BKWD|BRTEDG, ">"] 
      GOSUB Ready 
      OWOUT owio, 0, [noparse][[/noparse]DUMPADR, RESULTS + 5] 
      OWIN owio, 2, [noparse][[/noparse]lft_edge, rgt_edge] 
      IF (rgt_edge) THEN 
        DEBUG "Width: ", DEC rgt_edge - lft_edge + 1, CR
      ELSE
        DEBUG "Nothing there." 
      ENDIF 
      DEBUG "Exposure interval: ", DEC 100, CR
    LOOP
    
    
    


    -Phil
  • RokkiRokki Posts: 3
    edited 2010-03-31 17:16
    thanks, Phil, it works now!
Sign In or Register to comment.