Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:46 11 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : RS-485

Author Message
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 01:21am 24 Mar 2018
Copy link to clipboard 
Print this post

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]Edited by Phil23 2018-03-25
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3308
Posted: 02:41am 25 Mar 2018
Copy link to clipboard 
Print this post

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: Thailand
Posts: 2209
Posted: 04:05am 25 Mar 2018
Copy link to clipboard 
Print this post

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 States
Posts: 600
Posted: 09:53am 25 Mar 2018
Copy link to clipboard 
Print this post


@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: Australia
Posts: 1667
Posted: 08:28pm 25 Mar 2018
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 4126
Posted: 09:59pm 25 Mar 2018
Copy link to clipboard 
Print this post

  Phil23 said   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.


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: Australia
Posts: 1667
Posted: 04:23am 26 Mar 2018
Copy link to clipboard 
Print this post

  JohnS said  
  Phil23 said   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.


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


@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: Thailand
Posts: 2209
Posted: 04:52pm 26 Mar 2018
Copy link to clipboard 
Print this post

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: Australia
Posts: 195
Posted: 11:42pm 26 Mar 2018
Copy link to clipboard 
Print this post

  Phil23 said  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.


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: Australia
Posts: 1667
Posted: 12:30am 27 Mar 2018
Copy link to clipboard 
Print this post

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.



 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025