完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,我已经成功地用MAR47传送了一个主和一个从UART到PIC16F87A的消息-MAX87--------------------------------------------------------------------------------------------MAX-1688AN---PIC16F877 ANOW。我必须配置1个接收器和25个发射器(半DulpEX)单向传输不同的数据(单接收器)。ER)使用RS-485通信。如何编写程序?将数据从不同的发射机发送到单个接收机?——TS9
以上来自于百度翻译 以下为原文 Hi, I have communicated the One Master and One Slave with MAX487 Successfully over UART . PIC16F877A -----MAX487 ----------------------Media---------------MAX487 -----PIC16F877A Now I have to configure 1 Receiver and 25 Transmitters ( Half Dulpex ) one way transmission different data (on single receiver) using RS-485 communication. How to write program ? for sending data from different transmitters to single receiver ? -- TS9 |
|
相关推荐
19个回答
|
|
|
你如何确保一个只有25个将一次发送?你可以给他们每个人分配一个ID号,让接收者要求每个人发送数据,或者你可以让他们一次发送一个,每个人都看公共汽车看一个发送数据的WEN。如果其中一个失败了,可能会变得复杂,下一个就要超时了。无论如何,最好的解决方案取决于你的要求,你还没有完全指定。
以上来自于百度翻译 以下为原文 How will you make sure that only one of the 25 will transmit at a time? You could assign each of them an ID number, and get the receiver to ask each to send its data. Or you could get them to send one at a time, and each watch the bus to see wen the one before has sent its data. That could get complicated if one of them failed though, the next one would have to timeout and send anyway. The best solution depends upon your requirements, which you have not fully specified. |
|
|
|
|
|
25发射机和一个接收机?在RS485上不是那么容易。试试1个大师和25个奴隶。主人会一次一次地调查奴隶,另一方面并不是那么简单。
以上来自于百度翻译 以下为原文 25 transmitter and one receiver? Not that easy on RS485. Try 1 Master and 25 slaves. The Master will poll the slaves one at a time for data. The Other way is not so simple. |
|
|
|
|
|
嗨QHB和NKurzman,感谢更新…将附加工作在矿山案件?谢谢——TS9
以上来自于百度翻译 以下为原文 Hi qhb and NKurzman, Thanks for update.. Will attach work at mine case ? Thanks -- TS9 Attachment(s) RS-485 Send and Rec.txt (1.34 KB) - downloaded 268 times |
|
|
|
|
|
|
|
|
|
|
|
谢谢QHB。但是为什么呢?我需要什么改变?请教
以上来自于百度翻译 以下为原文 Thanks qhb.. But Why ? What Change do I need ? Please Advice |
|
|
|
|
|
如果你对代码的注释稍微好一点,我可能会把我的答案扩大一点。你只粘贴了两块代码,很少有帮助的注释,而且似乎根本没有处理我的文章或NKurzman的文章中的要点。
以上来自于百度翻译 以下为原文 If you comment your code a bit better, I might extend my answer a bit more. You just pasted two slabs of code, with few helpful comments, and don't appear to have addressed the points in my post or NKurzman's at all. |
|
|
|
|
|
请检查一下…添加注释和地址方案。
以上来自于百度翻译 以下为原文 Please Check this... Added Comments and Address Scheme. Attachment(s) RS-485 Send and Rec1.c (2.01 KB) - downloaded 215 times |
|
|
|
|
|
|
|
|
|
|
|
你不明白我们说的话吗?你只需要一小部分代码来实现你所描述的。你所做的只是展示你如何打包数据,没有提到你将如何避免我们提到的问题。你说你需要25个发射机,但是只有三的硬编码。你没有做任何事情来确保每次只有一个发送器正在驱动总线。你的发射机代码。甚至从不将缓冲区转换为传输模式,所以它们都会同时试图驱动总线。你的接收代码假定它与传输代码完全同步。如果你不向发射机发送请求,你怎么能确定接收到的下一个字节是包中的第一个字节。如果发射机在接收机前开始运行会发生什么情况?你没有提到你需要多长时间发送这些数据。发射机是否只发送数据包,或者是连续的?
以上来自于百度翻译 以下为原文 Did you simply not understand anything we said? You posted only a tiny fraction of the code that would be required to implement what you describe. All you have done is show how you would packetise the data, with no mention of how you would avoid the issues we mentioned. You say you want 25 transmitters, but have hard coded for only three. You have done nothing to make sure only one transmitter is driving the bus at a time. Your transmitter code never even switches the buffers out of transmit mode, so they will all by trying to drive the bus at the same time. Your receive code assumes it is perfectly in synch with your transmit code. If you're not sending a request to the transmitter, how can you be sure the next byte received is the first in a packet. What happens if your transmitter starts running before your receiver? You have not mentioned how often you need to send this data. Do transmitters only send packets now and then, or is it continuous? |
|
|
|
|
|
您好QHB,请检查我的答复如下:现在我想是的……我提到三,同样的方式,我必须使用25个发射机。我怎么能做到这一点?这是我所要求的。你的接收代码假设它与你的传输代码完全同步。如果你不向发射机发送请求,你怎么能确定接收到的下一个字节是包中的第一个字节。但使我=0。并且复制零个值作为地址字节的第一个数组元素..这正是我要问的吗?或要求用户首先在RevEVER比传输。使用键盘键…片刻之后的几秒钟。不连续的它将保存数据外部锁存器(CD4049)用于显示。请建议…我怎样才能实现它?——TS9
以上来自于百度翻译 以下为原文 Hello qhb, Please check my reply as below: Now I think Yes.. As I mention for three,Same Way I have to use for 25 transmitters. How I can do this..? This is exaclty what I am asking.. Your receive code assumes it is perfectly in synch with your transmit code. If you're not sending a request to the transmitter, how can you be sure the next byte received is the first in a packet. Not Sure ... But making i=0. And copied 0th value as first array element for Address byte.. This is exaclty what I am asking ? or ask user to first on recevier than transmittier. Using Keyboard Keys... After A while of seconds. Not continuous. It will save data External latchs like(CD4094) for Display. Please advice.. How I can implement it....? --TS9 |
|
|
|
|
|
好的,我们需要备份几个步骤,并尝试首先覆盖基础。只有一个发射器一次可以激活。所有其他的都必须被禁用。你的发射机PICS和RS485缓冲器上的缓冲区发送使能信号之间有连接吗?
以上来自于百度翻译 以下为原文 ok, we need to back up a few steps, and try to cover the basics first. Only one transmitter can ever be active at a time. All the others must be disabled. Do you have a connection between your transmitter PICs and the buffer transmit enable signal on the RS485 buffers? |
|
|
|
|
|
在发射机PICS和RS485缓冲器上的缓冲区发送使能信号之间有连接吗?对于PIC单片机的MX48和RD7,我只绑定了引脚2和3。在接收时选择传输方向,请检查附件。
以上来自于百度翻译 以下为原文 Do you have a connection between your transmitter PICs and the buffer transmit enable signal on the RS485 buffers? I have only tied pin 2 and 3 for MAX487 and RD7 of PIC MCU . For Direction select either for transmission on reception. Please check attachment... Attached Image(s) |
|
|
|
|
|
好,所以你用RD7U控制方向,现在需要添加一些代码来打开缓冲区,发送一个数据包,等待最后一个字符完成发送,然后再次关闭缓冲区(即将其切换回接收模式)。你需要使用TrMT位来做这件事。你的数据仅仅是ASCII字符吗?在数据包的起始处放置一个不可能出现在数据中的字符是一个好主意。这样,接收器可以很容易地检测到包的开始。
以上来自于百度翻译 以下为原文 ok, so you're controlling the direction with RD7 You now need to add some code to turn the buffer on, send a packet, wait for the last character to finish sending, then turn the buffer off again (i.e. switch it back to receive mode). You will need to use the TRMT bit to do this. Is your data just ASCII characters? It would be a good idea to put a unique character at the start of your packet that cannot occur in the data. Probably something with the top bit set. That way the receiver can easily detect the start of a packet. |
|
|
|
|
|
嗨,谢谢QHB……我有如下的爱好:1)启用MAX472(包的发送开始(特殊)3),发送地址(4)发送数据DATA(发送数据DATA2)发送数据包(特殊的)启动8)。我不知道使用TrMT位从传输。请检查附件和建议- TS9
以上来自于百度翻译 以下为原文 Hi, Thanks qhb... I have do like below: 1) Enable MAX487 2) SENT START OF PACKET (Special) 3) SENT ADDRESS 4) SENT DATA1 5) SENT DATA2 6) SENT DATA3 7) SENT START OF PACKET (Special) 8) Disable MAX487 For One Transmitter only. I have no idea to use TRMT bit from Transmission. Please check attachment..and advice -- TS9 |
|
|
|
|
|
为什么要在包的末尾发送特殊的起始字符?这就破坏了显示包开始的效用。只需在PIC的数据表中搜索TrMT位。
以上来自于百度翻译 以下为原文 Why would you send the special start character at the end of the packet? That destroys the utility of it showing the START of the packet. Just search in the datasheet of your PIC to see what the TRMT bit does. |
|
|
|
|
|
在示意图中,我丢失了发射机的R线,还有接收器的T线。我建议你们总线需要硬件中的所有导线。发射机必须监听总线电平。接收方必须发送发射机获得的正确的T- ID。利用这个,您可以创建一个分时器,或者多路复用。这是用同步传输。Asynchron将是发射机侦听总线,如果空闲,他发送一个启动字节并侦听失真。在电线上。如果总线真的是空闲的,那么他发送完整的数据帧,然后发送器终止总线并进入监听模式。如果不是,发射机必须立即终止总线并进入监听模式。节点之间的距离有多长?如果它们很长,你也会寻找总线定时。这就是我所想的。
以上来自于百度翻译 以下为原文 In the schematic I'm missing the R wire of the transmitters, also the T wire of the receiver. I would suggest you that the bus needs all wires in the hardware. The transmitter must listening the bus level. The receiver must send the T-ID that which transmitter gets the right to send. With this you can create an Arbiter with time sharing, or multiplexing. That is with synchron transmission. Asynchron would be that the transmitter listen the bus, then if free he sends one start byte and listen for distortions on the wire. - e.g. LAN If the bus really is free, then he sends the complete data frame. After that the transmitter terminate the bus and go to listening mode. If not, immediately the transmitter must terminate the bus and go to listening mode. How long are the distances between the nodes? If they are long you look for bus timing too. That's what i think about. Gerald --- |
|
|
|
|
|
总线监听-所有的发射机都必须这样做。这就是我所想的。总线通信可以有两层或三层。也见朗格拉德
以上来自于百度翻译 以下为原文 Bus listening - all transmitter have to do this. That's what i think. The bus-communication can have two or three layers. -> see also LAN Gerald --- |
|
|
|
|
|
您好QHbLo..从PIC16F87A数据表-页面111TrMT:发送移位寄存器状态BIT1= TSR EMPTY0= TSR从PIC16F877 A数据表-页28 TXIF:USAT传输中断标志BIT1= USAT传输缓冲器为EMPTY0= USAT传输缓冲器已满但我从不使用TrMT位用于任何应用程序在下面……TS9
以上来自于百度翻译 以下为原文 Hello qhb Read.. From PIC16F877A Datasheet -page 111 TRMT: Transmit Shift Register Status bit 1= TSR empty 0= TSR full From PIC16F877A Datasheet --page 28 TXIF: USART Transmit Interrupt Flag bit 1= The USART transmit buffer is empty 0= The USART transmit buffer is full But I never use TRMT bit for any application. Is below the way... void SerialTransmit(unsigned char c) { while(PIR1bits.TX1IF && TXSTA1bits.TRMT ); TXREG=c; } -- TS9 |
|
|
|
|
|
所有真实的杰拉尔德,但我认为你在这一阶段的理解之外还有几个步骤。我们将不得不采取这一小步骤。
以上来自于百度翻译 以下为原文 All true Gerald, but I think you're several steps beyond what this OP understands at this stage. We're going to have to take this in small steps. |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473 浏览 0 评论
5793 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1122浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1095浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
872浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
473浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 21:55 , Processed in 1.139005 second(s), Total 110, Slave 93 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2953