další naskladnění 5.11.18
ARDUINO AC sensor proudu SCT-013 SCT013 do 15A AC, neinvazivní.
15A AC = 1V DC.
Arduino demo:
/* Single CT Arduino based PV load dump controller
Uses an AC voltage input to determine in which diretion the current is flowing
Measures current 20 times per half cycle for 10 seconds totalising readings.
If below threshold decrements counter driving outputs
If above threshold increments counter.
Built in LED lights when input is between thresholds
Currents much above or below threshold just hit the end stops
Outputs are controlled by LSB of state_
counter
Status messages are sent to Serial port
A off line calibration run with a known test load is need to set thresholds
Enable appropriate code section near end depending on number and type of outputs
Original version Eric Ward Jan 2011
*/
#define LED 13 // Built in LED
/***************************************************
* Define pin connections actually used
* Only restriction is that CT must be an analog pin
******************************************************/
#define CT A1
#define PHASE 3
#define SSR1 A2 // first output
#define SSR2 A3 // second output (if used)
/*************************************************************
***** EDIT THIS VALUE AFTER A CALIBRATION RUN ****************/
#define TEST_TOTAL 3755000 // Edit after calibration run
// Values for thresholds as percentage of test load
#define MAX_EXPORT 120
#define MIN_EXPORT 10
/************************************************************/
void setup()
{
// set pin directions
pinMode(CT,INPUT);
pinMode(PHASE,INPUT);
pinMode(LED,OUTPUT);
pinMode(SSR1,OUTPUT);
pinMode(SSR2,OUTPUT);
pinMode(A4,OUTPUT);// Turn outputs off
digitalWrite(LED,LOW);
digitalWrite(SSR1,HIGH);
digitalWrite(SSR2,HIGH);
Serial.begin(9600);
}
int state_counter;
void loop()
{
unsigned long total;
int current;
// Calculate threshold values
unsigned long max_total = MAX_EXPORT*TEST_TOTAL/100;
unsigned long min_total = MIN_EXPORT*TEST_TOTAL/100;
total = 0;
// take average over 500 cycles (10 secs)
for( int cycle_loop = 0; cycle_loop < 500 ; cycle_loop++)
{
/******* Detect +ve edge on PHASE ***/
// wait for PHASE input to go low
while( digitalRead(PHASE) == 1)
{
;
}
// Wait for phase to go high again
while( digitalRead(PHASE) == 0)
{
;
}
// Measure 20 times per half cycle
for(int slice_loop = 0; slice_loop < 20; slice_loop++)
{
digitalWrite(A4,HIGH); //DEBUG
current = analogRead(CT);
total += current;
digitalWrite(A4,LOW); //DEBUG
delayMicroseconds(300);
}
delay(5);
} // end of # cycles
Serial.print("Total ");
Serial.print(total);
Serial.print(" max ");
Serial.print(max_total);
Serial.print(" min ");
Serial.print(min_total);
Serial.print(" state ");
Serial.print(state_counter);
// setup output drives
digitalWrite(LED,HIGH); //Turn on LED
// Turn LED off if change needed
if(total < min_total)
{
if(state_counter != 0)
{
Serial.print(" Reducing load");
}
state_counter--;
/* When appliance heating elements are switched on the is a sudden increase 3kW? in consumption
to avoid a short burst of consumption is it better to switch off all our loads
and then let it step back on again ??
state_counter = 0;
*/
digitalWrite(LED,LOW);
}
if(total > max_total)
{
state_counter++;
digitalWrite(LED,LOW);
}
// uncomment this block for single output
if(state_counter ==1)
{
Serial.print(" Increasing load");
}
state_counter = constrain(state_counter,0,1);
// Set output (HIGH is off)
digitalWrite(SSR1,!(state_counter & 1));
/******************************
* // *** Uncomment this block for two equal outputs ***
* if(state_counter < 3)
* {
* Serial.print(" Increasing load");
* }
* state_counter = constrain(state_counter,0,2);
* // Set outputs (HIGH is off)
* if(State_counter == 0)
* {
* digitalWrite(SSR1,HIGH);
* }
* else
* {
* digitalWrite(SSR1,LOW);
* }
* digitalWrite(SSR2,!(state_counter & 2));
**********************************/
/********************************
* // *** Uncomment this block for two binary weighted outputs ***
* if(state_counter < 4)
* {
* Serial.print(" Increasing load");
* }
* state_counter = constrain(state_counter,0,3);
* // Set outputs (HIGH is off)
* digitalWrite(SSR1,!(state_counter & 1));
* digitalWrite(SSR2,!(state_counter & 2));
***********************************************/
Serial.println();
}
// ======================== end ============================
Proudový senzor proudová cívka čidlo
Tento produkt byl přidán dne Úterý 23. říjen 2018.