Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 07:49 10 May 2024 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 : RS232 Problem

Author Message
Martrogers
Newbie

Joined: 03/07/2016
Location: Australia
Posts: 4
Posted: 10:09am 12 Mar 2017
Copy link to clipboard 
Print this post

Hello All

I would like to interrogate my house Orion solar inverter in order to log the output of my solar cells on an hourly basis. This will help me make a decision on whether to purchase additional solar cells and also to determine at what cost a battery would be economic.The inverter has a RS232 interface and the protocol is published on the web.

I have the Micromite set up as per the manual with 10k resistor and diode (although I have tried slightly different resistors and diodes to no effect).

When the program is run the inverter responds to the Query Network command albeit after 2 attempts and the MM displays the hex reply. The inverter responds twice but the MM only picks up the second reply. The problem is that the MM will not display any further replies from the inverter.

When I connect the MM Rx to my laptop RS232 probe I can see that the inverter is replying to all requests so the MM is sending the request correctly, but the MM is not picking up the response.

For simplicity I have only attached this first part of the program but the same problem occurs with further requests to the inverter, the inverter replies but the MM will not display the reply.

Any help would be much appreciated.

Regards
Martin



2017-03-12_200043_Solar_Inverter.zip
 
led-bloon

Senior Member

Joined: 21/12/2014
Location: Australia
Posts: 203
Posted: 11:29am 12 Mar 2017
Copy link to clipboard 
Print this post

<deleted>
Re-read your code and you seem to handle INPUT$ correctly!
Edited by led-bloon 2017-03-13
Miss you George
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5917
Posted: 12:08pm 12 Mar 2017
Copy link to clipboard 
Print this post

A link to the protocol would help.

You are not waiting long enough for the response to arrive before re-sending the command.
This will probably end up with the response being part of one reply and the start of the next reply etc.
You should send the command once and then wait for all the expected data to arrive before re-sending the command.

  Quote  
OPTION BASE 1
OPEN "COM1:9600, INV" AS #1

aa$=
""
q$=
""
m$=
""

attempts=
0
DO

'Initialise
PRINT #1, CHR$(170);
PRINT #1, CHR$(170);
PRINT #1, CHR$(1);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(4);
PRINT #1, CHR$(0);
PRINT #1, CHR$(1);
PRINT #1, CHR$(89);

PAUSE 100
'Query Network
PRINT #1, CHR$(170);
PRINT #1, CHR$(170);
PRINT #1, CHR$(1);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(1);
PRINT #1, CHR$(85);

PAUSE 500 ' wait long enough for the data to arrive ******
attempts=attempts+1
q$=
INPUT$(21, #1)
LOOP UNTIL LEN(q$)=21

PRINT "query response attempts " attempts
PRINT "query response start"
FOR w=1 TO 21
v$=
HEX$(ASC(MID$(q$,w,1)))
PRINT v$ +" " ;
NEXT w
PRINT
PRINT "query response end"

attempts=
0
PAUSE 100
DO

'Assign address to serial
PRINT #1, CHR$(170); 'send command to inverter
PRINT #1, CHR$(170);
PRINT #1, CHR$(1);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(0);
PRINT #1, CHR$(1);
PRINT #1, CHR$(11);
PRINT #1, CHR$(49);
PRINT #1, CHR$(48);
PRINT #1, CHR$(48);
PRINT #1, CHR$(51);
PRINT #1, CHR$(85);
PRINT #1, CHR$(48);
PRINT #1, CHR$(48);
PRINT #1, CHR$(55);
PRINT #1, CHR$(50);
PRINT #1, CHR$(54);
PRINT #1, CHR$(1);
PRINT #1, CHR$(3);
PRINT #1, CHR$(122);

PAUSE 500 ' wait long enough for the data to arrive ******
aa$=INPUT$(12, #1) 'receive reply from invertor
attempts=attempts+1
LOOP UNTIL LEN(aa$)=12


PRINT "address response attempts " attempts
PRINT "address response start"
FOR w=1 TO 12
v$=
HEX$(ASC(MID$(aa$,w,1)))
PRINT v$ +" " ;
NEXT w
PRINT
PRINT "address response end"



CLOSE #1



I have added two 500mS delays (way too long but I don't know how quickly the unit waits before replying with data).
This is a cheap and nasty way to get the data in one bite.

Jim

VK7JH
MMedit   MMBasic Help
 
Martrogers
Newbie

Joined: 03/07/2016
Location: Australia
Posts: 4
Posted: 10:45pm 12 Mar 2017
Copy link to clipboard 
Print this post

Jim

Thank you so much - works perfectly now.

Regards
Martin
 
Print this page


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

© JAQ Software 2024