Datalogging 10 bit stream

Any wideband device that doesnt have its own category yet.

Moderator: Matt

Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Datalogging 10 bit stream

Post by Matt »

Nistune runs under linux but there is a problem with the comms dropping out with consult which I have on my list to look at

I'm trying to get VEMS working at the moment and get that release done. Then I'll add this one next, but we need a clear definition of inputs to use
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Datalogging 10 bit stream

Post by Matt »

Okay guys here is your Anduino solution. There are no Nistune software changes required for this so it will work with all current Nistune version. Basically I've taken the DLP definitions and protocol and put most of it into the Arduino. Several hours later we have something which is compatible with the analog inputs for DLP Design A/D converter and means no additional Nistune code needed :D

Get the code below, compile and upload to your chosen Arduino device. It creates a COM port @ 115200bps and acts like a DLP device for the purpose of Nistune uses. Nistune will poll the device, then setup binary mode and then query channels 1-8. I've tested tonight with two channels. Make sure the device is grounded. I seem to get a bit of fluctuation on my bench but that may be the power supply I'm using

Channel 1 (A0) is AFR LHS like with DLP and channels 2-6 (A1-A5) are auxillary inputs AUX1-AUX5

Code: Select all

/* Arduino One - DLP emulation */

const int DLP_CMD_DIGITAL_IN_CH1 = 0x41;
const int DLP_CMD_DIGITAL_IN_CH2 = 0x53;    
const int DLP_CMD_DIGITAL_IN_CH3 = 0x44;    
const int DLP_CMD_DIGITAL_IN_CH4 = 0x46;    
const int DLP_CMD_DIGITAL_IN_CH5 = 0x47;    
const int DLP_CMD_DIGITAL_IN_CH6 = 0x4E;    
const int DLP_CMD_DIGITAL_IN_CH7 = 0x4A;    
const int DLP_CMD_DIGITAL_IN_CH8 = 0x4B;

const int DLP_CMD_ANALOG_IN_CH1 = 0x5A;
const int DLP_CMD_ANALOG_IN_CH2 = 0x58;
const int DLP_CMD_ANALOG_IN_CH3 = 0x43;
const int DLP_CMD_ANALOG_IN_CH4 = 0x56;
const int DLP_CMD_ANALOG_IN_CH5 = 0x42;
const int DLP_CMD_ANALOG_IN_CH6 = 0x4E;
const int DLP_CMD_ANALOG_IN_CH7 = 0x4D;
const int DLP_CMD_ANALOG_IN_CH8 = 0x2C;

const int DLP_CMD_TEMPERATURE_IN_CH1 = 0x39;
const int DLP_CMD_TEMPERATURE_IN_CH2 = 0x30;
const int DLP_CMD_TEMPERATURE_IN_CH3 = 0x2D;
const int DLP_CMD_TEMPERATURE_IN_CH4 = 0x3D;
const int DLP_CMD_TEMPERATURE_IN_CH5 = 0x4F;
const int DLP_CMD_TEMPERATURE_IN_CH6 = 0x50;
const int DLP_CMD_TEMPERATURE_IN_CH7 = 0x5B;
const int DLP_CMD_TEMPERATURE_IN_CH8 = 0x5D;

const int DLP_SETUP_FARENHEIT = 0x4C; // not used
const int DLP_SETUP_CELCIUS = 0x3B; // not used
const int DLP_SETUP_ASCII = 0x60;
const int DLP_SETUP_BINARY = 0x5C;

const int DLP_CMD_PING = 0x27;
const int DLP_RESP_PING = 0x51;

const int SET_MODE_ASCII = 0;
const int SET_MODE_BINARY = 1;

const float AD_MULTIPLIER = 5.0/1024.0;

void setup() {
  Serial.begin(115200);
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(A2,INPUT);
  pinMode(A3,INPUT);
  pinMode(A4,INPUT);
  pinMode(A5,INPUT);
}

int rxByte = 0;
int currMode = SET_MODE_ASCII;
int sensorValue = 0;

void loop() 
{
  if (Serial.available() > 0)
  {
     rxByte = Serial.read();
     int sendADVal = false;
     int sendTempVal = false;
     
     switch (rxByte)
     {
       case DLP_SETUP_ASCII:
         currMode = SET_MODE_ASCII;
         break;
       case DLP_SETUP_BINARY:
         currMode = SET_MODE_BINARY;
         break;
       case DLP_SETUP_FARENHEIT:
         break; // not used
       case DLP_SETUP_CELCIUS:
         break; // not used
       case DLP_CMD_PING:
         // ping response
         Serial.write(DLP_RESP_PING);
         break;
       case DLP_CMD_ANALOG_IN_CH1:
         sensorValue = analogRead(A0);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH2:
         sensorValue = analogRead(A1);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH3:
         sensorValue = analogRead(A2);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH4:
         sensorValue = analogRead(A3);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH5:
         sensorValue = analogRead(A4);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH6:
         sensorValue = analogRead(A5);
         sendADVal = true;
         break;
       case DLP_CMD_ANALOG_IN_CH7:
       case DLP_CMD_ANALOG_IN_CH8:
         sensorValue = 0; // not available
         sendADVal = true;
         break;
       case DLP_CMD_TEMPERATURE_IN_CH1:
       case DLP_CMD_TEMPERATURE_IN_CH2:
       case DLP_CMD_TEMPERATURE_IN_CH3:
       case DLP_CMD_TEMPERATURE_IN_CH4:       
       case DLP_CMD_TEMPERATURE_IN_CH5:       
       case DLP_CMD_TEMPERATURE_IN_CH6:       
       case DLP_CMD_TEMPERATURE_IN_CH7:       
       case DLP_CMD_TEMPERATURE_IN_CH8:       
         sensorValue = 0; // not available
         sendTempVal = true;       
         break;       
       default:
         break;
     }
     
     if (sendADVal || sendTempVal)
     {
        if (currMode == SET_MODE_BINARY)
        {
           Serial.write((char)(sensorValue >> 8));
           Serial.write((char)(sensorValue));
        }
        else
        {
           Serial.print((float)sensorValue * AD_MULTIPLIER,2);
           Serial.println("V");
        }
     }
  }
}
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Datalogging 10 bit stream

Post by Matt »

Okay followup post. The indenting gets lost when posting on the forum, so I've included a zip file here to use instead

Okay as for reasons for this way:
1. MIL-tec solution with configuring AD outputs to power the boost sensor straight from the board plugged in is fine but you waste inputs.

You can still modify my code and just assign unused extra channels with 0 response, the same as 7 and 8 which have no physical inputs.

2. Alternate protocol format. We dont use the header because definitions are in the AUX1.csv files etc. Also prefer binary over text as its easier to parse and my DLP code already does it for free
Sensor1 name, Sensor2 name,Sensor3 name<CR><LF>
value1, value2, value3<CR><LF>
Attachments
nistune_ad_converter.zip
DLP A/D emulation
(1.13 KiB) Downloaded 1217 times
djstatic
 

Posts: 175
Joined: Fri Apr 16, 2010 8:59 pm
Location: South East QLD, Gold Coast

Re: Datalogging 10 bit stream

Post by djstatic »

Matt wrote:Okay followup post. The indenting gets lost when posting on the forum, so I've included a zip file here to use instead
Then use the "code" tag :wink: Exhibit A:

*matt edit*
Thanks. Fixed! Now I look like a dumb ass 8)

Its right there next to "quote" !!
makro86
 

Posts: 11
Joined: Sun Dec 25, 2011 8:43 pm

Re: Datalogging 10 bit stream

Post by makro86 »

Hi Matt,

I'm trying to understand all of the code in the sketch.

Code: Select all

if (sendADVal || sendTempVal)
     {
        if (currMode == SET_MODE_BINARY)
        {
           Serial.write((char)(sensorValue >> 8));
           Serial.write((char)(sensorValue));
        }
        else
        {
           Serial.print((float)sensorValue * AD_MULTIPLIER,2);
           Serial.println("V");
        }
     }
(char)(sensorValue >> 8)
What is the purpose of this? Why would you bit shift the value 8 places across?
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Datalogging 10 bit stream

Post by Matt »

To put out the MSB of the value first, and then the LSB

(char) conversion filters to 8 bits. Doing the shift before (char) enables us to put the MSB out
dlP
 

Posts: 6
Joined: Thu Jul 30, 2009 11:44 pm

Re: Datalogging 10 bit stream

Post by dlP »

Hey Matt, i have an unused board with a pic18 in it, and i'm trying to emulate the DLP IO8 serial protocol.
But i'm getting an Comm. TimeOut at the wideband window in NISTUNE. See pics attached please...

Can you tell me wich mode are NISTUNE using (ASCII or binary).
And if it is ASCII, is there a null character or CR at the end of every response?


Thanks!
Attachments
Terminal_dlp1.jpg
Sending a ping, input CH1, input CH2, input CH2, from Terminal
Response with null char and CR
(54.76 KiB) Downloaded 11873 times
Nistune_dlp2.jpg
... and few seconds later...
(21.08 KiB) Downloaded 11873 times
Nistune_dlp1.jpg
When i clin in Lambda...
(34 KiB) Downloaded 11873 times
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Datalogging 10 bit stream

Post by Matt »

Configured for Binary mode (and Celcius)

We ping with 0x27

Then we send a command to read inputs Analog IN CH 1.. CH7

Afterwards we expect 14 bytes back (2 bytes per each channel)

There are no CR/LF characters

Your output 0x27 (ping) then 0x5A (CH1) then 0x58 (CH2) then 0x58 (CH2 again?!) then 0x43 (CH3) is reading the channels

Response 0x51 is correct, then 2 x bytes for each channel. Appears too many bytes below
dlP
 

Posts: 6
Joined: Thu Jul 30, 2009 11:44 pm

Re: Datalogging 10 bit stream

Post by dlP »

Thanks Matt!

The first time you query DLP also set C° and Binary mode, so the complete secuence is...

27 '
3B 5C 5A 58 43 56 42 4E 4D ;\ZXCVBNM

and then repeatedly...

27 '
5A 58 43 56 42 4E 4D ZXCVBNM


All AUX sorted out, but... how are you interpreting/scalling first channel (AFR) bytes? may be 0v:8-5v:32, linearly? can i change this scalling in nistune?

Edit: got it... afr1.csv ... :oops:
Attachments
NT_DLP-io8_2.jpg
(178.13 KiB) Downloaded 11859 times
Last edited by dlP on Sat Feb 01, 2014 1:12 am, edited 1 time in total.
dlP
 

Posts: 6
Joined: Thu Jul 30, 2009 11:44 pm

Re: Datalogging 10 bit stream

Post by dlP »

Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Datalogging 10 bit stream

Post by Matt »

Ahah... pretty clever!
Tengis
 

Posts: 38
Joined: Thu Oct 23, 2014 2:21 am

Re: Datalogging 10 bit stream

Post by Tengis »

Found this through a google search. I've been getting into programming and recently purchased an arduino for other purposes. I may have to try this out.
vanepico
 

Posts: 30
Joined: Mon Jul 03, 2017 3:19 am

Re: Datalogging 10 bit stream

Post by vanepico »

Hi guys,

I don't know if this will help anyone, but if you are using an Arduino DLP you can alter the "pinmode(A*, INPUT)" to "pinmode(A*, INPUT_PULLUP)" you will get less fluctuation if there is no signal connected.

I am still having some problems with my AFR readout being up to 0.7 out however.
Matt
Site Admin
 

Posts: 8961
Joined: Sun Jan 29, 2006 1:45 am
Location: Adelaide, Australia
Contact:

Re: Datalogging 10 bit stream

Post by Matt »

Not sure on the variance reported, but sounds like PULLUP uses an internal low value resistor for the line. DLPs can have flucutation on the pins if unused lines are not all pulled low
vanepico
 

Posts: 30
Joined: Mon Jul 03, 2017 3:19 am

Re: Datalogging 10 bit stream

Post by vanepico »

https://youtu.be/FHU6rCLDdU0

This is a video of my uego next to my nistune readout. I haven't checked the output voltage yet, I was thinking maybe the signal might need a smoothing capacitor, unless like others, the voltage is not the thing causing the fluctuation.
Post Reply