Hi All,
I am trying to measure an AC current at the secondary. With a bulb in series at the priamary i get 19A in the clamp meter.
How can i read this with the TAMURA Current Sensor
Thanks in Advance.
Hi All,
I am trying to measure an AC current at the secondary. With a bulb in series at the priamary i get 19A in the clamp meter.
How can i read this with the TAMURA Current Sensor
Thanks in Advance.
That sensor data sheet shows it’s basically going to output 2.5 volts at 0 AMP and approx 3.25 volts at 200 AMP.
So your primary is 19 AMP which would be read as approx 2.57 volts.
Doubt your going to get standard analog arduino useful data from that sensor with the reduced secondary output current .
Using a voltage amplifier or a better A/D, or a sensor designed for the expected current ranges your using might work.
Sorry i meant the measure 19A is at the secondary.
What current do you expect to measure?
What frequency?
What specifically don't you understand about the data sheet?
cattledog:
What current do you expect to measure?What specifically don't you understand about the data sheet?
The spot welder project, ::). The weld current. At the moment just trying to calibrate it to read with a load in series like a bulb.
Not sure how to use the datasheet values in code. with Alegro Models there is video done by RoboJax and i was thinking of following that but some values were missing in the Tamura datasheet.
to begin with i was just following Robojax
const int TRIAC = A1;
const int VIN = A7;
float voltage;
byte cal = 0;
unsigned int maxReading = 0;
unsigned int minReading = 1023;
unsigned int reading = 0;void setup()
{
Serial.begin(115200);
pinMode(TRIAC, OUTPUT);
//pinMode(Isense, INPUT_PULLUP);
}void loop()
{
if (cal == 0)
{ cal = 1;
digitalWrite(TRIAC, HIGH);
reading = analogRead(A2);
Serial.println("Calibrating.....");
while (millis() < 1000)
{
voltage = analogRead (VIN);
}
digitalWrite(TRIAC, LOW);
float voltage_raw = (5.0/1023.0) * voltage;
voltage_raw = voltage_raw - 0.03;
float current = voltage_raw/ (20/1000);
Serial.print("Current: ");
Serial.print(current, 2);
Serial.println("A");
Serial.println(voltage);
output values are way off. So just trying to figure out.
digitalWrite(TRIAC, HIGH);
reading = analogRead(A2);
I think this will just read some random current. Is it a zero cross triac, or random turn on?
I also see a problem with trying to read AC, in that you will just see readings centered around 2.5v.
If you are trying to read peak currents, you will need to time the reading to the current max.
but when using this type of sensor, is that necessary ? i mean it would give dc voltage reading from 0-5v depending on the current flowing through the sensor ?
That is how i understand about these hall effect current sensor. Yes figure reading the sensor once wouldn't help so doing a loop.
if (cal == 0)
{ cal = 1;
digitalWrite(TRIAC, HIGH);
reading = analogRead(A2);
Serial.println("Calibrating.....");
while (millis() < 1000)
{int i;
for (i = 0; i <= 10; i++)
{
int VIN = analogRead (VIN);
voltage = voltage + VIN;
Serial.println(voltage);
}
}
Are the sensor output readings are on A7? What is being read on A2?
I suggest you print out the ten readings. Or place them in an array and read them after the fact. What do they look like? From the sensor data sheet, it looks like you should be reading 2.5v (analogRead() == 512) with no current. You will get the 10 analog readings in about 1 ms so I'm still not sure where in the AC cycle you will pick them up.
With the control variables
if (cal == 0)
{ cal = 1;
I don't see why you need this
while (millis() < 1000)
A little in the sampling.
void loop()
{
if (cal == 0)
{
int counter = 0;
cal = 1;
digitalWrite(TRIAC, HIGH);
int i;
for (i = 0; i <= 10; i++)
{
int Vin = analogRead (VIN);
voltage = Vin;
voltage += Vin;
//Serial.print(i);
//Serial.print(" ");
Serial.println(voltage);
}
digitalWrite(TRIAC, LOW);
}
}
With the above code i get the following
618
650
660
654
640
622
604
584
564
542
518
int Vin = analogRead (VIN);
voltage = Vin;
voltage += Vin;
All this is doing is giving a reading for voltage that is 2x Vin.
AnalogRead() takes about 110 microseconds. One ac cycle at 50 Hz takes 20 milliseconds. I would suggest that you take 200 readings to cover once complete ac cycle and see what the data looks like.
In my opinion you are better putting the data into an array and printing after the complete acquisition cycle rather than printing the output as it is read.
with the below sketch i am getting close to the what the clamp is reading
void loop()
{
if (cal == 0)
{
int adc;
int current;
cal = 1;
digitalWrite(TRIAC, HIGH);
int i;
int voltage_raw[105];
for (i = 0; i <= 20; i++)
{
int Vin = analogRead (VIN);
voltage = Vin;
// Serial.print(i);
// Serial.print(" ");
// Serial.println(voltage);
}
digitalWrite(TRIAC, LOW);
Serial.println(voltage_raw[voltage]);
int adc_val = voltage_raw[voltage];
voltage = (adc_val / 1024) * 5000;
voltage = (adc - 0.035) / 280;
current - voltage/100;
Serial.print("Current: ");
Serial.println(current);
}
}
but this part of the code does not seem to be working.
Serial.println(voltage_raw[voltage]);
int adc_val = voltage_raw[voltage];
voltage = (adc_val / 1024) * 5000;
voltage = (adc - 0.035) / 280; // 0.035mV, offset voltage in the datasheet, 280 is a figure to get it close to clamp meter reading.
current - voltage/100;
Serial.print("Current: ");
Serial.println(current);
the serial output
26847
Current: 0
not sure why i get a negative value when i sample for 200ms.
Your code does not make sense to me.
For a start, please post complete code including global variable declaration/initialization and setup().
for (i = 0; i <= 20; i++)
{
int Vin = analogRead (VIN);
voltage = Vin;
// Serial.print(i);
// Serial.print(" ");
// Serial.println(voltage);
}
This reads 20 values and retains the last one in the variable "voltage". Sometimes two readings are recommended when switching analogRead() pins, but 20 readings seems excessive.
int voltage_raw[105];
This array is declared locally, and is not initialized. It probably should be global. While trying to write a short piece of test code to see what is going on, there is no need for strict encapsulation and I would think you have a better chance of things working properly with global declarations. I do not see you store any values in this array.
but this part of the code does not seem to be working.
Serial.println(voltage_raw[voltage]);
int adc_val = voltage_raw[voltage];
This is nonsense. voltage is an analogRead value. If it is larger than 104 it will be out of range of the array.
Lets go back to basics. Stuff 200 analog readings, which should cover one ac cycle into a globally declared and inititialized array of integers. What does the data look like.
const int TRIAC = A1;
const int Vin = A7;
byte cal;
int voltage;
int voltageSample[202]; // returns an error when not definging storage size
int adc;
float current;
void setup()
{
Serial.begin(115200);
pinMode(TRIAC, OUTPUT);
//pinMode(Isense, INPUT_PULLUP);
}
void loop()
{
if (cal == 0)
{
cal = 1;
digitalWrite(TRIAC, HIGH);
int i;
for (i = 0; i <= 200; i++)
{
Serial.println(analogRead(Vin));
}
}
digitalWrite(TRIAC, LOW);
}
270
267
261
252
254
255
257
258
258
258
259
259
260
261
263
264
266
267
268
269
270
272
273
273
273
273
272
272
270
268
266
264
261
258
255
253
253
253
255
270
283
302
319
335
348
361
370
378
382
382
383
380
375
368
361
352
339
324
309
293
276
256
249
253
255
256
258
260
261
264
266
268
269
271
273
274
273
272
271
268
264
260
255
253
254
256
269
283
302
319
334
348
361
371
378
382
383
383
381
376
369
362
353
341
325
310
295
277
258
249
253
255
256
257
259
261
263
265
267
269
271
273
274
273
273
271
268
264
260
256
254
254
256
269
281
300
318
333
347
360
370
378
382
383
384
382
377
370
363
354
342
327
312
296
279
259
249
253
254
256
257
259
261
263
265
267
269
271
273
274
273
273
271
269
265
261
256
254
254
256
267
280
299
317
333
347
359
370
378
382
383
384
382
377
371
364
355
343
328
313
297
You're not using the storage array, and printing while reading takes more time.
Change that array to [200], and print separate, after the triac has been turned off.
for (int i = 0; i < 200; i++) voltageSample[i] = analogRead(Vin); // read 200 samples into the array
for (int i = 0; i < 200; i++) Serial.println(voltageSample[i]); // print the array
Leo..
I'm not sure what to make of your data. If there is no current flowing, that is, don't turn on the triac, what do you see for the readings. If there is no noise or bias, the data sheet indicates that you should be near 512.
Your data is a three digit number and a line return--4 characters = 40 bits (10 bits per character with the stop start bits). At 115200 baud, the prints are taking 347 microseconds which is probably messing with the data. Try reading into the array and only printing when the reading cycle is over.
EDIT: I see that Leo made the same suggestion while I was posting. Its a good thing that his eyes are on this thread, as he is a much better hardware guy than I am.
What do you expect the current to be from your clamp measurements?
Random values of about 300 could be a floating (not connected) analogue pin.
Not sure what to make of that "if (call == 0)" statement.
In that snippet you fire a triac at a seemingly random time, and turn it off ater ~200 A/D samples.
You sample for ~200*110ns, but the triac might be 'on' for longer than that.
Leo..
here is the schematic of the sensor.
i don't see anything on the serial out when using
for (int i = 0; i < 200; i++) voltageSample[i] = analogRead(Vin); // read 200 samples into the array
for (int i = 0; i < 200; i++) Serial.println(voltageSample[i]); // print the array

Array works fine here,
Try this short sketch.
const byte sensorPin = A0;
int sample[200];
int count;
void setup() {
Serial.begin(115200);
}
void loop() {
for (int i = 0; i < 200; i++) sample[i] = analogRead(sensorPin); // read 200 samples into the array
for (int i = 0; i < 200; i++) Serial.println(sample[i]); // print the array
Serial.print("End of array ");
Serial.println(count);
count++;
delay(3000);
}
But why an array.
Maybe you should just use a peak/peak detector, like any other hall current sensor does.
Plenty of AS712 code around to show you how.
Leo..
You sample for ~200*110ns,
110 microseconds.
i don't see anything on the serial out when using
Code: [Select]
for (int i = 0; i < 200; i++) voltageSample = analogRead(Vin); // read 200 samples into the array
_ for (int i = 0; i < 200; i++) Serial.println(voltageSample*); // print the array*_
[/quote]
Please post complete code which demonstrates this. Like Leo, my test code for this works fine.
> But why an array.
@anishkgt was trying to figure out how to use an L06PXXXS05 sensor and couldn't make sense of the data. I was trying to get him to read a full ac cycle to help understand. To read AC current he is either going to need a peak detector, or else read the sensor with constant timing from the zero cross point.