Hello! First time posting here. I am a beginner when it comes to electronics and I have to work on a project that requires a lot of Arduino knowledge. I want to create an EMG amplifier using this schematic (the first one is the original one - Figure 8 Nerve Impulse Amplifier and the second one is the one that I am using, instead of the Rg I added the digital potentiometer AD8402 because it is a must to have an automation part - I have to control the digipot through Arduino, while the rest of the circuit is powered by 2 +9V batteries).
My teacher told me to put a 1k braking/brake resistor in series with the 2 Rgs from the LT1167 (I wish I knew why lol), like this
My problem is that I have no idea what code should I use to control the AD8402 digipot, which pins (both from AD8402 and Arduino) should I use for the code. I found these 2 codes but apparently they are for AD8403.
- /*
Digital Pot Control
This example controls an Analog Devices AD8403 digital potentiometer.
The AD8403 has 4 potentiometer channels. Each channel's pins are labeled
A - connect this to voltage
W - this is the pot's wiper, which changes when you set it
B - connect this to ground.
The AD8403 is SPI-compatible. To command it you send two bytes.
The first byte is the channel number starting at zero: (0 - 3)
The second byte is the resistance value for the channel: (0 - 255).
The AD8403 also contains shutdown (SHDN) and reset (RS) pins. The shutdown
pin disables all four of the potentiometers when taken low and enables all
pots when high. The values of the pots can be adjusted while shutdown is active.
The reset pin sets all of the pots back to their center value when taken low.
Reset may or may not be useful for your particular application. In this circuit
reset is simply tied to +5v to keep it inactive.
The circuit:
- All A pins of AD8403 connected to +5V
- All B pins of AD8403 connected to ground
- An LED and a 220-ohm resisor in series connected from each W pin to ground
- RS - to +5v
- SHDN - to digital pin 7 and a pull down resistor
- CS - to digital pin 10 (SS pin)
- SDI - to digital pin 11 (MOSI pin)
- CLK - to digital pin 13 (SCK pin)
Thanks to Tom Igoe and Heather Dewey-Hagborg for their code which this was built on.
*/
// inslude the SPI library:
#include <SPI.h>
// set pin 10 as the slave select for the digital pot:
const int slaveSelectPin = 10;
const int shutDownPin = 7;
void setup() {
// set the slaveSelectPin as an output
pinMode (slaveSelectPin, OUTPUT);
// set the shutDownPin as an output
pinMode (shutDownPin, OUTPUT);
// initialize SPI
SPI.begin();
//Shutdown the pots to start with
digitalWrite(shutDownPin, LOW);
//Set all pots to zero as a starting point
for (int channel = 0; channel < 4; channel++) {
digitalPotWrite(channel, 0);
}
}
void loop() {
digitalWrite(shutDownPin, LOW);
int channel = 0;
// Loop through the four channels of the digital pot.
for (int channel = 0; channel < 4; channel++) {
// Change the resistance on this channel from min to max.
// Starting at 50 because the LED doesn't visibly change
// before that point.
digitalWrite(shutDownPin, HIGH);
for (int level = 50; level < 255; level++) {
digitalPotWrite(channel, level);
delay(2);
}
// wait a bit at the top
delay(5);
digitalWrite(shutDownPin, LOW);
// change the resistance on this channel from max to min:
digitalWrite(shutDownPin, HIGH);
for (int level = 0; level < 205; level++) {
digitalPotWrite(channel, 255 - level);
delay(2);
}
}
digitalWrite(shutDownPin, LOW);
}
void digitalPotWrite(int address, int value) {
// take the SS pin low to select the chip:
digitalWrite(slaveSelectPin, LOW);
// send in the address and value via SPI:
SPI.transfer(address);
SPI.transfer(value);
// take the SS pin high to de-select the chip:
digitalWrite(slaveSelectPin, HIGH);
}
- #include <SPI.h>
const int slaveSelectPin = 10;
int value=0;
void setup(){
Serial.begin(115200);
pinMode(slaveSelectPin, OUTPUT);
SPI.begin();
digitalPotWrite(0,0); // remember to initialize
digitalPotWrite(1,0); // remember to initialize
}
void loop(){
Serial.print("Hello\n");
for (byte channel = 0; channel < 2; channel++){
for (byte level = 0; level < 255; level++){
digitalPotWrite(channel, level);
delay(2);
Serial.print(0+channel);
Serial.print(" ");
Serial.println(0+level);
}
}
}
void digitalPotWrite(byte address, byte value){
digitalWrite(slaveSelectPin, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(slaveSelectPin, HIGH);
I don't know which addresses, channels and pins to use in my case. My teacher also told me to not have a GND so that I will have symmetrical power supply (?) and to only power the LT1167/circuit by the 2 +9V batteries. I will then connect the circuit to some surface electrodes for the EMG signaIs, I will have to use Visual Analyser both as a signal generator and as a digital measuring device. I am really confused and don't know what to do. Sorry for my not so best English and weird words, I am really a complete beginner. I would love to get some help Thank you!