I'm getting very phantom readings, nothing connected to the inputs but spikes up to 100% on both channels...
What can cause this behaviour?
I just used an 8Mhz prescaler:
//Define parameters used.
Code: Select all
#define SPU_SET_PRESCALAR_8MHz 0b01000110 /* 8MHz prescalar with SDO active. */
#define SPU_SET_CHANNEL_1 0b11100000 /* Setting active channel to 1 */
#define SPU_SET_CHANNEL_2 0b11100001 /* Setting active channel to 2 */
#define SPU_SET_BAND_PASS_FREQUENCY 0b00101010 /* Setting band pass frequency to 7.27kHz. */
#define SPU_SET_PROGRAMMABLE_GAIN 0b10101111 /* Setting programmable gain to 0.222. */
#define numberofCylinders 4 /* Defines the amount of cylinders for calculating engine speed. */
#define SPU_SET_INTEGRATOR_TIME 0b11001010 /* Setting programmable integrator time constant to 100µs */
#define KNOCK_THRESHOLD_LEVEL 204 /* Setting knock LED level, max value of 255. */
#define MEASUREMENT_WINDOW_TIME 3000 /* Defining the time window of measurement to 3ms. */
Serial printout:
Code: Select all
Channel 1: 17% - Channel 2: 17%
Channel 1: 16% - Channel 2: 3%
Channel 1: 3% - Channel 2: 17%
Channel 1: 17% - Channel 2: 17%
Channel 1: 17% - Channel 2: 17%
Channel 1: 17% - Channel 2: 17%
Channel 1: 17% - Channel 2: 100%
Channel 1: 100% - Channel 2: 35%
Channel 1: 35% - Channel 2: 17%
Channel 1: 17% - Channel 2: 16%
Channel 1: 31% - Channel 2: 100%
Channel 1: 28% - Channel 2: 17%
Channel 1: 17% - Channel 2: 17%
Channel 1: 17% - Channel 2: 17%
Channel 1: 16% - Channel 2: 100%
Channel 1: 100% - Channel 2: 38%
Channel 1: 17% - Channel 2: 31%
Channel 1: 31% - Channel 2: 31%
Channel 1: 31% - Channel 2: 31%
Channel 1: 31% - Channel 2: 31%
Channel 1: 31% - Channel 2: 31%
Channel 1: 17% - Channel 2: 17%
Channel 1: 17% - Channel 2: 17%
Channel 1: 17% - Channel 2: 17%
Channel 1: 100% - Channel 2: 16%
Channel 1: 10% - Channel 2: 10%
Channel 1: 10% - Channel 2: 17%
Channel 1: 1% - Channel 2: 1%
Channel 1: 16% - Channel 2: 30%
Channel 1: 30% - Channel 2: 100%