Close

code and me whining and winning

A project log for USB cable tester

I want something usb stick thingy-ish to check a usb cable

davedarkodavedarko 09/08/2015 at 20:215 Comments

Using the attiny15 footprint/part in eagle from the atmel library for the attiny45 is not right, because B4 and B3 are reversed and it's not the first time I noticed that. But this time I just went in and changed the part in the library. Muahaha. Evil, I know. PCB is updated (again), "code" is here:

#include <avr/sleep.h>

int leds[] = {0,1,2,4};
void setup() 
{
  for (int i=0; i<4; i++)
  {
    pinMode(leds[i], OUTPUT);
    digitalWrite(leds[i], HIGH);
    delay(200);
    digitalWrite(leds[i], LOW);
    delay(200);
  }
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  sleep_enable();
  sleep_mode();
}

void loop() { }

Discussions

davedarko wrote 09/09/2015 at 06:58 point

I have a terrible feeling that the power down stuff doesn't work - I measured 200uA power consumption, which is in the active range of an attiny45 and far away from 0.1uA in power-down mode, taken from the datasheet. Never just copy and paste stuff from the internet.

  Are you sure? yes | no

Stefan-Xp wrote 09/08/2015 at 20:50 point

Nice one... but one question to the code: Why does it work?

Shouldn't there be an ISR or something? or is the Button just your Reset Button?

  Are you sure? yes | no

davedarko wrote 09/08/2015 at 21:05 point

exactly that :) I thought about interrupts etc. but remembered reading about "only a reset could restart it, if interrupts were set wrong" - so I used that :)

  Are you sure? yes | no

Stefan-Xp wrote 09/08/2015 at 21:26 point

Hehe okay ;) 

And now... what will it do?

BTW: Are those still the awesome Teal Color LEDs? ;)

  Are you sure? yes | no

davedarko wrote 09/08/2015 at 22:09 point

Well it goes through every pin and checks the cable. The (normal) blue LEDs show which pin is activated, and when the cable is not broken or shorted out, then only the corresponding red LED will glow. It's really not that big of a deal, until you're standing next to a customer on a lake and try to check a 150 Euro cable with a 10 Euro multimeter that shorts out on the connector shielding. 

I only have 5 or 6 left of the cyan LEDs and they are hard to solder by hand - that's why I used the toaster oven instead for the matrices. 

  Are you sure? yes | no