Input capture interrupt problem

Store Forums Video Experimenter General Discussion Input capture interrupt problem

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #515
    cadbury
    Member

    Hi,

    I’m working on a project that listens for a web request from an Ethernet Shield(http://arduino.cc/en/Main/ArduinoEthernetShield), changes a TV’s channel via IR (using Timer2) then listens for specific Closed Captioning data.

    Inside initOverlay, when TIMSK1 |= _BV(ICIE1) runs the sketch freezes.

    Here is my setup, I see 2 from the serial port not but 3. If i comment out the line above, the sketch runs but I never get any CC data.

    Do you have any idea what is causing this?

    void setup(){
    tv.set_hbi_hook(pserial.begin(57600));
    pserial.println("-Start-");

    Ethernet.begin(mac);
    //Ethernet.begin(mac, ip, gateway, subnet); //for manual setup

    delay(1000);

    pserial.print("IP: ");
    pserial.println(Ethernet.localIP());
    delay(1000);
    server.begin();

    pserial.println("1");

    //TV
    tv.begin(_NTSC, W, H);
    pserial.println("2");
    initOverlay();
    initInputProcessing();
    pserial.println("3");
    tv.setDataCapture(line, dataCaptureStart, ccdata);
    y = 0;
    //tv.select_font(font6x8);
    //tv.fill(0);
    pserial.println("4");

    }
    #1075
    cadbury
    Member

    I took your Closed Captioning example and by adding:

    #include 
    #include

    EthernetServer server = EthernetServer(80);

    I never see “1” from the serial port.

    if I comment out EthernetServer server = EthernetServer(80); I see the “1” and the sketch works properly

    void setup()  {
    tv.begin(_NTSC, W, H);
    tv.set_hbi_hook(pserial.begin(57600));
    initOverlay();
    initInputProcessing();
    tv.setDataCapture(line, dataCaptureStart, ccdata);
    pserial.write("1");
    y = 0;
    }
    #1058
    grantm009
    Member

    Hi

    I have a similar problem – i.e. the program freezes when it does the TIMSK1 |= _BV(ICIE1); line.
    However I am just running the demo code for the board – no ethernet or anything else.
    my board is an arduino duemilanove.
    I reduced the code and objectives from the demo quite a bit as it was too big for my board. In the debug outputs I always get a “done 1” but never a “done 2”.
    Again, same as Cadbury, if i comment out the TIMSK1 |= _BV(ICIE1); line the sketch runs but no output.

    Originally I had the jumpers set to SyncSelect=V-input and outputSelect=overlay. In that setting I get video on the screen but no overlay 🙁 . I changed it to output-select=sync-only as I understand that should block the video and just give me my overlay text. But, sigh, I get nothing on the screen 😛 . So I thought about trying to use the TVout lib sync D9 with output select sync only but …. still nothing. :'(

    The code is below.

    any help would be appreciated.
    regards
    Grant

    #include
    #include
    #define W 128
    #define H 96

    TVout tv;
    unsigned char x,y;
    char s[32];

    void setup() {
    Serial.begin(9600);
    Serial.println(“setting up tv.”);
    tv.begin(PAL, W, H);
    Serial.println(“tv begin. done”);
    initOverlay();
    Serial.println(“initoverlay. done”);
    initInputProcessing();
    Serial.println(“initInputProcessing done”);

    tv.select_font(font4x6);
    Serial.println(“setting up tv.”);
    tv.fill(0);

    Serial.println(“done”);
    }

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

    // Enable input capture interrupt
    TIMSK1 |= _BV(ICIE1);
    Serial.println(“done 2”);

    // Enable external interrupt INT0 on pin 2 with falling edge.
    EIMSK = _BV(INT0);
    Serial.println(“done 3”);
    EICRA = _BV(ISC01);
    Serial.println(“done 4”);
    }

    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
    }

    ISR(INT0_vect) {
    display.scanLine = 0;
    }

    void loop() {
    tv.print(0,90,millis());
    tv.print(40,90,tv.millis());
    tv.print(60,90,display.frames);
    //Serial.println(“loop start”);
    // tv.capture();
    // tv.resume();
    // tv.delay_frame(5);
    // Serial.println(“loop done”);
    }

    #1061
    Michael
    Keymaster

    You can’t use the Serial library with TVout. You can’t use any library or shield that utilizes interrupts, as there are only so many interrupts that can be handled by an Arduino, and video depends on it completely.

    That’s why the polling implementation pserial is used for serial communication. Use pserial if you need to communicate with the computer. The designer of TVout wrote pserial for this purpose.

    #1056
    grantm009
    Member

    Hi

    So you are saying that the serial output is screwing up the program.

    Well i’ll be……

    debug stuffed my program 🙂

    I’ll have a look at it straight away

    thanks for the input.

    #1057
    grantm009
    Member

    Well that did not change anything. I took all references to the serial out. below is the new code.
    One thing I did notice is that when i put the output select on sync only, the video camera output disappears (as expected) but the screen does remain blank. My monitor, if there is no input signal, puts a logo in the top left corner. Because there is no logo displaying, this says to me that the monitor is receiving something from the board.

    I was wondering about the W & H variables and if they need to be adjusted for my wide format screen.
    I also tried changing (blindly) the tv.fill(0) value to other values in the 0-255 range.

    Otherwise, being a mere hobbyist – i don’t know where to look next.
    Are there maybe any “test” points that I could measure with a multimeter on the board ?

    I remember now that I only put the serial print lines in because it was not working.

    regards
    Grant

    #include
    #include
    #define W 128
    #define H 96
    TVout tv;
    unsigned char x,y;
    char s[32];

    void setup() {
    tv.begin(PAL, W, H);
    initOverlay();
    initInputProcessing();
    tv.select_font(font4x6);
    tv.fill(0);
    }

    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(ISC01);//Serial.println(“done 4”);
    }

    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
    }

    ISR(INT0_vect) {
    display.scanLine = 0;
    }

    void loop() {
    tv.print(0,90,millis());
    tv.print(40,90,tv.millis());
    tv.print(60,90,display.frames);
    delay(500);
    }

    #971
    Michael
    Keymaster

    grantm009, ok let’s take a step back. Have you been able to overlay anything at all onto an input signal? If you are just doing overlay, you can take out the “initInputProcessing” code. That’s for frame capture.

    You are using PAL in your code — you are in a PAL country, right (not in North America)?

    Earlier you said “I reduced the code and objectives from the demo quite a bit as it was too big for my board”. What did you mean by that? Does your Arduino have an ATmega328 chip? If it has an ATmega168 you will not be able to do video at this resolution.

    #999
    grantm009
    Member

    Hi

    Have you been able to overlay anything at all onto an input signal?
    The only thing I have ever had out is the video signal from the camera. I’ve not been able to get text of any kind
    to display.

    you are in a PAL country,
    right: Im in australia.

    Does your Arduino have an ATmega328 chip?
    The chip is a ATMega168. So I understand I can’t do the video at this resolutions.

    What options do I have ?
    1) can i plug an ATMega328 into the my board ?
    2) can I run it at a lower resolution, and how would i do that ?

    regards
    Grant

    #1003
    Michael
    Keymaster

    yes, you can put an ATmega328 with Arduino bootloader into your Duemilanove.

    You can try lower resolution, like 96×48 by changing H and W

    #997
    grantm009
    Member

    OK then Michael

    now we are starting to get somewhere

    I think the text is on the screen now, it is not readable but it is there, Im sure.

    I set the res to 96.48. The background image is fine but the text is displaying about 1 quarter down the screen with some kind of sync issue. It is on a lean, and repeated across the screen.

    I think at this stage I’ll order the new chip and start there. Thanks very much for the help.

    regards
    Grant

    #985
    cadbury
    Member

    I found the cause of my issue…memory.

    I decreased the H to 16 and the sketched worked!

    #986
    Michael
    Keymaster

    cadbury, that’s great to hear. I guess the lesson here is that the Ethernet library takes up memory, so you can’t use the normal 128×96 resolution of TVout. The Arduino really is memory constrained.

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