ENGLISH SDS MICRO voltage monitoring example

Z onlinetechnology.cz

Přejít na: navigace, hledání

Obsah

Complete example

This example will show you how to:

  • use SDS MICRO to create a 230Vac presence/fail detector (email alarm)
  • measure DC voltage on a external battery

What do we need ?

HARDWARE:

  • 1 piece SDS MICRO (DIN) - eshop: here
  • 1 piece RELAY with 230Vac COIL - eshop: here
  • 1 piece RESISTOR (value - see text) (we ship this item, mostly for free)
  • (power supply for SDS MICRO - if not already powered from batteries) - eshop: here
  • wires

SOFTWARE:

  • firmware - already shipped with device (SDS MICRO), also new firmware is always free (download from this WiKi)
  • SDS-C compiler/uploader - download (always for free) from this WiKi
  • our specific SDS-C program (behavior script), written specifically for this project (more info here)

Using the device ability to be programmed via SDS-C, you can modify the behaviour any time, and add new functions !

Also, you can use the cheaper SDS MICRO LIGHT, if you do not mind soldering. Or you can use SDS MACRO, if you need way more inputs and outputs... It all depends on the actuall project.

Schematic

This is just one of the many possible configurations :

Soubor:Sds_example_connection_det230micro.gif

So the configuration for this example project follows:

SDS MICRO connection configuration for this project
"V+" DC power for the SDS MICRO device (typically 12Vdc, maximum 25Vdc - if you need more, ask us for it)
"GND" Connect all GND connectors together, to 0V (GND) output of the power supply. Important note: all analog voltages (pins A3 to A0) are referenced to GND.
"A0" First of the four analog input - we use this to measure voltage (in this project, the voltage of the battery).

The A0 input is referenced to GND, so the measured voltage=A0-GND.

"OPTO 0+" Anode of the internal LED in optocoupler "0". In this project, we connect this to output of the 230Vac relay, via a resistor (do not forget to use the external resistor, because there is no resistor inside SDS MICRO - if you apply voltage directly to OPTO pins without the resistor, the optocoupler will immediatelly damage itself).
"OPTO 0-" Cathode of the internal LED in optocoupler "0". In this project, we connect this to GND.
"Ethernet" Connect the Ethernet cable here.

What about the unused pins / connections ? Of course, you can use them ! For example, insert the electricity meter and connect its S0 output to S0+/S0- pins of SDS MICRO. Or connect the 1-Wire thermometers, and so on... You can also use the rest of the optical and analog inputs, also the R1 and R2 outputs and what else.

Do not forget this limitations:

  • SDS MICRO DIN: maximal voltage on any Ax input (A3 to A0) must not go over 30Vdc !
  • SDS MICRO light: maximal voltage on any Ax input (A3 to A0) must not go over 5Vdc !
  • Always have the GND of the SDS MICRO connected with the GND (0V) of the measured voltage (Ax inputs measure referenced to GND)

What to do, if you need to measure more than just 30Vdc for DIN version (respective 5Vdc for light version) ? This is simple, just use a external resistor wired in series to the Ax input, you need to modify. What should be the resistor value? There is a manual at other page in this WiKi.


Software

When we have all the wiring done, we will test if all works well. This is very simple ! Open the web interface of the device.

  • info: default device IP address is : 192.168.1.250
  • info: default entrance password is : test

After logging in, go to the "Actuall status" web page. You will see the online status of all the inputs and output. So look at "OPTO 0" and "AD0" field in the table. The "OPTO 0" must show the status of 230Vac line (voltage present or not], and the "AD0" should show the measured voltage of the connected battery (I'm following this example project schematic).

Now when we know, that SDS MICRO is working well, and that all the inputs are working well, we will create the SDS-C program for our purposes.

We want:

  • to send an email when we loose the 230Vac input
  • to send an email when the measured voltage at A0 input goes below 11Vdc

Of course, this is just an example functions. You can modify it by modifying the SDS-C program source code. Or you can add way more functions... there are almost no limits.

How do we create the SDS-C program and how will we upload it to the device ? Go to this page - everything is described there. Once uploaded, the program stays in the device forever, until it is replaced by a new program.

The example program is listed here (modify it to suit your needs) :

// first, define some hardware link
#define OPTO0_STATUS sys[151]
 
// now define our variables we are going to use
var last_OPTO0_status;
var sentEmail;
 
// function
sendOptoIsOff
{
  // we do not want to send an email more than once per each alarm
  if (sentEmail == 0)
  {
    // store the flag
    sentEmail = 1;
 
    // send an email
    smtp_send('joe@foo.com', 'alarm notice', 'ALARM: 230V failed !');
 
    // write an info to console (you can delete that)
    echo('Sending an email - ALARM');
  }
}
 
// function
sendOptoIsOn
{
  // we do not want to send an email more than once per each alarm
  if (sentEmail == 0)
  {
    // store the flag
    sentEmail = 1;
 
    // send an email
    smtp_send('joe@foo.com', 'info notice', 'INFO: 230V is back ON !');
 
    // write an info to console (you can delete that)
    echo('Sending an email - INFO OK');
  }
}
 
// function
OptoChanged
{
  // we get here if the OPTO input status changes
 
  // first, make sure we send an email, because OPTO state changed
  sentEmail = 0;
 
  // store the OPTO status so we can compare next time
  last_OPTO0_status = OPTO0_STATUS;
 
  // the following code depends on the actuall circuit connection:
  // we expect that if OPTO LED is lighting, then
  // the system is OK. If OPTO LED is dark (no power to LED)
  // then we have an error and we want an alarm
 
  // note: OPTO LED without power (dark): sys[opto] != 0
  //       OPTO LED with power (lighting): sys[opto] == 0
 
  if (OPTO0_STATUS != 0) sendOptoIsOff() else sendOptoIsOn();
}
 
// function - main program start
main
{
  // print info to console (you can delete that)
  echo('program started.');
 
  // store the status, so we can compare it next time
  last_OPTO0_status = OPTO0_STATUS;
 
  // set default value, to make sure we will send an email immediately
  sentEmail = 0;
 
  // main program loop
loop:
 
  // check if OPTO status is different than the last time
  if (last_OPTO0_status != OPTO0_STATUS) OptoChanged();
 
  // continue the loop
  goto loop;
 
}

Conclusion

This is one of the easiest projects to start with, doing it you will learn:

  • basics of the usage of SDS MICRO - the web interface
  • using the inputs of SDS MICRO
  • what SDS-C is and how to create or modify your own programs
  • how to upload SDS-C program to device

This is just the basics. We have not discussed the outputs, and any other of the many features. See this in the next example project.

Osobní nástroje
Translate