Analog output for Knock Shield

Support forum for the Knock Shield designed to connect knock sensors to Arduino projects.
Post Reply
User avatar
Christian_Bylund
Posts: 270
Joined: 07 Mar 2015 18:09

Analog output for Knock Shield

Post by Christian_Bylund » 19 Dec 2019 00:45

Is it possible to implement an analog output for the Knock Shield?
Yes, just like we did for the Lambda Shield.

Image
Here is how to connect the RC-filter to the Arduino.

Image

This is the RC-filter used in the example.

To enable the output first we need to define the pin to be used.

Code: Select all

#define ANALOG_OUTPUT_PIN 3 /* Pin used for the PWM to the 0-1V analog output. */
Second we need an output proportional to the input.

Code: Select all

uint8_t analogOutput = map(adcValue_UA, 0, 1023, 0, 255);
analogWrite(ANALOG_OUTPUT_PIN, analogOutput);
Image
The RC-filtered signal (blue) and unfiltered PWM signal (red).

Download the updated example code from GitHub.
Best Regards,
Christian Bylund
Bylund Automotive AB

Post Reply