Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Troubleshooting / need help!!!  arduino SPI programming the MCP6S21 on: September 17, 2010, 07:03:12 am
Hi,
Can somebody please help me understand how to program using the SPI library on MCP6S21. I'm using the Arduino Duemilanove(Atmega328) with the software ver 0019.
The MCP6S21 is 8-PDIP from microchip programmable gain amplifier (PGA) using SPI: SCK, SI, CS (only 3 pins - input only).
I've tried over and over again to simply write a program that changes the amplifier gain to X2 but with no success at all. The MCP6S21 basically programmed through the SPI interface using 16-bit words.
From what I see in the datasheet it supposed to be very simple but I've tried many variations of programs like the arduino examples: DigitalPotControl, BarometricPressureSensor or even something more close: /playground/Code/MCP3208
so far nothing worked.
 
I'm new to SPI and if someone can shade a light for me I'll be very grateful...
2  Forum 2005-2010 (read only) / Interfacing / Re: need help!!!  arduino SPI programming the MCP6S21 on: September 17, 2010, 12:16:29 pm
I've found out what was wrong: the problem was in my circuit..
I used VSS<0 and I missed that it must be: |VDD-VSS|<7v
as mention in the datasheet...
Now it's working great and it's a very precise gain amp.
3  Forum 2005-2010 (read only) / Interfacing / Re: need help!!!  arduino SPI programming the MCP6S21 on: September 17, 2010, 10:03:44 am
deSilva:

Based on what u say VREF should not be set to ground?
according to the datasheet of the MCP6S21:

for VREF=VSS=GND: VOUT=GAIN*CH0
and for VDD>=VREF>VSS=GND: VOUT=VREF+GAIN*(CH0-VREF)
4  Forum 2005-2010 (read only) / Interfacing / Re: need help!!!  arduino SPI programming the MCP6S21 on: September 17, 2010, 09:25:04 am
deSilva:
First thanks for your post,

I've tried what u suggested:
SPI.setClockDivider(SPI_CLOCK_DIV16);
or
SPI.setClockDivider(SPI_CLOCK_DIV32);
even
SPI.setClockDivider(SPI_CLOCK_DIV64);
or changing CS to high in the beginning,
but nothing changed a thing . I am still reading on the output wire the same voltage in the CH0 (input) , meaning x1 gain and not x2.
maybe there is a problem with the SPI library ?

Here is my circuit schematic:
5  Forum 2005-2010 (read only) / Interfacing / Re: need help!!!  arduino SPI programming the MCP6S21 on: September 17, 2010, 08:31:38 am
Here is my current program:

#include <SPI.h>
/*
  * CS - to digital pin 10  (SS pin)
  * SDI - to digital pin 11 (MOSI pin)
  * CLK - to digital pin 13 (SCK pin)
*/

#define CS  10

void setup() {
  // set CS as an output:
  pinMode (CS, OUTPUT);
  // initialize SPI:
  SPI.begin();
  SPI.setBitOrder(MSBFIRST); // MSB first bit order
  SPI.setDataMode(SPI_MODE0); //SPI Mode 0
  SPI.setClockDivider(SPI_CLOCK_DIV4); // 16MHZ/4 = 4MHZ
   // take the SS pin low to select the chip:
  digitalWrite(CS,LOW);
  //  send in the address and value via SPI:
  SPI.transfer(B01000000); // Instruction Register set to "write to register"
  SPI.transfer(B00000001); // Gain Register set to "Gain of +2"
  // take the SS pin high to de-select the chip:
  digitalWrite(CS,HIGH);
  SPI.end();
}

void loop() {
}
6  Forum 2005-2010 (read only) / Interfacing / need help!!!  arduino SPI programming the MCP6S21 on: September 17, 2010, 07:09:05 am
Hi,
Can somebody please help me understand how to program using the SPI library on MCP6S21. I'm using the Arduino Duemilanove(Atmega328) with the software ver 0019.
The MCP6S21 is 8-PDIP from microchip programmable gain amplifier (PGA) using SPI: SCK, SI, CS (only 3 pins - input only).
I've tried over and over again to simply write a program that changes the amplifier gain to X2 but with no success at all. The MCP6S21 basically programmed through the SPI interface using 16-bit words. link to DATASHEET:  http://ww1.microchip.com/downloads/en/DeviceDoc/21117a.pdf

From what I see in the datasheet it supposed to be very simple but I've tried many variations of programs like the arduino examples: DigitalPotControl, BarometricPressureSensor or even something more close: http://www.arduino.cc/playground/Code/MCP3208
so far nothing worked.
 
I'm new to SPI and if someone can shade a light for me I'll be very grateful...
Pages: [1]