Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:25 06 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 : Maximite - Picaxe, Serial / RS485 Comms

Author Message
nasi
Newbie

Joined: 08/07/2015
Location: Australia
Posts: 16
Posted: 05:44pm 01 Oct 2016
Copy link to clipboard 
Print this post

Hello All

This is my first post, I apologize in advance if there is a thread already covering this, however extensive browsing has eluded me to some light of help.

I am attempting to build an rs485 network around my house to control and monitor various attributes of our off grid setup.

My micro controllers of choice are maximites and picaxes as I have a surplus in the workshop.

So to cut to the chase I am struggling with Sending data from a maximite to a picaxe.
I have been reading the SNAP / Scaleable Node Address Protocol for inspiration and have had some success.

Currently I have been able to accurately control a picaxe 08m2+ with 4 relays no problems
I then increased the RS 485 network to a third node with a picaxe 18m2+
I practically took the same code from the 08m2+ and modified it to reflect the 18m2+ configuration.

The pickle I am in is that for some reason the 18m2+ simply does not want to co-operate in the same fashion as the 08m2+ which is weird and I am messing with baud rates, pauses and chip freq without any idea why the 18m2+ under the same environment will not logically function.

The issue seems to be centered around the serin command

--------------------------------------------------------
08m2+

serin 3,T4800,(SYNC),HDB2,HDB1,DAB1,SAB1,DB1

'debug


18m2+

serin b.6,T4800,(SYNC),HDB2,HDB1,DAB1,SAB1,DB1

debug

--------------------------------------------------------

The basic bytes of data I change respectively to poll the nominated controller.
As I said the 08m2+ works great if I remove the qualifier brackets for the 18m2+ when debugging I can get some data in but it comes through wrong the sync byte may sometimes show up correctly or in the wrong variable but its so inconsistent.

I have removed the 08m2+ from the equation to just test between the maximite and the 18m2+ still no success.

Anyway I hope this is enough info to get started and I appreciate anyones input.

Once again apologies for any lack of forum etiquette on my part.

PS, I am using the little MAX 485 modules
Link here should provide an image of the module:

http://www.aliexpress.com/item/Precise-MAX485-Module-RS-485-TTL-to-RS485-MAX485CSA-Converter-Module-For-Arduino-Integrat ed-Circuits-Products/32309776786.html

Happy to provide more info if needed.

Cheers Ladys and Gents

Richard
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 06:09pm 01 Oct 2016
Copy link to clipboard 
Print this post

Hello and welcome.

Some users have found that a delay between bytes is helpful when sending from maximites/micromites to picaxes
Using two stop bits is the easiest way to achieve the delay.

I am not sure if the above is relevant for rs485.

Jim
VK7JH
MMedit
 
nasi
Newbie

Joined: 08/07/2015
Location: Australia
Posts: 16
Posted: 06:17pm 01 Oct 2016
Copy link to clipboard 
Print this post

Jim

Thank you very much for such a prompt reply.

Forgive me could you elaborate on how you would implement the stop bits,

My MM code for testing is as:

--------------------------------------------------------------------


Dim DBYTE(5)

DBYTE(0) = 250 ' SYNC BYTE
DBYTE(1) = 80 ' HEADER DEFINITION BYTE 2
DBYTE(2) = 1 ' HEADER DEFINITION BYTE 1
DBYTE(3) = 50 ' DESTINATION ADDRESS BYTE
DBYTE(4) = 255 ' SOURCE ADDRESS BYTE
DBYTE(5) = 1 ' DATA BYTE (COMMAND / FUNCTION / DATA)

menu:
Cls
Print "1, Send Packet"
Print " "
Print "6, Quit Program"
Print " "

Input cmd
If cmd = 1 Then Send_PCKT
If cmd = 6 Then End
Cls
End
EndIf
GoTo menu

Sub Send_PCKT

Open "com1:4800, DE" As #1

For i = 0 To 5

Print #1, Chr$(DBYTE(i));
'Pause 50

Next
Close #1
GoTo menu

End Sub

--------------------------------------------------------------------

Thanks again Jim


 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 235
Posted: 06:30pm 01 Oct 2016
Copy link to clipboard 
Print this post

hi Nasi

This is a sample program I used to send data to a picaxe 14m2 (oled display 4 Line)

[code]
OPEN "COM1:2400, INV, S2" as #1
pause 30
Print #1,chr$(254) + chr$(1);
pause 30
Print #1,chr$(254) + chr$(128); ' line 1
Print #1,"Hello world ";
Print #1,chr$(254) + chr$(192); ' line 2
Print #1,"What a great Day";
Print #1,chr$(254) + chr$(148); ' line 3
Print #1,"to be alive";

[/code]

BillEdited by Bill.b 2016-10-03
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
nasi
Newbie

Joined: 08/07/2015
Location: Australia
Posts: 16
Posted: 06:43pm 01 Oct 2016
Copy link to clipboard 
Print this post

Bill Thank you

And Thank you also Jim.

It does seem impossible until it's done.

 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 06:54pm 01 Oct 2016
Copy link to clipboard 
Print this post

I am not sure what the DE line does between characters of if it matters.
Here are two options to try
The first is your code with S2 in the initialise string. You can play with the pause between characters as I assume you have been doing.

The second builds the data into a string and then sends it in one go. This way the DE control line behaves as I think it should.
  Quote  
OPEN "com1:4800, DE, S2" AS #1
FOR i = 0 TO 5
PRINT #1, CHR$(DBYTE(i));
'Pause 50
NEXT
CLOSE #1

' make a string of the data to send first
toSend$=""
FOR i = 0 TO 5
toSend$=toSend$+
CHR$(DBYTE(i))
NEXT i

' send it in one go
OPEN "com1:4800, DE, S2" AS #1
PRINT #1, toSend$;
'Pause 50
CLOSE #1


Jim
VK7JH
MMedit
 
nasi
Newbie

Joined: 08/07/2015
Location: Australia
Posts: 16
Posted: 07:26pm 01 Oct 2016
Copy link to clipboard 
Print this post


S2....

ahhh ok of course thats in the manual, :)

Jim thank you for this.
I will experiments and see how I go.

Thank you again also Bill.

 
nasi
Newbie

Joined: 08/07/2015
Location: Australia
Posts: 16
Posted: 11:55pm 01 Oct 2016
Copy link to clipboard 
Print this post

I figured it out Gents.

Just to give you some feedback.

It ended up being these ttl to RS485 modules.

I picked up a bunch of them online for cheap and it is starting to look as though they have somewhat of a failure rate.

But thank you all anyway.

Look forward to threading more in future.

Hopefully I can return the favour.
 
redrok

Senior Member

Joined: 15/09/2014
Location: United States
Posts: 209
Posted: 11:10am 02 Oct 2016
Copy link to clipboard 
Print this post

Hi nasi;
  nasi said  It ended up being these ttl to RS485 modules.

I picked up a bunch of them online for cheap and it is starting to look as though they have somewhat of a failure rate.
What RS485 modules are you using?
I have been just using EXAR SP485 and SP485E chips.
redrok
 
nasi
Newbie

Joined: 08/07/2015
Location: Australia
Posts: 16
Posted: 03:34pm 08 Oct 2016
Copy link to clipboard 
Print this post

I sent you a private message Redrok

Apologies in advance if breaking etiquette.

I will check out those chips, I picked these other units as they are fairly ready to hook up and obviously cheap.

Look forward to speaking more.

Cheers

Richard
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 235
Posted: 04:07pm 08 Oct 2016
Copy link to clipboard 
Print this post

Hi nasi

When I connected a pic32mx170 to C5 (pin4) of the 14m2, I did not use any
interface modules.
I connected the output of the 170 via a 100ohm resistor to the input
of the 14m2 and all worked OK.

BillEdited by Bill.b 2016-10-10
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
nasi
Newbie

Joined: 08/07/2015
Location: Australia
Posts: 16
Posted: 09:48pm 08 Oct 2016
Copy link to clipboard 
Print this post

Hey Bill

I have not done much Pic programming in C but that sounds very interesting.

I was concerned about the distance that data could be sent as I need to send around my property up to a possible 100m

I have connected some of these micro controllers up directly at TTL levels but I was under the assumption they could not handle long runs nor was it safe to do so just in case of cable potential buildup.

Please correct me if I am wrong.

Speak again soon

Richard
 
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