Replacing existing pic


Results 1 to 30 of 30

Threaded View

  1. #10
    Join Date
    May 2008
    Posts
    46


    Did you find this post helpful? Yes | No

    Default

    I'm not actually using the serial at the moment, I'm just trying to get to the "other" part of the code, but I'll try 2400 bps, I'll also try the osccal

    So you're telling me I should set that bit to 0 in my code?


    Nope still no go This is the code and attached is the schematic

    I know the slave is bringing the pins high (multi-meter and beep confirms it)

    Edit: One clue I have is.... if I comment out the serial routine and tell it to goto the 'testSlave' label, it works fine

    Code:
    ' Configure the pic
    @     device pic12F675, INTRC_OSC_NOCLKOUT, WDT_ON, PWRT_ON, MCLR_OFF, BOD_ON, CPD_OFF, PROTECT_OFF
    
    DEFINE OSCCAL_1K 1
    N2400   con      4
    
    CMCON        = 7
    ANSEL        = 0
    OPTION_REG.7 = 0
    
    Relay1       VAR GPIO.5
    Relay2       VAR GPIO.4
    
    SlavePower   VAR GPIO.2
    SlaveRelay1  VAR GPIO.0
    SlaveRelay2  VAR GPIO.1
    
    Serial       VAR GPIO.3
    
    B0           var BYTE
    SlaveState   VAR BYTE
    WhichRelay   VAR BYTE
    
    INPUT SlaveRelay1
    INPUT SlaveRelay2
    INPUT Serial
    
    OUTPUT Relay1
    OUTPUT Relay2
    OUTPUT SlavePower
    
    LOW Relay1
    LOW Relay2
    
    restart:
    SlaveState = 0
    PAUSEUS 1000
    HIGH SlavePower
    
    main:
        B0 = 0
        SERIN Serial, N2400, 20, testSlave, [1], B0
        LOW SlavePower
        SELECT CASE B0
            CASE 2
                GOSUB subUp
            CASE 3
                GOSUB subDown
            CASE 4
                GOSUB subStop
        END SELECT
        GOTO restart
    
    testSlave:    
        WhichRelay = GPIO & 3
        IF SlaveState <> WhichRelay THEN
            SlaveState = WhichRelay
            SELECT CASE WhichRelay
                CASE 0
                    GOSUB subStop
                CASE 1
                    GOSUB SubUp
                Case 2
                    GOSUB subDown
            END SELECT
        ENDIF   
    goto main
    
    subUp:
        LOW Relay2
        HIGH Relay1
        RETURN 
    subDown:
        LOW RELAY1
        HIGH Relay2
        RETURN
    subStop:
        LOW Relay1
        LOW Relay2
        RETURN
    Attached Images Attached Images  
    Last edited by Freman; - 27th May 2008 at 17:30. Reason: Code and picture

Similar Threads

  1. SMS via pic
    By kenandere in forum GSM
    Replies: 15
    Last Post: - 10th March 2010, 10:00
  2. Replacing Hall Effect throttle with PIC
    By idtat in forum General
    Replies: 4
    Last Post: - 22nd October 2009, 21:55
  3. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  4. Replacing shift register with PIC
    By TonyA in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 7th April 2008, 18:31
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

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