Arduino AEAT sampling problem

I have an Arduino code which runs decently.

// Read in 10-bits Magnetic Encoder AEAT-6010-A06 into Arduino Uno
// Sampling

// Declarate

const int CSn = 4; // Chip select
const int CLK = 7; // Clock signal
const int DO = 8; // Digital Output from the encoder which delivers me a 0 or 1, depending on the bar angle…
int analogPin = 3;
int val = 0;
unsigned int sensorWaarde = 0;

void setup() {
//Fix de tris

pinMode(CSn, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(DO, INPUT);

//Let’s start here
digitalWrite(CLK, HIGH);
digitalWrite(CSn, HIGH);

void loop() {

val = analogRead(analogPin);
// val = val - 670;
sensorWaarde = readSensor();
delayMicroseconds(1); //Tcs waiting for another read in

unsigned int readSensor() {
unsigned int dataOut = 0;

digitalWrite(CSn, LOW);
delayMicroseconds(1); //Waiting for Tclkfe

//Passing 10 times, from 0 to 9
for (int x = 0; x < 10; x++) {
digitalWrite(CLK, LOW);
delayMicroseconds(1); //Tclk/2
digitalWrite(CLK, HIGH);
delayMicroseconds(1); //Tdo valid, like Tclk/2
dataOut = (dataOut << 1) | digitalRead(DO); //shift all the entering data to the left and past the pin state to it. 1e bit is MSB

digitalWrite(CSn, HIGH); //
Serial.print(" “);
Serial.print(” ");

return dataOut;

From the delay data i assumed that i will be having approximately a sampling rate of 500 Hz, however it seems that the sampling rate is approximately 300± Hz, without a proper confirmation.

My system is to be run in a Magnetic Encoder by Avago, but i have difficulties determining the sampling rate.

If possible, may i know what code should i use to indicate the time and sampling number?


Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7,148850.0.html

This will help to make your sketch easier to read and the diagram will help with your connections.
Can you post a link to the data of your encoder please.

Thanks Tom… :slight_smile: