Sari la conținut
ELFORUM - Forumul electronistilor

INTERFATA PIC IN LABVIEW


costi002

Postări Recomandate

Vizitator mihai_ylye

nu merge nici daca ma rog de el in genunchi insa am o speranta....tot incercand eu aici...la un moment dat mi a afisat...apoi nu a mai mers...care crezi ca e problema?

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

Top autori în acest subiect

  • Liviu M

    13

  • costi002

    13

  • Vlad Mihai

    12

din cate am vazut in progr tau, la pornire pic-ul trimite un caracter dupa care nu mai face nimic. asa este? daca da, fa o rutina care sa trimita periodic acelasi caracter si vezi ce iese. daca e deja facut asa soft-ul, sigur e o conexiune electrica nasoala.LE; am recitit si se pare ca asa este, trimite odata si apoi se termina, nu mai face nimic. Refa soft-ul sa trimita periodic.

Link spre comentariu
Vizitator mihai_ylye

am mai facut niste cautari si am adaptat un cod care cred ca respecta chestia cu bucla....imi trimite un caracter la infinit....crezi ca acest cod este bun... ca sa ma pot concentra pe partea electrica??

Link spre comentariu
Vizitator mihai_ylye

#include __config _FCMEN_OFF& _IESO_OFF& _MCLRE_OFF& _WDT_OFF& _INTOSCIO clock equ 8 ; 8 MHz baud equ 19200 ; 19200, 57600, or 115200 brgdiv equ 4 ; divider value for BRG16 = 1 brgval equ (clock*10000000/baud/brgdiv+5)/10-1 v_reset clrf STATUS ; force bank 0 and IRP = 0 goto Init ; ;****************************************************************** ; RS232 subroutines * ;****************************************************************** Put232 btfss PIR1,TXIF ; transmit buffer empty? |B0 goto Put232 ; no, branch, else |B0 movwf TXREG ; send character |B0 return ; |B0 ;****************************************************************** ; main init * ;****************************************************************** Init bsf STATUS,RP1 ; bank 2 |B2 clrf ANSEL ; turn off ADC pins |B2 clrf ANSELH ; turn off ADC pins |B2 ; ; setup 8 MHz INTOSC ; bcf STATUS,RP1 ; bank 0 |B0 bsf STATUS,RP0 ; bank 1 |B1 movlw b'01110000' ; '01110000' |B1 movwf OSCCON ; |B1 Stable btfss OSCCON,HTS ; osc stable? yes, skip, else |B1 goto Stable ; test again |B1 ; ; setup ports ; clrf TRISA ; setup PORT A all outputs |B1 clrf TRISB ; setup PORT B all outputs |B1 clrf TRISC ; setup PORT C all outputs |B1 ; ; setup UART module for 19200 baud (8 MHz Clock) ; movlw low(brgval) ; |B1 movwf SPBRG ; |B1 movlw high(brgval) ; |B1 movwf SPBRGH ; |B1 bsf BAUDCTL,BRG16 ; select 16 bit BRG |B1 movlw b'00100100' ; '0-------' CSRC, n/a (async) |B1 ; '-0------' TX9 off, 8 bits |B1 ; '--1-----' TXEN, tx enabled |B1 ; '---0----' SYNC, async mode |B1 ; '----0---' SENDB, send brk |B1 ; '-----1--' BRGH, high speed |B1 ; '------00' TRMT, TX9D |B1 movwf TXSTA ; |B1 bcf STATUS,RP0 ; bank 0 |B0 movlw b'10010000' ; '1-------' SPEN, port enabled |B0 ; '-0------' RX9 off, 8 bits |B0 ; '--0-----' SREN, n/a (async) |B0 ; '---1----' CREN, rx enabled |B0 ; '----0---' ADDEN off |B0 ; '-----000' FERR, OERR, RX9D |B0 movwf RCSTA ; |B0 movf RCREG,W ; flush Rx Buffer |B0 movf RCREG,W ; |B0 ;****************************************************************** ; main loop * ;****************************************************************** Loop MOVLW 'a' call Put232 ; echo character back goto Loop ; loop forever ;****************************************************************** end

Link spre comentariu
Vizitator mihai_ylye

hai sa ti spun ce am rezolvat...ti am spus ca ultimul cod l am adaptat putin...m am enervat si pana la urma l am rulat pe tot si sa vezi ce face...in hyperterminal apas orice tasta si mi o afiseaza...deci partea electrica de la mine e ok...aici daca as putea sa tai partea cu receptia si sa imni ramana decat partea cu transmisul unui caracter...ce vreau eu ar fi perfect...asta am incercat eu sa fac dar nu am reusit...daca iti poti arunca o privire cand ai timp ar fi perfect...oricum o sa incerc sa l modific eu ...sa vad ce reusesc uite codul;****************************************************************** #include errorlevel -302, -207 ;--< 16F690 config fuses >----------------------------------------- __config _FCMEN_OFF& _IESO_OFF& _MCLRE_OFF& _WDT_OFF& _INTOSCIO ; ; _FCMEN_OFF ; -- fail safe clock monitor enable off ; _IESO_OFF ; -- int/ext switch over enable off ; _BOR_ON ; default, brown out reset on ; _CPD_OFF ; default, data eeprom protection off ; _CP_OFF ; default, program code protection off ; _MCLR_OFF ; -- use MCLR pin as digital input ; _PWRTE_OFF ; default, power up timer off ; _WDT_OFF ; -- watch dog timer off ; _INTOSCIO ; -- internal osc, RA6 and RA7 I/O ; ;--< constants >--------------------------------------------------- radix dec clock equ 8 ; 8 MHz baud equ 19200 ; 19200, 57600, or 115200 brgdiv equ 4 ; divider value for BRG16 = 1 brgval equ (clock*10000000/baud/brgdiv+5)/10-1 ;--< hardware notes >---------------------------------------------- ; ; RB5/RX, pin 12 ---> RS232 Host 'TX' ; RB7/TX, pin 10 ---> RS232 Host 'RX' ;****************************************************************** ; reset vector * ;****************************************************************** org 0x000 v_reset clrf STATUS ; force bank 0 and IRP = 0 |B0 goto Init ; |B0 ;****************************************************************** ; RS232 subroutines * ;****************************************************************** Get232 btfss PIR1,RCIF ; character available? |B0 goto Get232 ; no, branch, else |B0 movf RCREG,W ; get character |B0 return ; |B0 Put232 btfss PIR1,TXIF ; transmit buffer empty? |B0 goto Put232 ; no, branch, else |B0 movwf TXREG ; send character |B0 return ; |B0 ;****************************************************************** ; main init * ;****************************************************************** Init bsf STATUS,RP1 ; bank 2 |B2 clrf ANSEL ; turn off ADC pins |B2 clrf ANSELH ; turn off ADC pins |B2 ; ; setup 8 MHz INTOSC ; bcf STATUS,RP1 ; bank 0 |B0 bsf STATUS,RP0 ; bank 1 |B1 movlw b'01110000' ; '01110000' |B1 movwf OSCCON ; |B1 Stable btfss OSCCON,HTS ; osc stable? yes, skip, else |B1 goto Stable ; test again |B1 ; ; setup ports ; clrf TRISA ; setup PORT A all outputs |B1 clrf TRISB ; setup PORT B all outputs |B1 clrf TRISC ; setup PORT C all outputs |B1 ; ; setup UART module for 19200 baud (8 MHz Clock) ; movlw low(brgval) ; |B1 movwf SPBRG ; |B1 movlw high(brgval) ; |B1 movwf SPBRGH ; |B1 bsf BAUDCTL,BRG16 ; select 16 bit BRG |B1 movlw b'00100100' ; '0-------' CSRC, n/a (async) |B1 ; '-0------' TX9 off, 8 bits |B1 ; '--1-----' TXEN, tx enabled |B1 ; '---0----' SYNC, async mode |B1 ; '----0---' SENDB, send brk |B1 ; '-----1--' BRGH, high speed |B1 ; '------00' TRMT, TX9D |B1 movwf TXSTA ; |B1 bcf STATUS,RP0 ; bank 0 |B0 movlw b'10010000' ; '1-------' SPEN, port enabled |B0 ; '-0------' RX9 off, 8 bits |B0 ; '--0-----' SREN, n/a (async) |B0 ; '---1----' CREN, rx enabled |B0 ; '----0---' ADDEN off |B0 ; '-----000' FERR, OERR, RX9D |B0 movwf RCSTA ; |B0 movf RCREG,W ; flush Rx Buffer |B0 movf RCREG,W ; |B0 ;****************************************************************** ; main loop * ;****************************************************************** Loop call Get232 ; get character from Hyperterminal call Put232 ; echo character back goto Loop ; loop forever ;****************************************************************** end

Link spre comentariu

intre timp am modificat codul tau sa trimita un carcater la 1 secunda

 

movlw b'10000000' ; RB7(TX)=1 others are 0 movwf PORTBbsf STATUS,RP0 ; RAM PAGE 1movlw b'00110010' movwf TRISBmovlw B'01110000' ; full 8mhz internal oscmovwf OSCCONmovlw .12 ;12 -> ~9.6kbps@8mhz movwf	 SPBRG;	movlw .0;	movwf	 SPBRGH	movlw b'00100100' movwf TXSTAclrf dataL settle decfsz dataL,F goto settle;;;;;;;;;;;;;;;;;;;;;;;                               ;;BANKSEL RCSTA;      ;;initililzare port rs232, fara el nu trimite nimicBSF RCSTA,7              ;;                                 ;;;;;;;;;;;;;;;;;;;;;;;;;;;movlw '1' movwf TXREG ; send data in WTransWt bsf STATUS,RP0 ; RAM PAGE 1 WtHere ;btfss TXSTA,TRMT ; (1) transmission is complete if hi ;goto WtHere;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CALL DELAY_1SEC                                          ;MOVLW 'a'                                                      ; trimite caracterul aBANKSEL TXREG                                             ;MOVWF TXREG                                                ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GOTO WtHere;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; incepe rutina de diley 1 secunda la 8 mhzDELAY_1SEC	movlw	0x11	movwf	d1	movlw	0x5D	movwf	d2	movlw	0x05	movwf	d3Delay_0	decfsz	d1, f	goto	$+2	decfsz	d2, f	goto	$+2	decfsz	d3, f	goto	Delay_0			;4 cycles	goto	$+1	goto	$+1	RETURN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;	END

cel mai bine este sa intelegi cat de cat codul ce il vei folosi, ma gandesc ca va trebui sa il si prezinti si este bine sa stii ce este in el, nu sa il faci din bucati de pe net.

 

incearca si vezi daca merge. in simulatorul mplab-ului merge bine.

 

 

LE;pentru in seara asta, cam atat, am ceva treaba :da

ce ai pus tu, se modifica usor. eu cred ca nu prea ai tangente cu asm-ul si pic-ul dar vad ca esti insistent, si asta e bine. ne mai citim maine. succes

Link spre comentariu

de la pic printr un convertor rs232-usb si printr-un max232 pt a-i inversa logica...

Daca folosesti convertor usb-rs232 nu mai ai nevoie de nici un max. Chiar, ce convertor folosesti?Pe partea cu codul, pentru ca nu prea ma pricep la assembler nu pot sa spun prea multe (se pare ca ti-a facut costi002 un program), da' din ce am mai citit si eu:- ca sa schimbi bank-ul cel mai indicat e sa folosesti directiva BANKSEL;- (la multe picuri, da' nu la toate) portul B trebuie configurat corespunzator: Tx trebuie facut iesire si Rx (daca folosesti si receptia) trebuie setat ca intrare; - portul serial trebuie activat intodeauna (SPEN=1) ;- daca nu vreui sa astepti o perioada fixa suficient de mare (1 secunda e o perioada mare), poti folosi diversele flaguri sa testezi daca transmisia (in cazul tau, ca sunt o gramada de alte flaguri) s-a terminat. In cazul transmisiei RS232, unul din flag-uri e TRMT. Cat timp TRMT e zero, ai o transmisie neterminata. Cand transmisia se termina (si bufferul Tx e gol), TRMT e facut 1 de hard si poti copia un nou byte in TXREG.
Link spre comentariu
Vizitator mihai_ylye

folosesc un convertor de la connex electronics...esti sigur ca nu mai trebuie sa folosesc MAX232 ...pe toate schemele pe care le am vazut exista cate un MAX232...aseara am reusit sa imi afisez ceva in hyperterminal si mai exact i-am dat sa afiseze mesajul "merge"...problema e ca el afiseaza mesajul dar pe langa asta imi mai afiseaza si alte balari...alte caractere pe langa el de ex "~!@merge" si chesti de astea...banuiesc ca acum problema nu mai este din cod...poate semnalul meu este este afectat de ceva...

Link spre comentariu
Vizitator mihai_ylye

din cate am mai discutat si eu azi cica ar fi o problema la final cu stop goto stopdar am dezactivat tramsmisia prin curatarea bitului spen si tot nu mergea;****************************************************************** #include errorlevel -302, -207 ;--< 16F690 config fuses >----------------------------------------- __config _FCMEN_OFF& _IESO_OFF& _MCLRE_OFF& _WDT_OFF& _INTOSCIO ; ; _FCMEN_OFF ; -- fail safe clock monitor enable off ; _IESO_OFF ; -- int/ext switch over enable off ; _BOR_ON ; default, brown out reset on ; _CPD_OFF ; default, data eeprom protection off ; _CP_OFF ; default, program code protection off ; _MCLR_OFF ; -- use MCLR pin as digital input ; _PWRTE_OFF ; default, power up timer off ; _WDT_OFF ; -- watch dog timer off ; _INTOSCIO ; -- internal osc, RA6 and RA7 I/O ; ;--< constants >--------------------------------------------------- radix dec clock equ 8 ; 8 MHz baud equ 19200 ; 19200, 57600, or 115200 brgdiv equ 4 ; divider value for BRG16 = 1 brgval equ (clock*10000000/baud/brgdiv+5)/10-1 ;--< hardware notes >---------------------------------------------- ; ; RB5/RX, pin 12 ---> RS232 Host 'TX' ; RB7/TX, pin 10 ---> RS232 Host 'RX' ;****************************************************************** ; reset vector * ;****************************************************************** org 0x000 v_reset clrf STATUS ; force bank 0 and IRP = 0 goto Init ; ;****************************************************************** ; RS232 subroutines * ;****************************************************************** Put232 btfss TXSTA,TRMT ; transmit buffer empty? goto Put232 ; no, branch, else movwf TXREG ; send character return ;****************************************************************** ; main init * ;****************************************************************** Init BANKSEL ANSEL ; bank 2 clrf ANSEL ; turn off ADC pins clrf ANSELH ; turn off ADC pins ; ; setup 8 MHz INTOSC ; BANKSEL OSCCON movlw b'01110000' ; '01110000' movwf OSCCON ; Stable btfss OSCCON,HTS ; osc stable? yes, skip, else goto Stable ; test again ; ; setup ports ; clrf TRISB ; setup PORT B all outputs ; ; setup UART module for 19200 baud (8 MHz Clock) ; movlw low(brgval) ; movwf SPBRG ; movlw high(brgval) ; movwf SPBRGH ; bsf BAUDCTL,BRG16 ; select 16 bit BRG movlw b'00100100' ; '0-------' CSRC, n/a (async) ; '-0------' TX9 off, 8 bits ; '--1-----' TXEN, tx enabled ; '---0----' SYNC, async mode ; '----0---' SENDB, send brk ; '-----1--' BRGH, high speed ; '------00' TRMT, TX9D movwf TXSTA ; BANKSEL RCSTA movlw b'10000000' ; '1-------' SPEN, port enabled ; '-0------' RX9 off, 8 bits ; '--0-----' SREN, n/a (async) ; '---0----' CREN, rx disabled ; '----0---' ADDEN off ; '-----000' FERR, OERR, RX9D movwf RCSTA ; movf RCREG,W ; flush Rx Buffer movf RCREG,W ; ; main loop Loop movlw 'm' call Put232 movlw 'e' call Put232 movlw 'r' call Put232 movlw 'g' call Put232 movlw 'e' call Put232 STOP NOP goto STOP end

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