Krenuo sam u projekt izrade malog GSM kontrolera za releje i senzore. PIC koji koristim je 16F628 koji ima HW USART. Mobitel u pitanju je Siemens C35i, programiram u PIC Basic Pro, a programatori je PicKit2 (odnosno klon od Sure-a).
Zasada sam još u testnoj fazi pa nemam nikakav konkretan projekt. No ono što me muči je, da mi komunikacija PIC-mobitel radi samo u jednom smjeru i to PIC->mobitel. Znači, mogu poslati poruku s Siemensa kada pritisnem tipkalo koje je spojeno na PIC i to radi dobro. No ne mogu dobiti nikakvu povratnu informaciju s mobitel na PIC. Napisao sam jednostavan program, da kada pošaljem "AT" komandu na mobitel i primim "OK" na PIC da mi se upali LED i ostane goriti, a ako ne primim da se upali LED na jednu sekundu i pokuša ponovo. Naravno, meni se LED stalno pali po jednu sekundu nakon 6 sekundi, što znači da ne prima "OK" odgovor od mobitela.
Shemu za spajanja na mobitel sam našao tu na glavnoj stranici na projektu "666_CallAlarmSystem". Također pokušao sam i bez 10k otpornika koji ide na +5V i isto bude. Također sam pokuša spojiti mobitel i s shemom koju sam našao na projektu "502_gsm_kontroler_v1", ali mi tu ne radi ni slanje ni primanje, te kada ide poslati SMS, onda mobitel izgubi mrežu.
Nekako imam osjećaj da propuštam nešto jednostavno, a ne znam što. Dosta sam nov u ovome svemu, pa budite blagi prema meni
Evo kod za slanje SMS-a koji radi:
Code: Select all
@ DEVICE pic16F628, HS_OSC
' ---- High Speed Oscilator
@ DEVICE pic16F628, WDT_OFF
' ---- Watchdog Timer=OFF
@ DEVICE pic16F628, BOD_ON
' ---- Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF
' ---- Low-Voltage Programming=OFF
@ DEVICE pic16F628, MCLR_OFF
' ---- Reset Pin=Internal
@ DEVICE pic16F628, PWRT_ON
' ---- Power-On Timer=Disabled
@ DEVICE pic16F628, CPD_OFF
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
@ DEVICE pic16F628, PROTECT_OFF
' Program Code Protection
DEFINE OSC 20
DEFINE HSER_TXSTA 24h '24h=>BRGH=1, 20h=>BRGH=0, datasheet pg.74
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 19200
DEFINE HSER_CLROERR 1
OPTION_REG.7=0 'pullups on PortB
TRISA=0 'PORTA as outputs
TRISB.0=1 'PORTB as input
cr con 13 'Carriage Return character
lf con 10 'Line Feed character
ctrlz CON 26 'CTRL+Z character
mainloop:
PORTB.0=0'initail state of switch
PORTA=0 'LED off
IF PORTB.0=0 THEN 'if the switch is pressed
PORTA.0=1 'LED on
pause 2000
PORTA=0 'LED off
'send test sms
HSerout ["ATE0",cr] 'Echo off
Pause 1000
HSEROUT ["ATZ",cr] 'Default mode
PAUSE 1000
HSEROUT ["AT+CMGF=0",cr] 'set PDU mode
PAUSE 1000
HSERout ["AT+CMGS=17",cr] 'Length of SMS
PAUSE 1000
HSEROUT ["0001000C91839598531923000004F4F29C0E",ctrlz,cr,lf] 'message "test" to 0989359132
Pause 5000
PORTA.0=1 'LED on, diagnostic to see if sending was succesful
PAUSE 3000
ENDIF
goto mainloop
END
Code: Select all
@ DEVICE pic16F628, HS_OSC
' ---- High Speed Oscilator
@ DEVICE pic16F628, WDT_OFF
' ---- Watchdog Timer=OFF
@ DEVICE pic16F628, BOD_ON
' ---- Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF
' ---- Low-Voltage Programming=OFF
@ DEVICE pic16F628, MCLR_OFF
' ---- Reset Pin=Internal
@ DEVICE pic16F628, PWRT_ON
' ---- Power-On Timer=Disabled
@ DEVICE pic16F628, CPD_OFF
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
@ DEVICE pic16F628, PROTECT_OFF
' Program Code Protection
DEFINE OSC 20
DEFINE HSER_TXSTA 24h '24h=>BRGH=1, 20h=>BRGH=0, datasheet pg.74
DEFINE HSER_RCSTA 90h
DEFINE HSER_BAUD 19200
DEFINE HSER_CLROERR 1
TRISA=0 'PORTA as outputs
cr con 13 'Carriage Return character
lf con 10 'Line Feed character
HSEROUT ["ATE0",cr] 'echo off
pause 1000
index:
PORTA.0=1
pause 1000
PORTA=0 'LED off
HSerout ["AT",cr,lf]
HSerin 5000,index,[WAIT("OK")]
PORTA.0=1 'LED on
END
http://dl.dropbox.com/u/2440240/shema.png