Problem with image capture while using analogWrite()

Store Forums Video Experimenter Bugs/Problems Problem with image capture while using analogWrite()

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #672
    cowhen
    Member

    Hello all,

    I built a lasershow unit using an arduino and galvos. Each galvo is connected to an output pin and is driven using the analogWrite() command. So far, this works fine.

    Now I want to use the video experimenter to capture a frame of the laser image that my device projects. My problem is: The initialize functions break the ability to control my galvos. I want my ardino to control the galvos and then capture a single image. Then the control of the galvos is to be resumed.

    I tried to put together a small code example of what I am trying to do. The two analogWrite() command in the loop() are what is required to drive my laser show. How can I capture an image without this breaking?

    Thank you so much in advance!

    Kind regards,
    cowhen


    //
    video
    #include
    #include
    #define W 128
    #define H 96

    TVout tv;
    unsigned char x,y;
    char s[32];
    int count_j = 0;
    //
    /video

    int laser_pin = 12;
    int x_speaker_pin = 3;
    int y_speaker_pin = 5;


    void initOverlay() {
    TCCR1A = 0;
    // Enable timer1. ICES0 is set to 0 for falling edge detection on input capture pin.
    TCCR1B = _BV(CS10);

    // Enable input capture interrupt
    TIMSK1 |= _BV(ICIE1);

    // Enable external interrupt INT0 on pin 2 with falling edge.
    EIMSK = _BV(INT0);
    EICRA = _BV(ISC11);
    }

    void initInputProcessing() {
    // Analog Comparator setup
    ADCSRA &= ~_BV(ADEN); // disable ADC
    ADCSRB |= _BV(ACME); // enable ADC multiplexer
    ADMUX &= ~_BV(MUX0); // select A2 for use as AIN1 (negative voltage of comparator)
    ADMUX |= _BV(MUX1);
    ADMUX &= ~_BV(MUX2);

    ACSR &= ~_BV(ACIE); // disable analog comparator interrupts
    ACSR &= ~_BV(ACIC); // disable analog comparator input capture
    }



    void setup() {
    //----video
    //tv.begin(PAL,W,H);
    //tv.end();

    tv.select_font(font4x6);
    tv.fill(0);
    //
    /video

    pinMode(laser_pin, OUTPUT);
    pinMode(x_speaker_pin, OUTPUT);
    pinMode(y_speaker_pin, OUTPUT);
    }

    void loop()
    {
    analogWrite(y_speaker_pin, 50);
    analogWrite(x_speaker_pin, 25);


    if (count_j == 0)
    {
    initOverlay();
    initInputProcessing();
    tv.begin(PAL,W,H);
    tv.capture();
    tv.end();
    count_j++;
    }
    }
    #2184
    044hnoor
    Member

    Then the control of the galvos is to be resumed.

    I tried to put together a small code example of what I am trying to do. The two analogWrite() command in the loop() are what is required to drive my laser show.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.