Thursday, July 24, 2014

Mid-Week Update

I'm still here... just a little tired.  I have not had much going on.  I haven't felt like programming and none of the hardware projects are that inspiring at the moment.  I have mustered some effort to rework my version of the Metaboard.





Which is quite a bit different than the weekend version.  I have managed all the desired changes and have cleaned and revised the traces several times.  I could only get by to a point and then I had to use wire jumpers.  Trying to keep them to a minimum was my goal but unfortunately to get all the features, I had to use several.

At a minimum 7 jumpers are required for the board to function.  5 more are required for full functionality.  By that, I mean I have designed the board with optional components.  For instance, the power LED and pin 13 LED and their associated resistors can be totally omitted and the board will still function.  The same goes for the ICSP header and the power supply itself.

As it stands, the parts cost is hovering around $5 dollars.

PartQtyPriceCharge
ATMega328P13.503.50
28 pin socket10.110.11
10 pin socket header10.110.11
8 pin socket header20.090.18
6 pin socket header10.080.08
16 mhz crystal10.100.10
22pF ceramic capacitors20.010.02
Zener Diode 3.6V20.040.08
68ohm resistors20.010.02
1.5Kohm resistor10.010.01
Latching DPDT10.080.08
USB Connector10.260.26
100nF ceramic capacitor10.010.01
Tactile pushbutton10.040.04
LM7805 Voltage Regulator10.230.23
10uF capacitors20.020.04
Schottky Diode10.060.06
Barrel Jack10.160.16
Red LED10.010.01
Green LED10.010.01
220ohm resistors20.010.02
5.13
(optional)-0.53
4.60

These prices are from Tayda Electronics which are the best I can find anywhere.  Of course you have to buy 10 of some items (resistors), but even then were talking just pennies.

So I will call this my little Fiverino... to honor the endless stream of stupid derivative names of a... stupid name.  Think of it as the big brother to the OSI microcontroller.






Sunday, July 20, 2014

Mid-Weekend Update

Well as Saturday comes to a close, I have some time too put down my thoughts.  

I have spent some time with my Metaboard Redux design... putting in the missing power supply.  Here is the first revision...



It's not that different, so I have held off on constructing it just yet.  Here are some outstanding issues...

  • Placement of the programming jumper.  It can be moved closer to the chip and freeing up the area by the USB connector.
  • Lowering the reset button to be aligned with the component array.
  • Both power sources are routed through the two filtering capacitors.
    • I have not had any problems not using the filtering caps
    • I could the make the power supply completely independent and therefore optional
  • The two LED are optional (done).
  • The Reset signal is not wired in the headers (oh well!?!)
  • Nice to have an ICSP header in the empty space (optional of course)
  • Data disconnect for the two USB data pins
So I still have some work to do!





Sunday, July 13, 2014

Metaboard Redux 1.0

Well as I look for new projects to work on, I have the time to work on stuff that I have been planning.  One of those projects was building a Metaboard... an Arduino clone that is very interesting to me.  It is similar to the series of Attiny85 micro-controllers I have been building, except that it uses the USBAsp protocol for programming.  So here is my version of the Metaboard...



Thursday, July 10, 2014

Wednesday, July 9, 2014

Light Alarm Sketch

I have been playing around with the Sound-Sensor board and finally have a simple "light alarm" working.

/*
  Light Alarm Delayed
  Version 1.0
  2014-07-01 J.G. Wezensky
  
  This sketch will use the light sensor to detect changes in lighting and sound an alarm
  if it changes beyond a pre-determined threshold.  The user can reset the accepted 
  value by clicking the button in the middle.  Then the user will have ten seconds before 
  the alarm is armed.
*/

const int LDR_PIN = 0;
const int SPEAKER_PIN = 3;
const int BUTTON_PIN = 1;

const long DEBOUNCE_DELAY = 40;
const int DEADBAND = 40;
const int ARM_DELAY_SEC = 10;

int lightSetting = 0;
boolean alarmSet = false;
boolean alarmTripped = false;

// tracks the left button
int buttonState;
int lastButtonState = HIGH;
long lastDebounceTime = 0;

float freq = 300;
const float freq_max = 500;
const float freq_min = 300;
float offset = 25;

void setup()
{
  // watch for pin to go to GND
  pinMode(BUTTON_PIN, INPUT);
  digitalWrite(BUTTON_PIN, HIGH);

  // use sound to indicate button press
  pinMode(SPEAKER_PIN, OUTPUT);  
}

void loop()
{
  // check the left button for a mode change
  int reading = digitalRead(BUTTON_PIN);
  if (reading != lastButtonState)
  {
    if (reading == LOW)
      Pressed();
    lastDebounceTime = millis();
  } 
  if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY)
    buttonState = reading;
  lastButtonState = reading;
  
  int light = analogRead(LDR_PIN);  
  if (abs(light - lightSetting) > DEADBAND)
    alarmTripped = true;
  
  if (alarmTripped)
    Buzz();
  else
    noTone(SPEAKER_PIN);
}

// -----------------------------------------------------------------------------
// Processes the press of the primary button
// -----------------------------------------------------------------------------
void Pressed()
{
  int i;
  for (i=0; i<ARM_DELAY_SEC; i++)
  {
    Beep();
    delay(1000);
  }
  lightSetting = analogRead(LDR_PIN);
  alarmTripped = false;
}

// -----------------------------------------------------------------------------
// Audio feedback for button press
// -----------------------------------------------------------------------------
void Beep()
{
  tone(SPEAKER_PIN, 440, 50);
}

void Buzz()
{
  tone(SPEAKER_PIN, freq, 25);
  freq += offset;
  if (freq > freq_max || freq < freq_min)
    offset = -offset;  

}

You should be able to just copy and paste from above.  

Here is how you work it.  After you have programmed the above sketch into your Fidget, replace the Comm board with the Sensor-Sound Board.



Then connect the battery.  It should take a few seconds before the buzzer begins going off.  Now click the button in the middle.  The buzzing should change to a beep every second.  You have ten seconds to put the alarm in a box, drawer or some other enclosure before it becomes armed.  After that, if the light hitting the sensor changes... the buzzer will go off again.  To turn off the alarm, simply unplug the power.


Next Steps

So what's next?  I have a shipment of parts due Thursday that should contain the last batch of Attiny85 chips.  I have two extra and I think I may make two more ELF Tags.  For whom?  I don't know.  Maybe nobody.

Anyway, I have all these USB connectors and sound buzzers.  What should I do with them?  I guess I should consider what other parts I have as well.  Like these...


  • Light-Dependent Resistors
  • 5V-110V Relays
  • Real-Time Clock
  • LM386 OP-Amps

Oh well, at least I am not out a bunch of money!  

Fidget News

I created a new "starter" video for those guys that got a Fidget Micro-controller.


It's not very good at all, but at least it will help the guys get started.

OSI News

I also designed a new comm board for the OSI MIcro-controller.  Here it is compared to the old one...




The differences to note:

  1. Using a through hole version of the USB Mini connector
  2. Added a disconnect for the USB data lines
Although the disconnects make the board more complex to put together, it adds a valuable utility... allowing USB to just power the board.  This is great because you don't have to have a battery handy to develop and test sketches.  I use a Double-Pole Double-Throw latching switch but leave a set of poles open (using it effectively as a Double-Pole Single-Throw switch). Gee I hope that makes sense.




Sunday, July 6, 2014

ELF Tag Documentation

Purpose
The "Electronic Lost & Found" Tag or ELF Tag is the result of my desire to design and build a small electronic device that I could make and share with friends and colleagues.  Beginning with the small, inexpensive devices such as Adafruit's Trinket or DigiStump's DigiSpark, I started with the idea that I would give everyone a microcontroller.  Why a microcontroller?  Because they are cool and are good tools for technical people to learn about physical computing.

After several iterations, I hit upon a design that was useful and also simple enough for me to make a dozen or so copies of.

Usage
It is a small device with a built-in USB male plug that can emulate an HID keyboard device.  When it is plugged into a Windows computer's USB port, it will automatically type out information that was pre-programmed into the device.  The example I chose to use was an electronic lost and found tag that could type out information about the owner and how to return the lost items.

It can also be programmed to do other things, but for a gift, the lost and found tag functionality was fine.

Design
The device is based upon the Atmel Attiny85 microcontroller and uses a very simple circuit to help the microcontroller acts as a low-speed USB device.  This USB interface is used both for the programming of the device and in the lost and found program itself.

Only 6 components total.
The rest of the job of emulating a USB device is done by the Micronucleus firmware.  This wonderful piece of software takes care of programming the device as well as running the user's program.  The software also makes the device roughly compatible with the DigiSpark, which means we can use their version of the Arduino IDE to program the device.

Hardware
The device is built upon a double-sided PCB that was designed and laid out with the KiCAD electronics design software.




The PCB was pre-cut to make the front and back alignment easier to manage.  The only critical alignment are the vias that connect the on-board USB pads from one side, to the main set of traces on the other.  All the other pads on the top side of the copper are unconnected.

The toner-transfer method was used.

After the board is etched, the shape of the USB connector is cut and cleaned up with a Dremel and a normal cutoff wheel.  The holes are then drilled and the parts are then soldered in place.  All totaled, it takes about two-hours per board to build.

Software
The Attiny85 chip must first be loaded with the Micronucleus bootloader and the fuses set before it can be programmed with the DigiSpark software.  This was accomplished using a full Arduino device acting as an ISP programmer.  Using the ArduinoISP sketch and circuit, the Attiny85 is first loaded with the micronucleus firmware.  For example:

avrdude -C"C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf" -v -pattiny85 -cstk500v1 -P\\.\COM4 -b19200 -U flash:w:C:\temp\micronucleus-1.11.hex:i

Then the fuses are set...

avrdude -C"C:\Program Files (x86)\Arduino\hardware/tools/avr/etc/avrdude.conf" -v -pattiny85 -cstk500v1 -P\\.\COM4 -b19200 -U lfuse:w:0xf1:m -U hfuse:w:0xdf:m -U efuse:w:0xfe:m

Note that in the case of the ELF Tags, I do not disable the RESET pin.

Once the bootloader is loaded and the fuses are set, the chip is ready to be installed on the ELF Tag.  From that point, it can be programmed using the DigiSpark version of the Arduino IDE.

The final step in the software setup is the installation of the customized LostAndFound.ino sketch that is compiled and loaded by the Arduino software.

The most recent version of this sketch can be found here...


Once this sketch is loaded, the device is ready to go.

Saturday, July 5, 2014

ELF Tag Project Complete

Well, within a couple of hours of receiving the parts today, I was able to finish all twelve ELF Tags that I had started earlier this week.

So I am ready for Monday!  I printed a small card with each tag, explaining what it was and how to change it.

It redirects everyone to a shared document linked here.  I know the re-programming is a bit technical... but we are IT after all.  Anyway, I'm sure enough people will know how to do it, so they can help those who may not.

Anyway, this project is completed.  I'm happy with the result.  I would like to note that even though I spent about two hours on each tag, all I would need to do is look at the name and the time seemed all of a sudden worth the effort.  You know what I mean?

Friday, July 4, 2014

Happy Fourth of July

I have not had much news lately.  I am waiting for parts to put together ELF Tags for each of my co-workers.  I have managed to work through the tough parts of the build and have put together all of the boards partially.





All I am waiting for are the 3.6V Zener diodes and the Attiny85 chips.  They should arrive tomorrow, so I think I will be able to bring the finished tags in on Monday.

In the meantime, I did receive my buzzers and surprisingly... my order for 100 USB Mini connectors.  Here is what 100 USB connectors look like...



I have already tested the footprint I created in KiCAD and it was a perfect (but tight) fit.  The connections were clean though and the soldering was fairly easy.  So, I am happy with these little connectors.


It just amazes me that I was able to get 100 for under $4 dollars.  Even though I would probably never use 100, at 4 cents a piece compared to $1.15 it is a no-brainer.  The same with the buzzers.  The buzzers turned out to be of excellent quality.


They all seem to be working and are loud and clear.  Another win for Aliexpress.

Here is my first use of the through hole version of the mini USB connector.


It will be the smallest device I have made... and probably will make.  It manages to beat the ELF Tag by virtue of the connector.


You'll notice it is waiting on parts as well.  Oh well.  Some of it should arrive tomorrow as I said.  I actually have a second order coming afterward that has even more chips... and sockets.  I ran out of sockets as you can see.

And now I am close to running out of 68ohm resistors.  Whoooh.  I guess I will be making a THIRD order to Tayda for resistors.  I have 6 pairs left.  Maybe that will be enough for a while. Maybe.