read out position of normal potentiometer

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
You'd need an ADC to do that. Technically easy enough to get the PIC processor to do it, but then you'll need to modify the source code - meaning you have to understand PIC assembler. Do some searches on PIC analogue-to-digital conversion.

(There are several tricks to make an ADC without requiring a PIC that has onboard ADC too)

It would be easier I think to use a rotary encoder, (or even an ordinary rotary switch with the detent ball bearing removed, and the end stops removed, so it behaves like a rotary encoder) With some logic chips you could get that to mimic the UP/DOWN button pushes; otherwise once again, you need to modify the assembly source code to make it read the shaft encoder.
 
You have 2 options for monitoring the position of the pot.

1. Use a pot with additional channels/sections and use the extra section to
create a voltage divider by applying a reference voltage across it and reading
the voltage on the wiper via an A/D converter. A PIC microcontroller as in the
previous post, with an on-board A/D would be a simple solution. The micro
could also drive the display with the position data.

2. Use a couple of relays to switch between the audio signal and a reference
voltage applied to the pot. Then measure the voltage as in option 1. You will
need some way of changing the function between listen and measure such as
a button or switch.

Option 1 is the best way to go about it though.
 
I get the impression the OP does not want to put audio through the pot at all; i.e., it's a 'digital' level control and he wants a conventional look and feel to it.

One problem if you use a normal pot for this - AND remote control - the remote control can change the volume without moving the pot position, so there is a mismatch between where the pot says the volume is, and where the remote control says the volume is.
A rotary shaft encoder solves this problem, since the PIC only detects forward or backward motion of the knob, and not its absolute position.
 
hi,

I want to make a easy preamp but need to read out the position of an
regular potentiometer. The position of the potentiometer will be displayed
on a LCD of VFD display.

i have look for this design see link Remote volume

have any of you some links i can use?

Project Nr.2 from :
http://www.diyaudio.com/forums/anal...ther-volume-controlers-source-selections.html
it use CS3310 or PGA2310 and I have o variant which use an encoder for adjusting volume or input .
 
Last edited:
View attachment 154803

source

// LCD module connections
sbit LCD_RS at RC5_bit;
sbit LCD_EN at RC4_bit;
sbit LCD_D4 at RC0_bit;
sbit LCD_D5 at RC1_bit;
sbit LCD_D6 at RC2_bit;
sbit LCD_D7 at RC3_bit;

sbit LCD_RS_Direction at TRISC5_bit;
sbit LCD_EN_Direction at TRISC4_bit;
sbit LCD_D4_Direction at TRISC0_bit;
sbit LCD_D5_Direction at TRISC1_bit;
sbit LCD_D6_Direction at TRISC2_bit;
sbit LCD_D7_Direction at TRISC3_bit;
// End LCD module connections

void initial(void);// Declaration of the initial() routine
unsigned int temp;// Used for storing the data from ADC register
unsigned char dat[5]={0X31,0X31,0X31,0X31,0X31}; // Array containg data which will be displayed on the LCD
unsigned char i=0; // Variable for counting in For loop

void initial(void) // Begning of the Initial routine
{//par
//par
TRISA=1;// Making the 1st pin out PortA as input pin
ANSEL=0X01;//Making 1st Pin of PortA as anolog
TRISC=0;// Making the PortC as Output Port
INTCON=0XC0;// Enabling all the Interrupts
PIR1.TMR1IF=0;// Clear the interrupt flag of Timer1
PIE1.TMR1IE=1;// enable the interrupt of Timer1
TMR1L=0X00; // Least significant Byte of Timer1
TMR1H=0X00; //Most significant Byte of Timer1
PIR1.ADIF=0;// Clear the flag of the ADC
PIE1.ADIE=0;// Disable the interrupt of ADC
ADCON1=0X10; // Configure the ADC register
ADCON0=0X03; // Configure the ADC register
Lcd_Init() ; // Initilize the LCD and Lcd is connected to Portc
//T1CON=0X01;
temp=0X31;// Tempraory varaible
dat[0]='-'; // 1st data Byte
} // End of Initial routine
//par
//par

void main(void)// Begning of the Main routine
{

initial(); //Calling of the Initial() routine
LCD_Cmd(_LCD_CLEAR);// Command to clear the LCD
LCD_Cmd(_LCD_CURSOR_OFF); // Command for making Cursor off
LCD_OUT(1,1,"AUDIODESIGNGUIDE"); // Sending 'AUDIODESIGNGUIDE' to fist line and fist coloum of LCD
LCD_OUT(2,2,"Volume");// Sending 'Volume' to second line and second coloum of LCD
LCD_OUT(2,13,"Db");// Sending 'Db' to second line and thirteen coloum of LCD
while(1) // Infinite loop
{
if( ADCON0.F1==0 ) //Checking if data is present in ADC register
{
temp=ADRESH; // Storing the most significant BYte of ADC register

ADCON0=0X03; //Starting the ADC again
if(temp<=40) //if input is less than 40
temp=(temp*49)/40; // Perform this calculation in order to convert it in algorithmic
else // for input is greater than 40
temp=(((temp-40)*50)/215)+49;// Perform this calculation in order to convert it in algorithmic
}
dat[1]=temp%10;// Store the unite digit of data in data array which is passed to lcd Moude for display
dat[1]+=0x30;// Convert data to its ASCII value
dat[0]=(temp/10 )%10;// // Store the tens digit of data in data array which is passed to lcd Moude for display
dat[0]+=0X30; // Convert data to its ASCII value
if(dat[0]==0X30 && dat[1]==0X30)// If data is 00
{
Lcd_Chr(2,9,' '); // Clear the negative sign because 00 value cannot be negative
}
else // Other value than OO
Lcd_Chr(2,9,'-');// Put negative Sign
// End of if and else statement
for(i=0;i<2;i++)
Lcd_chr(2,10+i,dat);// Pass the data Byte by byte to LCD
}//End of While loop
}// End of Main() routine
 

Attachments

  • VFD  LCD.gif
    VFD LCD.gif
    24.3 KB · Views: 131
Hi,

the problem is that i already have a preamp with a normal old Alps potentiometer
the sound is good, now i want to readout the position of the pot. by turning up/down
you see on the display the volume up and down

i have a picture how can i add this.

I don't think your attachment has worked, although I can see your schematic.

I have had a few moments to think about what you want and can only see a couple of solutions, and both would need you to chuck out the alps pot and replace it with either
  1. a triple gang pot (if such a thing exists!) and use the extra gang to read a positional voltage from and to then output to a display
  2. purchase (or create) some form of digital volume control. This could be either a complete bolt-in module or you could build one up using say, a tpa joshua tree. This could have advantages of remote control as well.

You havn't mentioned what your preamp is or if you built it yourself.

There may be other options....
 
and both would need you to chuck out the alps pot and replace it with either
  1. a triple gang pot (if such a thing exists!) and use the extra gang to read a positional voltage from and to then output to a display
  2. purchase (or create) some form of digital volume control. This could be either a complete bolt-in module or you could build one up using say, a tpa joshua tree. This could have advantages of remote control as well.

There is also the option of coupling the existing pot (assumed to be a high grade audio specialist type) to an additional 'ordinary' pot or optical rotary encoder by means of a pair or row of spur gears, or a nylon cord drive as used on the tuning dial of radio tuners.

An oddball alternative might be to measure TWO audio voltages with the A/D converter - one going into the pot, and that comming out off the wiper. Then in software, compute the ratio of the two, and hence the position. This will fail however when the audio signal is very low or absent.
 
could you explain, which line must i change?

You could try something like the following....

in the header section:
Code:
unsigned int temp;// Used for storing the data from ADC register
#define ADC_READINGS 10  // number of samples to hold
unsigned char adc_reading[ADC_READINGS];  // array to hold last n samples
unsigned char adc_reading_count=0; // how many samples we have

then in the while loop section:

Code:
if( ADCON0.F1==0 ) //Checking if data is present in ADC register
{
  for(i=1;i<ADC_READINGS;i++) adc_reading[i]=adc_reading[i-1];  // shift 1 element right
  adc_reading[0]=ADRESH;    // Storing the most significant Byte of ADC register
  if(adc_reading_count<ADC_READINGS) adc_reading_count++;  // increment how many we have
  // now get total and calc average
  temp=0;
  for(i=0;i<adc_reading_count;i++) temp+=adc_reading[i];
  temp=temp/adc_reading_count;	// average reading

  ADCON0=0X03; //Starting the ADC again

etc

You could simplify it by removing the adc_reading_count variable and just accept that in the first few milliseconds of the program running (until the array fills up, that-is), the average won't be correct.
I havn't run the code, so there may be 'issues' ;)

HTH
 
Mike,

On the circuit PIN3 is connect to a smal capacitor of the use on the potentiometer
this will read out the position of the pot.




thanks, this source is writen in MicroElektronika, but i want it change to Microchip
because there is a different in compiler you can not exchange both.
 

Attachments

  • schema_cursus5.gif
    schema_cursus5.gif
    1.4 KB · Views: 82
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.