Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Anyone in UK programme some PICs for me???

Status
Not open for further replies.

Mr Chris

New Member
Hello, Im new to the forum, so hello everyone! Can anyone help out here? I will obviously pay you for your time/expertise/goodwill. I need a simple timer that will give a momentry 'on' once every 24 hours. Permanently connected to a 5 volt supply it would need to switch a micro relay on (so a pin high) for say 2 seconds once in every 24 hours. It is to force a hard reset on some telematics equipment, so as you can appreciate neither the 24 h or the 2 sec is too critical, just roughly once every day. I had a code supplied for a 10F chip (dont know why), but my programmer doesnt support this device.
It would be far easier just to get one of you guys to supply a hex file for a different device or a programmed chip that I could copy. Ideally no other components, just pic and relay, physical space is tight as it is being installed into existing equipment.

I realise its no big challenge but I would really appreciate any help with this!

Chris
 
Hi Chris,

Would you like me to rewrite that code for another chip Sir?

Regards, Mike

<added>

If anyone is interested, here's the original 10F200 code I threw together for Chris on the other forum. It toggles an "activity" LED on GP1 at half second intervals and it toggles the GP0 "relay" pin high for 2 seconds at 24 hour intervals.

Code:
;******************************************************************
;*                                                                *
;*                                                                *
;*     OEM timer (GP0 = Relay output, GP1 = Activity LED)         *
;*                                                                *
;*     MPLAB: 8.50    (tabs=8)                                    *
;*     MPASM: 5.35                                                *
;*                                                                *
;******************************************************************

        errorlevel      -302    ; suppress bank warnings
        radix   dec

        include "p10f200.inc"
        __CONFIG   _MCLRE_OFF & _CP_OFF & _WDT_OFF

;--< variables >---------------------------------------------------

delaylo equ     0x13            ; DelayCy() subsystem
delayhi equ     0x14            ; DelayCy() subsystem
hours   equ     0x15            ; Timer sub
minutes equ     0x16            ; Timer sub
seconds equ     0x17            ; Timer sub

;--< defines >-----------------------------------------------------

;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
;  K8LH DelayCy() subsystem macro generates five instructions     '
;                                                                 '
clock   equ     4               ; 4, 8, 12, 16, or 20 (MHz)
usecs   equ     clock/4         ; cycles/microsecond multiplier
msecs   equ     clock/4*1000    ; cycles/millisecond multiplier

DelayCy macro   delay           ; 12..524298 cycle range
        movlw   high((delay-12)/8)^255
        movwf   delayhi
        movlw   low ((delay-12)/8)^255
        movwf   delaylo
        call    uDelay-((delay-12)%8)
        endm

;******************************************************************
;  main.init                                                      *
;******************************************************************
        org     0x000

Init
        movwf   OSCCAL          ; factory INTOSC calibration
        movlw   b'00001000'     ;
        tris    GPIO            ; GP3 input, all others output
        clrf    GPIO            ; clear output latches
        movlw   b'10011110'     ; 10011110
                                ; 1-------, IOC off
                                ; -0------, weak pullups on
                                ; --0-----, T0CS source Fosc/4
                                ; ---1----, T0SE edge hi>lo
                                ; ----1---, PSA prescale WDT
                                ; -----110, PS prescaler 64
        option                  ; set OPTION reg'

;******************************************************************
;  main.loop                                                      *
;******************************************************************

cycle
        DelayCy(500*msecs)      ; burn off 1-sec minus overhead
        DelayCy(500*msecs-16)   ;
        movlw   23              ; 23:59:58 "off" time
        btfsc   GPIO,0          ; off? yes, skip, else
        movlw   0               ; 00:00:02 "on" time
        movwf   hours           ;
        movlw   59              ;
        btfsc   GPIO,0          ;
        movlw   0               ;
        movwf   minutes         ;
        movlw   57              ;
        btfsc   GPIO,0          ;
        movlw   1               ;
        movwf   seconds         ;
timer   
        DelayCy(500*msecs-19)   ; 1 sec minus 22 cycle loop time
        movf    GPIO,W          ;
        xorlw   2               ;
        movwf   GPIO            ; toggle LED on GP1 pin
        DelayCy(500*msecs-3)    ;
        movf    GPIO,W          ;
        xorlw   2               ;
        movwf   GPIO            ; toggle LED on GP1 pin
        movlw   59              ; W = 59 (mins/secs reset value)
        decf    seconds,F       ; decrement seconds
        btfsc   seconds,7       ; negative? no, skip, else
        decf    minutes,F       ; decrement minutes
        btfsc   seconds,7       ; negative? no, skip, else
        movwf   seconds         ; reset seconds = 59
        btfsc   minutes,7       ; negative? no, skip, else
        decf    hours,F         ; decrement hours
        btfsc   minutes,7       ; negative? no, skip, else
        movwf   minutes         ; reset minutes = 59
        movf    seconds,W       ;
        iorwf   minutes,W       ;
        iorwf   hours,W         ; timer timed-out?
        skpz                    ; yes, skip, else
        goto    timer           ; branch
        movf    GPIO,W          ;
        xorlw   1               ;
        movwf   GPIO            ; toggle GP0 output
        goto    cycle           ; loop (new cycle)

;******************************************************************
;  K8LH DelayCy() subsystem 16-bit "uDelay" timing subroutine     *
;                                                                 *
        nop                     ; (delay-12)%8 == 7 entry point
        nop                     ; (delay-12)%8 == 6 entry point
        nop                     ; (delay-12)%8 == 5 entry point
        nop                     ; (delay-12)%8 == 4 entry point
        nop                     ; (delay-12)%8 == 3 entry point
        nop                     ; (delay-12)%8 == 2 entry point
        nop                     ; (delay-12)%8 == 1 entry point
uDelay  incf    delaylo,F       ; subtract one 8-cycle loop
        skpnz                   ; borrow? no, skip, else
        incfsz  delayhi,F       ; done?  yes, skip, else
        goto    uDelay-3        ; do another 8-cycle loop
        retlw   0               ;

;******************************************************************
        end
<added>

Attached program source and hex for 12F629 device...
 

Attachments

  • Chris' OEM Timer.asm.txt
    7 KB · Views: 129
  • Chris' OEM Timer.HEX.txt
    485 bytes · Views: 107
Last edited:
Timer

Thanks Mike (and others). I cobbled a 12f and a few other components together and added them to a telematics unit. (This is the unit we need to force a reset on) I set it up so it will activate an input on the unit, so sending an event code to the server. This way I can monitor the 'reset' times from the server stats.

fingers crossed.....
 
Thanks Mike (and others). I cobbled a 12f and a few other components together and added them to a telematics unit. (This is the unit we need to force a reset on) I set it up so it will activate an input on the unit, so sending an event code to the server. This way I can monitor the 'reset' times from the server stats.

fingers crossed.....

Good luck Chris. Let us know how it works out.

If you like, I could modify that code to output every 30 seconds, or something like that, to help you verify operation in a more timely fashion.

Regards, Mike
 
timer

Yes, I thought of that too, might have been a good idea to test eh?
I might ask you to modify code for something else, will let you know.
Cheers for now.
 
Hi Chris,

Here are modified program files with a 60 minute cycle time that may help you qualify the hardware and software in a more timely fashion.

Cheerful regards, Mike
 

Attachments

  • Chris' OEM Timer.asm.txt
    7.1 KB · Views: 170
  • Chris' OEM Timer.HEX.txt
    485 bytes · Views: 107
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top