…about Linux, electronics, digital photography, whatever…
Icône RSS Icône Accueil
  • Bat Detector with adjustable gain

    Posté le 22nd mai 2009 leucos Pas de commentaires
    Bat Detector

    Bat Detector

    While I stumbled upon Tony Messina’s Simple Bat Detector pages long time ago,I really decided to build one only when I saw that Bre Pettis could :) .

    So I barely used Tony’s schematics and instructions, but spiced the circuit a bit by adding a gain adjustement potentionmeter, a on/off switch driven by the volume potentiometer, and a LED witness light.

    It’s pretty easy to build : thru-hole components, some wires, …. You can use the eagle schematics included below to build yours. The latest version is single sided, and doesn’t need the flying wire on the top side like mine.

    The most difficult part is to find the right compononents for the switch capable potentiometer (I choosed a push/push type : push to turn on, push again to turn off) and the box.

    The push/push 10kΩ potentiometer used is a tyco Electronics 17PCSA103MC19P. You can grab it at Farnell.
    The other potentionmeter is just a standard 10kΩ one, like the Tyco Electronics 23ESA103MMF50NF
    The enclosure is a Boss Enclosure, model BIM RETEX 551 (Betabox Series), also available at Farnell.

    What I didn’t find at Farnell is the piezo-ceramic earplug. Unfortunately, I don’t remember if I got the high (E10P) or low (S83) impedance earplug.

    Grab the schematic and board here :

    BatDetector Schematic

    BatDetector Board

    On the board, there is no connector to plug the potentiometer push/push switch. So you’ll have to wire one pin of the switch to the battery clip, and the other pin to the ‘+’ connector on the board. For ground, just wire directly.

    To test your detector, if you don’t have a bat under your hand, just open a water tap and aim the detector at it : it should make lots of noise. If not, try to adjust the gain settings. If nothing works, well… something is wrong :)

    Now, just make it and go out listen for the bats. They’re pretty easy to find in semi-urban area : bats love city lights (well, they love the insects that love the city lights), especially  mercury vapor bulbs (white lights), which attract more insects. Unfortunately, most towns are now installing high pressure sodium lamps (orange), which insects doesn’t like as much. The most common bats, Pipistrelle, emit two kind of calls :

    • echolocation for hunt, around 48KHz, you’ll hear those with the detector
    • social calls, around 20KHz; you can hear them without any device if you’re lucky enough (or young enough)

    Finally, but you probably already know that : do not wake up hinernating bats. If you do so, they have to fly, waste energy and even if they come back to sleep again, they will get hungry too early in the season. They will have to wake up to hunt, but too early means no insects, and the bat will probably die by waking too early.

    Have fun !

  • High-power TVBGone

    Posté le 16th mai 2009 leucos 4 commentaires

    This TVBG has been done a long time ago, but I never took time to write about it. It’s quite powerful : you can easily take off TV’s at 100ft, and even works thru your pocket (and pretty far if you wear GoreTex). But guess it, with power comes batteries, and the downside is it’s size, roughly the size of a cigarette pack (all the pictures below are pretty outdated…).

    TVBGone with it's camouflage package

    TVBGone with it

    The design is pretty simple : an AtTiny85, 6 TSAL 6100 IR diodes from Vishay (rated 1A for short pulses), 6+1 NPN transistors. Unlike what is show in the picture below, there is no more jumper (it was used to switch between programming mode and run mode). The tantalum capacitor has been scrounged, and not bought. If you know what coltan is, you know that buying tantalum stuff is rather bad.

    TBGone bottom view

    TBGone bottom viewTVBGone with it

    The thing is powered by 3xAA batteries. There is no current limiter, the only limit is provided by the batteries internal resistance so take care if you want to change supply for a LiPo or whatever, you’ll blow the LEDs for sure. In this case, add a resistor along each LED, or better, use some current regulator.

    For now, the 6 TSAL LEDs are sucking 2.5 Amps without a current limiter.

    TVBGone top view

    TVBGone top view

    The AVR code has been found on the net, and is provided here almost unmodified. The original authors are in the main.c header file, among which, of course, Limor (aka Ladyada).

    I’ve changed the IR codes a bit, removing some duplicates, reordered them too so the most used codes comes first (file with modified codes is PERSOcodes.c).

    One of the problems is that LG TV can not yet be turned off. This is a pain since LGs are everywhere. I don’t have time to reverse engineer timings for LG or use convert Lirc codes for now. But for sure, this would be valuable work. If you do it, please drop me a note.

    EDIT : CaitSith2 dropped a note saying he has more up to date code for TVBG which turns off LGs too (see comments). So you’d better use his code than mine. Thanks CaitSith2 !

    EDIT2 : It seems that CaitSith2 is more high power : 8 TSAL6100, 4xAA… nice !

    In the schematics (tvbgone2_cms), all the little pads near JP1 are for a very weird slide button (I was too leazy to draw an eagle lib part). So don’t panic and adjust for your switch.

    There is another schematic included : tvbgone_mini.sch, which is a variant intended to be build as jewelry. I plan to use CR2477 batteries but I never built it. If you make it, please tell me how things turned.

    The P & R pins are « Program » and « Run » respectively. When done programming, just cut the wire going from the central pad to P, and make a solder bridge between the central pad and the R pad. If you need to reprogram again, remove bridge, and bridge between the central pad and P, etc…

    Get the eagle schematics, grab the code, turn off those TVs and have fun.

  • WRT54G/GS/GL Relay Mod

    Posté le 27th septembre 2008 leucos 2 commentaires

    Sometimes, it could be handy if your router (in this case, a WRT54G) could restart the device that connects it to the internet. For instance, if your ADSL modem needs some reboot or your cable modem needs a kick, having the WRT to do this would be nice.

    This could be especially useful if the modem+router are deployed as an access point somewhere in the wild.

    This usage is not limitating : we’re gonna build a WRT managed relay. What you switch on/off with this relay is your problem. A modem seems a reasonable idea, but you could switch a coffee pot (in this case, you should go with HTCPCP [http://www.ietf.org/rfc/rfc2324.txt]), lights, etc…

    All this is possible with little modification. The behaviour of the system here is to switch the relay for approx. 14 seconds, but this time is also easy to change. You can even use a trim pot instead to make it fully tunable.

    Schematics

    Relay board schematic

    Relay board schematic

    The schematic is rather simple. The board is connected to the internal WRT54G serial port (TX pin). This pin uses LV-TLL signals (0, +3.3V), and logic high is 0V. In other words, when nothing is send out to the serial port by the WRT, the level is low and the TX pin show 3.3V. What we want is to activate the relay when voltage on this pins drop. The trick is to feed the TX pin to the Threshold pin of a 555 timer (see those excellent 555 links in Electronics Club and Mecanno Electronique in french). And this is what happens when we the WRT sends data to the serial port : square wave comes out of second serial port TX pin and triggers the 555. For this to work, the 555 is powered at 6V, and thus triggered when TX voltage drops below 2V (approx 1/3 of VCC). The 6V feed is very primitive and comes from WRT power (12V) sliced in half by a voltage divider. It would be wiser to use a voltage regulator (7805 or al.), but we’re going the easy way here.

    The trigger from the 555 is fed at the base of the 2N2222 transistor which in turns feed the coil enough current to switch.

    Primitive, as I said.

    Assembling it

    First, be aware that doing the bad things below will void your WRT warranty, your modem warranty. You also can burn things or yourself in the process, etc… So do at your own risk. This being said, that stuff has been my first electronics project so it is really easy. « my first electronics project » should also be taken as a warning.

    • Open your WRT54G (or GS, or GL) by pulling the blue cover out
    • Take the WRT PCB out.
    • Solder a wire in the TX pin (pin 3) of the serial port

    Soldering this port is really easy, even I did it without breaking anything or melting the router to a shapeless plastic blob. You’ll find more info and pictures on the LinkSys WRT5G/GS Dual Port Mod Page. You don’t need IDC headers or high end stuff like this. Just solder in the hole. It will be ok as long as you don’t pull too much on the wire.

    The blue front cover has holes inside. These holes can’t be seen from the outside because of the stickers. This is a good place to make a complete hole with a hot wire if you plan to put your PCB relay outside the WRT. For recent models, like the GL, the PCB can probably fit inside.

    • Pull the TX cable through the blue cover and assemble the WRT back
    • Solder the wires with the DC power jacks on the board
    • Cut power cables from modem and WRT. Be sure to cut it at the right place ! You need enough cable to plug the wall wart and enough cable to plug the modem and WRT.
    • Remove some insulating material from the power wires and insert them in the screw clamps. Don’t mess with polarity or which wire go where. You would burn something for sure.
    • Now we need software to get this going. The basic idea is to ping some IP address, and when consecutive failures are detected, the relay is activated and the stuff behind it reboots. You can push the shell script to the WRT running Sveasoft firmware under Administration/Diagnostocs/Run, then paster script and click « Save Startup ». You can do the same with OpenWRT and probably with other firmwares.
    #!/bin/sh</code>

    ########### Tunable Variables #############
    # which host to check
    checkhost="212.27.48.10"

    # how often to check
    checkinterval=20

    # how many failures to activate relay
    activateafter=3

    # where is the wrt_relay_mod
    # serial=/tmp/test
    serial=/dev/tts/1

    # how long should we rest after switching
    rest=120

    # how many log/debug lines do we keep
    keeplines=20
    ########### End Variables #################

    #
    pingfail=0
    logfile=/tmp/wrm.log
    debuglogfile=/tmp/wrm_debug.log
    version=1
    #

    log() {
    echo -n `date` &gt;&gt; $logfile
    echo " : "${1} &gt;&gt; $logfile

    # trim log file
    head -n 8 $logfile &gt; $logfile.tmp
    tail -n $keeplines $logfile &gt;&gt; $logfile.tmp
    mv $logfile.tmp $logfile
    }

    debug() {
    echo -n `date` &gt;&gt; $debuglogfile
    echo " : "${1} &gt;&gt; $debuglogfile

    # trim debug file
    tail -n $keeplines $debuglogfile &gt; $debuglogfile.tmp
    mv $debuglogfile.tmp $debuglogfile
    }

    check_loop() {
    # we sleep $checkinterval seconds
    sleep $checkinterval

    if ping -qn -c 1 $checkhost &gt; /dev/null ; then
    # network is ok
    pingfail=0
    debug "/-\ =&gt; ping ok"
    sleep $checkinterval
    else
    # network seems down
    pingfail=`expr $pingfail + 1`
    debug "/?\ =&gt; $pingfail ping failures"

    if [ $pingfail -ge $activateafter ]; then
    log "relay switched"
    debug "/!\ =&gt; switching relay..."
    echo ACTIVATE &gt; $serial
    debug "/-\ &gt; resting for $rest seconds"
    pingfail=0
    sleep `expr $rest - $checkinterval`
    fi
    fi
    }

    # log few information at boot
    log "######################################"
    log "# wrm daemon version $version starting"
    log "# checkhost=$checkhost"
    log "# checkinterval=$checkinterval"
    log "# activateafter=$activateafter"
    log "# serial=$serial"
    log "# rest=$rest"
    log "######################################"

    # initial rest
    sleep $rest

    # control loop
    while true; do check_loop; done

    Tune variables at your liking. You can see how the relay is software activated : it just writes ‘ACTIVATE’ to the device driving the second serial port. What you write is not important. ‘saddam’ and ‘george’ work equally well for instance. You should also restrain yourself from logging too much. The idel situation for deployment is to disable debug and logging. Space is scarce on the WRT.

    Here is the final thing assembler, with the driver modem (a Terayon TJ720). The system works fine but isAssembled setup quite static sensitive. So discharge yourself somewhere before touching the running circuit, or the relay might activate. Also, proper casing should be done. Putting the circuit inside the WRT is possible with latter models (WRT54GS and WRT54GL). This hasn’t been tester though, and might put some noise inside.

    Bill of materials

    Building this stuff shouldn’t take more than 2 hours and if you wish to buy parts, it will cost less than 4€ (3.0€ each by 20 at GoTronic in France).

    Here is the list of components required :

    Component Quantity
    MINIATURE RELAY 6-12V/12V-2A 1
    TWO WAY TERMINAL BLOCK 2
    1K RESIST. CARBON 1/4-5% 2
    47K RESIST. CARBON 1/4-5% 1
    33K RESIST. CARBON 1/4-5% 1
    TRANSISTOR NPN 50V-0.2A 1
    CAPACITOR 10n 1
    CAPACITOR 220u 1
    CAPACITOR 100u 1
    DIODE 1A 1N4007 or eq. 1
    DIODE 1N4148 or eq. 1
    NE555 TIMER 1
    LED 5MM RED (not in schematics) 1
    LEDS 5MM GREEN (not in schematics) 1
    PROTO BOARD (approx 20 holes x 20 holes) or PCB to etch 1

    Besides the board and may be the 555, the rest is easily scavengeable.

  • Nikon D50/D70 IR remote control

    Posté le 27th septembre 2008 leucos 9 commentaires

    The Project

    After chasing the idea of building a remote for my D50, I found this really interesting page with all you need (especially the IR timing) to get your remote up and running.

    But using a AtTiny2313 for this leaves a lot of room to play with. So I made an enhanced version with a 7-segments display and a menu system. The new firmware let’s you choose among several shooting modes.

    The remote is almost identical to the BigMike’s one except :

    • the firmware is, of course, modified
    • there is no On/Off button
    • there are two buttons for the menu (change/select)
    • there is a 7-segments display for the menu
    Remote control

    Remote control

    The firmware sets the Tiny2313 in sleep mode after 5 seconds of inactivity.
    In tis mode, the datasheet gives at most 2µA current usage. So, since a CR2032 yields 220 mAh, and if I didn’t mess up somehere, you should be up and running for 10 years.

    Modes description

    The remote offers 9 shot modes, which of course can be changed in the firmware.

    Whatever the mode, the dp dot blinks everytime a « take shot » IR frame is sent.

    • Single shot mode (symbol : reversed lower ‘c’) : one button press makes a single shot
    • Double shot mode (symbol : two horizontal dashes ) : one button press makes two shots in a row
    • Triple shot mode (symbol : three horizontal dashes ) : one button press makes three shots in a row
    • Continuous shot (symbol : lower ‘c’) : one button press starts continuous shooting as fast as possible until the ‘menu’ button is pressed again or the battery is dead :)
    • Continuous shot every second (symbol : number 1) : one button press starts shooting 1 picture per second until the ‘menu’ button is pressed again or the battery is dead

    Numbers 2, 5, 0 and 6 are also continuous shoot mode with 1 picture every 2, 5 10 and 60 seconds respectively.

    Modes selection

    Modes selection

    Files

    Wanna build yours ? You’ll need :

    Circuit schematic

    Circuit schematic

    Circuit board layout

    Circuit board layout

    The core of the code (IR timing loop) is taken straight from BigMike’s ASM source.

    Issues

    There are some issues in my version. I am not sure if they are firmware/hardware/ir issues. The problem is the reliability of triggering : sometimes it just doesn’t work. This does make the remote of reduced usability for continuous shooting modes where timing is critical.

    I wonder where this problem comes from : IR receptor low sensitivity ? inaccurate frequency generation ? AF mode induced triggering problems in some situations ?
    Since I have relatively few hardware here (no friend with another D50, no oscilloscope, …) I didn’t dig it up for now.

    And oh, BTW, the usual warnings apply : this remote can brick your MCU, destroy your Nikon, set your house on fire, etc… You’ve been warned !

    Thanks

    Big thanks to Bighignoli Michele, Jonas Diemer and Nate who pioneered the area.

    EDIT : I finally managed to put my hands back on the firmware ! You can grab the ASM source or the hex file. Have fun !