Average values reporting from printer

Hello everyone,

i am not familiar with programming and electronics in general (i am an environm. engineer) but i have a problem and i need your assistance.

I have a device with an RS-232 serial output , witch gives in terminal the following printout.

“25-08-15 13:32 M000 Ben 0.499 ug/m3 Tol 3.221 ug/m3 Etb 0.223 ug/m3 MP Xy 0.000 ug/m3 O Xy 0.000 ug/m3”.

These values are renewed every 15 minutes as every 15 minutes a new measurement starts. I need to connect a device that will collect the data and will report the hourly average of the measured values every hour in the same layout as above.
The 4 digits that follow the time, represent the state of the device. The first gives the state (measuring, stand-by, alarm etc-in this case is measuring) and the three that follow, indicate what is wrong(if anything is).
The values of witch i need to get the hourly average are the values following the measured compounds i.e. Ben, Tol, Etb, MP Xy and O Xy.
This is a general description as you can imagine but i can provide more info.

Is this possible with your devices?

Thank you in advance
Yiannis

Sure, just need to parse the message up as it comes on, pull out the needed data, and do a little math.
If the format is always the same, the same # of characters & stuff, you can put the data into an array as it comes in and then pull the same bytes out from the array for processing.

25-08-15 13:32  M000 Ben    0.499 ug/m3  Tol   3.221 ug/m3  Etb   0.223 ug/m3  MP Xy    0.000 ug/m3  O Xy     0.000 ug/m3
if (Serial.available()>124){ // assuming I counted the # of characters & spaces correctly
// or do something smarter and ignore the spaces and the other text characters such as Ben and ug/m3
for (count = 0; count<125; count = count +1){
array[count] = Serial.read();
}

So for example array[0] and array[1], have this:

dayMonth =(array[0] *10) + array[1]; // equals 25 with this data
month =(array[2] *10) + array[3];  // equal 08 with this data

Serial buffer may be set to 64 max, so can tweak the Serial library to allow 128 or work around that in other ways.

What is the voltage of the RS232 of the printer?
if it is true RS232 you need a voltage convertor or optocoupler to prevent damaging the Arduino.

These values are renewed every 15 minutes as every 15 minutes a new measurement starts. I need to connect a device that will collect the data and will report the hourly average of the measured values every hour in the same layout as above.

Where should it report the hourly report to?
to an LCD screen ?
to an SD card?
to ?

must the hourly average be the average of the last 4 measurements?

why not log all info on an SD card so you can post process it always in a spreadsheet?

Which printer is it?
do you have a link?

(BTW please lowercase your title, uppercase is considered shouting :wink:

You can collect, and store this info, but at some point you probably want to display/analyze it.

Is this to be done on a PC?

Can't you just feed the RS-232 signal into the PC ? Why would you need an arduino ?

Hello!

My friend Yiannis please dont shout at them! we want these guys help!!! :smiley:

I think we are going to be addicted to adruino!

What we want to do is actually use 2 RS232 ports. One for input and one for output.

I guess we can do that with Arduino Mega2560 Rev3. As i can see on the schematic:

it has 4 available rs232 ports. (TXD0(3 pin)-RXD0(2 pin), TXD1(46 pin)-RXD1(45 pin), TXD2(13 pin)-RXD2(12 pin), TXD3(64 pin)-RXD3(63 pin))

So the phrase:
"25-08-15 13:32 M000 Ben 0.499 ug/m3 Tol 3.221 ug/m3 Etb 0.223 ug/m3 MP Xy 0.000 ug/m3 O Xy 0.000 ug/m3".

Is going to be the input (e.x. TXD0-RXD0). Every 15 minutes we get one phrase like this.

In the output (e.x. TXD1-RXD1) we want the same phrase but the values will be the hour average.

(Sum of 4 values each 15 minutes) / 4

Thank you very much for your time.

We really appreciate it.

Christos

@Cristos, Yannis
Can you please answer the questions from #2 #3 #4 above

"What we want to do is actually use 2 RS232 ports. One for input and one for output."

Even tho the arduino can read and write serial data, it is not really RS-232 enabled. RS-232 indicates that the voltage on the wires are +12 volt and -12 Volt. Serial to and from the arduino uses the same timing/logic, but it's voltage is 0v - 5v (not really RS-232 specs).

If you can live with that, then you basically want the arduino to average the last 4 readings, and pass the result on to another computer? Not to be redundant, but can't the next computer do that math?

The arduino is well capable to do the math tho.

Actually the topic is a little bit wrong because the equipment we have to do is not a printer.
It is about a complicated equipment in which we cannot change its programming.
So we have to intervene with an external device so as to make the result we described above.

Q:Where should it report the hourly report to?
A:The result will be the same phrase BUT with the values of the hourly average in a second RS232 port.

Please ask again if you didnt understand.

Thank you again.

I think we will have to use an Oscilloscope so as to check the voltage level of the RS232 of the equipment we use.

Plan B: convert the device into Internet of Things node:

Arduino Yun/Yun shield + RS-232 USB/RS-232 adapter import data into database

Import data into Sqlite3 database.

Real time Web base graph sensor data

Monthly/Weekly summary report by Email

Minimum and maximum values alert by SMS