Gsm modem trying to parse the sender number URGENT help

stgaalka

New Member
Hello im using gsm modem in my project for wireless communication to log in data so im struggling in my code to parse out the sender number and show it in OLED display any help would be appreciated
1-microcontroller used 40xm2
here is attachment of the code file
if anyone worked with gsm modem before please let me know how to fix this issue :/
Thank youView attachment GSM_manualTest3.bas
 

BESQUEUT

Senior Member
Why using t9600_8 for serin but not for serout ?

What is the answer for "AT" only command ?

Maybe you can considere usinq a qualifier ?

You can write :
serout B.7,N2400,("N:",b4,b5,b6,b7,b8,b9,b10,b11,b12,b13)

NB : Main will be executed only one time.


Background receive would be better to do that...
 
Last edited:

stgaalka

New Member
Hello BESQUEUT,

Thank you for your message.

The AT was just for checking if we get the OK string back from the GSM modem.

The main issue is that I do not know how to read a large string (something like 80bytes) using serin command. Can serin be used to specify a serial read of an entire string (which is terminated by CR and LF) in a variable, instead of byte-by-byte read.

The serin with qualifier is a good idea and I tried it as follows

The message format is: "xxxx","+MMMMM","zzzzzz"

I want to parse out the MMMMM (5 bytes) so I used the serin with qualifier as follows:

serin B.2, t9600_8,("+"),b1,b2,b3,b4,b5

but this did not work.

Finally, would you be able to point me to some documenation around background receive in Picaxe.

Many thanks for your help
 

BESQUEUT

Senior Member
You can read this and/or that
But IHMO PAUSE must be in the Main loop, never in an Interrupt...

You do not need an interrupt :
- simply look at the hserptr in the main loop till you have enought bytes received...
 
Last edited:

Flenser

Senior Member
stgaalka,

you said that this code did not work:
Code:
serin B.2, t9600_8,("+"),b1,b2,b3,b4,b5
but this did not work.
Can you give us more details about what "did not work" means? Did you get any output on the LCD? If you did then what was displayed?
If you did not get any output then my guess is that your serin may not be receiving any characters.

My first step would be to confirm that the serial send & receive to B.1 & B.2 was working.

What do you get output on the LCD from this code:
Code:
serin B.2, t9600_8,b2,b3
pause 1000
serout B.1, t9600, ("AT+CMGL=",b1,"REC READ",b1, CR, LF )
I not would worry about getting the code to parse out the MMMMM string to work until after I was sure my serial comms were working.

You said that your chip is 40xm2. Is it a 40X2 or a 40M2? This could make a difference because the default freq is different.
From the manual:
The default value on X2 parts is 8MHz internal. The default value on all other parts is 4MHz internal.
If you chip is a 40M2 then "serin B.2, t9600_8" will not do what you expect.

Flenser
 

BESQUEUT

Senior Member
I not would worry about getting the code to parse out the MMMMM string to work until after I was sure my serial comms were working.
+1
That's why I asked "What is the answer for "AT" only command ?" (#2)...
stgaalka said "The AT was just for checking if we get the OK string back from the GSM modem." What does that mean ?
Did you actually get an "OK" ?
You said that your chip is 40xm2. Is it a 40X2 or a 40M2? This could make a difference because the default freq is different.
40M2 does not exist... So I guess it's a 40X2...
+ background receive does not work on all chips...
 

Goeytex

Senior Member
@stgaalka

Serin T9600_8 will generally not work for receiving multiple back-to-back bytes of data or when using a qualifier. This is due to command interpreter overhead. For 9600 baud to work acceptably, the system clock must be increased to either 16Mhz or 32MHz and all serin/serout statements must use either xxxx_16 or xxxx_32.

It is not clear as to what specific chip you have (there is no 40M2), or if it is using an external oscillator, so I cannot tell you specifically how to set the system frequency. Usually to set the system clock to 16MHz use "Setfreq M16.

Below is some code (untested) that sets the clock to 16MHz and configures the baud rates according. It demonstrates the use of directives and symbols, and should give you an idea of where you may need to make some changes.

Code:
[color=Green]'Directives[/color]
[color=Navy]#Picaxe [/color][color=Black]40X2[/color]
[color=Navy]#No_Data
#No_Table[/color]

[color=Green]'Symbols / Defines[/color]
[color=Blue]symbol LCD_OUT [/color][color=DarkCyan]= [/color][color=Blue]B.7
Symbol GSM_OUT [/color][color=DarkCyan]= [/color][color=Blue]B.1 
Symbol GSM_IN  [/color][color=DarkCyan]= [/color][color=Blue]B.2 

Symbol LCD_BAUD [/color][color=DarkCyan]= [/color][color=Blue]N2400_16
Symbol GSM_BAUD [/color][color=DarkCyan]= [/color][color=Blue]T9600_16

SetFreq M16

High LCD_OUT                  [/color][color=Green]; Initialise output B.1 for 't2400' serial[/color]
[color=Blue]pause [/color][color=Navy]20                      [/color][color=Green]; Delay while the receiver prepares for data [/color]

[color=Blue]serout  LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]1[/color][color=Blue])
pause [/color][color=Navy]60[/color]
[color=Blue]serout  LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]128[/color][color=Blue]) [/color][color=Green]; move cursor to Position (1,1)[/color]
[color=Blue]serout  LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black],[/color][color=Blue]([/color][color=Red]"Values Below"[/color][color=Blue])[/color]

[color=Purple]b1 [/color][color=DarkCyan]= [/color][color=Navy]0x22[/color]

[color=Black]main:[/color]

[color=Blue]serout GSM_OUT[/color][color=Black],[/color][color=Blue]GSM_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Red]"ATE0"[/color][color=Black], [/color][color=Blue]CR[/color][color=Black], [/color][color=Blue]LF )      
pause [/color][color=Navy]30[/color]

[color=Blue]serout GSM_OUT[/color][color=Black],[/color][color=Blue]GSM_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Red]"AT+CMGF=1"[/color][color=Black], [/color][color=Blue]CR[/color][color=Black], [/color][color=Blue]LF ) [/color][color=Green]; Output "AT"[/color]
[color=Blue]serin  GSM_IN[/color][color=Black],[/color][color=Blue]GSM_BAUD[/color][color=Black], [/color][color=Purple]b2[/color][color=Black],[/color][color=Purple]b3[/color]
[color=Blue]pause [/color][color=Navy]2000[/color]

[color=Blue]serout GSM_OUT[/color][color=Black],[/color][color=Blue]GSM_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Red]"AT+CMGL="[/color][color=Black],[/color][color=Purple]b1[/color][color=Black],[/color][color=Red]"REC READ"[/color][color=Black],[/color][color=Purple]b1[/color][color=Black], [/color][color=Blue]CR[/color][color=Black], [/color][color=Blue]LF )
serin  GSM_IN[/color][color=Black],[/color][color=Blue]GSM_BAUD[/color][color=Black], [/color][color=Purple]b4[/color][color=Black],[/color][color=Purple]b5[/color][color=Black],[/color][color=Purple]b6[/color][color=Black],[/color][color=Purple]b7[/color][color=Black],[/color][color=Purple]b8[/color][color=Black],[/color][color=Purple]b9[/color][color=Black],[/color][color=Purple]b10[/color][color=Black],[/color][color=Purple]b11[/color][color=Black],[/color][color=Purple]b12[/color][color=Black],[/color][color=Purple]b13[/color]

[color=Blue]serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]192[/color][color=Blue]) [/color][color=Green]; move cursor to Position (1,1)[/color]
[color=Blue]serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Red]"N:"[/color][color=Blue])    [/color][color=Green]'// 32 = space[/color]
[color=Blue]serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b4[/color][color=Black],[/color][color=Navy]32[/color][color=Blue]) 
serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b5[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])
serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b6[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])
serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b7[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])

serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]148[/color][color=Blue]) [/color][color=Green]'//next line [/color]
[color=Blue]serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b8[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])
serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b9[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])
serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b10[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])
serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b11[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])

serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Navy]254[/color][color=Black],[/color][color=Navy]212[/color][color=Blue]) [/color][color=Green]'//next line [/color]
[color=Blue]serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b12[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])
serout LCD_OUT[/color][color=Black], [/color][color=Blue]LCD_BAUD[/color][color=Black], [/color][color=Blue]([/color][color=Black]#[/color][color=Purple]b13[/color][color=Black],[/color][color=Navy]32[/color][color=Blue])

Do

Loop[/color]
 
Top