1
完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好!我尝试用RS232将PIC18F97 J91与SIM900进行接口。我想上传一个小数据到服务器。我已经在PC机上从GSM端口到终端进行了并行连接,所以我可以看到从PIC发送到SIM900的命令和SIM900的响应。当端口没有连接到GSM,并且只连接到PC时,我可以看到从PIC到端口的命令,也可以从PIC接收到的PC终端发送“OK”。现在,如果我把端口连接到GSM,我在PC上看不到任何东西,虽然我有从PIC到GSM的并行连接,PC.if i直接连接SIM900到PC,并发送命令,SIM900用“OK”回答。输入数据。也就是说,如果我将PIC端口连接到PC终端,并发送“OK”作为PC的回复,那么我的代码就可以正常工作。如果我将SIM900直接连接到PC机,并在PC端发送命令,它就用“OK”回答。但是PIC和GSM一起没有给出预期的结果。我的代码检查GSM的一部分是在下面给出的:***int CHECKSOMODEME(){int ReCYMM=3,CHECK=0;同时(!)在rn“,GSMport”;Rexym -;ClultKSd();ClrWdTh();(tiCKS和LT;155);GSMDATA();STRNCMP(BUFG,“OK”,2){{ CHECK=1;/Modem=1;} }(String){String String((无符号char)”调制解调器“RN”,TEMPport);返回1;}否则{String String((无符号CHAR*)”调制解调器不好RN“,TEMPport”;返回0;} } *G*DATA,其中GSMDATAN读取从GSM(BUFG字符串)接收的数据。请帮我整理一下这个问题好吗?谢谢您。
以上来自于百度翻译 以下为原文 hi! I am trying to interface PIC18F97J94 with SIM900 using rs232. I want to upload a small data to a server. I have taken a parallel connection from GSM port to Terminal on PC, so I can see the commands sent to SIM900 from PIC and response of SIM900. when port is not connected to GSM, and is only connected to PC, I can see the commands from pic to port and can also send "OK" from PC terminal which is received at PIC. now if I connect port to GSM too, I can't see anything on pc although I have parallel connection from pic to GSM and PC. if I connect sim900 to PC directly and send AT commands, sim900 replies with "OK". means, i think as soon as the port is connected to SIM900, UART port on pic stops sending and receiving data. i.e. my code works fine if I connect pic port to PC terminal and send "OK" as reply from PC. Also, if I connect SIM900 to PC directly and send AT commands from PC terminal, it replies with "OK". but PIC and GSM together dont give expected result. part of my code to check GSM is given below: **** int check_modem() { int retrym = 3, check = 0; while(!check && retrym) { transmitString((unsigned char *) "ATrn", GSMport); retrym--; clearTicks(); ClrWdt(); while(ticks < 155); GSMDataN(); if(!strncmp(bufG , "OK" , 2)) { check = 1; //modem = 1; } } if(check) { transmitString((unsigned char *) "modem is okay rn", TEMPport); return 1; } else { transmitString((unsigned char *) "modem is not okay rn", TEMPport); return 0; } } **** where GSMDataN reads data received from GSM(bufG string). Can anyone please help me sort out the issue? thank you. |
|
相关推荐
5个回答
|
|
猜猜看?“臭虫”是操作员!您是否意识到不能将PC(终端)与任一设备并行?虽然RX没有问题,但是2条TX线并行导致了垃圾——如果不是设备损坏。如果您想使用PC来监视消息交换(只要通信严格是半双工),就必须“布线”和PIC-GSM RX和TX线,并将这个专用信号连接到PC RX。线。PC TX必须是开放的或可以用来提供电压的上拉(见下文)。TX,阳极连接到PC RX和一些上拉(如1K)。希望这有帮助,你还没有吹一个TX引脚。
以上来自于百度翻译 以下为原文 My guess? The "bug" is the operator! Are you aware that you CANNOT parallel the PC (terminal) with either device? While RX is no problem, paralleling 2 TX lines results in garbage - if not device destruction. If you want to use the PC to monitor message exchange (provided that communication is strictly half-duplex), you have to "wire-AND" the PIC - GSM RX and TX lines and connect this anded signal to the PC RX line. PC TX has to be left open or can be used to supply the voltage for the pull-up (see below). Anding can be achieved eg. with 2 diodes (cathodes at RX resp. TX, anodes connected to PC RX and some pull-up (eg. 1k)). Hope this helps and you didn't already blow one of the TX pins. |
|
|
|
我同意,在没有更多解释的情况下与TX并行,至少是有问题的。有些设备可以保持高线,或者违反标准,或者谁知道。因为我缺少RS232端口(基本上我没有XD),所以我通常做的是创建一个虚拟串行COM,然后使用一些虚拟串口来实现一个虚拟串行分路器。虚拟COM-让我们说,COM1 -可以与虚拟串行分配器-让我们说COM2 -所以你可以沟通两个外部设备使用您的计算机在中间。因为COM2也是一个分配器,所以它可以共享,所以你只需要在你的计算机中打开一个终端,连接到COM2端口,你就可以嗅到通信而不用触碰硬件。ErthLogic和ELTIMA软件有很好的虚拟串行COM模拟器。!因为它不返回“逻辑”值,所以使用STRNCMP。我的意思是,在我看来,如果它返回0,或者不是0(正),对我来说是很好用的!(很小心,因为它们仍然是有价值的值-C缺少真正的布尔类型-而且你永远不知道编译器能做什么——记住便携式代码)。但是如果我不记得坏,STRNCMP返回0, 1或1,所以我会比较= = 0。只是一个观点或偏好的问题。无论如何,如果你使用!这是编译器的选择,如何实现!对于那个操作(我不是指结果,而是如何完成和生成的代码),但是如果使用==0,它应该使用一个简单的比较,并且(希望)在PIC中应该是很少的指令(设置Z标志,BLA BLA)。无论如何,检查您的RS232连接,因为如果您可以接收/发送设备配对,但不是并行时,听起来像一些硬件问题。你使用的是RS22-TTL适配器吗?UB-RS232/TTL适配器?有线和?SIM900使用3V。你的PIC在5V吗?是使用一个真正的RS232收发器(+12,-12V)或一个USB - RS232/TTL适配器(5V?3V?)它们有共同的GND吗?这可能是一个很好的混合问题。
以上来自于百度翻译 以下为原文 I agreed, that paralleling TX without more explanation how it was done, is at least, problematic. Some devices can held lines high, or violating the standard, or who knows. Since I'm short of RS232 ports (basically I have none xD), what normally I do is a create a virtual serial com, and then a virtual serial splitter using some virtual serial port. The virtual com -let's say COM1- can be linked with the virtual serial spliter -let's say COM2- so you can communicate both external devices using your computer in the middle.. but because COM2 is also a splitter it can be shared so you only need to open a terminal in your computer connect to that COM2 port and you can sniff the communication without touching the hardware. Eterlogic and Eltima Software have nice virtual serial com emulators. About your code, I'd not use the ! with strncmp since it does not returns "logic" values. I mean, in my opinion, if it returns somevalue like 0 or not zero (positive), for me it's fine using ! (with care because they are still aritmetic values -C lacks of real boolean types- and you never know what the compiler can do -having in mind portable code-). But strncmp returns 0, 1 or -1 if i don't remember bad, so I'd compare with ==0. Just a matter of opinions/preferences. Anyway if you use ! it's the compiler choice how to implement the ! for that operation (I don't mean the result but how it's done and the generated code), but if you use ==0, it should use a simple comparation and (hopefully) in a PIC should be few instructions (setting the Z flag, bla bla). Anyway review your RS232 connections, because if you can receive/send with devices paired but not when they are in parallel that sounds like some hardware problem. Are you using a RS232-TTL adapter? USB-RS232/TTL adapters? wired-and? The SIM900 uses 3V. Is your PIC at 5V? are using a real RS232 transceiver (+12, -12V) or a USB-RS232/TTL adapter (5V? 3V?), do they share common GND? it can be a nice mix of problems. |
|
|
|
嗨,你为什么使用PIC18F97 J91?仅仅因为它有4个UART?你需要更多?一些图片有5个UART(PIC18F67 K40),甚至更多的PIC24FJXXGA4YY。你可以使用地图来选择PIC,它拥有你需要的UARTs数:HTTP://www. McCHIP.COM/MAPSSENTION:
以上来自于百度翻译 以下为原文 Hi, Why do you use PIC18F97J94 ? Just because it has 4 UARTs ? you need more ? Some PICs have 5 UARTs (PIC18F67K40) or even more PIC24FJxxGA4yy you can use MAPS to select the PIC which have as many UARTs as you need : http://www.microchip.com/MAPS Regards |
|
|
|
谢谢,DU000 00 01,我将避免并行使用端口。幸运的是,我没有销毁任何TX PIN。我的PIC在3.3 V,在插件模块上有用于RS232-TTL转换的ADM32 22,我使用UB-RS232适配器来连接PC.SIM900提供12V。而且,如果我将UART端口连接到仅GSM,则无法将数据传输到GSM。我没有收到任何东西,甚至没有错误信息。
以上来自于百度翻译 以下为原文 Thank you, du00000001, I'll avoid using ports in parallel. And fortunately, I have not destroyed any Tx pin. My PIC is at 3.3 V and there is ADM3222 for RS232-TTL conversion on the plug in module, I am using USB-RS232 adapter to connect with PC. SIM900 is supplied with 12V. Also, if I connect UART port to only GSM, it fails to transmit the data to GSM. I don't receive anything, not even error message. |
|
|
|
对不起,当你说“UART端口只到GSM”时,你是指PC串口还是PICUSAT引脚?如果你不知道这个问题,回到一个所有的工作都是从那里开始的情况:首先测试PC和GSM之间的通信。放弃GSM串行模块中的任何问题,测试PIC和PC之间的通信。您需要确保PIC工作正常,并且它使用的串行适配器没有问题,然后测试PIC和GSM之间的通信。在两种方式中,如果一切都正常工作,那么你可以尝试使用嗅探器(如其他帖子中所解释的并行连接)。如果它不工作,那么你知道问题在嗅探器中,可以肯定的是,它会阻止TX /RX线在某种状态下阻止设备。为了检测启动位等,我假设您有2个不同的串行模块,一个(ADM32 22)在GSM模块和其他的USB - RS232板上。ADM32 22是一个RS232收发器,它需要3.3V信号,并将它们转换成真正的RS232电平(在+/- 15或12V之间)。UB-RS232…它们的范围很广,有的具有真实的RS232电平,有的是RS232-TTL(或3V-TTL),所以它们只提供TTL电平信号。是你的RS22-TTL吗?如果是,并且连接两个模块,它们将不起作用,因为它们提供的级别不兼容,并且有一个改变可以损坏它们。
以上来自于百度翻译 以下为原文 Sorry, when you say "UART port to only GSM", do you mean the PC serial port or the PIC USART pins? If you don't know the problem, step back to a situation where all is working and start from there:
If it doesn't work then you know the problem is in the sniffer, could be anything but surely it will be helding the TX/RX lines in some state that prevents the devices to detect the start bit, etc. I assume you have 2 different serial modules, one (ADM3222) on board in the GSM module and other the USB-RS232. The ADM3222 is a RS232 transceiver, it takes 3.3V signals and translates them to real RS232 levels (between +/-15 or 12V). The USB-RS232.... there are a wide range of them, some with true RS232 levels others are RS232-TTL (or 3V-TTL) so they only provide TTL level signals. Is yours RS232-TTL? If yes, and you are connecting both modules they won't work since the levels provided by them aren't compatible, and there is a change you can damage them. |
|
|
|
只有小组成员才能发言,加入小组>>
5238 浏览 9 评论
2028 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3204 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
778浏览 1评论
666浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
595浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
677浏览 0评论
576浏览 0评论
小黑屋| 手机版| Archiver| 德赢Vwin官网 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-23 08:40 , Processed in 1.403769 second(s), Total 85, Slave 69 queries .
Powered by 德赢Vwin官网 网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
德赢Vwin官网 观察
版权所有 © 湖南华秋数字科技有限公司
德赢Vwin官网 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号