Go Down

Topic: problems with TPIC6B595 and mega interface using SPI (Read 1 time) previous topic - next topic

yevgenievich

Feb 19, 2017, 02:54 pm Last Edit: Feb 21, 2017, 02:17 pm by yevgenievich
I am missing something trying to control the shift registers using the mega board. The schematic is attached. I am also using the adg732's and they are working correctly. I have a low level code down for testing. I am basically looking to have all of the shift registers to either sink the pins down or not.
Set the pins for spi dataPin = 50, clockPin = 52; latchPin = 53;
The shift registers have no response. Have verified gnds and V+ to be connected
 
Code: [Select]
// use SPI to control with TPIC6B595 Shift Register

#include <SPI.h>
//const int dataPin = 51; // MOSI / ser in
//const int clockPin = 52; // SPI CSLK / srck
const int latchPin = 53; // SPI SS / rck
int AD732A0=34;
int AD732A1=36;
int AD732A2=38;
int AD732A3=40;
int AD732A4=42;
int AD732CS=44;
int AD732WR=46;
int AD732EN=48;
int AD732A05=22;
int AD732A15=24;
int AD732A25=26;
int AD732A35=28;
int AD732A45=30;

int ledPin = 13;
//int enable = 2;
byte pulse = 0b11111111;
byte off = 0b00000000;
int timer = 5000;
int authtimer = 13000;
int longtimer = 5000;

void setup()
{
  // pinMode(enable, OUTPUT);
  pinMode(latchPin, OUTPUT);
 
  //pinMode(dataPin, OUTPUT);
  //pinMode(clockPin, OUTPUT);
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV8);
  pinMode(ledPin, OUTPUT);
  pinMode(AD732A0, OUTPUT);
  pinMode(AD732A1, OUTPUT);
  pinMode(AD732A2, OUTPUT);
  pinMode(AD732A3, OUTPUT);
  pinMode(AD732A4, OUTPUT);
  pinMode(AD732CS, OUTPUT);
  pinMode(AD732WR, OUTPUT);
  pinMode(AD732EN, OUTPUT);
  pinMode(AD732A05, OUTPUT);
  pinMode(AD732A15, OUTPUT);
  pinMode(AD732A25, OUTPUT);
  pinMode(AD732A35, OUTPUT);
  pinMode(AD732A45, OUTPUT);
  //digitalWrite (enable, LOW);
 

}

void loop()

{
 // digitalWrite (enable, HIGH);
  digitalWrite (AD732CS, LOW);
  digitalWrite (AD732WR, LOW);
  digitalWrite (AD732A0, LOW);
  digitalWrite (AD732A1, LOW);
  digitalWrite (AD732A2, LOW);
  digitalWrite (AD732A3, LOW);
  digitalWrite (AD732A4, LOW);
  digitalWrite (AD732EN, LOW);
  digitalWrite(ledPin, HIGH);
  delay (authtimer);
  digitalWrite (AD732EN, HIGH);
  digitalWrite(ledPin, LOW);
   digitalWrite (latchPin, LOW);
  //shiftOut(dataPin, clockPin, MSBFIRST, pulse);
      SPI.transfer (pulse);
  digitalWrite (latchPin, HIGH); 
  delay (timer);
  //digitalWrite (enable, LOW);
  digitalWrite(ledPin, HIGH);
   digitalWrite (latchPin, LOW);
  //shiftOut(dataPin, clockPin, MSBFIRST, off);
      SPI.transfer (off);
  digitalWrite (latchPin, HIGH); 
    delay(timer);
 // digitalWrite (enable, HIGH);
  digitalWrite(ledPin, LOW);
  delay(5000);
}

PaulRB



OK, you need to explain much more before anyone can help you.

What is your circuit designed to do? What is is application?

What is an ad732? Can you post a link to is data sheet?

How do you know that the ad732 are working and the tpic are not working?

Can you please Auto Format your code and add in some comments?

Can you please explain what you mean by "I have a low level code down for testing. I am basically looking to have all of the shift registers to either sinc the pins down or not."? Did you mean "sink" or "sync"?

yevgenievich

#2
Feb 20, 2017, 01:37 am Last Edit: Feb 20, 2017, 01:42 am by yevgenievich
Hello, the correct word is sink. By low level code, i mean it is simplified for testing without all the extras. There are 96 inputs that get cycled by adg732 multiplexer to read a value and then the 595's are used to sink all 96 inputs to ground. The multiplexer does selectively connect my inputs, but when trying to sink, i get no response.

yevgenievich

updated code
Code: [Select]
// use SPI to control with TPIC6B595 Shift Register

#include <SPI.h>
const int dataPin = 50; // MOSI / ser in
const int clockPin = 52; // SPI CSLK / srck
const int latchPin = 53; // SPI SS / rck
int AD732A0=34; //adg732 #4 A0
int AD732A1=36; //adg732 #4 A1
int AD732A2=38; //adg732 #4 A2
int AD732A3=40; //adg732 #4 A3
int AD732A4=42; //adg732 #4 A4
int AD732CS=44; //adg732
int AD732WR=46; //adg732
int AD732EN=48; //adg732
int AD732A05=22; //adg732 #5 A0
int AD732A15=24; //adg732 #5 A1
int AD732A25=26; //adg732 #5 A2
int AD732A35=28; //adg732 #5 A3
int AD732A45=30; //adg732 #5 A4
int AD732A06=23; //adg732 #6 A0
int AD732A16=25; //adg732 #6 A1
int AD732A26=27; //adg732 #6 A2
int AD732A36=29; //adg732 #6 A3
int AD732A46=31; //adg732 #6 A4

int ledPin = 13;
int enable = 2;
byte pulse = 0b11111111;
byte zero = 0b00000000;
int timer = 5000;
int authtimer = 13000;
int longtimer = 5000;
int shorttimer = 5000;

void setup()
{
  pinMode(enable, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  //SPI.begin();
  //SPI.setClockDivider(SPI_CLOCK_DIV8);
  pinMode(ledPin, OUTPUT);
  pinMode(AD732A0, OUTPUT);
  pinMode(AD732A1, OUTPUT);
  pinMode(AD732A2, OUTPUT);
  pinMode(AD732A3, OUTPUT);
  pinMode(AD732A4, OUTPUT);
  pinMode(AD732CS, OUTPUT);
  pinMode(AD732WR, OUTPUT);
  pinMode(AD732EN, OUTPUT);
  pinMode(AD732A05, OUTPUT);
  pinMode(AD732A15, OUTPUT);
  pinMode(AD732A25, OUTPUT);
  pinMode(AD732A35, OUTPUT);
  pinMode(AD732A45, OUTPUT);
  digitalWrite (AD732CS, LOW);
  digitalWrite (AD732WR, LOW);
  digitalWrite (enable, LOW);
 

}

void loop()

{
  digitalWrite (enable, HIGH); // disable 595
  digitalWrite (AD732A0, LOW); //turn 1 on
  digitalWrite (AD732A1, LOW);
  digitalWrite (AD732A2, LOW);
  digitalWrite (AD732A3, LOW);
  digitalWrite (AD732A4, LOW);
  digitalWrite (AD732EN, LOW); // enable adg
  digitalWrite (ledPin, HIGH);
  delay (authtimer);          // wait for auth
  digitalWrite (ledPin, LOW);
 digitalWrite (AD732EN, HIGH); //disable adg
  delay (timer);
  sink();
  delay(shorttimer);
  off();
  delay(shorttimer);
  sink();
  delay(shorttimer);
  off();
  delay(longtimer);
  sink();
}
void sink()
{
  digitalWrite (enable, LOW);
  digitalWrite (latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, pulse);
  //SPI.transfer (pulse);
  digitalWrite (latchPin, HIGH);  
}
void off()
{
  digitalWrite (enable, HIGH);
  digitalWrite (latchPin, LOW);
  shiftOut(dataPin, clockPin, MSBFIRST, zero);
  //SPI.transfer (off);
  digitalWrite (latchPin, HIGH);  
}

yevgenievich

#4
Feb 20, 2017, 09:03 pm Last Edit: Feb 20, 2017, 09:53 pm by yevgenievich
problem resolved. Noticed pin no8 going low after some time on the first chip in the chain. Cut the chip out and moved the serial to the next one in line. The rest of them work. First chip was bad.

PaulRB

Thanks for letting everyone know what the problem was.

Go Up