Saturday, April 16, 2016

Status Light

When moving into our new building at work, we were all given little status lights to place on the top of our cubicle walls; they looked like this:


You plug on end into your computer and it looks at your Lync status to determine if you are available, busy, or away from your computer. They are a handy way to determine at a glance if somebody is available for an impromptu meeting.

And they only work on Windows' computers. Having a Mac, I've been out of luck.

Recently fed up with the performance of Lync as my softphone, I requested a desk phone and the one I got (Polycom CX600) logs into Lync from the phone. Furthermore, it has a little circling arrow icon on the phone that lights up with the appropriate status color. 

And that's when I decided to make my own version of the status light.

In what is surely the least attractive way of doing this, I've mounted a color sensor over that double-arrow icon and use it to determine my current status. With that information, I drive a string of RGB LEDs to the appropriate color. My cube looks something like this and I've installed the LEDs so they shine on frosted glass above my desk.

Details:

  • Color sensor is TCS230. You toggle two control (S2 and S3) pins to select the color to measure and it varies the frequency of a square wave depending on the intensity of that light. You can reduce the overall frequency of the device (pins S0 and S1) to a few different levels and I choose the lowest scale to help make the measurement easier. Measuring frequency is done by...
  • ... Arduino's have a pulseIn function that can be used to measure the length of half a period of the output frequency. When a given color is very dark the output frequency is low and the pulse length is long. When the color being measured is bright, the frequency is high and the pulse length is short. Based on these measurements, I can classify the input color as red, green, or yellow and set the output PWM period of three transistor driving those colors on..
  • ... two meters of RGB LEDs. These are 12V LEDs and they are all one color, different than those that I used for my Lorenz project. I used some higher-power transistors I have laying around MPT16N25E to drive them.  Maximum current for these lights is 2A which is being split across three transistors. That current would only show up for maximum bright "white" light (full red, green, and blue power) so I don't really have much to worry about. 
  •  I used a a 250V 2A polyfuse for protection on the 12V supply. The power supply plugs into the Ardiuno barrel jack and then I tap the "Vin" pin for the 12V I need for the LEDs. The on-board polyfuse protects the Arduino but not the transistors and LED string. 
The system has been running for a week or two without much incident. The only tricky part was getting the sensor firmly attach to the light on the phone so the color measurements were consistent. I've been getting good feedback from my co-workers, especially those that realized it was more than decoration. Overall, I think we could call this a success.


Here's the schematic, picture of the board as completed, and source code:

   
 // Used to measure the status light color off a Lync-enabled desk phone and drive RGB LEDs to the same color  
 // 2016 Trevor Hardy  
   
 const int pinTCS230_S2 = 3;  
 const int pinTCS230_S3 = 4;  
 const int pinTCS230_Out = 2;  
 const int pinRedLed = 9;   
 const int pinGreenLed = 10;  
 const int pinBlueLed = 11;  
   
 const unsigned int max_width = 65000; //determined experimentally.  
 unsigned int PW_divisor = 0;  
 unsigned int pulseWidth = 0;  
   
 int TCS230_red = 0;  
 int TCS230_green = 0;  
 int TCS230_blue = 0;  
   
 int red_out = 0;  
 int blue_out = 0;  
 int green_out = 0;  
   
 // the setup routine runs once when you press reset:  
 void setup() {  
  Serial.begin(250000);  
  // declare pin 9 to be an output:  
  pinMode(pinRedLed, OUTPUT);  
  pinMode(pinGreenLed, OUTPUT);  
  pinMode(pinBlueLed, OUTPUT);  
  pinMode(pinTCS230_S2, OUTPUT);  
  pinMode(pinTCS230_S3, OUTPUT);  
  pinMode(pinTCS230_Out, INPUT);  
   
  PW_divisor = max_width/256;  
 }  
   
   
 // the loop routine runs over and over again forever:  
 void loop() {  
    
  read_TCS230();  
    
  Serial.print("Red: ");  
  Serial.println(TCS230_red);  
  Serial.print("Green: ");  
  Serial.println(TCS230_green);  
  Serial.print("Blue: ");  
  Serial.println(TCS230_blue);  
    
   
  if ( TCS230_red > 200){  
   //Red  
   red_out = 127;  
   green_out = 0;  
   blue_out = 0;  
   Serial.println("Red\n");  
  }  
  else if (TCS230_green > 120 && TCS230_red < 120 ){  
   //Green  
   red_out = 0;  
   green_out = 127;  
   blue_out = 0;  
   Serial.println("Green\n");  
  }  
  else if (TCS230_red > 150 && TCS230_green > 150){  
   //Amber  
   red_out =200;  
   green_out = 63;  
   blue_out = 0;  
   Serial.println("Amber\n");   
  }  
  else {  
   red_out = 0;  
   green_out = 0;  
   blue_out = 0;  
   Serial.println("Off\n");   
     
  }  
    
  analogWrite(pinRedLed, red_out);  
  analogWrite(pinGreenLed, green_out);  
  analogWrite(pinBlueLed, blue_out);  
  //delay(1000);  
 }  
   
 void read_TCS230()   
 {    
  digitalWrite(pinTCS230_S2, LOW);   
  digitalWrite(pinTCS230_S3, LOW);   
    
    
  //pulseWidth = pulseIn(pinTCS230_Out, digitalRead(pinTCS230_Out) == HIGH ? LOW : HIGH);   
  pulseWidth = pulseIn(pinTCS230_Out, LOW);  
  if (pulseWidth == 0){  
   pulseWidth = max_width;  
  }  
  //Serial.print("Red pulsewidth: ");  
  //Serial.println(pulseWidth);  
  TCS230_red = 255 - (pulseWidth/PW_divisor - 1);  
    
    
    
  digitalWrite(pinTCS230_S2, HIGH);   
  digitalWrite(pinTCS230_S3, HIGH);  
  pulseWidth = pulseIn(pinTCS230_Out, LOW);  
  if (pulseWidth == 0){  
   pulseWidth = max_width;  
  }  
  //Serial.print("Green pulsewidth: ");  
  //Serial.println(pulseWidth);  
  TCS230_green = 255 - (pulseWidth/PW_divisor - 1);  
   
    
  digitalWrite(pinTCS230_S2, LOW);   
  digitalWrite(pinTCS230_S3, HIGH);  
  pulseWidth = pulseIn(pinTCS230_Out, LOW);  
   if (pulseWidth == 0){  
   pulseWidth = max_width;  
  }  
  Serial.print("Blue pulsewidth: ");  
  Serial.println(pulseWidth);  
  TCS230_blue = 255 - (pulseWidth/PW_divisor - 1);  
    
 }  

Tuesday, March 15, 2016

Antenna Pre-amp - Part 3 - Switch Board and Antenna Jacks

Last time I left-off having built a second version of the pre-amp proper using the designers suggested layout and the circuit worked much better (as measured by the steady-state current).  Now onto the rest of the pre-amp box.

Again, taking cues from the original design, I decided to include attenuators, both before and after the amplifier. To do this, I used one of many calculators online to calculate the resistors for a T-style attenuator. The resistors were ordered as a part of the original pre-amp parts order. Metal film, 1%, still pennies a piece. I also decided to include an antenna switch in the design.

When it came to construction, wary of my previous inattentiveness to layout, I wanted to do the best I could to keep the leads short and provide a solid ground plane, even just for the attenuators. I decided to use a strip of PCB scrap as the common ground throughout the signal path. I also decided, in what is likely an abundance of caution, to use RG-316 coax between the attenuators.

The attenuators would be switched, and I used the leads of the switch as mounting points for the resistors. The switches were DPDT, bypassing the attenuator in one position and routing through it in another. Only the signal side of the attenuator was switched, the ground side was directly connected to the PCB strip.

Using an existing enclosure needing to finally have a project to house, I prepped the front plate for mounting the switches, punching guide holes for all the switches and drilling them out with a hand drill. The results were not the prettiest but most of the failings in my handiwork are hidden by the switches mounting hardware.

Here are the results as seen from the inside of the enclosure.





The back side of the enclosure was used to mount the three input antenna jacks, the output jack, and the power jack.  This was all much simpler; just drilling holes and mounting the hardware; the coax connections come later.



The final step comes next, completing the final assembly.

Saturday, January 16, 2016

Fixing the Vacuum Cleaner

Our vacuum cleaner stopped running for more than a second or two at a time so I tried fixing it.



After all of this work, I determined the motor was overheating for unknown reasons, even when no external load was being applied. Verdict: dead vacuum cleaner.

And I don't even get any spare parts out of this mess, just a pile of plastic to put in the trash.

Sunday, December 13, 2015

Antenna Pre-amp - Part 2 - Second Attempt

As I noted in my last post, I was fairly sure my pre-amp was not working correctly and I was going to try to recommended layouts from the designer (as indicated by another hobbyist who drew up the layout and posted it here). Here are the two layouts, side by side:

My layout (1st attempt)
Designer's layout (2nd attempt)
The big difference between the two designs is the amount of ground plane on the top layer. Both designs have the entire backplane acting as a ground and I mistakenly thought this would be enough. The designer's layout has most of the top layer also acting as ground. And as you might suspect, it made a world of difference. 80mA steady-state current (both with and without input and output termination) and cool to the touch with a nice, big heat-sink.



Its amazing to think that layout made that much difference but this is the world of RF where crazy things happen all the time.

Saturday, December 05, 2015

Rental Beast

I had a business trip last week to Seattle and due to my route cutting through the mountains in winter, I asked for an all-wheel drive rental car.  What I got was a beast.



Aside from needing to get over the mountains, this was exactly the wrong car to drive in a dense urban area, park in a garage with narrow spots, and try to make get back home through rush hour traffic.

But this is not a story about the mismatch between large vehicles and Seattle. This is a story about buttons.





I have never been a car with so many buttons. Quick, think of a feature a "fancy" car might have.

I'm not talking about things like powered seats, sunroof, and Sirrus/XM radio. Or even things like heated leather seats, built in GPS, back-up camera, push-button start or triple-zone climate control.

I'm talking about dynamic cylinder shut-down to increase fuel economy (we got over 19 MPG on the highway), cooled leather seats, and automatic windshield wipers that figured out how often they needed to swipe on their own.

And a vault hide your phone and connect to the media system while your in the store? It had that too.




Friday, November 20, 2015

Air Conditioner Measurement - Part 1 - First Cut


I was getting ready to update the hardware on my air-conditioner measurement system when I realized that I had never written about the initial set-up. So, several months after the fact, here's what I've been doing.

In my previous temperature measurement system, I was able to fairly easily measure the air-conditioner state by tapping into the relay that activated the central circulation fan. In this new house, that was not going to be so easy so I decided to try something more direct: measuring the condenser fan in the outdoor unit. I thought about tapping into the relay on that fan unit but that relay switches 240V and I didn't want to have to worry about making sure the wiring was properly protected for that higher voltage. Instead, I decided to measure the air pressure change caused by the fan turning on.

To do that I employed a BMP180 which measures both pressure and temperature.  I was able to get the sensor mounted on a little PCB and strap down an old milk jug to catch some of the air when the fan turns on, making a little pocket of slightly higher-pressure air. I wasn't sure if this was work but testing revealed the pressure increase was high enough for the sensor to clearly detect.


Air pressure capture for the fan. I've pulled the system for maintenance and it isn't shown.


I wanted to try to make correlations between outdoor temperature and air-conditioner run-time under the assumption that the air-conditioner would run longer when the outdoor temperature was higher. To do that, I employed one of the temperature sensors I previously used for indoor temperature measurement. Not being weather proof at all, I stuck it under the out-cropping on our house under, behind the air-conditioner. This is not ideal as it is very close to the ground (less than 6 inches of clearance) and natural air circulation is likely to not be very high. Its not great but it is out of the rain and is better than nothing. (I'm not able to use the BMP180's temperature sensor because the air blown by the air-conditioner fan will be hotter than ambient. The whole point of the outdoor half of an air-conditioner is to cool the hot coolant as a part of the thermal cycle.)

Since I don't have a real-time measurement system up and running to record the data collected, I decided to use an SD card logger commonly available for the Arduino platform. It is fairly easy to write specific values to the card and it includes a real-time clock to time-stamp each log entry. With this I measured the BMP180 pressure and temperature (the later just for fun), and the TMP36 outdoor temperature. I did this every 15 seconds and, through the use of an extension cord, was able to leave the unit plugged in, running indefinitely.

Here's the final schematic:

The two LEDs are diagnostic lights. The red one flashes every time the SD card is being written to and the green one is lit up when the system is powered.

Here's the hardware, pulled out for maintenance:
From left to right: Interface PCB for LEDs and TMP36 module, BMP180 module, SD card logger on top of an Arduino Uno, and TMP36 module.

And here's the code. Not all of it is working at present, such as the time measurement, but the core measurement functionality has been working great.

Thursday, November 12, 2015

MIDI Controller


A nerdy friend of mine plays electronic keyboard at his church for Sunday morning services. He's expressed a desire to have some kind of controller he could use for the bulk switching of settings between or during songs. He knows that its very possible to do this with MIDI, the protocol designed for communication between electronic instrumentation. Lacking a convenient controller, though, it wasn't possible to actually make this happen.

For his birthday, I decided to make him an Arduino-based MIDI controller. Not knowing the exact use-case he had in mind, I tried to make it as generic as possible without getting caught up in feature creep. I decided to go with two foot pedal inputs, four LED outputs, a MIDI in, and a MIDI out.

Here's the schematic:


I spent a little bit of time putting in hardware switch debounce that ended up working pretty well. The foot pedal jacks had the extra contacts to indicate when the pedals are plugged in, allowing for some fancy software mode-switching if so desired.  Not having any MIDI equipment, I have blindly implemented online schematics; let's hope it works. Oh, and due to the MIDI and the Arduino USB port using the serial port for communication, a hardware switch is needed to move the Arduino over into programming mode and switched back to run mode when its time to use the box.

So about the software. For better or worse, I'm leaving that largely up to my friend.  I've stubbed in a lot of code to demonstrate functionality and I don't expect that he'll have any trouble making this do exactly what he wants but I feel a little bad that this isn't a fully-realized product. Thankfully he's a nerd and I expect he'll enjoy completing this last little step on his own. Plus he'll get to make it do exactly what he wants it to do. Nothing beats fully customized electronics.

Here's the assembled kit, all done up in a cheap enclosure I got off of eBay.