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.
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?
"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?
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.