Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 66957

usbser.sys BSOD When Arduino sending data over USB

$
0
0

Thank you for viewing this thread. 

I am new to programming (in both C and LabVIEW) so I am certain that I have not written my coding in the most efficient way however it appears to be doing what I want. I am using and Arduino Uno along with a DAC (MCP4921) and a ADC (MCP3304). The ADC is taking readings of the voltage output from the DAC and temperature readings. These are just to simulate readings I will be taking at a later date and check that the project is working. 

I have written and deployed some code in the Arduino IDE 

#include <SPI.h> // necessary library
#include <MCP3304.h>
int del=15; // used for various delays                                                    //Changed del=1 to del=0
MCP3304 adc1(9);  //create an instance with pin 9 as CS
float tempreading;
float vtemp;
int temperatureC;
int reading;
float voltage;

word outputValue = 0; // a word is a 16-bit number
byte data = 0; // and a byte is an 8-bit number
void setup()
{
  //set pin(s) to input and output
  pinMode(10, OUTPUT);
  SPI.begin(); // wake up the SPI bus.
  SPI.setBitOrder(MSBFIRST);
  Serial.begin(115200);
}

void loop()
{
  for (int a=0; a<=1023; a++) //loops through increasing voltage from -2.5v to +2.5v
  {
    outputValue = a*4; //reduce number of readings needed
    digitalWrite(10, LOW);
    data = highByte(outputValue);
    data = 0b00001111 & data; //0b signifies that value to follow is binary then 00001111 gets upper nibble
    data = 0b00110000 | data; //0b signifies that value to follow is binary then 00110000 function set cmd
    SPI.transfer(data);
    data = lowByte(outputValue);
    byte x = SPI.transfer(data);
    digitalWrite(10, HIGH);

    reading = adc1.readSgl(0);    //read data from CH0 in SGL mode
    voltage = reading / 4095.0 * 5.06;    //convert reading into a voltage from 0 to 5V
    voltage=voltage-2.5; //offset for output serial printed voltage
    Serial.print(voltage, 3);
    Serial.print(",");   


    tempreading = adc1.readAdc(1,1);    //read data from CH0 in SGL mode
    vtemp = tempreading / 4096.0 * 5.06;    //convert reading into a voltage from 0 to 5V
    temperatureC = (vtemp - 0.5) * 100 ;  //converting from 10 mv per degree wit 500 mV offset to degrees ((voltage - 500mV) times 100)
    //Serial.print("Temperature ");
    Serial.print(temperatureC); 
    Serial.print(",");       
    Serial.println(); 

    delay(del);
  }
}

 This prints to serial the readings I obtain from the ADC.

I then built a VI that reads the data through USB via a COM channel.

The data is put into a buffer and extracted using Extract Numbers.vi. I was initially having problems with the buffer as my VI was not syncing at the same speed as the Arduino causing the same errors as seen in this thread (http://forums.ni.com/t5/LabVIEW/out-of-sync/td-p/1870983).

I added some code to the VI and Arduino code looking for the termination character performed by the code Serial.println(); to the VISA Configure Port. I also added the byte count for VISA to set how many bytes are read for each loop. 

Having done this, whilst the VI runs, I get a Blue screen of death after a minute or two with the driver info 'usbser.sys'. I am unsure what to do from here and any advice would be greatly appreciated. I am sorry if I have not mentioned all the necessary info, please do not hesitate to request it. I have attached my VI and Arduino code. 


Viewing all articles
Browse latest Browse all 66957

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>