Author Topic: Reading CurrentRanger serial data using the Bus Pirate (guide)  (Read 1486 times)

briangordon

  • NewMember
  • *
  • Posts: 8
When troubleshooting an issue, I wanted to read the Bluetooth output of the CurrentRanger. I realized that I didn't have a TTL to USB cable, but I did have a Bus Pirate. It took me a little while to figure out what to do in order to read from the CurrentRanger, so I thought I'd put together a little guide for anyone else in this position.

Preliminaries

Install a terminal program capable of VT100 emulation. I happen to have a ZOC7 license so I used that, but you can get PuTTY for free, or other programs for non-Windows operating systems.

Also, plug in the bus pirate at least once and have Windows install the FTDI drivers. (This step is unnecessary on Linux.) I had to go to Device Manager and right-click the device and select "Update driver" and have Windows Update download the driver for me twice before the device showed up correctly. This is what it should look like:



Note: You may also want to use a USB optoisolator like this one to protect your readings from noise.

Hooking up the bus pirate

Solder some M/F headers on the CurrentRanger's serial header. For UART you're going to want to connect the black wire to the Tx pin, the grey wire to the Rx pin, and the brown wire to the ground pin. Some 24AWG wire-wrapping wire will fit perfectly into some standard 0.1" headers and into the Bus Pirate leads. Power your CurrentRanger off.



Configuring your terminal emulator

Configure your terminal emulator to use the COM port which shows up in device manager. The data rate should be 115200 8/N/1 (that's 8 bit words, no parity, 1 stop bit). RTS/CTS and DTR/DSR should be off. Flow control should be off. Your terminal emulator should emulate the VT100.

Using the bus pirate

Open up the connection and type ? and press enter. You should see this:



Type m to change modes, and select 3 (UART). It will prompt you with various questions to configure the UART connection.

For serial speed, we need 230400 baud, but this isn't one of the built-in options so select 10 (BRG raw value). For the raw value, enter 16. Note that this is different from the baud needed for your computer to talk to the Bus Pirate- here we're configuring how the Bus Pirate will talk to the Current Ranger.

For data bits and parity, stop bits, and receive polarity, use the default values.

For the output type, select 2 (Normal). Now the UART connection should be ready:



Also, your CurrentRanger should have turned on, all on its own! Unfortunately, it's expecting an "OK" response from the Bluetooth module within the first second of power-on, so we have to be quick. Type "OK" (including the quotes) into your terminal quickly and press enter. This may take a few tries to get right.

Now enter { to start the live display of data. You'll see a bunch of *Bytes dropped* messages because the data transmission is too fast for the Bus Pirate's buffer to keep up. So enter } to stop the display.



We can use the UART bridge macro to dump the data as soon as it comes in, with no buffering. Type (1) and press enter to start the data dump!

« Last Edit: June 17, 2019, 04:11:34 PM by briangordon »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Reading CurrentRanger serial data using the Bus Pirate (guide)
« Reply #1 on: June 17, 2019, 09:26:31 AM »
Nice, but you spent all this effort because you didn't have a USB/serial adapter?

A few things to note:

You should not have Common ground between USB and your power supply, the #1 mistake that will overload/damage the CurrentRanger. That is why there is the BT (WIRELESS!!!!) for logging.
OR if your DUT is battery powered, then earth grounded USB is OK, but it will most likely introduce noise into the readings, especially in the lower ranges. Mains is noisy!

The AT/OK requirement for the BT device is there so the CR could determine if there is indeed an attached BT device, or else is does not make sense to sample the ADC (which is also a little noisy to the CR OUTPUT) and spit out data on that header.

briangordon

  • NewMember
  • *
  • Posts: 8
Re: Reading CurrentRanger serial data using the Bus Pirate (guide)
« Reply #2 on: June 17, 2019, 04:08:31 PM »
Quote
Nice, but you spent all this effort because you didn't have a USB/serial adapter?

Yeah  ;D

Quote
You should not have Common ground between USB and your power supply, the #1 mistake that will overload/damage the CurrentRanger

Yep, I read the docs and saw that. My DUT in this case was powered by a mains-isolated bench power supply.