Cos'è ElectroYou | Login Iscriviti

ElectroYou - la comunità dei professionisti del mondo elettrico

Invertire la logica di un segnale - Automotive

Elettronica lineare e digitale: didattica ed applicazioni

Moderatori: Foto Utentecarloc, Foto Utenteg.schgor, Foto UtenteBrunoValente, Foto UtenteIsidoroKZ

0
voti

[1] Invertire la logica di un segnale - Automotive

Messaggioda Foto Utentesteorai » 9 ott 2014, 16:58

ciao a tutti ho realizzato il circuito N°2 di questo sito http://talkingelectronics.com/projects/ ... ter-5.html vorrei metterlo sulla mia moto , al posto dei pulsanti up e down ho messo dei sensori hall . il problema è che vorrei collegare la spia della folle al pin del reset del PIC, in modo che quando la moto è in folle mi indica la F ,pero' per il reset del PIC ho bisogno il negativo e sulla spia ho il positivo
Avatar utente
Foto Utentesteorai
30 5
Frequentatore
Frequentatore
 
Messaggi: 109
Iscritto il: 9 ott 2014, 15:48

0
voti

[2] Re: invertire positivo in negativo

Messaggioda Foto UtenteRussell » 9 ott 2014, 17:03

Se inverti la posizione del pulsante e della resistenza si inverte la logica e dovrebbe andare come desideri
Avatar utente
Foto UtenteRussell
3.373 3 5 9
Master
Master
 
Messaggi: 2193
Iscritto il: 4 ott 2009, 10:25

0
voti

[3] Re: invertire positivo in negativo

Messaggioda Foto Utentesteorai » 9 ott 2014, 17:08

ho provato a mettre la resistenza sul meno (se intendi dire questo) ma rimane sempre in reset. calcola che il pulsante non lo metto, e che va collegato direttamente alla spia della folle, con una resistenza per abbassare la tensione
Avatar utente
Foto Utentesteorai
30 5
Frequentatore
Frequentatore
 
Messaggi: 109
Iscritto il: 9 ott 2014, 15:48

0
voti

[4] Re: invertire positivo in negativo

Messaggioda Foto UtenteRussell » 9 ott 2014, 17:15

Ti stai riferendo alla terzultima figura della pagina che hai linkato?
In particolare al piedino 18 (RA1)?



Questo circuito fa' rilevale ALTO sempre, ma quando premi l'interruttore fa' rilevare BASSO
Se inverti i componenti tra di loro risultera' sempre BASSO, e se premi va ALTO

Ho capito male la domanda, e, per rimanere in tema di moto, sono fuori strada?
Avatar utente
Foto UtenteRussell
3.373 3 5 9
Master
Master
 
Messaggi: 2193
Iscritto il: 4 ott 2009, 10:25

0
voti

[5] Re: invertire positivo in negativo

Messaggioda Foto Utentesteorai » 9 ott 2014, 17:21

ciao si è giusto il piedino 18 ra1 la resistenza a + e pulsante a meno senti adesso riprovo metto la resistenza a meno e ti faccio sapere
Avatar utente
Foto Utentesteorai
30 5
Frequentatore
Frequentatore
 
Messaggi: 109
Iscritto il: 9 ott 2014, 15:48

0
voti

[6] Re: invertire positivo in negativo

Messaggioda Foto UtenteRussell » 9 ott 2014, 17:39

steorai ha scritto: metto la resistenza a meno e ti faccio sapere


... e pero' anche l'interruttore a positivo...

disegnino:

Avatar utente
Foto UtenteRussell
3.373 3 5 9
Master
Master
 
Messaggi: 2193
Iscritto il: 4 ott 2009, 10:25

0
voti

[7] Re: invertire positivo in negativo

Messaggioda Foto Utenteclaudiocedrone » 9 ott 2014, 17:43

steorai ha scritto:il pulsante non lo metto, e che va collegato direttamente alla spia della folle, con una resistenza per abbassare la tensione

:-) Come la hai dimensionata la resistenza ? O_/
"Non farei mai parte di un club che accettasse la mia iscrizione" (G. Marx)
Avatar utente
Foto Utenteclaudiocedrone
21,3k 4 7 9
Master EY
Master EY
 
Messaggi: 15302
Iscritto il: 18 gen 2012, 13:36

0
voti

[8] Re: invertire positivo in negativo

Messaggioda Foto Utentesteorai » 9 ott 2014, 17:52

ciao il pulsante non lo metto andra' collegato diretto alla spia con resistenza per caduta tensione il PIC non gradisce oltre i 5v . la resistenza non la ho ancora calcolata il circuito è ancora su breadboar per qui ho solo i 5v . provato a mettere la resistenza a - ma resta sempre in reset vi metto il firmware in assembly modificato
Codice: Seleziona tutto
;****************************************************************

        list P = 16F628         ;microcontroller
        include <P16F628.inc>   ;registers for F628


        __Config        _CP_OFF & _LVP_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _MCLRE_OFF

;****************************************************************
; variables - names and files
;****************************************************************


                ;Files for F628 start at 20h
  CBLOCK 0x20
  temp1    ;for delay
  temp2    ;for delay
  temp3    ;for delay
  SwUp
  SwDwn
  count
  Sw_Flag
  ENDC

;****************************************************************
;Beginning of program
;****************************************************************
Start   org             00      ;reset vector address
                goto    SetUp   ;goto SetUp


table   addwf   PCL,F           ;02h,1  add W to program counter
        retlw   b'01110001'     ; "F"   -|F|E|D|C|B|A
        retlw   b'00000110'     ; "1"   -|-|-|-|C|B|-
        retlw   b'01011011'     ; "2"   G|-|E|D|-|B|A
        retlw   b'01001111'     ; "3"   G|-|-|D|C|B|A
        retlw   b'01100110'     ; "4"   G|F|-|-|C|B|-
        retlw   b'01101101'     ; "5"   G|F|-|D|C|-|A
        retlw   b'01111101'     ; "6"   G|F|E|D|C|-|A


;****************************************************************
;* port A and B initialisation                                  *
;****************************************************************

SetUp           bsf     STATUS,RP0
                movlw   b'00001111'             ;Make RA0,1,2,3 in
                movwf   05h
                clrf    06h                     ;Make all RB output
                bcf     STATUS,RP0              ;select programming area - bank0
                movlw   b'10000000'             ;Turn off T0CKI, prescale for TMR0 = 1:
                movwf   OPTION_REG
                clrf    PORTB                   ;Clear Port B of junk
                clrf    count                   ;zero the count file
                clrf    Sw_Flag
                movlw   07h                     ;turn comparators off and enable
                movwf   CMCON                   ;    pins for I/O functions
                goto    Pre                     ;shows 0,1,2,3,4,5,6,0  at 2Hz and stops on "0"



;****************************************************************
;*         Delay 10mS           10 x 1,000uS                    *
;****************************************************************

D_10mS          movlw   0Ah
                movwf   temp2
D_a             nop
                decfsz temp1,1
                goto    D_a
                decfsz temp2,1
                goto    D_a
                retlw   00


        ;Delay 0.51 sec

D_500mS         movlw   02h
                movwf   temp3
DelX            decfsz  temp1,1
                goto    DelX
                decfsz  temp2,1
                goto    DelX
                decfsz  temp3,1
                goto    DelX
                retlw   00


Up              btfsc   Sw_Flag,1
                goto    M1
                bsf     Sw_Flag,1
                movlw   06h             ;put 6 into w
                xorwf   count,0         ;compare count file with 6
                btfsc   03,2            ;zero flag in STATUS file. Will be set if count is 6
                goto    M1
                incf    count,f         ;increment display
                goto    M1


Down            btfsc   Sw_Flag,1
                goto    M1
                bsf     Sw_Flag,1
                movlw   01h             ;put 1 into w
                xorwf   count,0         ;compare units file with 1
                btfsc   03,2            ;zero flag in STATUS file. Will be set if count is 1
                goto    M1
                movlw   00h             ;put 0 into w
                xorwf   count,0         ;compare count file with 1
                btfsc   03,2            ;zero flag in STATUS file. Will be set if count is 0
                goto    M1
                decf    count,f         ;decrement display
                goto    M1


                ;Reset ONLY produces 0

Reset           clrf    count     ; "0"
                call    table
                movwf   PORTB
                goto    Pre


dim             clrf    PORTB
                call    D_10mS
                goto    Main

                ;Pre    shows 0,1,2,3,4,5,6,0  at 2Hz and stops on "0"


Pre             movlw   b'01110001' ;show 0
                movwf   PORTB
                call    D_500mS
                clrf    count
                call    table
                movwf   PORTB
                goto    M_First



;****************************************************************
;* Main                                                         *
;****************************************************************

M_First btfss   PORTA,1                         ;test switch-press for reset
                goto    Reset                   ;reset pushed
                btfss   PORTA,2                 ;test switch-press for up
                goto    $+5                             ;
                btfsc   PORTA,3                 ;test switch-press for down
                goto    M_First
                incf    count,1                 ;show 1 if down pressed at start
                goto    Main
                incf    count,1                 ;show 2 if Up pressed at start
                goto    Main


Main    btfss   PORTA,1                         ;test switch-press for RESET
                goto    Reset
                btfss   PORTA,2                 ;test switch-press for UP
                call    Up                      ;UP switch pressed
                btfss   PORTA,3                 ;test switch-press for Down
                call    Down                    ;Down switch pressed
                movf    count,w                 ;copy count value into w
                call    table                   ;unit display value will return in w
                movwf   PORTB                   ;output count value
                call    D_10mS                  ;call delay
                btfsc   PORTA,2                 ;bit will be zero when sw is pressed
                bcf             Sw_Flag,1
                btfsc   PORTA,3                 ;bit will be zero when sw is pressed
                bcf             Sw_Flag,1
                btfss   PORTA,0                 ;test switch for dim = HIGH input
                goto    dim
M1              goto    Main


               END[/quote]

[quote]vi metto il firmware in assembly modificato

Edit: s85 E già che ci sei mettilo tra i tag [code *]
Ultima modifica di Foto Utentesimo85 il 9 ott 2014, 22:25, modificato 1 volta in totale.
Motivazione: Inserito codice negli appositi tag
Avatar utente
Foto Utentesteorai
30 5
Frequentatore
Frequentatore
 
Messaggi: 109
Iscritto il: 9 ott 2014, 15:48

0
voti

[9] Re: invertire positivo in negativo

Messaggioda Foto Utenteclaudiocedrone » 9 ott 2014, 18:07

Codice: Seleziona tutto
A parte che il codice è più fruibile se inserito tra gli appositi tag...
(c'è il pulsante "code" nella pagina di risposta) se il circuito è ancora su breadboard stai usando un pulsante ? Un interruttore ? Un po' più di coerenza nelle descrizioni non guasterebbe ;-) grazie. O_/
"Non farei mai parte di un club che accettasse la mia iscrizione" (G. Marx)
Avatar utente
Foto Utenteclaudiocedrone
21,3k 4 7 9
Master EY
Master EY
 
Messaggi: 15302
Iscritto il: 18 gen 2012, 13:36

0
voti

[10] Re: invertire positivo in negativo

Messaggioda Foto UtenteRussell » 9 ott 2014, 18:10

Mah
forse allora ho capito che vuoi fare una cosa diversa, ovvero sfruttare lo stato dell'indicatore sul quadro (spia) per istruire il tuo controllore
in tal caso, se questo schema ti torna, puoi provare anceh con un semplice rele'

in figura a sinistra c'è la centralina della moto, che sotto precise condizioni accende la spia (riquadro verde)
tu potresti appenderti in parallelo alla spia per cercare di azioare un rele' (fili rossi) che chiudendo un contatto porterebbe il terminale meno al tuo controllore

Avatar utente
Foto UtenteRussell
3.373 3 5 9
Master
Master
 
Messaggi: 2193
Iscritto il: 4 ott 2009, 10:25

Prossimo

Torna a Elettronica generale

Chi c’è in linea

Visitano il forum: Nessuno e 36 ospiti