Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:43 04 Jul 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 : uMiteII IEEE 485 Example Code

Author Message
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 06:52am 14 Jan 2015
Copy link to clipboard 
Print this post

Hi All;

I've been experimenting with IEEE485/RS485 interfaces between a pair of uMiteIIs on a plugboard.
1. Using EXAR SP485E interface chips. These seem to be working fine.
2. Using COM1:
3. /DE is inverted to DE using a 2N7000 MOSFET.
4. /RE is grounded, (Although I have also tried connecting /RE to DE).

I'm not a "Software guy", pretty good at hardware though.
My "test goal" is to have each uMiteII read 2 i2c RTC clocks and compare them. The clock stuff works perfectly.
I'm now just attempting to just send and catch individual characters.
The master program just spits out 1 character every second.
'RS485ClockMaster1.bas
Start:
option autorun on
cpu 40
'OPEN "COMn: baud, buf, int, intlevel, DE, 9BIT, INV, OC, S2"
open "com1: 300,DE" AS #1
setpin 6, DOUT
Again:
PRINT #1, CHR$(65);
pin(6)=1:pause 500:pin(6)=0:pause 500
GoTo Again

The slave program should catch each character and send them to the console.
'RS485ClockSlave1.bas
Start:
option AUTORUN on
cpu 40
'OPEN "COMn: baud, buf, int, intlevel, DE, 9BIT, INV, OC, S2
open "COM1: 300, DE" AS #1
setpin 6, DOUT
Again:
IF LOC(1) >= 1 THEN ' check that we have at least one byte
pin(6)=1
A$ = INPUT$(1,1)
' Send the character to the console
print "<Lenth of A$=";len(A$);"><ASCII Code of A$=";ASC(A$);"><A$=";chr$(34);A$;chr$(34);">"
ENDIF
pin(6)=0
GoTo Again

However, it only sends this once and gets stuck.
> RUN
<Lenth of A$= 1><ASCII Code of A$= 0><A$="

This happens only once after the code is flashed.
I get nothing after a reset or a "RUN" command, it's just stuck.

Are there any "Running" code examples?
Something I can use to at least get things running?
The example in the manual is just a code snippet.

redrok
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 08:23am 14 Jan 2015
Copy link to clipboard 
Print this post

Hi redrok,

A couple of questions:

1> What is pin 6 connected to on the master and slave? (An LED maybe to act as a visual indicator??)
2> The print command on the Master ends in a semicolon. Could this be impacting on any other hardware (by it suppressing the CR & LF characters?
3> Is there any way you can test this without DE (to help eliminate things)?

WW
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2932
Posted: 08:38am 14 Jan 2015
Copy link to clipboard 
Print this post

Ok - been reading more about this . . .

One bit in the manual that stands out with your symptoms:
  Quote  
MMBasic does not check that data is printed or read to/from the COM port in pairs. If your program inadvertently sends or reads a single character it will disrupt all subsequent communications.


Have you tried using the example in the manual with 9bits (and byte pairs)?

WWEdited by WhiteWizzard 2015-01-15
 
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 04:01am 15 Jan 2015
Copy link to clipboard 
Print this post

Hi WhiteWizzard;
1. Yes, pin 6 is just an experimental LED indicator.
2. Apparently the tools I'm using, "MM Edit" & "TeraTerm", don't mind not having terminators. At least I haven't seen any problems.
3. I did try disabling DE, made DE high, to make sure the SP485E interface chips were working properly. They were apparently working well.
4. I did try the 9 bit method but that didn't work either.

But I did finally solve the problem. Actually 2 problems.
A. I had to add the "INV" invert parameter on both ends.
B. The master was over running the slave. Adding a small pause in the master allows the slave to process the characters it catches.

Ok, now that I have the physical layer running, at least in one direction, I can go on to the data link layer with addressing and data framing.

One question though, Why do I need the "Invert" parameter?
It would seem that if both ends are the same polarity the data would get through.
Apparently not true, but why?

redrok
 
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