Boron external power and USB or debug connection

I need to do a bit of debugging with my current project so I can see what the inputs to A0 and A1 are while I am connected to the battery that it will be powered from in the field. I think the map function has my scaling off and need to adjust it a bit.

When it is powered on the battery there is a battery to 5VDC regulator to power the Boron.

Would one way be just to isolate the 5VDC from the PC in the USB cable ? Same thing to isolate the 5VDC on the debugger ribbon cable ? I have not used the debugger before.

Or is there a better method to do this ? THANKS!!!

You could use Serial1 and the RX/TX pins in conjunction with a FTDI UART to USB converter (or another µC).

1 Like

Thanks ScruffR ! I think I have a FTDI UART to USB. I will give that a shot, I have not been able to figure out why the map function is not functioning the way it should. It works in Excel when I do the math. Why the Boron is coming up with the numbers it is I have not figured out yet.

Often it is the data types that give you problems.
i.e. when you do divisions with integer types your results may be way off due to the truncating nature of integer divisions.
If you show your code and give us some examples for those bad results we might be able to spot the error.

1 Like

Morning ScruffR,

I had the pressure and voltage going to the LCD and the cloud the way I wanted them, then had a Samsung SSD die on me and not realize that the .ino was on that drive.
I have the working code uploaded on a boron that I accidentally killed the power supply on. (Lesson learned of taking pin readings off the top of the board)

On the Gas pressure I want whole numbers on, the accuracy of #100 PSIG is good enough for this application, it is not time critical either. I am using analogsmoother to average the inputs. I am measuring the voltage across a resistor from a 4-20mA pressure transmitter.

Below is the section of code that I am trying to iron out. I initially thought that running that averaging the 10 readings, then running through map would be the best way to do this. I did notice on the LCD last night that when I power up with the battery the reading is nearly 3000 PSI then drops steadily ( pressure is at 0 PSIG ) It is like the Analogsmoother buffer is starting with it at 3000 and as lower values come in the output falls. I may need to add some lines in there to wait to send to the processed value to the LCD, Log, and the cloud until the buffer has been filled. I think I might be getting the info sent to the cloud before the buffer has been filled and wind up with a weird number. The code for the voltage is very similar to this, it is winding up high also.

The gas pressure is saying 2700 PSIG when it is about 2200, and the voltage is showing 15 volts when its about 12.5.

// GAS PRESSURE 1.89 @2200
AnalogSmoother gas_pressure(A1, 10);
int transmitter_lcd_power = D2;
int LCD_PIN_STATE = 0; 
int gas_pressurePin = A1;
int gas_pressureValue = 0;
int gas_pressureScaled = 0;
int last_gas_pressureScaled = 0;

void setup()                                                  //  SETUP ############################################
{
 // PINS AND PIN MODES 

 Serial.begin(115200);
 gas_pressure.fill();
}

   // GAS PRESSURE TROUBLE and PRESSURE VALUES
 gas_pressureValue = gas_pressure.read();
 gas_pressureScaled = map(gas_pressureValue,750,2325,10,3000);

   if(gas_pressureScaled < 5) {
 Log.info("Gas P AI:=%d", gas_pressureValue);
 lcd->setCursor(0,3);
 lcd->print("GAS:");
 lcd->print("TRBL ");
 }
   else
 {
 Log.info("GAS_pressure_Value:=%d",gas_pressureValue);
 lcd->setCursor(0,3);
 lcd->print("GAS:");
 lcd->print(gas_pressureScaled); 
 lcd->print("PSI");
 delay(1000);
 }
 String SgasP = String::format("%.f", gas_pressureScaled);
   if(gas_pressureScaled < 1) {
     Log.info("GAS PRESSURE BAD");
     SgasP = ("BAD");
   }
     else {
     Log.info("GAS PRESSURE SCALED:%d", gas_pressureScaled);
     String SgasP = String::format("%.f", gas_pressureScaled);
   }

Below is Analog Smoother.cpp

#include "AnalogSmoother.h"

AnalogSmoother::AnalogSmoother(int pin, unsigned int size) {
	mI = 0;
	mPin = pin;
	mSize = size;
	mTotal = 0;
	mReadings = new int[size];

	for (unsigned int i=0; i<mSize; i++) {
		mReadings[i] = 0;
	}
}

AnalogSmoother::~AnalogSmoother() {
	delete mReadings;
}

void AnalogSmoother::fill() {
	for (unsigned int i=0; i<mSize; i++) {
		read();
	}
}

float AnalogSmoother::read() {
	mTotal       -= mReadings[mI];    // Subtract old reading
	mReadings[mI] = analogRead(mPin); // Read new value
	mTotal       += mReadings[mI];    // Add new reading

	mI++; // Increment readings index
	if (mI >= mSize) {
		mI = 0;
	}

	return (float)mTotal / (float)mSize;
}

I think I have gotten an idea what is going on. It is in my circuit. I got my process meter back and can drive the mA input and see what the change is on the input to the Boron. My voltage drop across the resistor is not exactly linear, I may have to do some adjustments in my circuit. That is part of the reason I wanted to see how I could get data to the PC while plugged into the external power. I missed putting a pin jumper in on the VUSB on my PCB to easily be able to do this. I do have the Particle debugger and was hoping to be able to use it and send to serial with the log function. I may just make some changes to my LCD->print for testing. Or if I could bluetooth it to the PC that would be awesome.