Simple SD Audio Player with an 8-pin IC

Electronics & Electrical Engineering Topics
User avatar
Magneto
Major
Major
Posts: 430
Joined: Wed Jul 15, 2009 1:52 pm
Location: London

Re: Simple SD Audio Player with an 8-pin IC

Post by Magneto » Thu Apr 22, 2010 10:49 pm

Dear Friend ,

If you are a beginner , it is always better to use PIC micro controllers from Microchip. Because now they are highly
available in Sri Lanka and other thing is they are very cheap. I found a 16F877A micro controller at a electronic
shop ( KVG Electronics) in Rathmalana for the price of Rs. 450 /=. This has 40 pins and almost have all the
features , which a AVR microcontroller have in similar capacity. It contain all the peripherals like SPI , UART , ADC ,
PWM , CAPTURE , Timer , I2C modules. So this is more than enough controller for even an advance user.

Some ideas which can do from each peripheral in 16F877A

1. SPI - you can interface a SD card and this can use as a very large memory storage. if you want to measure and logged wind speed in every minute for a period of one year - this could be ideal storage.
2. UART - you can connect your micro controller to a Computer and you can make computer control devices.
And also you can connect a GPRS modem through this UART to your PIC . using a GPRS modem you can control lots of things using sms from your phone. How about on and off your television using your phone by sms from any where in the world :)

3. ADC - you can connect sensors to your micro controller like wind sensors , humidity sensors , temperature sensors through ADC controller. ideal for making a whether measuring station.
4. PWM - you can control DC motors (speed control) from PWM module. How about making a bowling machine ,
for practicing cricket. You have to send your ball through two rotating discs , which have different speeds. then
the bowl will swing , before it come to the bat. Amount of swing , you can control from the disc rotating speeds using PWM module.
5. CAPTURE - you can use capture module for measuring frequencies such as rotating speeds. This is ideal for making ROBOT vehicles , you can measure the amount of ROBOT travel by using this module , easily
6. I2C - two wire protocol , most of the time using to interface external EPROM s and sensors

Now can you see how many interesting things you can do from PIC microcontroller. So do not worry about AVR MCU ,
any more. All the resouces are around you. Only thing you have to do is , come up with a good project and start :)

Good Luck !!!!!!!!
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: Simple SD Audio Player with an 8-pin IC

Post by Rksk » Thu Apr 22, 2010 11:25 pm

Cool idea for me.

thankz.
i will come soon with results.
User avatar
Anjana Ishara
Posts: 1
Joined: Wed May 26, 2010 3:05 pm

Re: Simple SD Audio Player with an 8-pin IC

Post by Anjana Ishara » Wed May 26, 2010 3:12 pm

Thank U friend alot
User avatar
PJ11
Posts: 1
Joined: Sat Jul 10, 2010 6:23 pm

Re: Simple SD Audio Player with an 8-pin IC

Post by PJ11 » Sat Jul 10, 2010 6:33 pm

Mr Magneto,
i'm doing my final year project as a bluetooth visual aid for people with disabilities on their vision. i would like to know that can i use ur sample coding of the "Simple SD Audio Player with an 8-pin IC" for "PIC16F877A" to read data form a SD card and give it as an audio in for a bluetooth module?
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Simple SD Audio Player with an 8-pin IC

Post by Neo » Mon Jul 12, 2010 5:19 pm

Are you looking for any authorisation to use the code?
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: Simple SD Audio Player with an 8-pin IC

Post by Rksk » Mon Aug 29, 2011 4:17 pm

How to build this SD Audio player using a 16F877?

Does it want to change coding?
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Simple SD Audio Player with an 8-pin IC

Post by Neo » Mon Aug 29, 2011 5:15 pm

How to build this SD Audio player using a 16F877?
16F877A has PWM ports and SPI. You will have to use on of the PWM pins to speaker and connect the SPI pins to the SD card.
Does it want to change coding?
Of cause yes. The code is written for Atmel. So you will have to change it for PIC.
User avatar
Rksk
Major
Major
Posts: 730
Joined: Thu Jan 07, 2010 4:19 pm
Location: Rathnapura, Sri Lanka

Re: Simple SD Audio Player with an 8-pin IC

Post by Rksk » Mon Aug 29, 2011 5:34 pm

Neo wrote: The code is written for Atmel. So you will have to change it for PIC.
How to do it? where I have to change?
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: Simple SD Audio Player with an 8-pin IC

Post by Neo » Mon Aug 29, 2011 7:01 pm

Neo wrote:
The code is written for Atmel. So you will have to change it for PIC.
How to do it? where I have to change?
First do the necessary hardware changes. Then take the code of your current LED project (since it already have the basic structure) and do the code changes to operate PWM on the pic.

Here is a nice link that you can find the register settings for different inputs. Sample code is also there (It's compiled with mikroC compiler. However I'm sure you will be able change it for HITECH C).
PIC PWM Calculator & Code Generator

PIC18F example code:

pwmdemo.c

Code: Select all

#include "pwmdemo.h"

void init(void);
void get_period(void);
void get_dutycycle(void);
void update_pwm(void);

unsigned int DUTYCYCLE=0x0080;
unsigned char PERIOD=0xFF;
unsigned int PERCENTAGE;
unsigned char PRESCALE;

void main(void)
{
	init();
	while(1)
	{
		get_period();
		get_dutycycle();
		update_pwm();
		if (PERIOD==0) PERCENTAGE=0xFFFF;
		else	PERCENTAGE=(DUTYCYCLE*100/PERIOD);
	}
}

void init(void)
{
	GIE=0;		/* no interrupts are used */
	IPEN=0;
	
	TRISA=0x33;	/* pin 0 & 1 are analog inputs */
			/* pin 4 & 5 are inputs from DIP switch */	
	TRISC=0;	/* PORTC.2 is the output from PWM */
	ADCON1=0xC4;	/* configure A2D */
	
	CCP1CON=0x0F;	/* select PWM mode */
	
}

void get_dutycycle(void)
{
	ADFM=1;	/* need 10 bit result, right justify */
	ADCON0=0xC9;	/* select the channel of the duty cycle input pot */
	GODONE=1;
	while(!ADIF)continue;
	ADIF=0;
	DUTYCYCLE=ADRES/3;	/*right justified 10 bit result */
}

void get_period(void)
{
	ADFM=0;	/* period is an 8 bit value, left justify to get result from ADRESH */
	ADCON0=0xC1;	/* select the channel of the period input pot */
	GODONE=1;		/* start A2D */
	while(!ADIF)continue;
	ADIF=0;
	PERIOD=ADRESH;	/* Return 8 most signifigant bits of result */ 
}
		
void update_pwm(void)
{
	unsigned char dip_read;
/* update the PWM period */
	PR2=PERIOD;
/* update the PWM duty cycle */
	DC1B0=(bit)DUTYCYCLE;
	DC1B1=(bit)(DUTYCYCLE>>1);
	CCPR1L=(DUTYCYCLE>>2);
	
/* update the timer 2 prescaler */
	dip_read=DIP;
	
	if (dip_read == 0)
		PRESCALE=1;
	else if (dip_read == 1)
		PRESCALE=4;
	else PRESCALE=16;
	
	T2CON=(0x04+dip_read);
}
pwmdemo.h

Code: Select all

#ifndef _PWM_DEMO_
#define _PWM_DEMO_
#include <pic18.h>

#define PERIOD_POT 0
#define DUTY_POT 4
#define DIP ((PORTA>>4)&3)

#endif
User avatar
payamtooba
Posts: 1
Joined: Fri Feb 27, 2015 10:24 pm

Re: Simple SD Audio Player with an 8-pin IC

Post by payamtooba » Fri Feb 27, 2015 10:36 pm

hi
where can i get this complete module board ,can anyone introduce a site for that? I need it but i dont have time to make it for myself and i m not sure that can build it correct ,I am not very expert in electronics ,but if i can buy the module i ll be appreciate and i can personalize it for my need
how can I prepare it,
tanks
Post Reply

Return to “Electronics & Electrical Engineering”