Forget Me Not :  eLDERmon  Hardware Hacking #2

 

This post continues with my Hardware modification to provide a 'status' indication back from RF switched Outlets

 

Link to other posts
Forget Me Not : eLDERmon Intro
Forget Me Not :  eLDERmon  Electrical
Forget Me Not :  eLDERmon  Outlets
Forget Me Not : eLDERmon Planning
Forget Me Not : eLDERmon Parts 1
Forget Me Not :  eLDERmon  Sponsor Parts
Forget Me Not : eLDERmon Hardware Hacking
Forget Me Not : eLDERmon GNUplot
Forget Me Not: eLDERmon Protocol
Forget Me Not : eLDERmon Hardware Hacking #2
Forget Me Not : eLDERmon Hardware Hacking #3
Forget Me Not : eLDERmon OpenHAB

 

The first part of the task was tracing the circuit to find the important parts

  • Volts
  • Outputs

 

The main processor IC doesn't include any markings.

Luckily there is an Atmel 24C02 eeprom fitted which presumably uses the same voltage and connects to the processor.

 

Outlet_parts.jpg

 

The relay is 24v, and is a good starting point to identify the voltage and ground rails.

The IC's are unlikely to be 24v, but checking against the eeprom datasheet. (8 leg PDIP), you can confirm the ground, and look for a regulator.

 

Atmel24C02_pinout.PNG

The operating voltage limits are also in the datasheet.

Atmel24C02_voltage.PNG

This confirms there is a regulator, and the voltage is within the ATtiny85 range, we can plan to connect to the same supply.

 

Tracing the circuit is a matter of identifying the part, and then tracing where each pin connects to.

It becomes easier once you know the parts, but even if you don't know what the device is, or what each pin does, you can still trace it.

 

Use a large piece of paper and don't worry too much about being too tidy.

Once you have enough completed (or its too messy), then start with a new piece of paper and tidy it up.

part_schem.png

 

Included with the Challenge is Cadsoft Eagle, so its very useful for drawing a schematic ...providing you know the parts.

I have decided that the main control IC is a 18 pin PIC based on the voltage pins and the resonator.

 

 

Control Pin

There are two pins that change when the Outlet is ON, the relay drive and the LED.

You will note the circuit above I elected to use the LED pin.

This was because it already had a pullup (the LED), and had some extra pads available.

 

As I reviewed the design, it struck me that during the 'learning' mode (where you give the Outlet a code), the LED flashes at different rates.

Rather than code for this, I have decided to use the relay control pin (before the resistor).

 

part_schem2.png

 

 

 

ATtiny85

In my last Challenge, I had a few problems with programming these very useful devices.

In the end I used a Digispark, rather than waste too much time.

http://www.element14.com/community/groups/wireless-power-solution/blog/2014/06/08/wireless-challenge-the-other-bit-2

http://www.element14.com/community/groups/wireless-power-solution/blog/2014/06/25/wireless-challenge-beer-tap-the-other-bit--4-assembly

 

I made the fatal mistake of assuming ....

 

I knew both the Digispark and the Orblink used the V-USB hack where a couple of 3.6v zeners and a pullup resistor provide the USB connection.

What I didn't realise is they used different pins on the ATtiny85.

 

So while I had programmed the raw IC correctly, when I tried placing it in the Orblink board, I couldn't talk to it.

 

 

To solve that I brought an Tiny AVR programmer

TinyAVRProgrammer.png  TinyAVRProgrammer2.png

 

     image source https://learn.sparkfun.com/tutorials/tiny-avr-programmer-hookup-guide/

 

The advantage of this device is that you can use the prototyping pins to connect to the external parts without removing it.

 

 

 

Arduino IDE

One major advantage of the ATTtiny85 is that you can program it with the Arduino IDE, and apart from the smaller code space, the libraries work.

 

The ATtiny85 has no facility for an external resonator or crystal, and the clock speed is set during the programming.

 

TinyAVR_Arduino.png

But this causes issues since most things are based around the Arduino 16MHz clock.

Even delay(500) is only a 500mS timer when the clock is 16MHz.

 

The images below show the simple blink program running at different clock speeds.

 

Board_Blink_1.png  ATtiny85_1MHz.JPG

     At 1Mhz clock our 1 sec waveform is 16.5Hz

 

Board_Blink_8.png   ATtiny85_8MHz..JPG

     At 8Mhz clock our 1 sec waveform is 2Hz

Board_Blink_16.png   ATtiny85_16MHz..JPG

     At 16Mhz clock our 1 sec waveform is 1Hz (cursor is slightly off)

 

So the moral of this story is to ensure the clock speed matches, if you are using the internal libraries.

 

Luckily the Digispark board setting has the 16MHz clock option and is available here.

digispark:tutorials:connecting [Digistump Wiki]

 

The libraries all work (or have been tweaked to suit the ATtiny85) BUT the Digispark bootloader allows for the P5 to be used (the reset pin).

So unless you reprogram your ATtiny85, you should avoid using that pin.

 

 

 

Installation

I was hoping to have a picture of the hardware installed, but other things transpired and prevented me from doing the installation.

I will do this over the next day or so, but in the meantime Christopher usually does his weekly summary, so it's better to publish now.

 

 

Mark