1

I have set up a single pulse (width of ~400 ms) using the burst feature on the Tektronix AFG3102 function generator and I want to transfer this signal to the digital pin of Arduino UNO. Essentially I want to continuously (in a loop) perform reading on pin 7 using the built-in digitalread() function. So I'm expecting to see 0 when I did not trigger the signal and 1 when I trigger the signal for a duration of 400 ms and then back to 0. However, this is not the case here as I'm just reading 0s even though I trigger my signal. Interestingly when I change the width of the pulse to 1ms I can see the signal coming through, but It does seem to work with 400 ms.

I have placed my code here for your review. I would highly appreciate some help on this.

void setup() {      
    Serial.begin(9600); // start serial for output
    pinMode(7,INPUT);
}
void loop() {
      Serial.println(digitalRead(7));
      Serial.print('\n'); 
}

Thank you,

Nikan

4
  • To what voltage did you set the function generator? Also currently you are very fast filling up the Serial buffer. Have you tried a delay at the end of loop(), like 50ms, and/or increasing the baudrate to something like 115200?
    – chrisl
    May 10 at 14:05
  • 1
    Does your AFG share its ground with the Arduino? What does the pulse look like on the scope? Side note: there is no point in Serial.print('\n');, as Serial.println() already adds "\r\n". @chrisl: Filling the serial buffer should be no issue: it justs adds a small latency (< 7 ms) to the transmitted data. May 10 at 14:14
  • @chrisl: the voltage from the function generator is at 3 Vpp, Also What Im not understanding is that when I send continuous square waves, PIN 7 starts to pick up at the voltage above 2 Vpp. Of course I need to keep this below 5.
    – Nikan
    May 10 at 16:25
  • @chrisl: Also to answer your questions regarding the ground. In fact they are connected.
    – Nikan
    May 10 at 16:26

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.