Current sensing WCS1700 with arduino 328P

 I have made one years ago with Allegro (ASC 750?) current sensor on a arduino 

5V 328 with zigbee for wireless. it was a RC project for testing duck fan current in a safe distance. it was 2011..


This time I wish to make one for my electrical motorbike(Soco TC). the battery pack is 72V 30Ah, the motor is about 3Kw. But seeing the wiring and performance I don't think it would delivey 3Kw...


It's a very similar sensor, you don't need to cut you wire but you have to find a way to pass the hole.


if you look at the sheet, you may believe it will measure current like:
A=1/2Vdd+(Vout-1/2Vdd)*1000/33
But above table lack of data of operating the sensor on other voltage.



Winson provide 2 set of testing data, one for 5V operation and on e for 3.3V operation. This make thing more clear:
1. the zero current voltage is not exactly 1/2 Vdd, it's 2.4677 for 5V Vdd(a little bit less than 1/2 Vdd), and 1.7323 for 3.3Vdd(a little more than 1/2 Vdd)
But the data sheet does not show the relation of Vdd and Vzero

2. the slope is not always 33mV/A, 32.8mV/A for 5V and 26.9mV/A for 3.3V
from the upper right chart, you see the sensitivity vs Vdd, it's not linear, and it vary larger at 3.3V, so using 5V could be a better idea.

Since the measurement accuracy depends on Vdd, I think it would be good to know the Vdd and do some compensation.(Vdd on my arduino may vary some how.)

The solution could be making a very stable Vdd @ 5V or 3.3V. Or measure the Vdd and compensate the calculation base on the measurement.

Read Vcc

With some atmel chips. there are ways to use the internal reference voltage to read chip Vcc. The method is the use Vcc as reference voltage of ADC and measure the internal reference voltage(1.1V for 328P, but has 10% error range)

Reading Vref

This Vref vary from chip to chip, but it's stable on same chip...
so the first step is to measure your Vref, by setting analogReference( INTERNAL ) and make several reading on analogread(), then use a vlotmeter to read the pin.

const uint8_t PinLED = 13;

void setup( void )
{
  Serial.begin( 9600 );
  Serial.println( "\r\n\r\n" );

  pinMode( PinLED, OUTPUT );
  digitalWrite( PinLED, LOW );
  delay( 1000 );

  analogReference( INTERNAL );
}

void loop( void )
{
  Serial.println( analogRead( 0 ) );
  digitalWrite( PinLED, HIGH );
  delay( 1000 );
}



here is the way to measure the Vcc
here is how you can use Vcc to calculate actural adc reding

note: base on your Vref, you have to change the parameter 1126400 to your measurement: Vref*1000*1024
ex: my Vref is 1.079V, then my parameter=1104896

Adjust WSC reading

mV/A is quite clear with the chart on data sheet, but I still need to find the relation between Vzero and Vcc, I wish to know the relation with Vdd, when Vdd is about 4-5V. I think we can test it out with the code form sensorsIot

void setup() {
  Serial.begin(9600);
  pinMode(A0, INPUT);
  delay(1000);
  Serial.println(readVcc());

}

void loop() {
  delay(1000);
  // read normal Arduino value
  int in0 = analogRead(A0);
  float val0 = in0 * 5.0 / 1024.0;
  // read correct supply voltage
  float supply = readVcc() / 1000.0;
  // correct it
  float val0Corrected = supply / 5 * val0;
  Serial.println("       ");
  Serial.print("readVcc=    ");
  Serial.println(supply, 3);
  Serial.print("readA0=     ");
  Serial.println(val0, 3);
  Serial.print("correctedA0=");
  Serial.println(val0Corrected, 3);
}

I got:
Vdd:     4.384      4.419   4.437   4.473   4.491
Vzero:  2.188      2.205   2.214   2.232   2.246

The Vzero value at 5V is bit different from datasheet. Then I would trust my measurement.

Calibration on Vzero base on Vdd

After few tests on Vzero while changing Vdd, I got:
the left chart shows the difference on Vzero and Vdd/2
the right chat shows the linear approach and measured Vzero

I decided to take the range of Vdd on 4.5V~5.22V 
then: 
Vzero=2.262+(Vdd-4.5)*0.54861 

where:2.262 is the Vzero when Vdd=4.5


These nrs will vary base on 2 points:
1. the arduino board: every board will have different Vref
2. every sensor could have different Vzero and it's curve. 


sensitivity

Base on the data sheet:
at Vdd=4.5V, sensitivity is about 34mV
at Vdd=5V, sensitivity is about 33mV
Sen=34+(Vout-4.5)*(33-34) = 34+(Vout-4.5)*(-2)

Plan of measurement:

if we measure Vdd to get accurate Vout form sensor, with the table we have on Vdd vs Vzero, the zeroing method will be different: in case of zeroing, we need to redo the table. 

Here is the fist measurement between -10 to 10A, it seems the mV/A is not as written in data sheet. 

base on the above measurement, I calculate the mV/A as 29.22
The I use this 29.22mV/A to do the measurement from 4 to 40A.(in fact I still run the current load from 1-10A, but I pass the wire 4 times through the sensor)

Then the measurement deviate after 20A, I redo the calculation on mV/A.
Since my measurement on e bike will focus on higher current(20-40A), so I redo the math on mV/A.
the I end up using 28.8 mV/A (fix value).

My little opinion: This sensor does not perform as it's data sheet, but measure Current is still doable, you will need to calibrate the Zero current sensor out voltage and the mV/A.



留言

這個網誌中的熱門文章

Heltec ESP32+OLED+Lora, hardware testing

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

Install Network Time Protocol(NTP) on BeagleBone with Angstrom linux and set local time zone