What is the difference between n2400 and n2400_4 ?

BrendanP

Senior Member
Im having problems all of a sudden serially recieving SMS's from the GSM module Im working with. When I originally wrote the program I used the older n2400. I then discovered that the n2400_4 is supposed to be used with the 40X1 so I changed.

Im now having problems with the reception of messages. Im trying to narrow down possibilities as to bugs. A basic version of the program works using plain n2400.

Should I just use that if it works?

What is the difference between n2400 and n2400_4 ?
 

hippy

Ex-Staff (retired)
What is the difference between n2400 and n2400_4 ?
Nothing, they both have the same pre-defined value of "4".

It's just convenience to help indicate the actual baud rate for the operating speed used; N2400, N2400_4, N4800_8 and N9600_16 all have the same value. No matter which is used, the tokenised program downloaded into the PICAXE is exactly the same. Once the program is downloaded into the PICAXE it won't know which you used in your source code.

It would seem to be one of those mysteries of the cosmos as to why the program works with N2400 but not N2400_4, just bad luck, unfortunate coincidence, and I believe the problem lies elsewhere..
 

BrendanP

Senior Member
Thanks for the advice Hippy, at least I can cross that off the list.

The problem lays in the seemingly innocuous bit of code below. When I would send a SMS I'd start the message with a ?. The program would run through all the header info untill it came to the ? and then it would stop the data flow from the module and then jump to another place in the program and RTS more data which would be the message and act accordingly. It worked fine and then started playing up.

b1=0

recieve:
low 7 'RTS; low to tell module to send more data
serin 0,T600_4,b0
high 7
if b0=$3F then high 7: endif '$3F means a ? mark highing 7 stops RTS
if b0=$3F then goto mess
serout 4,n2400_4, (b0)
goto recieve

I re wrote the above part of program like this. It performs OK so far. The header info with the fills the first serin so it then goes to the second serin which the if... then part reads.

I'll try it with serin time outs tommorrow. Playing with this stuff is addictive.



recieve:
low 7 'RTS; low to tell module to send more data

serin 0,T600,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b2

serin 0,T600,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b18,b19,b20,b21,b22,b23,b24,b25,b27

high 7 'stop RTS

if b22=$31 then goto one
if b22=$32 then goto two
if b22=$33 then goto three
if b22=$34 then goto four
if b22=$35 then goto five
if b22=$36 then goto six
if b22=$37 then goto seven
if b22=$38 then goto eight
if b22=$39 then goto nine
if b22=$30 then goto zero
 
Last edited:

hippy

Ex-Staff (retired)
One issue can be how quickly a sender responds to RTS. It may be part way through sending when RTS is 'stop!' and it may even send extra characters after 'stop!' depending if RTS is handled in hardware or software.

If using a SERIN and you don't want most of the data you can simply re-use the same byte over and over, although I don't know if that's applicable here ...

- SerIn 0,T600,b0,b0,b0,b0 ... b0,b0,b1
 

BrendanP

Senior Member
Yep,I thought that could happen , that by the time the sender responds to the highing of the RTS it might send a couple of more characters. I had previously observed that and that was why I had opted for the slow baud rate.

Thanks Hippy for the tip re. reusing the same byte, I didnt know that.
 

BrendanP

Senior Member
Just a follow up to my earlier posts. I continued to have problems with serial comms with the GSM module and with the LCD. I was using the internal res 2 4mghz. I decided to attach a external 8 mghz res. and the problems ceased.

In future I will use a external res. as a matter of course on all 40X1/2 projects. I spent about 20 hours stuffing around trying to sort out the problem. The external res. fixed it immediately.


It seems that maybe there is a difference between 2400n and 2400_8. This simple bit of code below produces corrupted characters on the LCD when I use plain 2400N. It runs fine when run as below. I wouldnt have the cheek to gainsay Hippy. Im a bit puzzled, anyone have any ideas?

setfreq em8
top:
serout 4, n2400_8,("?f") 'clear screen move to pos 1 first line
pause 1000

serout 4, n2400_8,("WAITING TO RECIEVE SMS")
pause 1000

serout 4, n2400_8,("?f") 'clear screen move to pos 1 first line
pause 1000

goto top
 
Top