Simple SD Audio Player with an 8-pin IC

Electronics & Electrical Engineering Topics

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

Postby Magneto » Thu Apr 22, 2010 5:19 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
Magneto
 
Posts: 430
Joined: Wed Jul 15, 2009 8:22 am
Cash on hand: 7,055.80
Bank: 3,811,838.30
Location: London
Medals: 1
EC_Achievment (1)

Invitations sent: 5
Registered friends: 0
Reputation point: 8
Corporal

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

Postby Rksk » Thu Apr 22, 2010 5:55 pm

Cool idea for me.

thankz.
i will come soon with results.
User avatar
Rksk
 
Posts: 751
Joined: Thu Jan 07, 2010 10:49 am
Cash on hand: 4,834.60
Bank: 212,150.20
Location: Rathnapura, Sri Lanka
Medals: 1
EC_Achievment (1)

Invitations sent: 35
Registered friends: 12
Reputation point: 12
Corporal

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

Postby Anjana Ishara » Wed May 26, 2010 9:42 am

Thank U friend alot
User avatar
Anjana Ishara
 
Posts: 1
Joined: Wed May 26, 2010 9:35 am
Cash on hand: 125.40

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

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

Postby PJ11 » Sat Jul 10, 2010 1:03 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
PJ11
 
Posts: 1
Joined: Sat Jul 10, 2010 12:53 pm
Cash on hand: 131.80

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

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

Postby Neo » Mon Jul 12, 2010 11:49 am

Are you looking for any authorisation to use the code?
User avatar
Neo
Site Admin
Site Admin
 
Posts: 2612
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 221,202.10
Bank: 15,536,454.00
Location: Colombo/London
Medals: 2
EC_Bronze_Star (1) EC_Achievment (1)

Invitations sent: 94
Registered friends: 12
Highscores: 13
Reputation point: 74
Lieutenant

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

Postby Rksk » Mon Aug 29, 2011 10:47 am

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

Does it want to change coding?
User avatar
Rksk
 
Posts: 751
Joined: Thu Jan 07, 2010 10:49 am
Cash on hand: 4,834.60
Bank: 212,150.20
Location: Rathnapura, Sri Lanka
Medals: 1
EC_Achievment (1)

Invitations sent: 35
Registered friends: 12
Reputation point: 12
Corporal

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

Postby Neo » Mon Aug 29, 2011 11:45 am

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
Neo
Site Admin
Site Admin
 
Posts: 2612
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 221,202.10
Bank: 15,536,454.00
Location: Colombo/London
Medals: 2
EC_Bronze_Star (1) EC_Achievment (1)

Invitations sent: 94
Registered friends: 12
Highscores: 13
Reputation point: 74
Lieutenant

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

Postby Rksk » Mon Aug 29, 2011 12:04 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
Rksk
 
Posts: 751
Joined: Thu Jan 07, 2010 10:49 am
Cash on hand: 4,834.60
Bank: 212,150.20
Location: Rathnapura, Sri Lanka
Medals: 1
EC_Achievment (1)

Invitations sent: 35
Registered friends: 12
Reputation point: 12
Corporal

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

Postby Neo » Mon Aug 29, 2011 1:31 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
Syntax: [ Download ] [ Hide ]
Using C Syntax Highlighting
  1. #include "pwmdemo.h"
  2.  
  3. void init(void);
  4. void get_period(void);
  5. void get_dutycycle(void);
  6. void update_pwm(void);
  7.  
  8. unsigned int DUTYCYCLE=0x0080;
  9. unsigned char PERIOD=0xFF;
  10. unsigned int PERCENTAGE;
  11. unsigned char PRESCALE;
  12.  
  13. void main(void)
  14. {
  15.         init();
  16.         while(1)
  17.         {
  18.                 get_period();
  19.                 get_dutycycle();
  20.                 update_pwm();
  21.                 if (PERIOD==0) PERCENTAGE=0xFFFF;
  22.                 else    PERCENTAGE=(DUTYCYCLE*100/PERIOD);
  23.         }
  24. }
  25.  
  26. void init(void)
  27. {
  28.         GIE=0;          /* no interrupts are used */
  29.         IPEN=0;
  30.        
  31.         TRISA=0x33;     /* pin 0 & 1 are analog inputs */
  32.                         /* pin 4 & 5 are inputs from DIP switch */     
  33.         TRISC=0;        /* PORTC.2 is the output from PWM */
  34.         ADCON1=0xC4;    /* configure A2D */
  35.        
  36.         CCP1CON=0x0F;   /* select PWM mode */
  37.        
  38. }
  39.  
  40. void get_dutycycle(void)
  41. {
  42.         ADFM=1; /* need 10 bit result, right justify */
  43.         ADCON0=0xC9;    /* select the channel of the duty cycle input pot */
  44.         GODONE=1;
  45.         while(!ADIF)continue;
  46.         ADIF=0;
  47.         DUTYCYCLE=ADRES/3;      /*right justified 10 bit result */
  48. }
  49.  
  50. void get_period(void)
  51. {
  52.         ADFM=0; /* period is an 8 bit value, left justify to get result from ADRESH */
  53.         ADCON0=0xC1;    /* select the channel of the period input pot */
  54.         GODONE=1;               /* start A2D */
  55.         while(!ADIF)continue;
  56.         ADIF=0;
  57.         PERIOD=ADRESH;  /* Return 8 most signifigant bits of result */
  58. }
  59.                
  60. void update_pwm(void)
  61. {
  62.         unsigned char dip_read;
  63. /* update the PWM period */
  64.         PR2=PERIOD;
  65. /* update the PWM duty cycle */
  66.         DC1B0=(bit)DUTYCYCLE;
  67.         DC1B1=(bit)(DUTYCYCLE>>1);
  68.         CCPR1L=(DUTYCYCLE>>2);
  69.        
  70. /* update the timer 2 prescaler */
  71.         dip_read=DIP;
  72.        
  73.         if (dip_read == 0)
  74.                 PRESCALE=1;
  75.         else if (dip_read == 1)
  76.                 PRESCALE=4;
  77.         else PRESCALE=16;
  78.        
  79.         T2CON=(0x04+dip_read);
  80. }
  81.  
Syntax parsed in 0.012 seconds


pwmdemo.h
Syntax: [ Download ] [ Hide ]
Using C Syntax Highlighting
  1. #ifndef _PWM_DEMO_
  2. #define _PWM_DEMO_
  3. #include <pic18.h>
  4.  
  5. #define PERIOD_POT 0
  6. #define DUTY_POT 4
  7. #define DIP ((PORTA>>4)&3)
  8.  
  9. #endif
  10.  
Syntax parsed in 0.004 seconds
User avatar
Neo
Site Admin
Site Admin
 
Posts: 2612
Joined: Tue Jul 14, 2009 8:37 pm
Cash on hand: 221,202.10
Bank: 15,536,454.00
Location: Colombo/London
Medals: 2
EC_Bronze_Star (1) EC_Achievment (1)

Invitations sent: 94
Registered friends: 12
Highscores: 13
Reputation point: 74
Lieutenant

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

Postby payamtooba » Fri Feb 27, 2015 5:06 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
User avatar
payamtooba
 
Posts: 1
Joined: Fri Feb 27, 2015 4:54 pm
Cash on hand: 132.10

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

PreviousNext

Return to Electronics & Electrical Engineering

Who is online

Users browsing this forum: No registered users and 1 guest

cron