Using max485 to interface energy meter with arduino.

Hello I generally have a lot of trouble when trying to interface a new device with the arduino
"Sensors , communication devices ,etc"
My energy meter has an option to read data using rs-485 communication, I connected the pins 'A' and 'B' to the max-485 directly and the all the other connections to the arduino and power connections.

Now the problem is that I want to print out the readings from the meter on the serial monitor HOW CAN I DO THIS

the datasheet of the energy meter is 2 pages long. Very unhelpfull. If anybody can help me out or lead me the right way I would really appreciate it XD XD XD.

This is not going to work. We don't work this way. Post a schematic and code.

I thought the circuit described was pretty simple and clear.

For the schematic I copied the exact same connections in the following figure plus the A and B connections to the A,B ports on max 485

and as for the code: all the codes that i wrote where unhelpful, so seeing my code isn't gonna change anything cause either way i'm gonna have to write it all again from scratch.

**again i only want to output the readings from the energy meter which are inserted into ports A, B on the max485, on the serial monitor **

Here is code if it helps although I don't think it would

int EN = 2;
int Val;

void setup() /****** SETUP: RUNS ONCE ******/
{
  pinMode(EN, INPUT );
  Serial.begin (19200);

}
void loop()    /****** LOOP: RUNS CONSTANTLY ******/
{
  digitalWrite (EN, LOW ); // enable receive
  Val = Serial.read ();
  if (-1 != Val) 
  {
    if ( 'A' == Val) 
    {
      Serial.print ('A');
    }
    if ( 'B' == Val)
    {
      Serial.print ('B');
    }
  }
}

Post the energy meter datasheet.
Also, use code tags ( "#" button) for your code. (Use MODIFY button to edit your code. Highlight the code and click the "#" then click SAVE.

I didn't know how to attach the pdf file, but here's the link

http://www.ekt2.com/products/productdetails?ProductId=21f3843c-7c3c-4cdc-8849-d5935a9de2f8

I didn't know how to attach the pdf file, but here's the link

Click the "Additional Options" link and then select file.

the datasheet of the energy meter is 2 pages long.

The datasheet (attached is only 1 page long; still very UNhelpful.
We need a good photo of the RS-485 connector(s) of the meter. If you see any pin markings , state that.

40_ENERGY_METER_C2000.pdf (79.7 KB)

I posted the datasheet again and a photo of the meter and rs-485 connections the white and the red wires are where I plugged A, B respectively

40_ENERGY_METER_C2000.pdf (79.7 KB)

Remember this:

I connected the pins ‘A’ and ‘B’ to the max-485 directly and the all the other connections to the arduino and power connections.

and this:

gain i only want to output the readings from the energy meter which are inserted into ports A, B on the max485, on the serial monitor

The MAX481, MAX483, MAX485, MAX487–MAX491, and MAX1487 are low-power transceivers for RS-485 and RS422 communication. Each part contains one driver and one receiver. The MAX483, MAX487, MAX488, and MAX489 feature reduced slew-rate drivers that minimize EMI and reduce reflections caused by improperly terminated cables, thus allowing error-free data transmission up to 250kbps. The driver slew rates of the MAX481, MAX485, MAX490, MAX491, and MAX1487 are not limited, allowing them to transmit up to 2.5Mbps.

Did you read the datasheet for the Max485 ?

MAX485.pdf (440 KB)

Well if I didn't have a problem with reading datasheets as I already said in my first post, that I have trouble interfacing communication devices and sensors with the arduino, that means although there are datasheets for these devices, they didn't help solve my problem because there are a lot of information in the datasheet, that in fact it confuses me a lot more.

Till now I haven't got anything useful from you, and I have to submit my project real soon. So could you stop being condescending just because I'm a newbie and help me out.

And one more thing i didn't understand how this could help solve my problem:

The MAX481, MAX483, MAX485, MAX487–MAX491, and MAX1487 are low-power transceivers for RS-485 and RS422 communication. Each part contains one driver and one receiver. The MAX483, MAX487, MAX488, and MAX489 feature reduced slew-rate drivers that minimize EMI and reduce reflections caused by improperly terminated cables, thus allowing error-free data transmission up to 250kbps. The driver slew rates of the MAX481, MAX485, MAX490, MAX491, and MAX1487 are not limited, allowing them to transmit up to 2.5Mbps.

Till now I haven't got anything useful from you, and I have to submit my project real soon. So could you stop being condescending just because I'm a newbie and help me out.

If this is for a class, you are very, very late in doing the basic project research.

Since RS485 communications is listed as an option, it may be that the meter has to be ordered with that option activated. If you actually have such a meter, have you checked with a multimeter to see if there is any activity (changing voltages) on the terminals that you think are the RS485 output?

ok I was incorrect about the max485 not working with an arduino. It doesn’t say anything on the datasheet about converting the RS485 to TTL but it does that.

I connected the pins ‘A’ and ‘B’ to the max-485 directly and the all the other connections to the arduino and power connections.

For the schematic I copied the exact same connections in the following figure plus the A and B connections to the A,B ports on max 485
http://dereenigne.org/wp-content/uploads/modbus.png

Have you tried using the Serial Monitor to see if you can read anything from the meter ?
Do you have anything on the communication speed of the RS485 connection of the meter ?
Here’s a link to the arduino MODBUS library page

This is the link for the MODBUS tutorial with example code:
http://playground.arduino.cc/Code/ModbusMaster#.Uy8J2vldW_g
You probably only need the receive part of the example code.
That’s all I can do for you.

jremmington,

If you actually have such a meter, have you checked with a multimeter to see if there is any activity (changing voltages) on the terminals that you think are the RS485 output?

According to this post, it is difficult to measure the differential signals with an oscilloscope differential probe.
[http://www.electronicsqa.co.uk/q/answers-how-do-i-measure-differential-signals-like-rs-485-or-dmx-on-an-oscilloscope-76514.html/url]

the multimeter shows readings around 111.5mV when i put the function on DCV.
and a resistance between the terminals A and B of about 2.1MOHMs.

also the serial monitor does not display anything (That was my original problem " How to display thee readings on the serial monitor"

im reading the links you posted right now to see if i can further fix this issue i have

Try the MODBUS library

 int EN = 2;
int Val;

void setup() /****** SETUP: RUNS ONCE ******/
{
  pinMode(EN, INPUT );
  Serial.begin (19200);

}
void loop()    /****** LOOP: RUNS CONSTANTLY ******/
{
  digitalWrite (EN, LOW ); // enable receive
  Val = Serial.read ();
  if (-1 != Val) 
  {
    if ( 'A' == Val) 
    {
      Serial.print ('A');
    }
    if ( 'B' == Val)
    {
      Serial.print ('B');
    }
  }
}

Where did you get this code ?
There is no library include in this code.
Serial.read:

int incomingByte = 0;   // for incoming serial data

void setup() {
        Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
}

void loop() {

        // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);
        }
}

Communication and devices[edit]

Each device intended to communicate using Modbus is given a unique address. In serial and MB+ networks, only the node assigned as the Master may initiate a command. On Ethernet, any device can send out a Modbus command, although usually only one master device does so. A Modbus command contains the Modbus address of the device it is intended for. Only the intended device will act on the command, even though other devices might receive it (an exception is specific broadcastable commands sent to node 0 which are acted on but not acknowledged). All Modbus commands contain checksum information, to ensure a command arrives undamaged. The basic Modbus commands can instruct an RTU to change a value in one of its registers, control or read an I/O port, as well as command the device to send back one or more values contained in its registers.
There are many modems and gateways that support Modbus, as it is a very simple protocol and often copied. Some of them were specifically designed for this protocol. Different implementations use wireline, wireless communication, such as in the ISM band, and even short message service (SMS) or General Packet Radio Service (GPRS). One of the more common designs of wireless networks makes use of Mesh networking. Typical problems that designers have to overcome include high latency and timing issues.

Limitations[edit]

Since Modbus was designed in the late 1970s to communicate to programmable logic controllers, the number of data types is limited to those understood by PLCs at the time. Large binary objects are not supported.
No standard way exists for a node to find the description of a data object, for example, to determine if a register value represents a temperature between 30 and 175 degrees.
Since Modbus is a master/slave protocol, there is no way for a field device to "report by exception" (except over Ethernet TCP/IP, called open-mbus)- the master node must routinely poll each field device, and look for changes in the data. This consumes bandwidth and network time in applications where bandwidth may be expensive, such as over a low-bit-rate radio link.
Modbus is restricted to addressing 247 devices on one data link, which limits the number of field devices that may be connected to a master station (once again Ethernet TCP/IP proving the exception).
Modbus transmissions must be contiguous which limits the types of remote communications devices to those that can buffer data to avoid gaps in the transmission.
Modbus protocol itself provides no security against unauthorized commands or interception of data.[7]

I saw similar codes related to rs485 communication with arduino and I kinda wrote this on my own

Did you install the library and try the "Basic" sketch ?

this is the page where i got my code from. 95% of my code is copied from this page