Skip to content

GPIO Output Test

Kshitij Sharma edited this page Mar 2, 2022 · 1 revision

Introduction

The deadman switch requires a square wave at a frequency of 100Hz. This test was conducted to ensure the Arduino UNO and BeagleBoneBlack were both able to output a wave at the required frequency.

Arduino

Source Code

unsigned int freq = 0;
int sqwPin = 13;

void setup() {
  Serial.begin(9600); // Serial Port Baud = 9600 8,N,1
}

void loop() {
  while (Serial.available() > 0) {
    char tmpChar = Serial.read();
    if (isDigit(tmpChar)) {
      freq = (freq * 10 ) + tmpChar - '0';
    }
    if (tmpChar == '\n' || tmpChar == '\r') {
      if (freq > 0) {
        Serial.print(freq);
        Serial.println(" Hz Sqw");
        tone(sqwPin, freq);
      }
      freq = 0;
    }
  }
}

Method of Testing

  1. Connect Oscilloscope to Pin 13 on the Arduino and GND.
  2. Flash Arduino with sketch
  3. Enter required frequency via the serial monitor

Results

Frequency Output
75
100
250
500
1000
2500

BeagleBoneBlack

Source Code

var_count=0
repeat=1000
while [ $var_count -lt $repeat ]
do
    echo 1 > /sys/class/gpio/gpio88/value
    sleep 0.005
    echo 0 > /sys/class/gpio/gpio88/value
    let 'var_count+=1'
    if [ $var_count -ge $repeat ]
    then
        echo "Test Completed"
    fi
done

Method of Testing

  1. Connect Oscilloscope to Pin P8_28 (28th pin on the right header) on the BBB and GND.
  2. Run file as an executable

Results

Frequency Output
125 Fluctuations down to 75Hz
100 Fluctuations down to 75Hz
75 Fluctuations down to 50Hz
50
Clone this wiki locally