|
Forum Index : Microcontroller and PC projects : RS-485
| Author | Message | ||||
| Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Hi All, Have a few of these modules. Presume I can't directly connect them straight to a 28 pin chip. [Quote=MicroMite Manual] The 'DE' option in the OPEN comspec$ for COM1: specifies that the Data output Enable (ENABLE) signal for the IEEE 485 protocol will be generated. This signal will appear on pin 7 on the 28-pin chip and is normally high. Just before a byte is transmitted this output will go low and when the byte has finished transmission the output will go high again. Note that this polarity is the opposite of that used in the Maximite family and an inverter is normally required to drive the DE input of an IEEE 485 transceiver. [/quote] Is it at all possible to invert this signal in software to avoid the additional device? I know Geoff wrote a C-Function to manipulate the state of certain pins. Is that relevant in this case? Would be nice if the MAX485 could just be directly connected. Thanks Phil. Edit:- ChangePin is the embedded C-Function I was thinking of. [Quote]7 LATINV Invert digital output[/quote] |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
No, unfortunately you are stuck. The inverted polarity of the DE pin is a 'feature' of the PIC32 hardware that MMBasic uses and annoyingly cannot be changed. Using the ChangePin CFunction also will not help. The LATINV parameter will flip a pin into its opposite state (ie, a hi to a lo). It does not invert the data. Geoff Geoff Graham - http://geoffg.net |
||||
MicroBlocks![]() Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
These are easy to use and require not much space: http://www.onsemi.com/PowerSolutions/product.do?id=MC74VHC1GT04 Microblocks. Build with logic. |
||||
Quazee137![]() Guru Joined: 07/08/2016 Location: United StatesPosts: 600 |
@MicroBlock I agree those are great. but if you don't have and need to test now go old school ![]() Quazee |
||||
| Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
What about using an alternate pin to "fake" DE? Would something like this work, if Pin 6 was connected to the DE of the MAX485. [Code] Open "Com1:9600,,RecData,1,DE" As #1 .. .. .. .. Pin(6)=1 Print #1, ReqFrame; Pin(6)=0 [/code] Phil. |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4126 |
The general idea may work (I don't know) but I think that example will not - because the Print #1, ReqFrame will still be sending chars from the internal buffer when the pin is set low. If it is to work I think you'd have to wait for the buffer to be empty before dropping the pin. I think MMBasic does let you test for the buffer being empty. I'm not sure if you'd also need to add a small delay? (To make sure the char transmission has finished.) John |
||||
| Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
@Geoffg, would it be possible to do something like this with an embedded C-function that allows another pin to follow Pin 7, but in an inverted state? Phil. |
||||
MicroBlocks![]() Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
It is kind of weird that that signal needs to be inverted. Are there no other chips for 485 that accept this without the need of an inverter. Microblocks. Build with logic. |
||||
| erbp Senior Member Joined: 03/05/2016 Location: AustraliaPosts: 195 |
Phil. Phil, If you have 2 pins spare you could handle this in your code without the need for a C-Function. Assign one pin as a Digital Input and connect it to the DE pin (7). Assign the second pin as a Digital Output. In your code add an Interrupt on the Input pin activated on both Hi and Lo transitions, and in the interrupt handler just set the output pin to the opposite polarity of the input one - so it becomes the DE inverted pin to connect to your RS-485 module. It would add a very small delay to the DE signal transitions, not sure it this might cause any problems at the start of transmission. Maybe you would need to transmit a dummy character at the start of the real data just in case the first character gets missed due to any DE latency. Cheers, Another Phil. |
||||
| Phil23 Guru Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
Thanks, Also some alternate Modules arrived yesterday. These, https://www.aliexpress.com/item/TTL-turn-RS485-module-485-to-serial-UART-level-mutual-conversion-hardware-automatic-flow -control/32709226383.html?spm=a2g0s.9042311.0.0.0pGBWV They might be easier to live with as they handle the flow control themselves. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |