Bluetooth Robot-2

ফেব্রুয়ারি 16, 2014 § 2 টি মন্তব্য

I will discuss the circuit diagram and mechanical description of the bluetooth robot now.

Here is the previous post that contains the program.

Actually, It’s not a robot. It’s some kind of remote controlled car that can be controlled over bluetooth from a laptop or PC.

The power of the microcontrollers are too low compared to the modern laptop or desktop. There is no huge computing power, no scope for image processing, no scope for huge amount of data logging, no scope for multitasking(Although there is some multitasking OS available for microcontrollers, They are complex, Time consuming, Requires a lot processing power to achieve multitasking.) and other limitations.

So, My concept was Why not build a slave device that is controlled from a central server that has huge processing power.

You can say that why not build such big robot that can carry a whole laptop inside it? Then the answer maybe The CPU requires a lot more power, Adds an extra weight to carry, has restrictions for harsh/rough environments and more…

OK, Enough now i will come to the main point.

The robot chasis is like normal tank principle. It has two treads attached with two geared motors. When both motors move forward, the chasis will go forward, opposite applies for backward movement, and when one motor is running and the other one is stopped, it will take a turn. I will add detailed images about the robot chasis later.

Now, about the circuit..

BT-robo

The heart of the circuit is the atmega8 microcontroller, which gets commands from the hc-06 bluetooth module and drives a l293d motor controller Which controls the speed and direction of the motor. The speed of the motor is controlled by pwm dc motor speed control method. You can get brief of it into the codes.

Oh.. Sorry

A correction. I have drawn this circuit with fritzing. The HC-06 bluetooth module i can’t found in fritzing but used here RN-41 module. The connection is same for HC-06.

Bluetooth Robot

জানুয়ারি 6, 2014 § ১ টি মন্তব্য

I am testing around a bluetooth module. And this is the result of the test.

I have recently bought a HC-06 bluetooth module, and after couple of hours of searching in the internet, I’ve figured out how to use the module. Detailed info and source here.

hc06-top-side

The module runs on 3.3v-5v, default pairing code 1234 and baudrate is 9600, N, 8,1. For only communication purposes, you don’t need to mess about the AT commands(it is in the online also).

hc-06-and-hc-05-source-wavesen-data-sheet

If you want to test the module if it works or not, i have a way, Download PUTTY here, you need another USB>Serial converter(I’ve used PL2303) and a bread board. Then connect TXD(pl-2303)>>RXD(HC-06), RXD(pl-2303)>>TXD(HC-06),  GND(pl-2303)>>GND(HC-06),  VCC 3.3v(pl-2303)>>VCC(HC-06).

jy-mcu-bt_board-v1-05-bottom-side

Run Putty,  from connection type radio button, select serial,  From Serial line, Edit that to com6(in my case), click open. This will open the desired bluetooth com port.  Run putty again, from connection type radio button, select serial,  From Serial line, Edit that to com8(in my case), click open. This will open serial port of pl-2303. And you can transmit and receive your keystrokes.

Here is a slight little problem. You need to know which com port of your pc is used for communicating with which device. Is it a real problem? No. Just right click Computer>manage>device manager>ports (Com & LPT). And here will show the ports. You can identify the pl2303 port because of it named as prolific or similar. And another confusion is which port is used for bluetooth device? The answer is after pairing with HC-06 you need to try each port one by one in putty. And whenever a successful connection is made. The LED of the HC-06 will stop blinking and it will stay on always.

Ok, Enough .. Here comes the code for arduino(atmega8). Will work on other 168/328 too.

int incomingByte;      // a variable to read incoming serial data into
void setup() {
  // initialize serial communication:
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(11,INPUT);
  pinMode(12,INPUT);
  pinMode(13,INPUT);
  pinMode(14,INPUT);
  pinMode(15,INPUT);
  pinMode(16,INPUT);
  pinMode(17,INPUT);
  pinMode(18,INPUT);
    analogWrite(9,80);
    analogWrite(10,80);
}

void loop() {
  // see if there's incoming serial data:
  if (Serial.available() > 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it's a capital H (ASCII 72), turn on the LED:
    if (incomingByte == 'w') {
      GoForward();
    }
    // if it's an L (ASCII 76) turn off the LED:
    if (incomingByte == 's') {
      GoBackward();
    }
    if (incomingByte == 'a') {
      TurnLeft();
    }
    if (incomingByte == 'd') {
      TurnRight();
    }
    if (incomingByte == 'i') {
      analogWrite(9,80);
      analogWrite(10,80);
    }
    if (incomingByte == 'u') {
      analogWrite(9,100);
      analogWrite(10,100);
    }
    if (incomingByte == 'y') {
      analogWrite(9,120);
      analogWrite(10,120);
    }
    if (incomingByte == 't') {
      analogWrite(9,140);
      analogWrite(10,140);
    }
    if (incomingByte == 'r') {
      analogWrite(9,180);
      analogWrite(10,180);
    }
    if (incomingByte == 'o') {
    digitalWrite(5, LOW);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, LOW);
    }
  }
}

void GoForward()
{
    digitalWrite(5, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(8, HIGH);
}

void GoBackward()
{
    digitalWrite(5, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(7, HIGH);
    digitalWrite(8, LOW);
}

void TurnRight()
{
    digitalWrite(5, HIGH);
    digitalWrite(6, HIGH);
    digitalWrite(7, LOW);
    digitalWrite(8, HIGH);
}

void TurnLeft()
{
    digitalWrite(5, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, HIGH);
}

void HardLeft()
{
    digitalWrite(5, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(7, LOW);
    digitalWrite(8, HIGH);
}

void HardRight()
{
    digitalWrite(5, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(7, HIGH);
    digitalWrite(8, LOW);
}

Most of the functions are self-explaining. And some of them are unused and for later uses. This hardware was made for one of my previous PID Line follower project and that’s another story :D .

The Hardware/Circuit diagram?
You need to wait until my next free time….

Camera Hack

ডিসেম্বর 18, 2013 § মন্তব্য দিন

I have got a couple of webcams, those seems useless to me.

Sometimes i dream to have a binocular which can do video recording and zoom further away just like the spy movies ha ha. So this story is an attempt to make such thing. Not actually the camera in the spy movies, somewhat close to that what i want to build.

So that is the idea, and i started with a couple of magnifying glasses and arranged in series in a line through my window, and started projecting the objects that i can see through my window on a white sheet of paper.

Most of the camera’s uses the same technology to project an image on a slide of film or on a CCD/CMOS camera sensor.

Then I’ve bought a webcam, disassembled it opened the lens and put my magnifying glass on the CMOS sensor and started playing with that level of zoom :D . It gave me an awesome result but also have caused some problem.

The magnifying glass combination was not perfect for me cause i can’t customize their magnifying factor/customized magnifying glasses are not available in the local market, the distance of the glass and sensor can not be controllable via electronics(though controllable by hand)/it is hard to make such hardware for me and it is not compact. So, i have searched for a long time to find commercially available zoom lenses/lense used in SLR camera.

But, those are too pricey for me to use in a project. I kept on searching.

One day my digital camera has some problem and repaired it in local camera repairing store. I asked them would they have any damaged/faulty camera and if they want to sell it. They answered no. it was quite hard for me to hear that answer. They told me that sometimes the old camera parts is very useful for them to repair a new one.

I had a scope. I asked them that if there was any such old camera that’s parts cannot reusable then i am going to buy it. They asked me what i want to do with it. I answered about my project. and they gave me a lens of an old handycam.

I opened it, It has some lenses, two stepper motors, and two sensors(i mean infrared limit switch).

I’ve put my webcam on the CCD slot of the lens unit. For this, i had to cut down my webcam motherboard a little bit. If you are going to do this project then you must understand what parts of your webcam motherboard is safest to cut down. Then i removed the two steppers and started playing with the lens unit.

It gave me awesome result. Maybe 20X zoom capability :D .

And i started to make a project in arduino to control the steppers by a computer.

It was another story, I will tell you later. Till then………..

Atmega32 usbasploader-3

ডিসেম্বর 15, 2013 § মন্তব্য দিন

Description about the hardware part:

DSC00629done

I’m sorry i can’t give you the exact circuit diagram because i have made this project before one year and that was a trial and error based project so no exact schematic had been made. After having success on this project, i was so excited that i had no time to draw a complete circuit diagram. But i will give you some clue and results. The main theory is just combine the usbasploader(here) hardware with my pinouts.

As written in the code,

#define USB_CFG_IOPORTNAME D
#define USB_CFG_DMINUS_BIT 1
#define USB_CFG_DPLUS_BIT  2

That means the D+ pin is PD2
And the D- pin is PD1 of the Atmega32 microcontroller.

And the board is made on a double layer veroboard :D . Actually it is not a double layer veroboard. It is a bit made of two different slices of veroboard. And i have cut a big hole inside of the top layer to insert the crystal and other parts. I have cut it for my fun only, it’s not essential.  If you can put the crystal and other things on the reverse side of the top layer, then it will be perfect. I have mounted the whole microcontroller circuit on the top layer and added the essential parts to able to run it without the bottom layer.

DSC00617done DSC00619done

The bottom layer has the USB voltage driver/dropper circuit from vusb with a couple of zener diodes, some resistors, a USB-B mini port and some resistors. I mean the USB-B female port is very much essential here. We know that the 4th pin of the USB-B mini port is unused. And we also know that we need a jumper for usbasploader. So,I have disassembled the USB data cable and shorted the 4th pin with the 5th pin or easily saying that 4th pin to ground and the 4th pin of the female jack of the USB-B mini on the circuit board is connected with PD0 as says the following line of the configuration code.

#define JUMPER_BIT 0

So, whenever you inserted the cable, after pressing the reset button, the microcontroller automatically goes to programming mode. Isn’t the feature beautiful and essential? And after removing the cable, the microcontroller always goes to run mode.

DSC00626done DSC00627done DSC00631done DSC00625done DSC00624done

Atmega32 usbasploader-2

ডিসেম্বর 14, 2013 § ১ টি মন্তব্য

Now I will describe the bootloader software part.

I have faced and i know that almost everyone faces problem with the boot-loader. The boot-loader/hardware miss-configuration makes it impossible to work and falls us into frustration. It takes 3 months for me to have a success.

I have compiled these with WINAVR in windows xp/7 successfully.

Download the Winavr from sourceforge, install it. Download the usbasp package, unzip it.

Then you only need to make the following files. The files will be exactly look like-

1. bootloaderconfig.h

</pre>
/* Name: bootloaderconfig.h
 * Project: USBaspLoader
 * Author: Christian Starkjohann
 * Creation Date: 2007-12-08
 * Tabsize: 4
 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
 * License: GNU GPL v2 (see License.txt)
 * This Revision: $Id: bootloaderconfig.h 729 2009-03-20 09:03:58Z cs $
 */

#ifndef __bootloaderconfig_h_included__
#define __bootloaderconfig_h_included__

/*
General Description:
This file (together with some settings in Makefile) configures the boot loader
according to the hardware.

This file contains (besides the hardware configuration normally found in
usbconfig.h) two functions or macros: bootLoaderInit() and
bootLoaderCondition(). Whether you implement them as macros or as static
inline functions is up to you, decide based on code size and convenience.

bootLoaderInit() is called as one of the first actions after reset. It should
be a minimum initialization of the hardware so that the boot loader condition
can be read. This will usually consist of activating a pull-up resistor for an
external jumper which selects boot loader mode.

bootLoaderCondition() is called immediately after initialization and in each
main loop iteration. If it returns TRUE, the boot loader will be active. If it
returns FALSE, the boot loader jumps to address 0 (the loaded application)
immediately.

For compatibility with Thomas Fischl's avrusbboot, we also support the macro
names BOOTLOADER_INIT and BOOTLOADER_CONDITION for this functionality. If
these macros are defined, the boot loader usees them.
*/

/* ---------------------------- Hardware Config ---------------------------- */

#define USB_CFG_IOPORTNAME D
/* This is the port where the USB bus is connected. When you configure it to
 * "B", the registers PORTB, PINB and DDRB will be used.
 */
#define USB_CFG_DMINUS_BIT 1
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
 * This may be any bit in the port.
 */
#define USB_CFG_DPLUS_BIT 2
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
 * This may be any bit in the port. Please note that D+ must also be connected
 * to interrupt pin INT0!
 */
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
/* Clock rate of the AVR in MHz. Legal values are 12000, 16000 or 16500.
 * The 16.5 MHz version of the code requires no crystal, it tolerates +/- 1%
 * deviation from the nominal frequency. All other rates require a precision
 * of 2000 ppm and thus a crystal!
 * Default if not specified: 12 MHz
 */

/* ----------------------- Optional Hardware Config ------------------------ */

/* #define USB_CFG_PULLUP_IOPORTNAME D */
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
 * V+, you can connect and disconnect the device from firmware by calling
 * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
 * This constant defines the port on which the pullup resistor is connected.
 */
/* #define USB_CFG_PULLUP_BIT 4 */
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
 * above) where the 1.5k pullup resistor is connected. See description
 * above for details.
 */

/* ------------------------------------------------------------------------- */
/* ---------------------- feature / code size options ---------------------- */
/* ------------------------------------------------------------------------- */

#define HAVE_EEPROM_PAGED_ACCESS 1
/* If HAVE_EEPROM_PAGED_ACCESS is defined to 1, page mode access to EEPROM is
 * compiled in. Whether page mode or byte mode access is used by AVRDUDE
 * depends on the target device. Page mode is only used if the device supports
 * it, e.g. for the ATMega88, 168 etc. You can save quite a bit of memory by
 * disabling page mode EEPROM access. Costs ~ 138 bytes.
 */
#define HAVE_EEPROM_BYTE_ACCESS 1
/* If HAVE_EEPROM_BYTE_ACCESS is defined to 1, byte mode access to EEPROM is
 * compiled in. Byte mode is only used if the device (as identified by its
 * signature) does not support page mode for EEPROM. It is required for
 * accessing the EEPROM on the ATMega8. Costs ~54 bytes.
 */
#define BOOTLOADER_CAN_EXIT 1
/* If this macro is defined to 1, the boot loader will exit shortly after the
 * programmer closes the connection to the device. Costs ~36 bytes.
 */
#define HAVE_CHIP_ERASE 0
/* If this macro is defined to 1, the boot loader implements the Chip Erase
 * ISP command. Otherwise pages are erased on demand before they are written.
 */
//#define SIGNATURE_BYTES 0x1e, 0x93, 0x07, 0 /* ATMega8 */
/* This macro defines the signature bytes returned by the emulated USBasp to
 * the programmer software. They should match the actual device at least in
 * memory size and features. If you don't define this, values for ATMega8,
 * ATMega88, ATMega168 and ATMega328 are guessed correctly.
 */

/* The following block guesses feature options so that the resulting code
 * should fit into 2k bytes boot block with the given device and clock rate.
 * Activate by passing "-DUSE_AUTOCONFIG=1" to the compiler.
 * This requires gcc 3.4.6 for small enough code size!
 */
#if USE_AUTOCONFIG
# undef HAVE_EEPROM_PAGED_ACCESS
# define HAVE_EEPROM_PAGED_ACCESS (USB_CFG_CLOCK_KHZ >= 16000)
# undef HAVE_EEPROM_BYTE_ACCESS
# define HAVE_EEPROM_BYTE_ACCESS 1
# undef BOOTLOADER_CAN_EXIT
# define BOOTLOADER_CAN_EXIT 1
# undef SIGNATURE_BYTES
#endif /* USE_AUTOCONFIG */

/* ------------------------------------------------------------------------- */

/* Example configuration: Port D bit 3 is connected to a jumper which ties
 * this pin to GND if the boot loader is requested. Initialization allows
 * several clock cycles for the input voltage to stabilize before
 * bootLoaderCondition() samples the value.
 * We use a function for bootLoaderInit() for convenience and a macro for
 * bootLoaderCondition() for efficiency.
 */

#ifndef __ASSEMBLER__ /* assembler cannot parse function definitions */

#define JUMPER_BIT 0 /* jumper is connected to this bit in port D, active low */

#ifndef MCUCSR /* compatibility between ATMega8 and ATMega88 */
# define MCUCSR MCUSR
#endif

static inline void bootLoaderInit(void)
{
 PORTD |= (1 << JUMPER_BIT); /* activate pull-up */
 if(!(MCUCSR & (1 << EXTRF))) /* If this was not an external reset, ignore */
 leaveBootloader();
 MCUCSR = 0; /* clear all reset flags for next time */
}

static inline void bootLoaderExit(void)
{
 PORTD = 0; /* undo bootLoaderInit() changes */
}

#define bootLoaderCondition() ((PIND & (1 << JUMPER_BIT)) == 0)

#endif /* __ASSEMBLER__ */

/* ------------------------------------------------------------------------- */

#endif /* __bootloader_h_included__ */
<pre>

2. Makefile

</pre>
/* Name: bootloaderconfig.h
 * Project: USBaspLoader
 * Author: Christian Starkjohann
 * Creation Date: 2007-12-08
 * Tabsize: 4
 * Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
 * License: GNU GPL v2 (see License.txt)
 * This Revision: $Id: bootloaderconfig.h 729 2009-03-20 09:03:58Z cs $
 */

#ifndef __bootloaderconfig_h_included__
#define __bootloaderconfig_h_included__

/*
General Description:
This file (together with some settings in Makefile) configures the boot loader
according to the hardware.

This file contains (besides the hardware configuration normally found in
usbconfig.h) two functions or macros: bootLoaderInit() and
bootLoaderCondition(). Whether you implement them as macros or as static
inline functions is up to you, decide based on code size and convenience.

bootLoaderInit() is called as one of the first actions after reset. It should
be a minimum initialization of the hardware so that the boot loader condition
can be read. This will usually consist of activating a pull-up resistor for an
external jumper which selects boot loader mode.

bootLoaderCondition() is called immediately after initialization and in each
main loop iteration. If it returns TRUE, the boot loader will be active. If it
returns FALSE, the boot loader jumps to address 0 (the loaded application)
immediately.

For compatibility with Thomas Fischl's avrusbboot, we also support the macro
names BOOTLOADER_INIT and BOOTLOADER_CONDITION for this functionality. If
these macros are defined, the boot loader usees them.
*/

/* ---------------------------- Hardware Config ---------------------------- */

#define USB_CFG_IOPORTNAME D
/* This is the port where the USB bus is connected. When you configure it to
 * "B", the registers PORTB, PINB and DDRB will be used.
 */
#define USB_CFG_DMINUS_BIT 1
/* This is the bit number in USB_CFG_IOPORT where the USB D- line is connected.
 * This may be any bit in the port.
 */
#define USB_CFG_DPLUS_BIT 2
/* This is the bit number in USB_CFG_IOPORT where the USB D+ line is connected.
 * This may be any bit in the port. Please note that D+ must also be connected
 * to interrupt pin INT0!
 */
#define USB_CFG_CLOCK_KHZ (F_CPU/1000)
/* Clock rate of the AVR in MHz. Legal values are 12000, 16000 or 16500.
 * The 16.5 MHz version of the code requires no crystal, it tolerates +/- 1%
 * deviation from the nominal frequency. All other rates require a precision
 * of 2000 ppm and thus a crystal!
 * Default if not specified: 12 MHz
 */

/* ----------------------- Optional Hardware Config ------------------------ */

/* #define USB_CFG_PULLUP_IOPORTNAME D */
/* If you connect the 1.5k pullup resistor from D- to a port pin instead of
 * V+, you can connect and disconnect the device from firmware by calling
 * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h).
 * This constant defines the port on which the pullup resistor is connected.
 */
/* #define USB_CFG_PULLUP_BIT 4 */
/* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined
 * above) where the 1.5k pullup resistor is connected. See description
 * above for details.
 */

/* ------------------------------------------------------------------------- */
/* ---------------------- feature / code size options ---------------------- */
/* ------------------------------------------------------------------------- */

#define HAVE_EEPROM_PAGED_ACCESS 1
/* If HAVE_EEPROM_PAGED_ACCESS is defined to 1, page mode access to EEPROM is
 * compiled in. Whether page mode or byte mode access is used by AVRDUDE
 * depends on the target device. Page mode is only used if the device supports
 * it, e.g. for the ATMega88, 168 etc. You can save quite a bit of memory by
 * disabling page mode EEPROM access. Costs ~ 138 bytes.
 */
#define HAVE_EEPROM_BYTE_ACCESS 1
/* If HAVE_EEPROM_BYTE_ACCESS is defined to 1, byte mode access to EEPROM is
 * compiled in. Byte mode is only used if the device (as identified by its
 * signature) does not support page mode for EEPROM. It is required for
 * accessing the EEPROM on the ATMega8. Costs ~54 bytes.
 */
#define BOOTLOADER_CAN_EXIT 1
/* If this macro is defined to 1, the boot loader will exit shortly after the
 * programmer closes the connection to the device. Costs ~36 bytes.
 */
#define HAVE_CHIP_ERASE 0
/* If this macro is defined to 1, the boot loader implements the Chip Erase
 * ISP command. Otherwise pages are erased on demand before they are written.
 */
//#define SIGNATURE_BYTES 0x1e, 0x93, 0x07, 0 /* ATMega8 */
/* This macro defines the signature bytes returned by the emulated USBasp to
 * the programmer software. They should match the actual device at least in
 * memory size and features. If you don't define this, values for ATMega8,
 * ATMega88, ATMega168 and ATMega328 are guessed correctly.
 */

/* The following block guesses feature options so that the resulting code
 * should fit into 2k bytes boot block with the given device and clock rate.
 * Activate by passing "-DUSE_AUTOCONFIG=1" to the compiler.
 * This requires gcc 3.4.6 for small enough code size!
 */
#if USE_AUTOCONFIG
# undef HAVE_EEPROM_PAGED_ACCESS
# define HAVE_EEPROM_PAGED_ACCESS (USB_CFG_CLOCK_KHZ >= 16000)
# undef HAVE_EEPROM_BYTE_ACCESS
# define HAVE_EEPROM_BYTE_ACCESS 1
# undef BOOTLOADER_CAN_EXIT
# define BOOTLOADER_CAN_EXIT 1
# undef SIGNATURE_BYTES
#endif /* USE_AUTOCONFIG */

/* ------------------------------------------------------------------------- */

/* Example configuration: Port D bit 3 is connected to a jumper which ties
 * this pin to GND if the boot loader is requested. Initialization allows
 * several clock cycles for the input voltage to stabilize before
 * bootLoaderCondition() samples the value.
 * We use a function for bootLoaderInit() for convenience and a macro for
 * bootLoaderCondition() for efficiency.
 */

#ifndef __ASSEMBLER__ /* assembler cannot parse function definitions */

#define JUMPER_BIT 0 /* jumper is connected to this bit in port D, active low */

#ifndef MCUCSR /* compatibility between ATMega8 and ATMega88 */
# define MCUCSR MCUSR
#endif

static inline void bootLoaderInit(void)
{
 PORTD |= (1 << JUMPER_BIT); /* activate pull-up */
 if(!(MCUCSR & (1 << EXTRF))) /* If this was not an external reset, ignore */
 leaveBootloader();
 MCUCSR = 0; /* clear all reset flags for next time */
}

static inline void bootLoaderExit(void)
{
 PORTD = 0; /* undo bootLoaderInit() changes */
}

#define bootLoaderCondition() ((PIND & (1 << JUMPER_BIT)) == 0)

#endif /* __ASSEMBLER__ */

/* ------------------------------------------------------------------------- */

#endif /* __bootloader_h_included__ */
<pre>

Then run command prompt, cd to the folder where you unzipped, then type the commands and press enter.
1. To Compile And Upload To Microcontroller-
make flash
2. To Set Fusebits
make fuse
3. To Set Lockbits.
make lock
Issue these commands and enjoy. I will come later with the circuit diagram. But it’s already written in the codes. :D

Ok, And for better help(also less explaining for me :p ) I uploaded complete package zipped, Click here to download it. The .bat scripts helps to avoid the damn command prompt.  You can play with them but be careful(they can blow your PC off :p ).

Wifi Robot – 4

জুলাই 15, 2013 § মন্তব্য দিন

This is the second and final version of wifi-speaker.

After following the instructions of Wifi Robot – 3, you can follow the instructions on this page cause some of the software package installed in my previous post is needed here.

Install mpd(music player daemon),  mpc(music player daemon console)  alsa is a sound card driver.

opkg update
opkg install mpd mpc alsa-lib alsa-utils libsndfile

Then with winscp go to /etc/mpd.conf and make the file look exactly like following. If you have different hardware then search google for that.

# An example configuration file for MPD
# See the mpd.conf man page for a more detailed description of each parameter.
# Files and directories #######################################################
#
# This setting controls the top directory which MPD will search to discover the
# available audio files and add them to the daemon's online database. This
# setting defaults to the XDG directory, otherwise the music directory will be
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
music_directory "/home/music"
#
# This setting sets the MPD internal playlist directory. The purpose of this
# directory is storage for playlists created by MPD. The server will use
# playlist files not created by the server but only if they are in the MPD
# format. This setting defaults to playlist saving being disabled.
#
#playlist_directory "~/.mpd/playlists"
#
# This setting sets the location of the MPD database. This file is used to
# load the database at server start up and store the database while the
# server is not up. This setting defaults to disabled which will allow
# MPD to accept files over ipc socket (using file:// protocol) or streaming
# files over an accepted protocol.
#
db_file "/home/music/system/mpd.db"
#
# These settings are the locations for the daemon log files for the daemon.
# These logs are great for troubleshooting, depending on your log_level
# settings.
#
# The special value "syslog" makes MPD use the local syslog daemon. This
# setting defaults to logging to syslog, otherwise logging is disabled.
#
log_file "/home/music/system/mpd.log"
#
# This setting sets the location of the file which stores the process ID
# for use of mpd --kill and some init scripts. This setting is disabled by
# default and the pid file will not be stored.
#
#pid_file "~/.mpd/pid"
#
# This setting sets the location of the file which contains information about
# most variables to get MPD back into the same general shape it was in before
# it was brought down. This setting is disabled by default and the server
# state will be reset on server start up.
#
#state_file "~/.mpd/state"
#
# The location of the sticker database. This is a database which
# manages dynamic information attached to songs.
#
#sticker_file "~/.mpd/sticker.sql"
#
###############################################################################
# General music daemon options ################################################
#
# This setting specifies the user that MPD will run as. MPD should never run as
# root and you may use this setting to make MPD change its user ID after
# initialization. This setting is disabled by default and MPD is run as the
# current user.
#
#user "nobody"
#
# This setting specifies the group that MPD will run as. If not specified
# primary group of user specified with "user" setting will be used (if set).
# This is useful if MPD needs to be a member of group such as "audio" to
# have permission to use sound card.
#
#group "nogroup"
#
# This setting sets the address for the daemon to listen on. Careful attention
# should be paid if this is assigned to anything other then the default, any.
# This setting can deny access to control of the daemon.
#
# For network
#bind_to_address "any"
#
# And for Unix Socket
#bind_to_address "~/.mpd/socket"
#
# This setting is the TCP port that is desired for the daemon to get assigned
# to.
#
port "6600"
#
# This setting controls the type of information which is logged. Available
# setting arguments are "default", "secure" or "verbose". The "verbose" setting
# argument is recommended for troubleshooting, though can quickly stretch
# available resources on limited hardware storage.
#
#log_level "default"
#
# If you have a problem with your MP3s ending abruptly it is recommended that
# you set this argument to "no" to attempt to fix the problem. If this solves
# the problem, it is highly recommended to fix the MP3 files with vbrfix
# (available from <http://www.willwap.co.uk/Programs/vbrfix.php>), at which
# point gapless MP3 playback can be enabled.
#
#gapless_mp3_playback "yes"
#
# This setting enables MPD to create playlists in a format usable by other
# music players.
#
#save_absolute_paths_in_playlists "no"
#
# This setting defines a list of tag types that will be extracted during the
# audio file discovery process. Optionally, 'comment' can be added to this
# list.
#
#metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc"
#
# This setting enables automatic update of MPD's database when files in
# music_directory are changed.
#
#auto_update "yes"
#
# Limit the depth of the directories being watched, 0 means only watch
# the music directory itself. There is no limit by default.
#
#auto_update_depth "3"
#
###############################################################################
# Symbolic link behavior ######################################################
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links outside of the configured music_directory.
#
#follow_outside_symlinks "yes"
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links inside of the configured music_directory.
#
#follow_inside_symlinks "yes"
#
###############################################################################
# Zeroconf / Avahi Service Discovery ##########################################
#
# If this setting is set to "yes", service information will be published with
# Zeroconf / Avahi.
#
#zeroconf_enabled "yes"
#
# The argument to this setting will be the Zeroconf / Avahi unique name for
# this MPD server on the network.
#
#zeroconf_name "Music Player"
#
###############################################################################
# Permissions #################################################################
#
# If this setting is set, MPD will require password authorization. The password
# can setting can be specified multiple times for different password profiles.
#
#password "password@read,add,control,admin"
#
# This setting specifies the permissions a user has who has not yet logged in.
#
#default_permissions "read,add,control,admin"
#
###############################################################################
# Input #######################################################################
#

input {
 plugin "curl"
# proxy "proxy.isp.com:8080"
# proxy_user "user"
# proxy_password "password"
}

#
###############################################################################

# Audio Output ################################################################
#
# MPD supports various audio output types, as well as playing through multiple
# audio outputs at the same time, through multiple audio_output settings
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.
#
# See <http://mpd.wikia.com/wiki/Configuration#Audio_Outputs> for examples of
# other audio outputs.
#
# An example of an ALSA output:
#
#audio_output {
# type "alsa"
# name "My ALSA Device"
## device "hw:0,0" # optional
## format "44100:16:2" # optional
## mixer_type "hardware" # optional
## mixer_device "default" # optional
## mixer_control "PCM" # optional
## mixer_index "0" # optional
#}
#
# An example of an OSS output:
#
#audio_output {
# type "oss"
# name "My OSS Device"
# device "/dev/snd/controlC0" # optional
# format "44100:16:2" # optional
# mixer_type "software" # optional
## mixer_device "/dev/mixer" # optional
## mixer_control "PCM" # optional
#}
audio_output {
 type "alsa"
 name "Generic USB Audio Device"
 device "hw:0,0" # optional
 format "44100:16:2" # optional
 mixer_type "software"
 mixer_device "default"
 mixer_control "PCM"
}
#audio_output {
# type "oss"
# name "My OSS Device"
# device "/dev/snd/"
# format "44100:16:2"
#}
#
# An example of a shout output (for streaming to Icecast):
#
#audio_output {
# type "shout"
# encoding "ogg" # optional
# name "My Shout Stream"
# host "localhost"
# port "8000"
# mount "/mpd.ogg"
# password "hackme"
# quality "5.0"
# bitrate "128"
# format "44100:16:1"
## protocol "icecast2" # optional
## user "source" # optional
## description "My Stream Description" # optional
## genre "jazz" # optional
## public "no" # optional
## timeout "2" # optional
## mixer_type "software" # optional
#}
#
# An example of a recorder output:
#
#audio_output {
# type "recorder"
# name "My recorder"
# encoder "vorbis" # optional, vorbis or lame
# path "/var/lib/mpd/recorder/mpd.ogg"
## quality "5.0" # do not define if bitrate is defined
# bitrate "128" # do not define if quality is defined
# format "44100:16:1"
#}
#
# An example of a httpd output (built-in HTTP streaming server):
#
#audio_output {
# type "httpd"
# name "My HTTP Stream"
# encoder "vorbis" # optional, vorbis or lame
# port "8000"
# bind_to_address "0.0.0.0" # optional, IPv4 or IPv6
## quality "5.0" # do not define if bitrate is defined
# bitrate "128" # do not define if quality is defined
# format "44100:16:1"
# max_clients "0" # optional 0=no limit
#}
#
# An example of a pulseaudio output (streaming to a remote pulseaudio server)
#
#audio_output {
# type "pulse"
# name "My Pulse Output"
## server "remote_server" # optional
## sink "remote_server_sink" # optional
#}
#
## Example "pipe" output:
#
#audio_output {
# type "pipe"
# name "my pipe"
# command "aplay -f cd 2>/dev/null"
## Or if you're want to use AudioCompress
# command "AudioCompress -m | aplay -f cd 2>/dev/null"
## Or to send raw PCM stream through PCM:
# command "nc example.org 8765"
# format "44100:16:2"
#}
#
## An example of a null output (for no audio output):
#
#audio_output {
# type "null"
# name "My Null Output"
# mixer_type "none" # optional
#}
#
# This setting will change all decoded audio to be converted to the specified
# format before being passed to the audio outputs. By default, this setting is
# disabled.
#
#audio_output_format "44100:16:2"
#
# If MPD has been compiled with libsamplerate support, this setting specifies
# the sample rate converter to use. Possible values can be found in the
# mpd.conf man page or the libsamplerate documentation. By default, this is
# setting is disabled.
#
#samplerate_converter "Fastest Sinc Interpolator"
#
###############################################################################
# Normalization automatic volume adjustments ##################################
#
# This setting specifies the type of ReplayGain to use. This setting can have
# the argument "off", "album" or "track". See <http://www.replaygain.org>
# for more details. This setting is off by default.
#
#replaygain "album"
#
# This setting sets the pre-amp used for files that have ReplayGain tags. By
# default this setting is disabled.
#
#replaygain_preamp "0"
#
# This setting enables on-the-fly normalization volume adjustment. This will
# result in the volume of all playing audio to be adjusted so the output has
# equal "loudness". This setting is disabled by default.
#
#volume_normalization "no"
#
###############################################################################
# MPD Internal Buffering ######################################################
#
# This setting adjusts the size of internal decoded audio buffering. Changing
# this may have undesired effects. Don't change this if you don't know what you
# are doing.
#
#audio_buffer_size "2048"
#
# This setting controls the percentage of the buffer which is filled before
# beginning to play. Increasing this reduces the chance of audio file skipping,
# at the cost of increased time prior to audio playback.
#
#buffer_before_play "10%"
#
###############################################################################
# Resource Limitations ########################################################
#
# These settings are various limitations to prevent MPD from using too many
# resources. Generally, these settings should be minimized to prevent security
# risks, depending on the operating resources.
#
#connection_timeout "60"
#max_connections "10"
#max_playlist_length "16384"
#max_command_list_size "2048"
#max_output_buffer_size "8192"
#
###############################################################################
# Character Encoding ##########################################################
#
# If file or directory names do not display correctly for your locale then you
# may need to modify this setting.
#
#filesystem_charset "UTF-8"
#
# This setting controls the encoding that ID3v1 tags should be converted from.
#
#id3v1_encoding "ISO-8859-1"
#
###############################################################################
# SIDPlay decoder #############################################################
#
# songlength_database:
# Location of your songlengths file, as distributed with the HVSC.
# The sidplay plugin checks this for matching MD5 fingerprints.
# See http://www.c64.org/HVSC/DOCUMENTS/Songlengths.faq
#
# default_songlength:
# This is the default playing time in seconds for songs not in the
# songlength database, or in case you're not using a database.
# A value of 0 means play indefinitely.
#
# filter:
# Turns the SID filter emulation on or off.
#
#decoder {
# plugin "sidplay"
# songlength_database "/media/C64Music/DOCUMENTS/Songlengths.txt"
# default_songlength "120"
# filter "true"
#}
#
###############################################################################

Then you need to make the following folders in root of your router via winscp. make the following files also.

Make a folder named home in root. Inside home folder make a folder named music. Inside music folder, make a folder named system. Inside system create two blank file named mpd.db and mpd.log . And set properties of each folder to read+writeable from their properties. You can also load some music into /home/music with winscp(slower) or attaching the pendrive to a linux PC(ultra faster).

blg3

Then install Auremo (it is a good looking mpd controller software) from here. You need Microsoft .net framework 4.0 to run auremo, google for it and install it. i haven’t provided link for that coz microsoft’s download location may change.

Restart router, after router rebooted, run auremo from the desktop and ssh to your router, and type the following comands -

mpd
mpc

Then configure auremo like the following image says -
blg3
Click Apply>>OK Then auremo blg3
It will say connected, and show the files i have uploaded via winscp to /home/music. Drag chosen items to the right side and click play and enjoy. Of course you can play web radio streams/local vlc streams(described on my previous post) by auremo. And i think this is a awesome front-end for the cute little router.

wifi Robot – 3

জুলাই 14, 2013 § 3 টি মন্তব্য

I have gone a little bit far away from making robot to making a wifi speaker.

Now, at present i will tell you about how i have converted a TP-Link Tl-MR3020 Router to a wifi-sound system or wifi-sound-box or wifi-speaker whichever you prefer/like to call the project.

Ok, after installing the a new usb pendrive(a 8gb pendrive with 75000 mb avilibility) which is partitioned as 500 mb as linux swap and 7 gb of linux ext4 formatted filesystem. And it is installed by my previous posts.

After mounting the pen drive the system says just like the following picture:

blg1

Then i have installed the packages kmod-usb-audio and kmod-sound-core by this command in ssh.

opkg update
opkg install kmod-usb-audio kmod-sound-core

After success, the basic support of sound is installed. Now, we have to install an audio player. At starting point, we will use an easier one. For that i have selected madplay. To install madplay, insert the following command and then press enter in ssh.

opkg install madplay

After success, attach your usb sound card and restart router. I have used the following cheapest sound card.

dbf9e868-c309-4601-b9c0-faebb79803fa

Then re-login using your putty and also with winscp. Browse with winscp to this folder /www/cgi-bin make a file there named index.cgi and paste the following code(this code is for testing only, it is not optimized).

</pre>
#!/bin/sh
#!/www/cgi-bin/80sonly

&nbsp;

echo "Content-type: text/html"
echo ""
echo "<html>"
#echo "<body bgcolor='#000000'>"
echo "|------[ ] <font size="5" face="Monaco"><a href="off.cgi">Turn OFF</a></font><br/>"
echo '<a href="../StartAudioStream.vbs" target="_blank">Download Script</a>'

echo "My IP IS : ${REMOTE_ADDR}"

echo "<form method=GET action=\"${SCRIPT}\">"\
 '<table nowrap>'\
 '<tr><td>IP</TD><TD><input type="text" name="val_x" size=12 value="'${REMOTE_ADDR}'"></td></tr>'\
 '<tr><td>Port</td><td><input type="text" name="val_y" value="8085" size=12 value=""></td>'\
 '</tr></table>'
echo '<br><input type="submit" value="Apply">'\
 '<input type="reset" value="Reset"></form>'
 # Make sure we have been invoked properly.

if [ "$REQUEST_METHOD" != "GET" ]; then
 echo "<hr>Script Error:"\
 "<br>Usage error, cannot complete request, REQUEST_METHOD!=GET."\
 "<br>Check your FORM declaration and be sure to use METHOD=\"GET\".<hr>"
 exit 1
 fi

&nbsp;
#sleep 1
#kill $(pidof madplay)

# If no search arguments, exit gracefully now.

 if [ -z "$QUERY_STRING" ]; then
 exit 0
 else
 # No looping this time, just extract the data you are looking for with sed:
 XX=`echo "$QUERY_STRING" | sed -n 's/^.*val_x=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
 YY=`echo "$QUERY_STRING" | sed -n 's/^.*val_y=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
# echo "val_x: " $XX
# echo '<br>'
# echo "val_y: " $YY
# echo '<br>'
wget -O - http://$XX:$YY/ | madplay -&

fi

echo '</body>'
echo '</html>'
<pre>

Then save it, right click again on the file>properties and make the property like the following picture(executable) and click ok.blg2

Then make another file there named off.cgi and paste the following codes :

</pre>
#!/bin/sh
#!/www/cgi-bin/80sonly
sleep 1
kill $(pidof madplay)
#killall madplay
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<body bgcolor='#000000'>"
echo "wait..."

#sleep 1
#kill $(pidof madplay)
#sleep 1
#opkg update
#opkg remove madplay
#opkg install madplay --force-depends --force-maintainer

echo "|------[ ] <font size="1" face="Monaco"><a href="index.cgi">Turn ON</a></font></br>"
echo "|------[ ] <font size="1" face="Monaco"><a href="off.cgi">Turn OFF</a></font>"

#wget -O - http://streaming206.radionomy.com:80/80sOnly | madplay - &
echo "</body>"
echo "</html>"
<pre>

Then, make the file(off.cgi) also executable.

Then  the configuration of the router aka wifi speaker is finished. Now, we need to configure our desktop/laptop to stream sound over lan/wifi.

for this, download vlc media player from here. Install it, Run it. Then configure it like the following pictures.

Click Media>Stream

blg3

Then click Capture Device and set everything like following picture.

blg3

click configure button of audio device name and set everything just like following.

blg3

If you can’t find stereo mix in the pin line drop-down menu, you need to google for it. After that, click OK click Stream, then the following window appears.

blg3

Click Destination Setup>New Destination(select HTTP from dropdown)>Add

blg3

Select Port=8085 and profile audio-mp3 and then click Stream.

blg3

Then you will get the window.

blg3

Then click the little vlc icon in the system tray and vlc window will disappear. For those who dont know what the system tray is -

blg3

Then with your router connected with lan and a speaker is connected with the usb sound card which is connected with the usb hub with the router, go to your favorite browser, type the following address YOUR ROUTER IP/cgi-bin/index.cgi in my case it is :

blg3

It will automatically detect your PC IP. In my case my local pc ip : 192.168.1.110 and my router ip is 192.168.1.250. You dont need to change anything here. Click apply and you can hear the audio played into your PC.

If any problem, then you have missed something. Although i have not told everything briefly coz your best friend google is there for you to help(yeah it helped me to do this project). And if you can please comment of your problems, i must help you if i can.

And another post will come later related this subject with much more controlling from desktop.

Follow

Get every new post delivered to your Inbox.

Join 236 other followers

%d bloggers like this: