Go Down

Topic: Reading data at 10 Khz rate (Read 16 times) previous topic - next topic

Graynomad

You have to up the serial port bit rate as Mike said, use 115200 and get the serial over with fast.

But I suspect that you will have another problem. What is the format of this data? Is each 4 bits a unique value or just part of a continuous bit stream. If it's a unique value you have to sync with the nibbles and with SPI that's all but impossible without another input or a longish time delay between nibbles.

Before working any more with code we need to know the exact nature of the incoming bits and the timing between the groups of four.

Quote
Data is coming from a decoding device

Data sheet?

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

newbee_2

Decoding device is under process(We are building our own homemade BCH decoder)
You can say it is filter tuned for 5.5 khz and 3.125 khz and it generates pulses and clock recovery system recover 10 khz clock now output from the 3.125 khz is passed through not gate to get stream of 128 bits(0 and 1) now each positive edge we need to read the value and each nibble we need convert to serial data and send it to pc. AS i said before it is like data acquisition system which can sample at 10 khz rate discrete input
If you have any other inquiry please let me know
Thanks in advance
Niladri   
Thanx & Regards

Niladri

Graynomad

#22
Oct 03, 2012, 10:16 am Last Edit: Oct 03, 2012, 10:22 am by Graynomad Reason: 1
Ok,

1. If there's 128 bits why do you need to grab them in nibbles.
2. Is there any space/extra time between the nibbles?
3. Is there any space/extra time between the 128-bit packets?
4. What is the format of each nibble?
5. Is there any way to detect the start/end of a 128-bit packet?

All this is leading to how do you sync with the data stream? If there is no spaces between nibbles and/or packets it is well nigh impossible to sync if you get out of whack.

EDIT: #5 added.
______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

newbee_2

#23
Oct 03, 2012, 11:50 am Last Edit: Oct 03, 2012, 12:12 pm by newbee_2 Reason: 1
No first 24 bit will be CAAC1F(in HEX) if it is then receive next 96 bits otherwise slide to next bit until it matches the string but the string matching is done on a PC where LabVIEW software is running so my job is to silde it until i get send all 96 bits command from labview

And this code is somewhat working can you take a look at it.
Code: [Select]

const int pin2 = 2;
const int pin4 = 4;
int clock;
int clock1;
int val1;
int val2;
int val3;
int val4;
int val5;
int val6;
int val7;
int val8;
byte value =0000000;

void setup()
{
 pinMode(pin2, INPUT);
 
 pinMode(pin4, INPUT);
 
 Serial.begin(2400);
}
void loop()
{
 static byte val  = 0b00000001;

   clock = digitalRead(pin2);
   if ((clock == HIGH) & (clock1 == LOW)) {  
      val <<= 1;
      val1 = digitalRead(pin4);
      val2 = digitalRead(pin4);
      val3 = digitalRead(pin4);
      val4 = digitalRead(pin4);
      val5 = digitalRead(pin4);
      val6 = digitalRead(pin4);
      val7 = digitalRead(pin4);
      val8 = digitalRead(pin4);
            if(val | 0x80) {   // flag bit has reached the top of the byte so we've done 8 iterations
         
          value=(value | (val1<<7));
          value=(value | (val2<<6));
          value=(value | (val3<<5));
          value=(value | (val4<<4));
          value=(value | (val5<<3));
          value=(value | (val6<<2));
          value=(value | (val7<<1));
          value=(value | (val8<<0));
         
         
         
          Serial.print(value & 0xFF, HEX);
          val = 0b00000001;
        }
       
   }
   clock1= clock;
}


And for your questions
1. I need to send them as hex format for labview understanding
2. No
3. No
4. HEX
5. Keep on sending that Data till i receive a command from pc send next 96 bits of data that data also need to in HEX format fro labview understanding.
Thanks in Advance
Niladri  
Thanx & Regards

Niladri

newbee_2

Sorry for that last code
Code: [Select]

const int pin2 = 2;
const int pin4 = 4;
int clock;
int clock1;

void setup()
{
  pinMode(pin2, INPUT);
   
  pinMode(pin4, INPUT);
 
  Serial.begin(2400);
}
void loop()
{
  static byte val  = 0b00000001;

    clock = digitalRead(pin2);
    if ((clock == HIGH) && (clock1 == LOW)) {   
       val <<= 1;

         val |= digitalRead(pin4);
             if(val | 0x80) {   // flag bit has reached the top of the byte so we've done 8 iterations
           

           
                     
           Serial.print(val & 0x7F, HEX);
           Serial.println();
           val = 0b00000001;
         }
   
    }
    clock1= clock;
}
Thanx & Regards

Niladri

Go Up