chipKIT® Development Platform

Inspired by Arduino™

Very large table help

Created Fri, 13 Dec 2013 15:36:15 +0000 by kaaasap


kaaasap

Fri, 13 Dec 2013 15:36:15 +0000

I am reading measurements from an LVDT sensor module via rs-485 to UART. The sensor measures down to .0001. I am making a table for 2600 points along the stroke (rows) and 15 scales (columns). The data read out is non linear due to the ADC and proprietary software built into the module.

It looks like this: E0 //status byte 43 //acknowledge byte 0 // null B6 //Four byte reading (32 bit) lsb first, however 1st and 4th bytes never change 9F
FE
FE 0 // null 20 //status byte 41 //acknowledge byte 0 // null 5C //status byte FE //acknowledge byte DE //acknowledge byte 0 // null

Attached is an excel of some of the points and conversion to scale.

First, how would I make a table this large? Second, how would I use the reply message to find conversion on table?


kaaasap

Fri, 13 Dec 2013 15:38:07 +0000

Oh, and its at 187500 baud.


rasmadrak

Mon, 16 Dec 2013 22:27:49 +0000

Hi there,

I don't mean any disrespect - but I don't understand what exactly you want to do? Unless I'm missing something you'd simply define an array, fill it with values and do what needs to be done with the values.

If it's a very large array you could create it dynamically or change the heap/stack size. But it depends on which board it is you're developing for?


kaaasap

Wed, 18 Dec 2013 15:32:09 +0000

I was able to get the manufacturer to release the non-standard rs485 protocalls that they use. For the four byte reading reply from the module, they run bytes 1 through 3 through a calculation as follows:

byte ((byte 3 x 65536) + (byte 2 x 256) + byte 1) / 16384.

I am having trouble capturing the bytes from the buffer to run through the calculation, then printing the result.

Here is my code: #include <genieArduino.h>

int buffer2 = 1; int buffer = 14; int testVal; int M1; int M2; int M3; int i;

void setup() {

Serial.begin(115200); Serial1.begin(187500);

pinMode(8, OUTPUT); digitalWrite(8, LOW); }

void loop() { unsigned char reading[buffer]; unsigned char RxVal[i]; while (Serial1.available()) { reading[buffer] = Serial1.read(); delayMicroseconds(1200); Serial.println(reading[buffer],DEC); delay(1); M3 = reading[5]; M2 = reading[4]; M1 = reading[3];} if (M1 != 0 && M2 != 0 && M3 != 0) for (i = 0; i < 1; i++){ RxVal[i] = ((((M3 * 65536) + (M2 * 256) + M1)/16384)); delay(1);} if (RxVal[i] != 0){ Serial.println(RxVal[i],DEC); delay(1); i = 0; M1=0; M2=0; M3=0; } }

/void PrintVal() { for (buffer = 0; buffer < 14; buffer ++){ unsigned int reading[buffer]; reading[buffer] = Serial1.read(); delayMicroseconds(1200); if (reading[0],DEC == 224)} }/

I know I am probably doing many things wrong, but can not figure out what.


kaaasap

Thu, 19 Dec 2013 15:39:05 +0000

I figured out the non standard the company is using to convert the bytes, now it turns out the four bytes are in raw hex (32 bit).

Now I just need to convert the raw hex to decimal to run through the math!


kaaasap

Thu, 19 Dec 2013 15:47:27 +0000

When I print (reading[buffer],HEX) , I get this: 04C14C6000047147008

04C1 is the read command bytes. 4C6000 is the reading response bytes (lsb first). the rest is just a status response.

So 6000 is 6 counts on the LVDT.