Go Down

Topic: Junk value receiving on serial monitor from modbus RTU ....URGENT PLZ HELP (Read 303 times) previous topic - next topic

terrorblade

Some body please help me. I have a secure Elite 440 energy meter.
I have tried to log into the meter using the following arduino code but unable to get anything sensible on serial monitor please check out the attachments.
I am using MAX 485 for the interfacing.

I have attached the memory map file of the meter and also the screen shot of the serial monitor.

PLZ HELP URGENTLY MY COLLEGE PROJECT FINAL DATES ARE APPROACHING TOOOOOO CLOSE I NEED TO GET IT DONE ANYWAY.

"
#include<ModbusMaster.h>
#define MAX485_DE 3
#define MAX485_RE_NEG 2
ModbusMaster secure_elite_440;
uint16_t resultMain;
 void preTx()
   {
     digitalWrite(MAX485_RE_NEG,0);
     digitalWrite(MAX485_DE,0);
   }
 void postTx()
   {
     digitalWrite(MAX485_RE_NEG,0);
     digitalWrite(MAX485_DE,0);
   }
 void setup()
 {
   pinMode(MAX485_RE_NEG, OUTPUT);
   pinMode(MAX485_DE, OUTPUT);
   digitalWrite(MAX485_RE_NEG, OUTPUT);
   digitalWrite(MAX485_DE, OUTPUT);
   Serial.begin(9600);
   secure_elite_440.begin(1, Serial);
   secure_elite_440.preTransmission(preTx);
   secure_elite_440.postTransmission(postTx);
 }
 void loop()
 {
    resultMain = secure_elite_440.readInputRegisters(0X40050,10);
    delay(100);
    if(resultMain == secure_elite_440.ku8MBSuccess)
     {
       for(int j = 0; j < 11; j++)
         {
           Serial.println("SECURE 440");
           Serial.println(secure_elite_440.getResponseBuffer(j));
         }
     }
 }"

AWOL

Code: [Select]
  Serial.begin(9600);
  Serial.println (F ("Ready..."));


Please remember to use code tags when posting code

pylon

Code: [Select]
    secure_elite_440.begin(1, Serial);

Code: [Select]
            Serial.println("SECURE 440");
            Serial.println(secure_elite_440.getResponseBuffer(j));


You're telling the ModbusMaster library that it may use the main serial interface for the Modbus communication but you also use the same interface to print out debugging information.

You must use a separate serial interface for the Modbus and for the communication with the PC. As the UNO has only one serial interface you should change the board. The Mega2560 has 4 serial interfaces while the Leonardo has a serial interface and internal USB capabilities for the communication to the PC. Both are viable products to use in your setup.

Robin2

PLZ HELP URGENTLY MY COLLEGE PROJECT FINAL DATES ARE APPROACHING TOOOOOO CLOSE
Everyone who asks a question is treated with the same "urgency". Don't expect to jump the queue just because you left it too late to start your college project.

Anyway, aren't your teachers paid to help with your problems?

Alternatively if this is something you are expected to work out for yourself to earn a grade then isn't it cheating to ask for help here?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

terrorblade

Code: [Select]
    secure_elite_440.begin(1, Serial);

Code: [Select]
            Serial.println("SECURE 440");
            Serial.println(secure_elite_440.getResponseBuffer(j));


You're telling the ModbusMaster library that it may use the main serial interface for the Modbus communication but you also use the same interface to print out debugging information.

You must use a separate serial interface for the Modbus and for the communication with the PC. As the UNO has only one serial interface you should change the board. The Mega2560 has 4 serial interfaces while the Leonardo has a serial interface and internal USB capabilities for the communication to the PC. Both are viable products to use in your setup.
Boss is there any method in which i can use uno for the project because getting an mega will fail the purpose of the project, i have been told to do it with the same serial port. My teacher said it is very possible and for many days i am trying to do it but now i donot see any hope and my end sem exams are also approaching now. Please tell me if there is any method to do it with same port. My teacher said some multiplexing logic i have to make but what is multiplexing logic here, what i read about multiplexer it is an ic for converting parallel lines to serial. How does it suits into this context

Paul_KD7HB

Are you the ONLY one with this specific project and teacher?

Paul

raymw

read up some more on multiplexing  https://www.bing.com/search?q=multiplex+signals&qs=n&form=QBLH&sp=-1&pq=multiplex+signals&sc=3-17&sk=&cvid=20DD9CE92C46432F904F8A06B0430DC9

use a timer, read one then 'tother. Stand on the shoulders of giants ;-)

terrorblade

Are you the ONLY one with this specific project and teacher?

Paul
Sir 3 more students are there in my group for this project but teacher is only one.
Those 3 are mainly dependent on me.
Thank you anyways sir

pylon

Quote
Those 3 are mainly dependent on me.
Bad for your group.

Quote
Boss is there any method in which i can use uno for the project because getting an mega will fail the purpose of the project, i have been told to do it with the same serial port. My teacher said it is very possible and for many days i am trying to do it but now i donot see any hope and my end sem exams are also approaching now. Please tell me if there is any method to do it with same port.
As long as you only write to the PC and never receive anything from there you might get it to work by simply holding DE LOW while writing debugging information. But using the same pins for different stuff is definitely not recommended and may lead to other errors.

Quote
but unable to get anything sensible on serial monitor
It might be worth to check the result code you get. Post the serial output you get!

Change the following line:
Code: [Select]
resultMain = secure_elite_440.readHoldingRegisters(0x40050,10);

The address numbering is often just to distinguish the holding registers from the input registers and everything above 40000 is usually a holding register.

terrorblade

I have tried to use interrupt and to read modbus only when serial communication is not happening between the PC and the controller and doing serial communication to PC only when modbus is not hapenning. BUT I am getting only 0 or 65535 in serial monitor. is it because meter is not connected to any load or some error is there atleast serial number model number or date something should come what is this. please help

pylon

Quote
I have tried to use interrupt
Bad idea. I haven't seen the code but that's definitely no use case for interrupts.

Quote
BUT I am getting only 0 or 65535 in serial monitor.
You should at least see also "SECURE 440" in the serial monitor. What return code do you get from the method call?

Go Up