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

sempaiscuba
1,0429 gold badges21 silver badges32 bronze badges
asked May 10, 2022 at 12:39
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? Commented May 10, 2022 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. Commented May 10, 2022 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. Commented May 10, 2022 at 16:25
  • @chrisl: Also to answer your questions regarding the ground. In fact they are connected. Commented May 10, 2022 at 16:26

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.