Go Down

Topic: Long distance communication problem with serial shift register (Read 275 times) previous topic - next topic

saki_001

Hi
I am communicating with CD4021 shift register with my arduino nano over the distance of around 15-20 feet. I am trying to receive data at 20KHz but I could not read output. when I lower the clock frequency (less than 10KHz) then I can read data correctly. My sensor side(which contain 4021 IC) is operating at 12V. So To get 12V for clock and Parallel/Serial  pin. I am using ULN2803 IC( to convert 5v to 12V) in inverting way. and voltage divider with data output line on arduino side( to convert 12V to 5V). The cable being used is ribbon cable. If I remove the cable and connect my controller card directly there. It works perfectly. but when i add cable I have to lower frequency alot. I guessed the problem is impedance mismatching but I don't know how to eradicate this problem. Is there simple way to solve this by changing anything on controller side(line driver, optocoupler or change resistor values). as I can't modify any thing on sensor array side.
Code: [Select]
int led = 12;
int latch =  11;
int cloc = 10;
int daata = 5;
const byte interruptPin = 2;
volatile byte state = LOW;
int add = 0, sum = 0;
void sample();
int readData();
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(led, OUTPUT);
  pinMode(latch, OUTPUT);
  pinMode(cloc,OUTPUT);
  pinMode(daata,INPUT);
  pinMode(interruptPin, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(interruptPin), sample, CHANGE);
 
  Serial.begin(57600);
    digitalWrite(latch, LOW);
      digitalWrite(cloc, LOW);
}

void loop(){
  int c=0;
  if (state == 1)
  {
   c = readData();
   state = LOW;
   if (c>0)
   {
    //Serial.println(c);
    add=1;
    sum+=2*c;
   }
   else if(add == 1)
   {
    Serial.println(sum/2);
    sum = 0;
    add = 0;
   }
  }

}


int readData(){
   int n=0,d=0;
   int i=0;
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1);   
  digitalWrite(latch,HIGH);
  digitalWrite(led,LOW);   // turn the LED on (HIGH is the voltage level)
  digitalWrite(13, LOW);   // turn the LED on (HIGH is the voltage level)
  for(i=63;i>=0;i--)
  {
    n= digitalRead(daata);
    if(n==1)                // check either c 0 or c 1 if(c!=0)
     d++;
     //else
     //Serial.println(i);
    // c=0;
    digitalWrite(cloc, HIGH);
    delayMicroseconds(10);
    digitalWrite(cloc, LOW);
    delayMicroseconds(10);
  }
  digitalWrite(latch,LOW);
 // Serial.println(d);
  return d;
}
void sample(){
  state = HIGH;
}

I am also adding picture for clarification of my circuit.

Paul_KD7HB

The capacitance of the ribbon cable is too much for the CMOS devices to drive a signal through, as proven by your test. The CMOS cannot produce enough current to charge/discharge the effective capacity of the cable. Add a buffer IC to drive the cable wires.

Paul

saki_001

The capacitance of the ribbon cable is too much for the CMOS devices to drive a signal through, as proven by your test. The CMOS cannot produce enough current to charge/discharge the effective capacity of the cable. Add a buffer IC to drive the cable wires.

Paul
But there is schmitt trigger being used on sensor side( every signal i.e P/S, Clock  and Q7 passes through schmitt trigger. So do I  need to add one on controller side too?

wolframore

post the actual schematic and not just part of it... and what is the 4021 being powered at?  That divider is eating a lot of current up.
Bad Boys Rate Our Young Girls But Violet Goes willingly - Get Some Now :) - ELI the ICE man

saki_001

post the actual schematic and not just part of it... and what is the 4021 being powered at?  That divider is eating a lot of current up.
I dont have full schematics of that circuit. I traced the circuit with which i was concerned and found that schmitt trigger is in between port of that sensor and shift register.

Grumpy_Mike

Quote
I guessed the problem is impedance mismatching
No it is not.

But there is schmitt trigger being used on sensor side( every signal i.e P/S, Clock  and Q7 passes through schmitt trigger. So do I  need to add one on controller side too?
Not necessarily you need a driver that can cope with the capacitance of the cable. This may or may not be another buffer. The fact that it has a Schmitt on the input is irrelevant.

Quote
I dont have full schematics of that circuit.
I am constantly amazed at how anyone builds a circuit without a schematic. If you try then you are just asking for trouble.

saki_001

No it is not.
Not necessarily you need a driver that can cope with the capacitance of the cable. This may or may not be another buffer. The fact that it has a Schmitt on the input is irrelevant.
I am constantly amazed at how anyone builds a circuit without a schematic. If you try then you are just asking for trouble.
Thanks for your response Mike. You are right but I don't have any experience of working with analog electronics. So i just saw the functionality of board and tried to interface with my controller. Now as I have already mentioned my problem. So I would really appreciate if anyone could give me practical solution to my problem which I could implement. When I checked the value of resistances from sensor bar port all value came to be very high. Please guide me what should I do

Paul_KD7HB

Thanks for your response Mike. You are right but I don't have any experience of working with analog electronics. So i just saw the functionality of board and tried to interface with my controller. Now as I have already mentioned my problem. So I would really appreciate if anyone could give me practical solution to my problem which I could implement. When I checked the value of resistances from sensor bar port all value came to be very high. Please guide me what should I do
We keep trying to tell you that you are dealing with DIGITAL circuits!

Paul

saki_001

We keep trying to tell you that you are dealing with DIGITAL circuits!

Paul
I know I am wrong. Could someone just guide me what to do here or everyone will just keep telling me that I am wrong. I need guidance on what I can do here

Paul_KD7HB

I know I am wrong. Could someone just guide me what to do here or everyone will just keep telling me that I am wrong. I need guidance on what I can do here
My suggestion is to look for a "line driver" cmos ic and put between the wires and the sensor.

Paul

Go Up