Tamura L06P800S05 Current Sensor

Hi Everyone,

I am a golf cart guy but, a software engineer by trade. As a hobby, I modify electric golf carts. For my modifications/rebuilds often use 600amp controllers to drive 3-phase 5kw inductive motors and 600amp DC controllers for DC motors. (72v - 48v depending on the project)

I want to build a tool that I could easily measure the current flow from the batteries to the controller. So I figured why not challenge myself and build one?

I did some research, asked some questions of engineering friends and was pointed into the direction of using a Tamura L06P800S05 current sensor to do this.

But, alas, unlike many of the Arduino projects I have tackled for my golf cart projects this one has me scratching my head as I am out of my depth and could use some help. I did some searching and came up with a thread that had me scratching more. I am nearly bald now. :slight_smile:

What I know is little but, this is what I know:

  • The golf cart controller can draw up to 600amps from the battery pack.
  • The batteries are generally 6x8v (48v) setups but, I am planning on doing a 9x8v (72v) setup. They are connected in series. They are lead-acid batteries.
  • I need to measure the current flow from the batteries to the controller for an extended period of time under different driving conditions that will force the controller to supply amps in all sorts of different ways. Hitting the pedal with the rear jacked will make the wheels spin but, to determine true load you need to drive the cart up a steep hill.
  • The sensor will be placed on the B- connection running from the controller to the B- of the battery pack. (I think this is where I am supposed to put it?)
  • I have built a solution to track and manage the voltage of each battery and the total output voltage. Its a wiring mess at the moment but does the job. (Voltage divider)
  • I have an Arduino Mega 2560 and Tamura L06P800S05 current sensor.
  • The controller has regenerative braking. I can set how much is returned to the battery in the controller config.

I am hoping there is someone out there that can point me in the right direction on how to:

  • Properly wire the Tamura L06P800S05current sensor to my Arduino.
  • Write the appropriate software to read the sensor or to a library that I should be using to do this all with that has all the maths already done. :smiley:

When I Googled Tramura L06P800S05 and Arduino not much came up. I also did some reading on hall effect open-loop sensors and various topics regarding 48v systems in the 300amp range. Still confused.

Thank-you,
GolfCartGreg

Have a look at the datasheet.
The pin assignments are shown on the second page. Measure the voltage using an analog input. It's a ratiometric device so the output will vary in sympathy with the supply voltage.
The graph on the first page shows the relationship between current and output voltage when the supply voltage is constant.

mikb55:
Have a look at the datasheet.

Ok. The datasheet I was looking at lacked some details found another one. And another one here.

mikb55:
The pin assignments are shown on the second page.

I have it hooked into the 5v, ground and A0 on my mega per the specs.

mikb55:
It's a ratiometric device so the output will vary in sympathy with the supply voltage.

Gotcha. Doing reading on "ratiometric devices" to get up-to-speed. Not much experience with electrical engineering but, quick learner.

mikb55:
The graph on the first page shows the relationship between current and output voltage when the supply voltage is constant.

Ok. So when looking at the graph if there is nothing going through the sensor, say when there is no current flowing through it, it will return a value of 2.5? If I get a 0.505 that would be -800 and 4.495 would +800 amps? (Studying the math provided in the second datasheet from above on how to calculate everything.) Less than basic knowledge in Electrical engineering. Have enough knowledge not to kill myself and that's about it. :slight_smile:

Cheers,
GolfCartGreg

Update...

Reading from the sensor on A0. My WH5000A tells me the voltage is 2.501 and I am getting 2.51-2.53 off the Arduino so that isn't too bad.

Now to figure out the math on this and find something I can put this on to draw some current on. No carts have controllers hooked up at the moment.

GolfCartGreg:
Ok. So when looking at the graph if there is nothing going through the sensor, say when there is no current flowing through it, it will return a value of 2.5?...

No, it should have 2.5volt (VCC/2) on the sensor output if sensor supply is 5.0volt and no current flows through the sensor. Read it with a common Arduino with a 10-bit A/D (0-1023), and it will return a value of about 1024/2= 512.

If you go by the graph, then you see that the sensor clips at max current at 0,25volt and 4.75volt (on a 5.0volt supply).
Better said (voltage independent), at 5% and at 95% of VCC, or at 5% and 95% of 1024.

-800Amp to +800Amp is a 1600Amp span. You only have a 90% (5-95) range of that A/D available,
so 1024*0.9= 921 values. Not enough for a 1Amp/step display.
Could use oversampling/smoothing to try to fix that.
A 600A sensor instead of an 800A sensor would also help.

Quick and dirty formula
float current = (analogRead(A0) - 512) * 1.7;
Leo..

Wawa:
No, it should have 2.5volt (VCC/2) on the sensor output if sensor supply is 5.0volt and no current flows through the sensor. Read it with a common Arduino with a 10-bit A/D (0-1023), and it will return a value of about 1024/2= 512.

The A0 pin is resulting in 515 as the value of the sensor with no current flow when I just read the sensor -> analogRead(A0).

With your formula you provided, it is giving me 5.10.

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
  Serial.println((sensorValue - 512) * 1.7);
  delay(5000);
}

Here is some output from the sensor:

515
5.10
515
5.10
515
5.10
516
6.80
516
6.80
515
5.10
516
6.80

No current is flowing through the sensor.

Wawa:
If you go by the graph, then you see that the sensor clips at max current at 0,25volt and 4.75volt (on a 5.0volt supply). Better said (voltage independent), at 5% and at 95% of VCC, or at 5% and 95% of 1024.

Wawa:
A 600A sensor instead of an 800A sensor would also help.

The controller I am using is "rated" for 600 amps but, can supply more than 600amps for a small period of time. Full load does go up over 600amps when I push the cart up a steep hill. So I went with the larger amp model. (Not sure if my logic on doing that was sound though.)

Still reading up on all this... If anyone knows of a good example online of someone doing this and kindly sharing the info please feel free to point me at it. :slight_smile:

Cheers,
GolfCartGreg

Should change '512' in the formula to '515' or '516', so it prints an average of zero Amp.

You see large gaps in the 'current' printout (5.10, 6.80), because of the 10-bit A/D (1024 steps) and the 1600+ steps needed.

Serial.println((sensorValue - 515) * 1.7, 0); // prints without decimal places.

The gaps can be minimised (1Amp steps) with smoothing code (multiple reads and averaging).
Leo..

Test sketch with simple averaging.

// Test sketch for bi-directional 800A sensor
// 10 readings for averaging

int offset = 5153; // calibrate zero current readout here by changing the last one or two digits.
int fullScale = 9728; // 95%
long rawValue;
int current;

void setup() {
  Serial.begin(9600);
}

void loop() {
  rawValue = 0; //reset
  for (int i = 0; i < 10; i++) rawValue += analogRead(A0);
  current = (rawValue - offset) * 800 / (fullScale - offset); // 800A sensor

  Serial.print("Current: ");
  Serial.print(current);
  Serial.println(" Amp");
  delay(500); // human readable
}

Wawa:
You see large gaps in the 'current' printout (5.10, 6.80), because of the 10-bit A/D (1024 steps) and the 1600+ steps needed.

Would the addition of an ADC between the sensor and the Arduino help or is that simply just overkill per your comment below?

Wawa:
The gaps can be minimised (1Amp steps) with smoothing code (multiple reads and averaging).
Leo..

Also thank-you for the sketch!!! Really appreciated! Sensor with no current is resulting in a clean 0 on the output. I put a controller on a cart and will put this sucker on to see how it works tomorrow.

Thank-you! :slight_smile:

Cheers,
GolfCartGreg

Adding a 12-bit A/D could add problems of it's own, and 12-bit 5volt ratiometric A/D converters are not that common. The Arduino A/D, with some coding tricks, might just do the job.
Leo..

Wawa:
Adding a 12-bit A/D could add problems of it's own, and 12-bit 5volt ratiometric A/D converters are not that common.

Gotcha. Just did some reading on 12-bit ADC 5 volt ratiometric converters... 12 pages in and I am just going to go with your suggestion. :slight_smile:

Wawa:
The Arduino A/D, with some coding tricks, might just do the job.
Leo..

In your example code, you set the offset to 5153. Unit reads 0 with no current flowing through it. I only have a 30v 10amp DC power supply (STP3010H) that can generate current with DC.

When I put the current through I get the following results:

Set Current -> Serial Output
10 -> 7
8 -> 5
6 -> 4
4 -> 2
2 -> 1
0 -> 0

(I wish I had a working cart to test this on with proper 2/0 wiring and a proper 48v 600amp controller drawing power to test this with properly.)

Some questions / clarifications.

  • I am assuming that the gage of the wire matters. I am just using the simple alligator clips that came with the DC power supply to close the loop and set amps. They are just floating around in the sensor. They don't "fill" the space very well.

  • Will the accuracy of the sensor be impacted by the gauge of wire I use? 4ga, 2ga, 2/0, etc?

  • Is the 7amp reading from the sensor "correct enough" for a 10amp current flow on small gauge wires considering it is an 800amp sensor?

  • Or... can I calibrate/smooth the readings to get a 10amp reading off my DC power supply with this setup?

Thank-you. I wouldn't have gotten this thing working without your knowledge and help!

Cheers,
GolfCartGreg

Magnet fields are additive therefore you can trick the sensor into thinking the wire is carrying a higher current by looping it through the sensor multiple times.

Your sensor returned 515, and sometimes 516 with zero current with the first test sketch.
Second sketch reads the sensor ten times and adds the results, so I estimated an idle value of about 5153.
Change last digit, and re-upload if zero is sometimes -1A or +1A.

"fullScale = 9728" was estimated from the graph (95% of 1024 times ten samples).
If current readout is off, then change that value until readout is about right.
Estimate could be off quite a bit.

As mikb55 said, multiple turns through the core could help you calibrate.
Try 10, or even 25 turns.
Leo..