Sunday, November 18, 2018

DIY GPS for Nikon D7000

Hello All,

With this unit plugged in, all pictures will be geo-tagged automatically secondly, camera clock will automatically be synced. Though there are GPS unit available in market for camera but for me it was fun to put it all together and do it as DIY project.

Here is how you can build your own unit.

Tech details before we proceed

Nikon D7000 → GPS input should be plugged into shutter release cable. Shutter release cable uses two wires which triggers Focus and Shutter release. GPS data needs another wire, only input, and data needs to go in TTL input with 4800 baud rate.

Adafruit GPS breakout board →  Works with 3.5V/5V input. Default baud rate of the unit is 9600. To get it to work at 4800, we need to have backup battery (CR1220 coin cell). Arduino / USB to TTL adapter to send GPS command to change baud rate of the unit.

MC-DC2 to USB Mini pin cable → Use multimeter to to figure out which MC-DC2 pin leads to USB pin.



USB Mini B breakout board

  • VCC → this draws power from camera
  • D - → shutter
  • D + → GPS Data in @ 4800 baud rate
  • ID → Focus 
  • "ID" pin is "D-" pin is for Shutter release

Once USB breakout board is connected to camera, it starts drawing power. There is no off switch. You can have GPS data flow in continuously or add a switch. I didn't add switch on purpose as I won't leave cable connected to camera on continuous basis.

If you are planning to use camera with shutter release cable, you will have to extend this circuit to have addition connections/controls for cable release. Have your cable control connected to PIN ID and D-. The way it works is with half shutter button press, Focus pin(ID pin on USB breakout) needs to be active and with full press Shutter pin needs to be active (D- pin on USB breakout). Note that with full press both(ID and D-) pins should be active.

As of now, I have only GPS data flowing in and I will not be using cable release controls.

Circuit

Components
  1. Nikon D7000 camera
  2. Adafruit GPS breakout (https://learn.adafruit.com/adafruit-ultimate-gps)
    • Mount header pins
    • Add coin cell at the back of the unit
  3. USB Mini B breakout board (https://core-electronics.com.au/breakout-board-for-usb-mini-b.html)
  4. MC-DC2 to Mini USB B cable (Search ebay for "Micnova GPS-N-7 Camera GPS cable for Nikon")
  5. A protoyping board
  6. CR1220 coin cell
  7. 9 PIN female header pin (to make GPS breakout board plug-n-play. I intend to use GPS in other applications as well)
  8. USB to TTL Converter (Amazon link) / Arduino Uno
Prototyping
First we need to get GPS unit working at 4800 baud rate. Adafruit GPS unit by default runs at 9600 baud rate. I ended up using Arduino Uno board and modified echo example to set set baud rate of GPS unit to 4800. The command we need to send it to GPS RX terminal is "$PMTK251,4800*14". Alternatively, you can use USB to TTL converter with any program which can communicates over TTL.

Arduino Code for ref.
#include 
// Connect the GPS Power pin to 5V
// Connect the GPS Ground pin to ground
// If using software serial (sketch example default):
//   Connect the GPS TX (transmit) pin to Digital 3
//   Connect the GPS RX (receive) pin to Digital 2

// If using software serial, keep these lines enabled
// (you can change the pin numbers to match your wiring):
#if ARDUINO >= 100
  SoftwareSerial mySerial(3, 2);
#else
  NewSoftSerial mySerial(3, 2);
#endif
Adafruit_GPS GPS(&mySerial);

#define GPSECHO  true

// this keeps track of whether we're using the interrupt
// off by default!
boolean usingInterrupt = false;
void useInterrupt(boolean); // Func prototype keeps Arduino 0023 happy

void setup() {    
  // connect at 115200 so we can read the GPS fast enuf and
  // also spit it out
  Serial.begin(115200);
  Serial.println("Adafruit GPS library basic test!");

  // 9600 NMEA is the default baud rate for MTK - some use 4800
  GPS.begin(9600);
  GPS.sendCommand("$PMTK251,4800*14");
  delay(1000);
  // You can adjust which sentences to have the module emit, below
  
  // uncomment this line to turn on RMC (recommended minimum) and GGA (fix data) including altitude
  GPS.sendCommand(PMTK_SET_NMEA_OUTPUT_RMCGGA);
  GPS.sendCommand(PMTK_SET_NMEA_UPDATE_5HZ);
  GPS.sendCommand(PMTK_API_SET_FIX_CTL_5HZ);
}

void loop() {

}


Please note: changing baud rate is one time activity - until backup battery on GPS unit runs out.

Verify the data that it works at 4800 baud rate. I have used USB to TTL converter.

Assembly
Let's put everything on breadboard to verify all connections work as expected.




Finished Product

Once everything is verified on breadboard, I hardwired the connection on prototyping board. And last is field test. :)




Field test


Monday, June 04, 2018

Tera Khayal...

Long distance relationships ... phew !!!

Aaj tu phir bahut yaad aaya hai,
Aaj phir khud ko bahut bechain humne paya hai

Beech humare -
Samundar ki gahrayi aur meelon ka faasla hai,
Ye soch, dil bechain kuch is kadar hua hai
Jazbaaton ka tufaan, ye dil, maano seene me dabaye baitha hai,
Aaj tera khayal kuch is kadar aaya hai
Wo teri naadaniyan, wo tera bholapan,
Wo tera bin wajah muskuraana,
Baat baat par ruth jaana ,
Chidate-chidate khud ro jaana,
Mujhe manane ki wajaye khud ko manwana,
Tere saath bitaye hua wo lamhe,
Sab ek pal me yaad aaya hai,
Aaj tera khayal kuch is tarah aaya hai


Aaj phir tujhe chedne ka dil kiya,
Gudgunane ka dil kiya,
Meelon ka fasla pal bhar me mitane jee kiya,
Bahon me bhar tujhe
So jaane ko dil kiya,
Khud ko tanha-akela,
Aaj phir humne paya hai,
Aaj tera khayal kuch is kadar aaya hai

Aaj message se tasalli na hogi
Aaj phone call se bhi tasalli na hogi,
Ru-ba-ru na hone ki teri kami kuch is tarah bechain kar rahi hai
Jaise mano, jism ko ruh ki kami khal rahi ho
Aaj tera khayal kuch is kadar aaya hai

Zindagi mano teher si gayi ho,
Saans ruki aur,
Jeene ki wajah kho si gayi ho,
Phir kisi tarah aaj humne khud ko samjhaya hai,
Aaj tera khayal kuch is kadar aaya hai,
...aakhen nam aur dil bhar aaya hai !!!


-Mayank

Friday, October 14, 2016

Volume Control script for Raspberry Pi

Here is a small script to control audio volume. Feel free to modify the script as per need. Make sure pulseaudio is is up and running.

Filename: volchg.sh

Usage: 
volchg.sh [+/-] [x]

volchg.sh --increase volume by 5%
volchg.sh + --increase volume by 5%
volchg.sh + 10 --increase volume by 10%
volchg.sh - --decrease volume by 5%
volchg.sh - 10 --decrease volume by 10%

Script

#!/bin/sh
#############################
### Volume Up/Down Script ###
#############################

# Specify increase or decrease
MODE=$1

# Percentage Change
VAL=$2

#Set defaut change to 5%
if [ -z "$2" ]; then
  VAL=5
fi

#Get MAX Value
MAX_VOL=`amixer cget numid=3 | grep "max=" |  cut -d, -f5 | cut -d= -f 2`

#Get current val
CURRENT_VOL=`amixer cget numid=3 | grep ":" | cut -d, -f2`

#UPDATE VOL

if [ "$MODE" = "+" ]; then
  MUL=1
else
  MUL=-1
fi

NEW_VOL=$(( ($CURRENT_VOL + ($MUL * (( $VAL * $MAX_VOL) / 100 ))) ))
PER_VOL=$(( ($NEW_VOL * 100) / $MAX_VOL ))

amixer cset numid=3 $NEW_VOL > /dev/null
echo "Volume Level: $PER_VOL%"

Have fun !!!