Hi all I need help in understanding how to send a command on Arduino IDE to an external device using a MAX3232cpe chip through a rs232 cable and then receiving power readings from the external device. In this case, I am using Yokogawa power meter CW121 as my external device and I want to extract the active and reactive power collected from the power meter to be projected on a touchscreen connected to an Arduino Mega. The touchscreen I am using is the 4D systems ULCD-43pt touchscreen.
Basically the current set up is like this :
USB from PC > Arduino MEGA> touchscreen & MAX3232cpe > RS232 cable > Power Meter
This is the current code I am working on and I am running out of time to complete this project. Please help.
#include <SoftwareSerial.h>
#include <ModbusRtu.h>
#include <genieArduino.h>
SoftwareSerial mySerial (2,3); //RX pin 2, TX pin 3
//unsigned long start =0; //variable to keep track of time
Genie genie;
int Leddigits0;
int LcdRead;
String command = "";
unsigned long nr =0;
void setup()
{
Serial.begin(9600); //"serial" is for communication with computer
mySerial.begin(19200); //"mySerial" is for communication with powermeter via MAX232 chip
genie.Begin (mySerial);
genie.AttachEventHandler(myGenieEventHandler);
pinMode (Leddigits0, OUTPUT);
}
void loop()
{
mySerial.write( ':MEASure:INTEgrate:ITEM:ALL');
mySerial.write( ':measure:integrate:value?');
genie.DoEvents();
NumRead0();
delay (300);
}
void myGenieEventHandler()
{
genieFrame Event;
char charbuf[50];
genie.DequeueEvent (&Event);
}
void NumRead0()
{
mySerial.write('D5013');
LcdRead = (1.0* ((byte)mySerial.read()));;
genie.WriteObject (GENIE_OBJ_LED_DIGITS, 0x00 ,LcdRead);
}