Author Topic: USB Datalogging - Nothing in Serial Monitor/Plotter  (Read 437 times)

mantonakakis

  • Newbie
  • *
  • Posts: 15
USB Datalogging - Nothing in Serial Monitor/Plotter
« on: March 21, 2019, 07:02:23 PM »
Pretty familiar with M0-based boards, but my CurrentRanger is not outputting to the Arduino IDE serial monitor or plotter when connected to my PC. It shows up in Arduino IDE as a CurrentRanger, the board info looks correct, I've selected the correct COM port.

With the device powered up and displaying reasonable data on the OLED, Serial Monitor shows nothing. I know with the M0 that SerialUSB can be finicky at startup, just wondering if I'm missing something simple? Do I need to make any firmware changes?

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5917
  • Country: us
    • LowPowerLab
Re: USB Datalogging - Nothing in Serial Monitor/Plotter
« Reply #1 on: March 22, 2019, 09:30:12 AM »
First, make sure you understand how to use the USB properly so you don't damage your CR, if you plan to have it connected to an earth Grounded circuit. Many warnings on that in this forum and in the guide.

And you dont see serial output because it outputs to Serial by default (the BT header), not SerialUSB. If you want it to unconditionally output to SerialUSB you will have to change a few lines of code to SerialUSB instead:

You have to remove BT_found and change the Serial to SerialUSB in this loop() code:

Code: [Select]
  if (BT_found && millis() - btInterval > BT_REFRESH_INTERVAL) //refresh rate (ms)
  {
    btInterval = millis();
    readVOUT();
    float VOUT = ((readDiff)/4096.0)*LDO_OUTPUT*1000*(OFFSET?1:OUTPUT_CALIB_FACTOR);
#if defined BT_OUTPUT_ADC
    Serial.println(readDiff,0);
#elif defined BT_OUTPUT_AMPS
    Serial.print(VOUT); Serial.print("E"); Serial.println(RANGE_NA ? -9 : RANGE_UA ? -6 : -3);
#elif defined BT_OUTPUT_NANOS
    Serial.println(VOUT * (RANGE_NA ? 1 : RANGE_UA ? 1000 : 1000000));
#endif
  }

mantonakakis

  • Newbie
  • *
  • Posts: 15
Re: USB Datalogging - Nothing in Serial Monitor/Plotter
« Reply #2 on: March 22, 2019, 10:59:47 AM »
First, make sure you understand how to use the USB properly so you don't damage your CR, if you plan to have it connected to an earth Grounded circuit. Many warnings on that in this forum and in the guide.

And you dont see serial output because it outputs to Serial by default (the BT header), not SerialUSB. If you want it to unconditionally output to SerialUSB you will have to change a few lines of code to SerialUSB instead:

You have to remove BT_found and change the Serial to SerialUSB in this loop() code:

Code: [Select]
  if (BT_found && millis() - btInterval > BT_REFRESH_INTERVAL) //refresh rate (ms)
  {
    btInterval = millis();
    readVOUT();
    float VOUT = ((readDiff)/4096.0)*LDO_OUTPUT*1000*(OFFSET?1:OUTPUT_CALIB_FACTOR);
#if defined BT_OUTPUT_ADC
    Serial.println(readDiff,0);
#elif defined BT_OUTPUT_AMPS
    Serial.print(VOUT); Serial.print("E"); Serial.println(RANGE_NA ? -9 : RANGE_UA ? -6 : -3);
#elif defined BT_OUTPUT_NANOS
    Serial.println(VOUT * (RANGE_NA ? 1 : RANGE_UA ? 1000 : 1000000));
#endif
  }

Thanks for the quick reply, Felix! That makes perfect sense - I hadn't gone through the firmware yet, but that sounds like an easy fix.

Just to confirm (I did try to carefully read the warnings re: grounds), all of my DUTs will be floating ground, battery-powered. For my purposes, most of the time I will not be using a scope/DMM on the output side of the CurrentRanger, since I have an OLED connected. In this setup (floating ground DUT, nothing connected to CR output), it seems like using the USB port should be okay? I can get a USB isolator to be safe. 

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 5917
  • Country: us
    • LowPowerLab
Re: USB Datalogging - Nothing in Serial Monitor/Plotter
« Reply #3 on: March 22, 2019, 12:07:46 PM »
Should be OK yes, BUT the USB might introduce mains noise. Especially if you have inductive loads around. That's visible on a scope.
I think an isolator would not help with the noise, but would help with ensuring the USB is galvanically isolated from mains.

FWIW - the OLED (12bit ADC readings) is not going to give you the accuracy you get from the CR OUTPUT terminals on a DMM. It's great for portability and getting a raw idea of what is going on with your load, but I would say it's within 0.5% or so.

mantonakakis

  • Newbie
  • *
  • Posts: 15
Re: USB Datalogging - Nothing in Serial Monitor/Plotter
« Reply #4 on: March 22, 2019, 01:53:18 PM »
Thanks, for the time being, 0.5% is definitely sufficient!