Hi I m new to this forum, so please fogive me if the question is not well posed or as already been answered.
I m using a Teensy3.6 board to read data from an encoder and then write the estimated angular position to pin A21 using analogWrite.
I ve noticed a problem and I d like to know if it is a known behaviour and if there is any way to mitigate/solve it.
The problem is the following:
After 12h of working time the analog output started to be noisy (noise range +-0.2V) which make it unusable for the purpose.
I then tried to change the ouput pin from A21 to A22 and the noise is reduced to the original values (noise range +- 0.005V).
Since i only changed the output pin without altering the circuit i can assume the noise does not come from othersignals connected to the DAQ nor from the power supply.
Is there a way to solve the problem?
thanks in advance!
The connection layout is quite simple,
- Input TTL signal A+, B+ on digital pin 6 and 7
- Analog Output on pin A21 connected to a DAQ
The board is powered using 5V from a dedicated power supply.
i used the following script:
I m using a Teensy3.6 board to read data from an encoder and then write the estimated angular position to pin A21 using analogWrite.
I ve noticed a problem and I d like to know if it is a known behaviour and if there is any way to mitigate/solve it.
The problem is the following:
After 12h of working time the analog output started to be noisy (noise range +-0.2V) which make it unusable for the purpose.
I then tried to change the ouput pin from A21 to A22 and the noise is reduced to the original values (noise range +- 0.005V).
Since i only changed the output pin without altering the circuit i can assume the noise does not come from othersignals connected to the DAQ nor from the power supply.
Is there a way to solve the problem?
thanks in advance!
The connection layout is quite simple,
- Input TTL signal A+, B+ on digital pin 6 and 7
- Analog Output on pin A21 connected to a DAQ
The board is powered using 5V from a dedicated power supply.
i used the following script:
Code:
Encoder myEnc(6, 7);
const float MPI(3.14159265358979323846);
const int nSteps(4096*2);
void setup() {
analogWriteResolution(12);
Serial.begin(9600);
Serial.println("Basic Encoder Test:");
}
long oldPosition = -999;
void loop() {
long newPosition = myEnc.read();
if (newPosition != oldPosition) {
float angleRad = 2.0*MPI*static_cast<double>(newPosition % nSteps ) / static_cast<double>(nSteps);
if ( newPosition < 0 ) {
angleRad += 2*MPI;
}
long analogAngle = (long)(angleRad/(2.0*MPI)*4096);
analogWrite(A22, analogAngle);
oldPosition = newPosition;
}
}
Attachments
Last edited: