Input Noise


Closed Thread
Results 1 to 14 of 14

Thread: Input Noise

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    What would be the easiest way to build the circuit with a separate power supply for the optos yet still only have one PCB
    Just design your board with two separate power planes, and power supply
    input terminals.

    Separate DC power supply's input to two separate regulators on the same
    PCB.

    |..P.S. input A.............P.S. input B]
    |--[+-]------------------[+-]-----|
    |..PIC side........<..out.[]..input..<..| AC connections on outer edge
    |.....................<..out.[]..input..<..| optos in center of board close
    |..one PCB........<..out.[]..input..<..| to controller ins/outs

    TIPS:

    Keep AC traces (if any) as short as possible, and located on the far edge
    away from the controller side of the board.

    Make the bottom layer under the "controller side" a large ground plane with
    decoupling caps at all power connection points.

    Do not cross-over traces from one side to the other. Noise will couple from
    one PCB trace to another right through your PCB substrate.

    If you have any mechanical relays on either board, consider MOV's (metal
    oxide varistors) across the relay contacts to snub contact spark/discharge.

    I've done a number of boards like this without any glitches. All for large
    motors & heavy appliances being controlled or monitored by the PIC.

    Im my experience, I've noticed that all of the 18F series and most 16F "A"
    series are all more succeptible to noise than older non "A" series 16F parts.

    a mind of its own and randomy turns on relays, outputs serial data, resets itself etc
    That definitely sounds like a serious noise problem, but it may also be the
    input you're using. Does it throw a fit if you connect this same input to
    any other signal?

    Which input are you using?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default

    I am using PORTB.0 for the encoder, i am using interrupts to capture the pulses.

    The relays do not control the motor directly but instead drive an AC Drive Inverter which creates the 3 Phase 330V AC required by the motor. The relays are the G5V-1 micro relays and are being driven by a ULN2003.
    Last edited by PJALM; - 28th February 2006 at 03:07.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Interrupts alone can cause seriously erratic behaviour depeding on your
    program structure & how you're handling things getting in/out of the int
    handler.

    I would still look at isolation, but it may also have something to do with your
    interrupts. Can you post your interrupt handler?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  4. #4
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default

    Here is the interrupt handler:

    Code:
    '-------------------------------------------------------------------------------
    ' Interrupt Handler
    '-------------------------------------------------------------------------------
        DISABLE INTERRUPT                        ' No interrupts past this point
    Main_Interrupt_Handler:
    
        '---------------------------------------------------------------------------
        ' PortB.0 Interrupt, Motor RPM Counter
        '---------------------------------------------------------------------------
    	IF INTCON.1 = 1 THEN
            IF Calibrating = 1 THEN
                Total_Pulses = Total_Pulses + 1
            ELSE
                IF System_Calibrated = 1 THEN
                    New_Position_Counter = New_Position_Counter + 1
    
                    IF New_Position_Counter >= (Pulses_Per_Position + Temp_Pulses) THEN
                        SELECT CASE Current_Direction
                            CASE Forward_Dir
                                Current_Position = Current_Position + 1
                                IF Current_Position > Total_Positions THEN
                                    Current_Position = 1
                                ENDIF
                            CASE Reverse_Dir
                                Current_Position = Current_Position - 1
                                IF Current_Position = 0 THEN
                                    Current_Position = Total_Positions
                                ENDIF
                        END SELECT
    
                        DEBUG 13, 10, "[ Position Change ] Current Position: ", DEC Current_Position, 13, 10
                        
                        New_Position_Counter = 0
                        Temp_Pulses = 0
                    ENDIF
                ENDIF
            ENDIF
                INTCON.1 = 0
    	ENDIF 
        '---------------------------------------------------------------------------
    
    
            
        '---------------------------------------------------------------------------
    	' PortB.1 Interrupt, Position 1 Sensor
        '---------------------------------------------------------------------------
    	IF INTCON3.0 = 1 THEN
            DEBUG 13, 10, "[ INTERRUPT ] Home Position Detected", 13, 10
                Pos1Found = 1
                New_Position_Counter = 0
                Temp_Pulses = 0
                Current_Position = 1
    	    INTCON3.0 = 0
    	ENDIF
        '---------------------------------------------------------------------------
    
    
    
        '---------------------------------------------------------------------------
        ' PortB.2 Interrupt, Fault Relay Input
        '---------------------------------------------------------------------------
        IF INTCON3.1 = 1 THEN
            DEBUG 13, 10, "[ INTERRUPT ] AC Invertor Fault Detected", 13, 10
            AC_Fault_Detected = 1
            INTCON3.1 = 0
        ENDIF
        '---------------------------------------------------------------------------
        
    
    
        '---------------------------------------------------------------------------
        ' USART Receive Interrupt
        '---------------------------------------------------------------------------
        IF PIR1.5 = 1 THEN
            'DEBUG 13, 10, "[ INTERRUPT ] USART Receive", 13, 10
    
            HSERIN [RS485_B0]
    
            SELECT CASE RS485_B0
                CASE RS485_STX
                    RS485_Receiving_Data = 1
                    RS485_Bytes_Received = 0
                    FOR i = 1 TO RS485_Buffer_Size
                        RS485_Data_Buffer[i] = 0
                    NEXT
                    
                CASE RS485_ETX
                    RS485_Receiving_Data = 0
                    
                    RS485_To_Address = RS485_Data_Buffer(0)
                    RS485_Command = RS485_Data_Buffer(1)
                    RS485_Parameter.HighByte = RS485_Data_Buffer(2)
                    RS485_Parameter.LowByte = RS485_Data_Buffer(3)
                    RS485_From_Address = RS485_Data_Buffer(4)
                    
                    RS485_Parameter = RS485_Parameter - 10
                    
                CASE ELSE
                    IF RS485_Receiving_Data = 1 THEN
                        RS485_Data_Buffer(RS485_Bytes_Received) = RS485_B0
                        RS485_Bytes_Received = RS485_Bytes_Received + 1
                    ENDIF
            END SELECT
            PIR1.5 = 0
        ENDIF
        '---------------------------------------------------------------------------
    
            
    IntDone:
    	RESUME					' Return to main program
        ENABLE INTERRUPT
    '-------------------------------------------------------------------------------

  5. #5
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    This looks OK to me except for PIR1.5 = 0.

    The USART receive interrupt flag bit can only be cleared by reading RCREG
    until the buffer is empty. You're reading this only once in your int handler.

    If you receive more than a single byte of data it can cause problems. I would
    test the flag again before exiting this particular int handler sub-routine.

    I don't think this is causing the problem you're seeing, but it could be one if
    you're expecting PIR1.5 = 0 to clear the USART interrupt flag.

    What happens if you remove the encoder, and replace it with a push-button
    switch?

    Does pressing the switch to simulate the encoder logic on the int0 input pin
    work?

    If it works then I would have to suspect an isolation problem.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  6. #6
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default

    Bruce, putting the switch works fine so I also suspect its an isolation problem. I am going to try your sujestions and build a second power supply.

  7. #7
    Join Date
    Jan 2006
    Location
    Toronto
    Posts
    109


    Did you find this post helpful? Yes | No

    Default

    I finally got it fixed.

    It turns out that the conduit I was using is made of aluminum not steel and for some reason it was not good enough to shield the 3 phase power cables to the motor. I changed it to steel and it works fine now.

    I also fixed the isolation problem thanks to your sugestions Bruce.

    Thanks everyone.

Similar Threads

  1. Sony LanC Program
    By l_gaminde in forum Code Examples
    Replies: 2
    Last Post: - 25th September 2009, 18:51
  2. RB0 + Internal Pullup + Interrupt
    By Freman in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 10th August 2009, 11:11
  3. LED "capacitance" won't get lower
    By flotulopex in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 3rd May 2007, 20:31
  4. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  5. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19

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