VU Meter


Closed Thread
Results 1 to 5 of 5

Thread: VU Meter

  1. #1

    Default VU Meter

    Hi there
    I have a LM358 amplifie-ing a maic signal to my pic16F913 AD input, this signal is used to drive 8 LED's in a VU meter fasion This part works fine.

    Now i have a input that when made gets the signal and set a alarm setpoint one LED lower than the current signal === First problem with the signal variang fast it does not whant to select properly

    Now what needs to happen is that as soon as the signal passes the setpoint again it needs to set a output basicly a high noise alarm, but my rele shutter if i add a timer it influence my VU meter

    any one with some idea, here is my code for info

    Code:
    INCLUDE "MODEDEFS.BAS"
    
    Asm
        ERRORLEVEL -306
    Endasm
    
    DEFINE OSC 20				' Define crystal as 20Mhz
    
    '*ADC setup*
    DEFINE ADC_BITS 10 			'SETS NUMBER OF BITS IN RESULTS 8,10,12
    DEFINE ADC_CLOCK 3 			'SETS CLOCK SOURCE (RC = 3)
    DEFINE ADC_SAMPLEUS 50 		'SETS SAMPLING TIME IN MICROSECONDS
     
    'This Part set PORTA 0-5 an analog inputs
    ADCON1 = %01110000			'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
    ANSEL  = %00000011			'PortA 0 & 1 Analog 2 - 5 Digital
    							'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
    CMCON0 = %00000111			'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
    TRISA  = %00001111			'set PORTA 0-4 as inputs PORTA 5 output
    ADCON0.7 = 1				'Right justify output of ADC datasheet P145 of 16F913 
        
    LCDCON = 0					'Disable LCD function on PORTC 0 - 2
    TRISC = %00000000			'Set PORTC  as output   
    TRISB = %00000000			'Sert PORTB as output 
    
    I VAR BYTE
    j VAR BYTE
    K VAR BYTE
    L VAR BYTE
    arr var word[10]
    
    V1 VAR WORD
    PORTB = 0
    
    
    READ 1,J
    
    Main:
    	for l = 0 to 9 
    		ADCIN 0,V1
    		arr(l) = V1/60
    	next l
    	
    	I = (ARR(0)+ARR(1)+ARR(2)+ARR(3)+ARR(4)+ARR(5)+ARR(6)+ARR(7)+ARR(8)+ARR(9))/10
    	
    	IF I >= J THEN
    		PORTA.5 = 1
    		
    	ENDIF
    	
    	IF I <= (J-1) THEN
    		PORTA.5 = 0
    	ENDIF
    	
    	
    	IF PORTA.2 = 0 THEN
    		K = I - 1
    		PAUSE 300
    		IF J <> K THEN
    			WRITE 1,K
    			J=K
    		ENDIF
    	ENDIF
    	
    	IF J = 1 THEN
    		PORTB.0 = 1
    	ELSE
    		PORTB.0 = 0
    	ENDIF
    	
    	IF J = 2 THEN
    		PORTB.1 = 1
    	ELSE
    		PORTB.1 = 0
    	ENDIF
    	
    	IF J = 3 THEN
    		PORTB.2 = 1
    	ELSE
    		PORTB.2 = 0
    	ENDIF
    	
    	IF J = 4 THEN
    		PORTB.3 = 1
    	ELSE
    		PORTB.3 = 0
    	ENDIF
    	
    	IF J = 5 THEN
    		PORTB.4 = 1
    	ELSE
    		PORTB.4 = 0
    	ENDIF
    	
    	IF J = 6 THEN
    		PORTB.5 = 1
    	ELSE
    		PORTB.5 = 0
    	ENDIF
    	
    	IF J = 7 THEN
    		PORTB.6 = 1
    	ELSE
    		PORTB.6 = 0
    	ENDIF
    	
    	IF J = 8 THEN
    		PORTB.7 = 1
    	ELSE
    		PORTB.7 = 0
    	ENDIF
    	
    	IF I >= 1 THEN
    		PORTC.0 = 1
    	ELSE
    		PORTC.0 = 0
    	ENDIF
    	
    	IF I >= 2 THEN
    		PORTC.1 = 1
    	ELSE
    		PORTC.1 = 0
    	ENDIF
    	
    	IF I >= 3 THEN
    		PORTC.2 = 1
    	ELSE
    		PORTC.2 = 0
    	ENDIF
    	
    	IF I >= 4 THEN
    		PORTC.3 = 1
    	ELSE
    		PORTC.3 = 0
    	ENDIF
    	
    	IF I >= 5 THEN
    		PORTC.4 = 1
    	ELSE
    		PORTC.4 = 0
    	ENDIF
    	
    	IF I >= 6 THEN
    		PORTC.5 = 1
    	ELSE
    		PORTC.5 = 0
    	ENDIF
    	
    	IF I >= 7 THEN
    		PORTC.6 = 1
    	ELSE
    		PORTC.6 = 0
    	ENDIF
    	
    	IF I >= 8 THEN
    		PORTC.7 = 1
    	ELSE
    		PORTC.7 = 0
    	ENDIF	
    	
    
    
    goto main
    
    
    END

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I tried and tried but... you lost me in your explanations.
    Now i have a input that when made gets the signal and set a alarm setpoint one LED lower than the current signal === First problem with the signal variang fast it does not whant to select properly

    Now what needs to happen is that as soon as the signal passes the setpoint again it needs to set a output basicly a high noise alarm, but my rele shutter if i add a timer it influence my VU meter
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,115


    Did you find this post helpful? Yes | No

    Default

    Now, if I understand what you try to say, is that, your noisy alarm has strong influence on your comparator? Like changing the setpoint?

    Ioannis

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default

    Hi, Andre

    If I understand it right ...

    one led column (I-port C) is the meter, and the other ( j -portB) is the ref index ...

    Now, you want to catch your ref level "in flight" ... ( Porta.2 turns to low )

    1st problem...

    time before you see level and you press the button ... level has changed.
    Why not extract the MAXIMUM of the readings while button pressed ???

    2nd problem...

    time you keep the finger on the button, your ref level is changing ... ( k= i-1 in a continuous LOOP )
    Your Button must act as a OneShot for K value ! ... or see Upper

    Alain
    Last edited by Acetronics2; - 19th May 2009 at 10:37.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5


    Did you find this post helpful? Yes | No

    Default

    thank you for everybody, i got the problem fixed by improving the rectifier sircuit after the op amp and before the PIC everything works good now

    Thanks again for everybody's advice

Similar Threads

  1. Hall Effect flow meter with 16F876
    By revelator in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th March 2010, 20:42
  2. Bicycle Speedo Meter
    By Ivan Cory in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 13th May 2009, 01:50
  3. AtoD - first attempts
    By malc-c in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 23rd January 2008, 19:13
  4. PIC10F206 - What is the LOWEST Power @ Rest or Sleep
    By rixtalbert in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 18th March 2007, 14:42
  5. Audio Level Meter
    By Peter1960 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 16th November 2006, 08:05

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts