Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

microchip tcp stack potentiometer application :

Status
Not open for further replies.

nikhilrajg

Member level 3
Joined
Mar 2, 2012
Messages
63
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Manipal,Karnataka,India
Activity points
1,834
Hello,

Can anyone help me plz.
I just want an information about the potentiometer application code applied in the stack. How does it works ? As in some of the boards there will be a potentiometer( ex: Explorer-16 board)..

When the web page is loaded from the PIC microcontroller through wi-fi.. the page shows potentiometer reading ,, as tghe potentiometer is rotated on the board.. They have implemented in the code.. It looks like it will be there in the analog format !! But how they are converting from analog to digital ?? plese help me..

Thank you very much for your consideration.
any heklp will be greatly appreciated.

Thank you.
Nikhil Raj.
 

the potentiometer i sconnected to the ADC (analog to digital converter) pin of the microcontroller, in the code you can scroll and find a function named potentiometer or something like that i dont remeber the exact name wher the code for getting the digital value is implemented.

---------- Post added at 10:41 ---------- Previous post was at 10:39 ----------

If you have the dev baord or if u have installed the demo app files to your own board you can check the dynamic variables page for the details and how to implement this.

---------- Post added at 10:44 ---------- Previous post was at 10:41 ----------

visit **broken link removed** to have a view demo of the webserver demo app .

I hope this would have helped you !
 

Hello sherazi,

Thanks for your reply :smile:..

there are 2 functions..
In maindemo.c.., One is that bellow shown..

Code:
// Processes A/D data from the potentiometer
static void  ProcessIO(void)
{
#if defined(__C30__) || defined(__C32__)
    // Convert potentiometer result into ASCII string
    uitoa((WORD)ADC1BUF0, AN0String);
#else
    // AN0 should already be set up as an analog input
    ADCON0bits.GO = 1;

    // Wait until A/D conversion is done
    while(ADCON0bits.GO);

	// AD converter errata work around (ex: PIC18F87J10 A2)
	#if !defined(__18F87J50) && !defined(_18F87J50)
		PRODL = ADCON2;
		ADCON2bits.ADCS0 = 1;
		ADCON2bits.ADCS1 = 1;
		ADCON2 = PRODL;
	#endif

    // Convert 10-bit value into ASCII string
    uitoa(*((WORD*)(&ADRESL)), AN0String);
#endif
}


In custumHTTPApp.c..,,

Code:
void HTTPPrint_pot(void)
{    
	BYTE AN0String[8];
	WORD ADval;

#if defined(__18CXX)
    // Wait until A/D conversion is done
    ADCON0bits.GO = 1;
    while(ADCON0bits.GO);

    // Convert 10-bit value into ASCII string
    ADval = (WORD)ADRES;
    //ADval *= (WORD)10;
    //ADval /= (WORD)102;
    uitoa(ADval, AN0String);
#else
	ADval = (WORD)ADC1BUF0;
	//ADval *= (WORD)10;
	//ADval /= (WORD)102;
    uitoa(ADval, (BYTE*)AN0String);
#endif

   	TCPPutString(sktHTTP, AN0String);
}


But which one is exactly converting A to D ???

Thank you.
Nikhil
 

if you want to display the value by including "~pot~" in your html file ,

you have to use the second code. this would replace ~pot~ by the value of potentiometer!
 
Actually I want code which will covert the analog to digital format.. I am recording the voice from the microphone and sending to the computer through wifi from the microcontroller instantly.. I mean something like live recording I have done my hardware part,.. but I am stuck with the coding part.. I dont know how to do analog to digital conversion. So analog audio signals should be converted to digital signals and then should be transmitted to the comp.. All these should be contrlled from the web page.. Like you said I got the point that ~pot~ is used to interact between MCU and the webpage..

Can you plz help me..

Than you.
Nikhil
 

plz check this https://www.electro-tech-online.com...voice-recorder-using-adc-microcontroller.html

for this u have to continuously convert the signal to digital ,

Code:
WORD mic_input()
{

	WORD ADval;

#if defined(__18CXX)
    // Wait until A/D conversion is done
    ADCON0bits.GO = 1;
    while(ADCON0bits.GO);

    // Convert 10-bit value into ASCII string
    ADval = (WORD)ADRES;
    //ADval *= (WORD)10;
    //ADval /= (WORD)102;
  
#else
	ADval = (WORD)ADC1BUF0;
	//ADval *= (WORD)10;
	//ADval /= (WORD)102;
   
#endif
return ADval;
}

this would return you the ADC value.

now you have to be sure to read the value as often as possible to get the required sample rate..


Hope this helped!
 
Thank you very much sherazi,

So I have to set the sample rate with which I have to stare the digital data after its conversion from analog.. If I am not wrong !! I want to store it in a file ... I am thinking of MIDI format which will very small in length and can hold large data.. Is i t possible ?

I will try the code that you posted above. Thanks once again for that... :smile:
As I am using PIC24FJ256GB106 for this... and using my own board,.. and ZG2100 as a wifi module.

Thank you.
Nikhil Raj.
 

well i havent worked with audio files yet
but i am just starting one . and i think i can get in touch with you for that . may i have your gmail contact?
mine is engrdostmhd @ gmail.com

Regards
Dost
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top