I want something usb stick thingy-ish to check a usb cable
A little ATtiny45, some LEDs and transistors - battery powered. It scans through the cable with some blinking LEDs, then goes to sleep.
USB cable tester | New Revision
2021-07-19 00:35:03
Today I went sorting through some USB cables, but before I could test anything, I had to solder the third and last of the boards that I had ordered years ago. The micro-B USB socket held for 15 cables before I had to add glue because it got loose [log for board 2]. So I decided to update some parts on the PCB and shift things around.
USB-A + micro/mini Sockets are turned 90 degrees, so you can test shorter cables
additional USB-B connector so you can test A-B cables
button is now a 6mm x 6mm sized one
LEDs all point in the same direction and are marked, good for soldering
Today I went sorting through some USB cables, but before I could test anything, I had to solder the third and last of the boards that I had ordered years ago. The micro-B USB socket held for 15 cables before I had to add glue because it got loose [log for board 2]. So I decided to update some parts on the PCB and shift things around.
USB-A + micro/mini Sockets are turned 90 degrees, so you can test shorter cables
additional USB-B connector so you can test A-B cables
button is now a 6mm x 6mm sized one
LEDs all point in the same direction and are marked, good for soldering
Since the USB micro connector broke off of the first board I had to solder one again. Still have to check if the consumption still is that low and all the code really works as intended.
Since the USB micro connector broke off of the first board I had to solder one again. Still have to check if the consumption still is that low and all the code really works as intended.
So the code from last time didn't work at all, when I woke up the blue LEDs where totally dim. I've check the datasheet for the attiny45 and noticed once again - what works on an arduino must not work on a board using non-atmega328s. I hooked up my new UNI-T UT61E and measured 200uA - not the 0.1uA I've expected to see. With the help of the gist from JChristensen I verified (read copied) my code for the power down and measured a success - yes it's measurable - 0.1uA !
/*
Things to safe power, according to datasheet:
- turn off adc (not needed for LEDs)
- turn off brown out detection (BOD)
- turn off analog comparator
- turn off internal voltage reference
- turn off watchdog timer
- disable port pins per register
With the help of JChristensen/AVR Sleep
https://gist.github.com/JChristensen/5616922
*/#include <avr/sleep.h>#define BODS 7 //BOD Sleep bit in MCUCR#define BODSE 2 //BOD Sleep enable bit in MCUCRint leds[] = {4,0,1,2};
voidsetup(){
for (int i=0; i<4; i++)
{
pinMode(leds[i], OUTPUT);
digitalWrite(leds[i], HIGH);
delay(200);
digitalWrite(leds[i], LOW);
delay(200);
}
die_until_reset();
}
voidloop(){ }
voiddie_until_reset(){
byte mcucr1, mcucr2;
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
MCUCR &= ~(_BV(ISC01) | _BV(ISC00)); //INT0 on low level
ADCSRA &= ~_BV(ADEN); //disable ADC
cli(); //stop interrupts to ensure the BOD timed sequence executes as required
mcucr1 = MCUCR | _BV(BODS) | _BV(BODSE); //turn off the brown-out detector
mcucr2 = mcucr1 & ~_BV(BODSE); //if the MCU does not have BOD disable capability,
MCUCR = mcucr1; // this code has no effect
MCUCR = mcucr2;
sleep_cpu();
}
USB cable tester | verify your results
2015-09-09 09:38:53
So the code from last time didn't work at all, when I woke up the blue LEDs where totally dim. I've check the datasheet for the attiny45 and noticed once again - what works on an arduino must not work on a board using non-atmega328s. I hooked up my new UNI-T UT61E and measured 200uA - not the 0.1uA I've expected to see. With the help of the gist from JChristensen I verified (read copied) my code for the power down and measured a success - yes it's measurable - 0.1uA !
/*
Things to safe power, according to datasheet:
- turn off adc (not needed for LEDs)
- turn off brown out detection (BOD)
- turn off analog comparator
- turn off internal voltage reference
- turn off watchdog timer
- disable port pins per register
With the help of JChristensen/AVR Sleep
https://gist.github.com/JChristensen/5616922
*/#include <avr/sleep.h>#define BODS 7 //BOD Sleep bit in MCUCR#define BODSE 2 //BOD Sleep enable bit in MCUCRint leds[] = {4,0,1,2};
voidsetup(){
for (int i=0; i<4; i++)
{
pinMode(leds[i], OUTPUT);
digitalWrite(leds[i], HIGH);
delay(200);
digitalWrite(leds[i], LOW);
delay(200);
}
die_until_reset();
}
voidloop(){ }
voiddie_until_reset(){
byte mcucr1, mcucr2;
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
sleep_enable();
MCUCR &= ~(_BV(ISC01) | _BV(ISC00)); //INT0 on low level
ADCSRA &= ~_BV(ADEN); //disable ADC
cli(); //stop interrupts to ensure the BOD timed sequence executes as required
mcucr1 = MCUCR | _BV(BODS) | _BV(BODSE); //turn off the brown-out detector
mcucr2 = mcucr1 & ~_BV(BODSE); //if the MCU does not have BOD disable capability,
MCUCR = mcucr1; // this code has no effect
MCUCR = mcucr2;
sleep_cpu();
}
USB cable tester | code and me whining and winning
2015-09-08 22:21:13
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:
USB cable tester | code and me whining and winning
2015-09-08 22:21:13
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:
USB cable tester | this project... like... so annoying
2015-09-08 14:10:15
I can't believe that I will say this, but there are some really annoying things with this design. The first and most obvious: the usb connectors and the battery connector aren't on the same side! The second one is that the connectors should be plane with the pcb, so that the micro / mini port would be useable with the USB A ports soldered on. I should stop calling designs "final".
I "redesigned" the battery part for eagle and by turning it 90 degrees I was able to save some space.
[UPDATE] Seems like I have connected the wrong pin of the battery holder - I took one of those 5 holes meant for plus, but not the centered one - good thing that I've redesigned that holder.
USB cable tester | this project... like... so annoying
2015-09-08 14:10:15
I can't believe that I will say this, but there are some really annoying things with this design. The first and most obvious: the usb connectors and the battery connector aren't on the same side! The second one is that the connectors should be plane with the pcb, so that the micro / mini port would be useable with the USB A ports soldered on. I should stop calling designs "final".
I "redesigned" the battery part for eagle and by turning it 90 degrees I was able to save some space.
[UPDATE] Seems like I have connected the wrong pin of the battery holder - I took one of those 5 holes meant for plus, but not the centered one - good thing that I've redesigned that holder.