CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem with receiving strings from SIM900 with INT_RDA
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Wed Sep 30, 2015 8:02 pm     Reply with quote

ezflyr wrote:
When you do get around to connecting your SIM900 modem, keep in mind that the SIM900 is a 3V device, so you can't just connect it directly to a 5V PIC. You need level shifting hardware to do this, or better yet, you need to obtain an 'LF' version of your PIC, and run it at 3.3ish volts!


ezflyr, I think you are right and i am in a mistake. I have been making some tests in real hardware, as all you said... using a ttl to usb converter and the sim900, and i think you are right about 3.3v in the tx and rx pins of sim900 (thats what i understood). Because when i test my program directly to my PIC, it doesn't work. But I test with ttl-usb adapter and it works, after that i remember what you said and check the voltage in tx-rx pins of sim900 = 3.8v ... and the PIC tx-rx=4.9. I make my conclusions and then sim900 works with 3.3v and PIC 5v.

...but i am still with some dudes because:
i already had used the same sim900 and a pic16f887 to send sms...and in that application...it works

...if i am wrong in something...please let me know.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Thu Oct 01, 2015 1:39 pm     Reply with quote

Hi,

The problem is two-fold. First, the PIC 'Tx' output will be too high for the SIM900 'Rx' input. A simple voltage divider can be used to scale this higher voltage to the appropriate lower voltage level. Second, and possibly the more serious problem, the SIM900 'Tx' output will be too low for the PIC 'Rx' input. This will prevent the PIC from receiving data from the SIM900. You'll need a proper level shifter here to solve this problem.

As I mentioned, you can avoid all of this by using an 'LF' version of your PIC, and running the PIC and the SIM900 at the same supply voltage, such as 3.8V or so.
_________________
John

If it's worth doing, it's worth doing in real hardware!
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Fri Oct 02, 2015 6:35 pm     Reply with quote

Thanks ezflyr, i have bought a voltage level elevator and tomorrow i will try again. I already have sent a mail to sainsmart, about information of sim900 but they didn't answer.
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Sat Oct 03, 2015 6:55 pm     Reply with quote

http://i1.wp.com/microcontrollerslab.com/wp-content/uploads/2014/08/Untitled1.png
hi, i found this configuration, use 3 diodes to get a low voltage. I think is a good idea, but i have some dudes about the configuration from SIM900 TX to PIC RX.

what do you think?
Ttelmah



Joined: 11 Mar 2010
Posts: 19561

View user's profile Send private message

PostPosted: Sun Oct 04, 2015 12:40 am     Reply with quote

Don't get me wrong, but it is the _fourth_ diode that really matters.

As Ezflyr has pointed out, there are two directions involved here. The TX (from the PIC), and the RX (to the PIC).

Now on the TX direction, the diodes should give the drop to prevent the PIC from trying to power the module over about 3.2v, but as shown do not ensure that the input to the module goes low when not being driven. A simple resistive divider is honestly easier and safer.

It is the fourth diode on the RX direction that is potentially critical. This treats the module output as if it is 'open collector', so only pulls down with the diode, and then allows the signal to be pulled 'up' one diode drop above the output voltage of the module. Potentially _just_ going high enough so that the PIC would see the line as high.
However 'just'. It's not a good circuit.
In both directions, the signals into the chips may not reliably go 'low'.
In the TX direction from the PIC there is nothing to ensure the signal into the module is reliably going to go down, and in the other direction, the 'low' to the PIC will be the low 'output' of the module _plus_ one diode drop. It doesn't take much for this not to be low enough to meet the VIl of your chip (0.2*Vdd on the serial pins - 1v).....

Have a look at the circuit here:
<http://www.smallridge.com.au/index.php?page=projects#HWREF>

On the 'Microcontroller with ENC28J60 Ethernet controller'. Look at the circuit used to adapt the 5v PIC to drive the 3.3v SD card. Involves one logic gate and three resistors. This is a safe reliable way of adapting between 5v and 3.3v, that will work (obviously used the 'other way round).

If you don't want to add extra parts (or don't have them), other than resistors, and the comparator on the PIC is unused, then simply use the resistive divider shown from the PIC to the module, for the PIC's TX line, and setup the PIC's comparator to give a non inverted output and use this to drive the PIC's RX line. Using a Vref at (say) 1.4v, gives a nice reliable way of converting the signal.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon Oct 05, 2015 9:21 am     Reply with quote

Hi,

Bi-directional level translation can also be done using two resistors and an n-channel MOSFET transistor. This is the method I favor when I only need to translate a couple of signals. You can see an implementation of this technique here: https://www.sparkfun.com/products/12009

Scroll down and click the 'Schematic' link to see the circuit diagram!

If you need to translate more than a couple of signals, I prefer a more integrated approach to keep the parts count down! Here is a good approach in that case:

https://www.sparkfun.com/products/11771
_________________
John

If it's worth doing, it's worth doing in real hardware!
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Thu Oct 08, 2015 10:58 pm     Reply with quote

Hi, thanks for your info, i have been making some tests with the configuration that i have posted...it works...but not completely, because i can receive the string with no problem using the RDA interrupt, but, when i want to send a sms...it doesnt work...

-i connect tx and rx directly from the PIC with the sim900 and it works... i can send sms with no problem (i still dont know why)...but when i want to receive a string, it doesnt work...the program stay forever in the interrupt and never go back to main program
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Thu Oct 08, 2015 11:14 pm     Reply with quote

ezflyr wrote:

As I mentioned, you can avoid all of this by using an 'LF' version of your PIC, and running the PIC and the SIM900 at the same supply voltage, such as 3.8V or so.


Hi, i also found my PIC16F887, and reading the datasheet i found that with 4Mhz the PIC can work from 2v to 5.5v. Then i connected tx and rx directly to SIM900 and i used this PIC with 2.5v,3v,3.5v,4v,4.5v,5v but didn't work. I only could send sms, but not receive the string with RDA.
You mentioned that we must run both with same voltage but it's not possible, the SIM900 works from 3.2v to 4.8v (its in the sim900 datasheet)but in the PCB is marked 5v. If i try to supply with less than 4.5v the module doesn't work.
(I think that in my next shop i will buy an article with full documentation from the manufacturer ...as you said).

***but i will keep trying, i think that your configurations from 3.3v to 5v will work.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Fri Oct 09, 2015 4:10 pm     Reply with quote

Yes, the PIC16F887 can run on voltages down to 2.5V when the clock stays below 8MHz. Running your PIC at 3.3V makes things a lot easier.

Mustang1945 wrote:
then i connected tx and rx directly to SIM900 and i used this PIC with 2.5v,3v,3.5v,4v,4.5v,5v but didnt work
I hope you included some serial resistors when you applied the higher voltages? Otherwise there is a good chance you damaged the SIM900.

Quote:
, the SIM900 works from 3.2v to 4.8v(its in the sim900 datasheet)...but...in the PCB is marked 5v...and if i try to supply with less than 4.5v the module doesnt work
Yes, the SIM900 runs at 3.3V, but it is very common that an extra 5V to 3.3V converter was included on the PCB. This explains why a power supply of less than 4.5V shuts down the module.
Some manufacturers will have included interface logic to make the Rx and Tx lines 5V compliant, but when this is present it is often the cheap resistor solution that you have found to fail for the PIC (it does work great with the Arduino and Atmel chips as these have standard inputs instead of the Schmitt Trigger from the PIC).

Just have a look at the PCB and follow the traces from your Rx/Tx connector to the SIM900 module.
Are these direct connections? Then it most likely is a 3.3V connection. Verify with a Volt meter.
However, do you see some tiny SMD components on the traces, then these are diodes and/or resistors for a passive 5V interface.

Check your PCB and tell us your findings. We can try to help you from there.
Perhaps you can post a close-up photo of your PCB?
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Sat Oct 31, 2015 6:00 pm     Reply with quote

Sorry, i have been busy in my job, here is the website and the pictures there are better than mine:
http://www.sainsmart.com/sim900-gprs-gsm-board-quad-band-module-kit-for-arduino-high-quality-new.html

I also have found this:
http://simcom.ee/documents/SIM900/SIM900_Serial%20Port_Application%20Note_V1.03.pdf

In this pdf (page 7) talk about the level converter and says that the module works with 3v (page 6).

Please help me about the transistors, i am trying with 2n3904 but doesn't work. Do you know what could i use?

... finally i have being making some extra tests and i am sure that the manufacturer didn't include the converter 3.3 to 5v because:

I connect my PIC to rs232-usb interface (using max232) and it works, but...
I try to do the same with the sim900 but didn't work, then i comprehended that the module logic levels are not 5v.

HELP ME WITH THE TRANSISTORS PLEASE
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Nov 01, 2015 4:38 pm     Reply with quote

level converters:

Bi-directional 3.3v to 5v (and 5v to 3.3v):
https://www.sparkfun.com/products/12009
Also done with 2N7000:
http://www.hobbytronics.co.uk/mosfet-voltage-level-converter


Logic levels to RS-232 levels:
https://www.sparkfun.com/products/449
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue Nov 03, 2015 11:15 am     Reply with quote

Hi,

I posted essentially the same 'level translator' info in this thread back almost a month ago! I don't think that 's the problem!

I think the problem is much more fundamental than that... The OP seems to be confused about the hardware he's actually got! The lack of accurate documentation is not helping either! He seems to be confusing the fact that the 'SIM900' (that is the square component with the red/white label) is actually a SIM900 mounted to a board with a lot of support components, probably including a 3V power supply, and an RS-232-to-TTL converter. Because he's using a SIM900 already mounted to an interface board, the Simcom docs. may or may not be applicable as far as interfacing goes....

The 'raw' SIM900 module has a 3V UART on pins 9 & 10 of the module. Those pins probably go to a header, and then to a MAX232. The purpose of the header is to allow the MAX232 to be disconnected from the SIM900 so that either RS232 or TTL levels can be used for communication. In the absence of any accurate documentation, the OP is going to have to do some detective work to trace Pin 9 & 10 on the SIM900, and see where they actually go, and see how to isolate them from the MAX232. At this point, the level converters would be inserted between the PIC UART (running at 5V), and the SIM900 UART (running at 3V). At this moment, I don't think the OP has any idea where these pins/connections might be!
_________________
John

If it's worth doing, it's worth doing in real hardware!
Mustang1945



Joined: 07 Jul 2015
Posts: 31
Location: Ecuador

View user's profile Send private message

PostPosted: Wed Nov 11, 2015 1:10 pm     Reply with quote

PCM programmer and ezflyr...thanks for your help , i have been working in this all these days and all that ezflyr said about my confusion is true... also, you talk about level converters, the are very useful and would help me a lot in my tests, but unfortunately in my country don't sell that, here, those level translators are the typical device that you must buy in Amazon or Ebay.

but i know where is the problem:

I have been using the command get_string, and this command waits for a string until a CR is found, well... i read again the SIM900 AT manual and it says that the responses from the SIM900 have the format: <CR><LF>data<CR><LF> ...then i modified the library for use get_string until a LF is found, and testing in real hardware via PIC-RS232-TERATERM...it worked.

But...testing with the SIM900, no!!..i had the same problem...the SIM900 received the sms,went to the interrupt and never returned to main program.

Then...i read the AT manual again and i found that when a new sms arrives to the PIC the string has the format:

+CMT:[<alpha>],<lenght><CR><LF><data>

data is the message i send from my mobile, it means that the string doesn't end in CR neither in LF...thats the problem because get_string is waiting for an CR or LF that never arrives...

Now i am using getc to get a character that i send via sms and it works!!!.. the sim900 receive the sms, goes and return fro the interrupt.

Really for my project i must use a character and not a string, but i wanted to try get a string because is more interesting, and in some forums the people get the sms string using getc and then i said... if there is a library for get a string using get_string...why they are using getc???...
but the problem is that the sms doesn't end in CR or LF.

Do you have any idea for get the sms string without use getc?
There must be a way to do it.

i will continue making some tests but later because i am late with my project...

but i will try:
-"clear interrupt" inside the interrupt for return to main program.
or
-modified the get_string library for get string ended for example in... *
it means that i should send a sms like this : SPITFIRE* then get_string will detect the * and it could work.

what do you think?
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri Nov 13, 2015 8:58 am     Reply with quote

Hi,

Unfortunately, I think the likely outcome of this project has fallen from 'unlikely' to 'hopeless'..... I hate to sound so pessimistic, but your last post clearly suggests that you are willing to dismiss what appear to be some fundamental hardware-related issues with your project, and just blast ahead in an attempt to get *something* to work.....

First, we don't *really* have a 100% clear idea the actual SIM900 interface board you are using, and because of that we don't have access to the definitive documentation for the board. As such, everything is pure (but educated!) speculation!

To summarize: The actual SIM900 module on your 'SIM900 interface board' operates at 3.6V. The SIM900 interface board has a 3.6V regulator to power the SIM900 module. It also has a MAX232 interface to translate the 3.6V signals from the SIM900 module UART to RS232 levels. In order to connect your PIC, running at 5V, directly to the SIM900 module UART, you will need a 5V -> 3.6V translation in the PIC UART to SIM900 module direction, and a 3.6V -> 5V translation in the SIM900 module to PIC UART direction. This *fact* is inescapable even if level translators are not available in your country!

You will note that in the above description, I am now careful to use the terms 'SIM900 module', and 'SIM900 interface board' uniquely as they are NOT the same thing! Again, the 'SIM900 module' is the square item mounted to the 'SIM900 interface board' with the red/white label.

You *really* need to find the UART pins on the SIM900 module, and trace them on the SIM900 interface board to see where they go. You need to find a way to isolate these traces so that they DO NOT connect to anything on the SIM900 interface board. You then need to connect these traces to your PIC UART pins with the level translators in the middle. Again, levels translators can be as simple as an N-channel MOSFET and a couple of resistors. Surely these components are available right?

It is pointless to think about anything else until you can achieve the above. Once that is done, the next step is to send the command ''AT\r' from the PIC to the SIM900 module, and receive the 'OK' acknowledgement back. This will establish that you have successful serial COMMs between the PIC and the SIM900 module. Anything else is really pointless, and I cannot emphasize that enough!!!
_________________
John

If it's worth doing, it's worth doing in real hardware!
temtronic



Joined: 01 Jul 2010
Posts: 9253
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 13, 2015 10:07 am     Reply with quote

You should really post a GOOD, CLOSEUP picture of the 'module or board you're using.

Jay
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group