Wednesday, April 9, 2014

Plot sine waves with Excel


During my study I had to draw and calculate sine waves pretty often. I used Excel to plot them and calculate their sums or product.

This first file calculates and plots 3 sine waves in the same chart from their function (amplitude, frequency, shift and offset):


Download the file


The second file calculates and plots 2 sine waves from their function and their product, very useful to see the usage of power when voltage and current are not in phase:


Download the file


The third file calculates and plots 2 sine waves from their function and their sum. It also plots the phasor diagram at 0 degrees:


Download the file

Solar Microgrid


Today I’m sharing with you a project I’m particularly proud of. As final stage of my Renewable Energy course I was asked to complete a project of a stand-alone, hybrid system. Stand-alone means that the plant is not connected to the grid, like in a remote area. Hybrid means that more than one source of energy is used. In this case I designed a 27kW solar system with a backup diesel generator.
A microgrid is an independent grid where more than one unit can produce and use the power of the grid.
The purpose of the system is to power the irrigation system of a cherry farm, the owner’s house, a shed, and the farmstay for workers. The farm really exists and I worked in it, in Griffith NSW. It’s grid connected but I designed this system pretending that it wasn’t.
This is the final diagram of the complete system:

  

LOAD ASSESSMENT


The first step of a power system design is a load assessment. This stage allows us to understand the needs and the size of the system, but also to improve the energy consumption. In this case I was able to reduce it up to 30% in summer, improving the efficiency of the air conditioning.

  

Decreasing the energy consumption decrease the size of the system and of the components.
The next chart shows the load assessment of the 4 units (pump, house, shed and farmstay) combined, in different seasons.



DESIGN

To design this system I followed the Australian standards and the Clean Energy Council guidelines but I exceeded their requirements. I created a complex spreadsheet to help me in future design of this size.
The microgrid is a 3 phase system, the loads are spread across the phases equally, and only the irrigation pump uses the 3 phase power.
The following charts compare the power used in each phase at different time.



The system is designed to be expanded easily in the future.
In good weather conditions the sun (daytime) and the batteries (nightime) are enough to power all the loads. The generator starts automatically to power the loads and recharge the batteries in rainy days.
To calculate a perfect system I analysed the solar data (from NASA) and the load across the year and I considered the worst scenario. In this spreadsheet you can see the comparison between the load and the energy from the sun:


I also compared the performance of my arrays at different angles. I calculated that changing the tilt of the array just twice a year the annual output of the system increase considerably. To do that, we need an adjustable tilt array. The following chart compares the energy output of the system with a different tilt:
  

I made the following spreadsheet to help me in matching the inverter with the array, using the calculation suggested by the Australian standards and CEC. It also calculates the size of cables and circuit breakers. I need 6 inverters to collect the power from the 3 arrays and put it on the 3 phase grid.




ARRAY SIZE

To calculate the distances between the arrays (needed to calculate the length of cables and the voltage drop), avoiding shading between 10am and 2 pm, I made a spreadsheet that can be used in any area in Australia. You just insert the size and number of panels in the array, the tilt of the array, and the latitude of the location. The result will be the minimum distance between arrays to avoid shading when the system is more productive.



I copied the formula from the Clean Energy Council tech info released in March 2010. For some reason it’s not on their website anymore so you can download it here.



CUSTOMER MANUAL

As a final task I was required to write a customer manual, according to the Australian standards. It’s written in simple words to explain the basics of how the system works. It has to include important instructions and procedures.


Wednesday, February 12, 2014

Low-pass filter and integrator in Excel


Today I want to publish a couple of useful spreadsheet I made to solve electrical circuits.
The first is an integrator circuit: a pulsing DC voltage charges a capacitor in steps. This spreadsheet calculates the voltages across the capacitor over time. It's a pretty complex formula to do it manually.

Download the file

The second spreadsheet calculates the frequency response in a series RLC circuit, in this case the voltage is taken across the capacitor, therefore it's a low-pass filter.

Download the file

Tuesday, February 11, 2014

Wireless (XBee) and serial communication, data acquisition and Labview


With this experiment I want to monitor some analog sensors and display the values on a graphical interface on my PC. There are many stages involved and there is much to learn in all of them. 

Arduino

First of all I need to wire up and program the Arduino to read the sensors. In this case I'm using six potentiometers to simulate alanog sensors. I want to display these values on a small LCD attached to the board, so I will compare them with the values displayed on the PC. To do that I need to import the LCD library at the beginning of the sketch. 
The string sent from the Arduino to the PC must contain a fixed number of digits for every variable. As I explained in a previous post, the values from the sensors vary from 0 to 1023, which means they can use one to four digits. I programmed the Arduino to divide all of these values by 1023, multiply by 900 and add 100. The result is a number between 100 and 999. So the string is always 21 digits long and each 3 digits represent a value. The opposite operation has to be done by the software on the PC to display the original values. Then I send these values to the PC using the serial connection.


This is the sketch I wrote

#include <LiquidCrystal.h>

LiquidCrystal lcd(10, 8, 7, 6, 5, 4);

void setup() 
{
  Serial.begin(9600);
  lcd.begin(16,2);
}

void loop() {
    String dataString = "";

  for (int analogPin = 0; analogPin < 6; analogPin++) {
    float sensor = analogRead(analogPin);
   int value = sensor / 1024 * 900 + 100;
   dataString += String(value);
   }
  Serial.println(dataString);

  lcd.println(dataString);
  delay(15);
}

Wireless communication

I'm using XBee radio transmitters to send data using radio frequencies. To connect the Arduino to the XBee module you need an Arduino Wireless Shield, and to connect the other XBee module to the PC you need a XBee Explorer board (see picture below). Each module has to be configured using the Explorer board and X-CTU, a free software distributed by Digi International. To communicate, the two modules have to use the same ID (the name of the network), and same baud speed; one have to be a coordinator and the other can be router, end device or both. In this case I set the one attached to the PC as coordinator and the one attached to the Arduino as end device. They can be configured to create very complex mesh networks, but I don't need it now.
I don't need to modify the sketch on the Arduino because the serial data flows through the XBee module. The wireless shield has a switch: it must be on “USB” when using serial to upload a sketch on the microcontroller, and on “MICRO” when using the XBee to send data.
The XBee module I've chosen are: XBee PRO series 2. They use 50 mW power at 2.4 GHz frequency (legal in Australia). The range of this model is about 3 km outdoor. 
I bought all the components from http://www.australianrobotics.com.au/, and I think they have good items, reasonable prices and an excellent service (I talked to them because I thought the explorer board didn't work). Here are all the parts I bought, but you can chose different combinations:

X-CTU has a "terminal" window where we can see the data received on the PC, but only one software at a time have access to the serial connection (Arduino IDE, X-CTU or LabVIEW).


The following pictures show the data string as transmitted to serial (read by the Arduino monitor), and as transmitted wireless (read by the X-CTU terminal). The left one shows broken data because the Arduino was working at maximum speed. So I had to add a delay of at least 15 milliseconds in the sketch and the data was received properly as in the right picture.



LabVIEW

I was able to get a student copy of LabVIEW so I’ll try it. It’s used in SCADA (Supervisory Control And Data Acquisition), for example to monitor and control oil rigs in the middle of the ocean, from an office in the city centre. It’s also used in military and space applications. The programming language of LabVIEW is graphical; it’s like a flow diagram, but not that easy. Sparkfun sells a kit with an Arduino UNO board and an old version of LabVIEW (here). That’s not the way I got it but I think it’s a good deal. Getting started with LabVIEW is easy: you have to use two windows, one to create objects graphically, and the other to connect them together and make them work.
To learn the programming language of LabVIEW I found these tutorials very useful.
LabVIEW needs another software to be able to read serial data. It's called VISA Shared Components and it's not included in the basic software. I had it installed for a coincidence (it was together with my dive computer software).
I noticed that LabVIEW has a library to program the Arduino boards, so I installed it and I had a look. You can use it to control the Arduino, but the program is not deployed on the board. So, to work, the Arduino has to be connected to the PC and LabVIEW, which is not what I want now.
I created a basic interface where the values are displayed graphically.



To read the serial data you need the VISA function. I tried some examples from the National Instruments tutorials, but they were all slow, the data was updated once a second. So I tried this example and the data rate was very quick. The configuration of the serial port is as follow:


The following picture shows the main loop:


The pink line is the string read by the VISA function. This string is then divided in substrings and converted to numbers. The operator can set a maximum value, when the value from the sensor goes over that limit, an alarm lights up. The white icon is a group of functions I've put together in one to make it easier to repeat it for every value. This group of functions is shown in the following picture:


It converts the string to number, calculate the original value and the max value.


Conclusions

I’ve set up my Arduino Uno to send data through serial port. The Arduino reads analog inputs from potentiometers (they simulate real sensors, sending an analog voltage) and keeps sending a string with all the data together through the serial port. The XBees modules send this data wireless to the PC. Labview reads this string (VISA function) and takes every single data out of the string. The single data is then displayed graphically.





Friday, February 7, 2014

Solar Mobile Workshop

This is one of the earliest project I have done in TAFE during my Renewable Energy course. 
The aim was to design a solar system for a caravan. I wanted to do something different and innovative, so I designed a caravan which can be used as a workshop when working in a remote location. For example it could support the construction of a shack in the bush, and provide a basic accomodation for two workers in the same time. The calculations in this project are done with the "rule of thumb", instead of the formulas provided by the Australian Standards. Reviewing this project now, I could do some improvements: the inverter should be larger, and I would use an integrated inverter/battery charger like the Sunny Island from SMA. A backup generator could provide some extra power to operate a welder or other power demanding tools. This would increase the weight and will require a very strong structure for a caravan.
This design need to be improved, but the idea is still innovative and useful.

Click here for the specification
Click here for the tender
Click here for the full report

I have done the drawings with Google Sketchup, a very easy and free 3D design software. To draw the caravan I used some parts downloaded from Google Warehouse.








Datalogger

Here I start with a simple project with my Arduino: a data logger. I want to monitor temperature, humidity and light and record all the data on SD card. To do that I need my Arduino Board, a photo or light sensitive resistor (it changes its resistance according to the light), a temperature and humidity sensor and an SD module (and of course breadboard and jumper wires).
The Arduino software (or IDE) is free and comes with many examples. You can also find many useful information on their website and the forum. You can buy Arduino boards and other components from Ebay and many electronics shops. Genuine boards and clones work exactly the same, but only buying genuine boards you support the developers who also provide free software. Genuine boards are marked "made in Italy" (not "design in Italy"). A reasonable price in Australia for a genuine Arduino UNO is about 32 $. I bought a lot of electronic components and sensors from CoreElectronics and I was happy with them, they have genuine boards and also sell on Ebay. If you are not in a hurry, you can buy the other components and sensors from China and Hong Kong on Ebay and save some money.
To learn how to program and wire them up, I found this series of tutorials very useful. If you need to start from the basic then this series of tutorials would be easier.
The light resistor is wired as a voltage divider in series with a fixed resistor. The Arduino reads the voltage across the photo resistor through the Analog input 0. This value will be between 0 and 5 volts (depending on the value of the fixed resistor, I’m using a 1.4 kΩ) but the value read by the Arduino will be between 0 and 1023, because the Analog to Digital Converter uses 10 bits (2^10 = 1024 values).
The temperature and humidity sensor is a cheap DHT11 sensor. It has an internal circuit able to read the analog voltages, calculate the right values and send a string with these values to the Arduino. The sketch or program in the Arduino must include the DHT11 library to be able to read this string.
The SD module is able to read and write data on a file .log or .txt, but only one file at a time. The communication used by the DHT11 is SPI (Serial Peripheral Interface), it needs 4 pins plus ground and VCC (5 volts). These 4 pins in the Arduino UNO are 10 (SDCS), 11 (MOSI), 12 (MISO) and 13 (SCK). The sketch must include the SD library in order to use the commands regarding the SD module.
To do the schematics I used Fritzing, an useful, easy and free software (you can draw PCB as well).


And this is how it looks in real life:

To write the sketch I’ve copied some parts of the Datalogger example sketch and DHT11 sketch:

#include <DHT11.h>
#include <SD.h>

int pin=3;
DHT11 dht11(pin); 

const int chipSelect = 4;

void setup()
{
  pinMode(10, OUTPUT);
  
  if (!SD.begin(chipSelect)) {
    return;
  }
}

void loop()
{
  int err;
  float temp, humi;
  if((err=dht11.read(humi, temp))==0)
  {
  int t,h;
  t = (int) temp;
  h = (int) humi;
  String dataString = "";
    dataString += "temperature:";
    dataString += String(t);
    dataString += ",";
    dataString += "humidity:";
    dataString += String(h);
    dataString += ",";
    dataString += "light:";
    dataString += String(analogRead(0));
        
  File dataFile = SD.open("datalog.log", FILE_WRITE);
  if (dataFile) {
    dataFile.println(dataString);
    dataFile.close();
  }
  }
  delay(30000);
}

I’ve tried many times with different SD cards and looks like some SD cards cannot be read by the SD module, even if they work fine in cameras and other devices. They have to be formatted as FAT (16 or 32), but even then, not all are readable. Anyway, I found one that works and I started recording.
This is how the data was recorded in the file, every 30 seconds (the board doesn't know what time it is, so you should mark the time when you start recording):

temperature:27,humidity:36,light:658
temperature:27,humidity:37,light:671
temperature:27,humidity:36,light:678
temperature:26,humidity:37,light:673
temperature:26,humidity:37,light:670

After few hours I plugged the SD card into my computer, imported the data in Excel and plotted a chart.