Tuesday, June 26, 2012

Netduino - Update Relay Control Board Mock-Up

I have finally managed to get my relay control board prototype working. What this allows me to do is control the relays with 12 volts and also to light a 12v LED to display which relays are on.

I am currently using a 74HC595 to provide the control logic to switch the transistors on and off. The next stage is to control the fans using PWM, I also need to add a DS18B20 that will connect in to my 1-wire bus. The temperature sensor will be used to control the speed of the fans, I may in fact used 2 temperature sensors to control the 2 fans independently for each of the heat sinks.

As I now have a Netduino GO I am working towards modularising my main aquarium control board. The first thing I want to modularise is this control board so it will work with the GO bus. I am hoping that the STM8 will provide enough IO to control the transistors and also PWM for the 2 fans. It would also be amazing if there was a spare serial port so I can create a 1-wire bus on the same board, but I have a fair bit of learning to do before I can get started with the STM8S103F2P6 chips I've got.

Here is a little video showing the shift registers switching the transistors on and off that control the LEDs.


Sunday, June 24, 2012

Alpha Numeric Counter

Hi,

Here is a little Alpha numeric counter I have written that will either continue counting or will return the next value.


public string AlphaNum(string val)
        {
            StringBuilder sb = new StringBuilder(val);
            bool incNext = false;
            for (int n = sb.Length; n > 0; n--)
            {
                if (n == sb.Length || incNext)
                {
                    char nextChar;
                    char letter = Convert.ToChar(sb.ToString(n - 1, 1));
                    if (letter == '9')
                    {
                        incNext = true;
                        nextChar = 'A';
                    }
                    else if (letter == 'Z')
                    {
                        if (n - 2 > -1)
                        {
                            if (sb.ToString(n - 2, 1) != "Z")
                            {
                                incNext = true;
                                nextChar = '0';
                            }
                            else
                            {
                                incNext = true;
                                nextChar = 'Z';
                            }
                        }
                        else
                        {
                            incNext = true;
                            nextChar = 'Z';
                        }
                    }
                    else
                    {
                        nextChar = (char)(((int)letter) + 1);
                        incNext = false;
                    }
                    sb.Remove(n - 1, 1).Insert(n - 1, nextChar.ToString());
                }
            }
            return sb.ToString();
        }