Sari la conținut
ELFORUM - Forumul electronistilor

astabil 12 ore releu on/ 5 secunde releu off


elcomar

Postări Recomandate

salutare din nou :)

 

pentru pasionati, propun rezolvarea unei scheme de astabil care va trebui sa fie alimentat la 12v si sa aiba la iesire 12v timp de 12 ore iar dupa aceea sa intrerupa acesti 12 volti de la iesire timp de 5 secunde apoi sa reia ciclul. Am nevoie de acest modul pentru resetarea unui echipament care dupa 11-12 ore o ia razna si trebuie neaparat sa-i intrerup alimentarea ca sa-si revina.

 

dupa documentatia mea am gasit urmatoarea schema si soft dar care ar mai trebui modificate putin ambele numai ca nu stiu cum si unde sa umblu.

 

iata documentatia gasita de mine: http://picprojects.org.uk/projects/ldt/ ... escription

Link spre comentariu
  • Răspunsuri 13
  • Creat
  • Ultimul Răspuns

Top autori în acest subiect

  • elcomar

    7

  • francezu

    5

  • Depanatorul

    1

  • MatyC

    1

Top autori în acest subiect

Extern nu ai cum sa modifici timpi de ON/OFF, doar frecventa de lucru al oscilatorului.

Oscilatorul intern se calibreaza cu un Software (12F629/12F675):

 

http://picprojects.org.uk/projects/recal/recal.htm

 

 

 

salutare din nou :)

 

pentru pasionati, propun rezolvarea unei scheme de astabil care va trebui sa fie alimentat la 12v si sa aiba la iesire 12v timp de 12 ore iar dupa aceea sa intrerupa acesti 12 volti de la iesire timp de 5 secunde apoi sa reia ciclul. Am nevoie de acest modul pentru resetarea unui echipament care dupa 11-12 ore o ia razna si trebuie neaparat sa-i intrerup alimentarea ca sa-si revina.

 

dupa documentatia mea am gasit urmatoarea schema si soft dar care ar mai trebui modificate putin ambele numai ca nu stiu cum si unde sa umblu.

 

iata documentatia gasita de mine: http://picprojects.org.uk/projects/ldt/ ... escription

Link spre comentariu

ceea ce imi arati tu este de fapt calibrarea...

 

 

am gasit si instructiunile pentru schimbarea timpului nu mai ca nu stiu cum sa le folosesc:

 

;***************************************************************

;* Timing Lookup Table - please read these notes *

;***************************************************************

;

; User defined Mark / Space period in seconds

; Minimum 1 second, Maximum 65535 seconds ( 18h12m15s)

; Do not enter a value of 0

;

; The table is read through sequentially until it reaches the end

; where it will restart from the beginning of the table.

;

; The maximum number of entries is 900 or 450 pairs

;

; First entry is Mark period in seconds

; Second entry is Space period in seconds

; Subsequent pairs of entries continue as Mark / Space

;

; NOTE. You can enter an odd number of time entries in the table

; If you do this it alters the behaviour of the output signal so that

; it will alernate bewteeen Mark-Space-Mark-Space-Mark..... and

; Space-Mark-Space-Mark-Space....

;

; If you have a single entry, then it generates a signal with equal

; mark / space ratio (50% duty cycle)

;

; Timing is generated from the PICs internal RC Oscillator. Therefore

; the time period is dependant on the accuracy of the oscillator which

; is subject to variation from temperature, supply voltage and accuracy

; of the calibration word.

;

; You should test to establish if the timings generated by this code

; are accurate enough for your intended application.

;

;---------------------------------------------------------------

 

time 1 ; mark

time 2 ; space

time 1 ; mark

time 3 ; space

 

;---------------------------------------------------------------

 

 

 

 

iar aici am codul sursa unde ar trebui modificat dar ce?

; *********************************************************

; Long Period Astable timer

; For PIC 12F629 / 12F675 (will also run on 12F685 with minimal changes)

;

; Pete Griffiths, January 2009

; Version 1.2

;

; To assemble this code use MPLAB IDE

;

; From the MPLAB menu choose "Config - Select Device" and set the Device: to either 12F629 or 12F675

; depending on which PIC you are going to use.

;

; Next from the menu select

; "File - Open" and load LongDelayF5.asm

;

; then

;

; "Project - Quickbuild" LongDelayF5.asm

;

; If there are any errors reported during the quickbuild you must correct

; them and retry the quickbuild until it is successful.

;

; You will also need to open LongDelayTimes.inc and edit the delays

; to suit your particular application. You should do this before

; re-assembling and remember to save the file.

;

;

; This is free software for non-commercial use only.

;

; This software and accompanying information is are provided "as is",d

; and without warranty of any kind, either express or implied.

;

; Before use you should read information in this file and at

; http://picprojects.org.uk/projects/ldt/ldt.htm

;

; If both the Q and notQ outputs go high and remain high after reset then

; the calibration word at program memory 0x3FF has been erased or lost.

; You can recover the calibration word using a Microchip PICkit2 programmer or,

; if you don't have one see http://picprojects.org.uk/projects/recal/recal.htm

;

;

; ********************************************************************************

;

; ___ ___

; Vdd -|1 ^ 8|- Vss

; Reset edge select -|2 7|- Q out

; Hold (active low) -|3 6|- notQ out

; MCLR tie to Vdd via 1K0 -|4 5|- reset (edge triggered)

; ¯¯¯¯¯¯¯

;

; All inputs use the PIC internal weak-pull up so no external pull resistor

; is required.

;

; Reset edge select. Connect to Vss for falling edge, leave open for rising edge

;

; MCLR must be tied to Vdd using a 1K resistor.

; ********************************************************************************

 

 

IFDEF __12F675

#include "p12f675.inc"

ENDIF

 

IFDEF __12F629

#include "p12f629.inc"

ENDIF

 

 

__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT & _MCLRE_ON & _CPD_OFF

 

errorlevel -302 ; suppress banksel warning messages

errorlevel -311 ; suppress HIGH operator warning messages

 

cblock 0x20

lo ; tick timer (3 bytes)

mid ; counts nominal 1 second intervals

hi ;

tablePtrLo ; lookup table pointer Lo Byte

tablePtrHi ; lookup table pointer Hi byte

delaylo ; seconds counter low

delayhi ; and high byte pair

copyout ; working output register (copied to GPIO port)

endc

 

#define bank0 bcf STATUS,RP0 ; Sel Bank 0

#define bank1 bsf STATUS,RP0 ; Sel Bank 1

 

; Define I/O pin functions

#define Qout 0

#define notQout 1

#define rset 2 ; This must be GPIO2 as it use the edge triggered interrupt

#define hold 4

#define edgeSelect 5

 

 

 

 

org 0x000

nop

btfsc INTCON, INTE

goto badOsccal

goto start

 

org 0x004

;---------------------------------------

; Interrupt handler

;---------------------------------------

 

btfsc INTCON,INTF

call resetOut

 

btfsc INTCON,T0IF

call tick

 

retfie ; and return from interrupt

;---------------------------------------

 

 

;------------------------------------------------------------------------------

; Initialisation code

;------------------------------------------------------------------------------

 

start movlw (1<

movwf copyout

movwf GPIO

 

movlw 0x07

movwf CMCON ; Disable Comparator on GPIO pins

 

bank1

 

 

IFDEF __12F675

clrf ANSEL ; Disable analogue inputs (12F675 / 683 only)

ENDIF

 

movlw ~(1<

movwf TRISIO

 

bcf OPTION_REG, INTEDG

bcf OPTION_REG,NOT_GPPU ; enable global weak pull-up.

bcf OPTION_REG, PSA ; prescaler to TMR0

bcf OPTION_REG, T0CS ; TMR0 clock soruce internal

bcf OPTION_REG, PS0 ; Set TMR0 prescaler to 1:2

bcf OPTION_REG, PS1

bcf OPTION_REG, PS2

 

bsf INTCON, INTE

call 0x3FF ; get factory calibration byte

movwf OSCCAL ; write to OSCCAL register

bcf INTCON, INTE

 

movlw (1<

movwf WPU

 

bank0

 

call resetOut ; initialise outputs and timers

 

clrw ; set reset edge

btfsc GPIO, edgeSelect

movlw (1<

bank1

iorwf OPTION_REG,F ; set GP2 interrupt edge

bank0 ; 0 -> falling edge | 1 -> rising edge

 

; setup interrupts

bcf INTCON, INTF ; clear GP2 int flag

bcf INTCON, T0IF ; clear TMR0 interrupt flag bit

bsf INTCON, INTE ; enagle GP2 edge interrupts

bsf INTCON, T0IE ; enable TMR0 interrupts

bsf INTCON, GIE ; enable Global interrupts

 

 

idle goto idle

 

;------------------------------------------------------------------------------

; Tick timer function

; Get a nominal 1 second tick from 1Mhz instruction clock

;------------------------------------------------------------------------------

; TMR0 prescaler divides 1Mhz instruction clock by 2

; 1Mhz = 1,000,000 / 2 = 500,000

; 8-bit timer divides the prescaled clock 256

 

period equ .500000

 

 

tick bcf INTCON, T0IF ; clear TMR0 interrupt flag

 

btfss GPIO, hold

return

 

movlw -.1

addwf mid,F ; subtract 1 from mid

skpc ; skip next if no underflow

addwf hi,F ; subtract 1 from high

skpnc ; skip next if it did underflow

return

; nominal 1 second has passed so we

; add 500,000 - 256 back into the counter

reload movlw LOW period ;

addwf lo,F ; remainder in lo counter byte is added back

 

movlw HIGH period-.256

skpnc ; if low byte overflowed

movlw HIGH period ; increment mid byte by one

addwf mid,F

 

movlw UPPER period ; mid byte never overflows so we

movwf hi ; just reset the hi byte

 

 

;------------------------------------

; Delay and output

;-----------------------------------

 

; State 1 Delay timer

delay decfsz delaylo,F ; decrement delay counter

return ; return if lo byte not zero

 

decf delayhi,F ; This is a bit odd because we pre-decrement

incfsz delayhi,W ; the hi byte ahead of the lo byte underflowing

return ; but we only need to know when the count

; reahces zero so this works as required

 

changeOut call lookup ; get the next delay value from the table lookup

movwf delaylo

call lookup

movwf delayhi

xorwf delaylo,W

skpz ; skip if delay pair value is zero

goto setOutput ; if delay read from table isn't zero, toggle output bits

call initTablePtr ; if we've reached the end of the table

goto changeOut ; reset table pointer and go round again

 

 

 

setOutput comf copyout,W ; toggle bits in copyout, save in W

movwf copyout ; write W back to copy out

movwf GPIO ; and to GPIO port

return

 

 

resetOut movlw ~(1<

movwf copyout ;

comf copyout,W ; then changes it to a mark

movwf GPIO ; before writing it to the GPIO port

; This is done to make the output 'reset' as soon

; as possible after the interrupt without being.

; affected by the following code.

 

 

bcf INTCON,INTF ; clear timer interrupt flag

 

call initTablePtr ; initialise table pointer

 

movlw LOW period ; initialise timer counter

movwf lo

movlw HIGH period

movwf mid

movlw UPPER period

movwf hi

 

goto changeOut

 

 

; If the OSCCAL word is missing the code will halt

; with Q / notQ outputs both high

badOsccal bank0

movlw (1<

movwf GPIO

stop goto stop

 

 

;---------------------------------------------------

; initialise table pointer base address to start

; of time delay table

initTablePtr

movlw HIGH delay.base.addr

movwf tablePtrHi

movlw LOW delay.base.addr

movwf tablePtrLo

return

 

 

;--------------------------------------------------

; LongDelayTimes.inc file is included here

; macros used to simplify the time entries are also

; defined below

;--------------------------------------------------

 

; Table lookup with post increment of table address pointer.

 

lookup movfw tablePtrHi

movwf PCLATH

movfw tablePtrLo

incf tablePtrLo,F

skpnz

incf tablePtrHi,F

movwf PCL

 

; Macro definition, used in the LongDelayTimes.inc file to make creation of the delay

; entries user friendly.

time MACRO seconds

radix decimal

if seconds == 0

error "Invalid delay time value entered in LongDelayTimes.inc file. "

error "Value is 0 and must be 1 <= Delay <=65535. Please correct and reassemble."

endif

 

if seconds >65535

error "Invalid delay time value entered in LongDelayTimes.inc file. "

error "Value is >65535 and must be 1 <= Delay <=65535. Please correct and reassemble."

endif

 

retlw LOW seconds

retlw HIGH seconds

radix hex

ENDM

 

loop MACRO

retlw 0x00

retlw 0x00

ENDM

 

delay.base.addr

#include LongDelayTimes.inc

 

loop ; indicates end of data

; lookup pointer is reset to start of data

 

 

 

 

end

Link spre comentariu

Nu e mare inginerie, trebuia doar sa citesti mai atent prin documentatie.Nu trebuie sa modifici decat fisierul LongDelayTimes.inc astfel:

 

;***************************************************************;*       Timing Lookup Table   - please read these notes       *;***************************************************************;; User defined Mark / Space period in seconds; Minimum 1 second, Maximum 65535 seconds ( 18h12m15s); Do not enter a value of 0;; The table is read through sequentially until it reaches the end ; where it will restart from the beginning of the table.;; The maximum number of entries is 900 or 450 pairs;; First entry is Mark period in seconds; Second entry is Space period in seconds; Subsequent pairs of entries continue as Mark / Space; ; NOTE. You can enter an odd number of time entries in the table;  If you do this it alters the behaviour of the output signal so that;  it will alernate bewteeen Mark-Space-Mark-Space-Mark..... and;  Space-Mark-Space-Mark-Space....;;  If you have a single entry, then it generates a signal with equal;  mark / space ratio (50% duty cycle); ; Timing is generated from the PICs internal RC Oscillator. Therefore; the time period is dependant on the accuracy of the oscillator which; is subject to variation from temperature, supply voltage and accuracy; of the calibration word.;; You should test to establish if the timings generated by this code; are accurate enough for your intended application.; ;---------------------------------------------------------------	time	5	        ; puls 5 secunde	time	43200	; pauza 12h = 43200s/3600		;---------------------------------------------------------------

 

La iesirea Q vei pune un tranzistor NPN/mosfet cu canal-N prin care vei alimenta bobina unui releu. Echipamentul tau ce trebuie resetat il vei alimenta prin contactul NC al releului.

Link spre comentariu

iti multumesc pentru rabdarea acordata, dupa cateva incercari am reusit dar daca nu mi-ai fi spus pas cu pas nu aveam de unde sa stiu/ m-a derutat faza cu cele 2 fisiere, eu credeam ca trebuie sa folosesc doar pe cel .asm nu si .incAm mai invatat ceva... multumesc mult

Link spre comentariu

Cu placere. Fisierul LongDelayTimes.inc este un fisier aditional in care sunt declarate duratele palierelor de semnal, pana la 450 de perechi ( in cazul tau sunt necesare doar doua paliere). Continutul acestui fisier este adaugat la proiect prin directiva #include... plasata in asm.

#include	LongDelayTimes.inc
Fragmentarea codului in module se practica pt a fi mai usor de modificat/urmarit.
Link spre comentariu

am descoperit o mica problema a softului: are o intarziere de aproximativ 10 minute dupa fiecare 12 oreadica daca a pornit releul azi la ora 0, data viitoare porneste dupa 12 ore si 10 minute si tot asa se tot decaleaza cu 10 minute la fiecare ciclucrezi ca se poate rezolva problema asta?

Link spre comentariu

Problema nu este din soft ci este legata de precizia si stabilitatea oscilatorului. Citeste AICI

O varianta ar fi sa recalibrezi oscilatorul intern al pic-ului la tensiunea de alimentare pe care o folosesti. AICI ai un montaj pentru asa ceva.

A doua varianta ar fi sa renunti la intrarile "Reset Edge Select" si "Hold" si sa folosesti un quart extern, bineinteles cu modificarea cuvantului de configurare al pic-ului.

Link spre comentariu

La echipamentul care face probleme nu ai vreun semnal care sa dispara in momentul blocari lui? Sa concepi un fel de WatchDog.

nu am un semnal care dispare in momentul blocarii, este un echipament gsm care daca sta mult timp pe aceeasi retea (mai bine zis antena sau celula) este blocat intr-un fel de retea si trecut pe alta celula mai slaba singurul remediu indicat de catre cei care detin reteaua gsm este: resetp.s. echipamentul este in italia si nu are nici o legatura cu retelele noastre
Link spre comentariu

Problema nu este din soft ci este legata de precizia si stabilitatea oscilatorului. Citeste AICIO varianta ar fi sa recalibrezi oscilatorul intern al pic-ului la tensiunea de alimentare pe care o folosesti. AICI ai un montaj pentru asa ceva. A doua varianta ar fi sa renunti la intrarile "Reset Edge Select" si "Hold" si sa folosesti un quart extern, bineinteles cu modificarea cuvantului de configurare al pic-ului.

intrebarea este cat de mult se va decala timerul? sau mai bine zis de la 12 ore e posibil sa ajunga la 13-14 sau mai multe ore? care va fi maximul de decalaj ?
Link spre comentariu

Stai putin, eroarea nu este cumulativa, adica perioada NU se va mari de fiecare data cu inca 10 min, ci pur si simplu nu va fi 12h cat ai setat din soft ci, mai mult sau mai putin in functie de precizia oscilatorului. In schimb daca te raportezi la ceas, da echipamentul se va reseta de fiecare data la o alta ora.

Link spre comentariu

daca este o eroare de 5-10 minute este ok - eu imi imaginasem ca de la 12 ore timp de reset o sa sa se mareasca cine stie cat si dupa aia nu o sa-si mai aiba rostul...ok, multumesc mult atunciam aici si pozele si-s foarte mandru ca am reusit sa fac singur cablajul (cu mici defecte de treasee si putin corodat dar ok) :dans:

Link spre comentariu

Creează un cont sau autentifică-te pentru a adăuga comentariu

Trebuie să fi un membru pentru a putea lăsa un comentariu.

Creează un cont

Înregistrează-te pentru un nou cont în comunitatea nostră. Este simplu!

Înregistrează un nou cont

Autentificare

Ai deja un cont? Autentifică-te aici.

Autentifică-te acum



×
×
  • Creează nouă...

Informații Importante

Am plasat cookie-uri pe dispozitivul tău pentru a îmbunătății navigarea pe acest site. Poți modifica setările cookie, altfel considerăm că ești de acord să continui.Termeni de Utilizare si Ghidări