Pages: [1]   Go Down
Author Topic: Need help interfacing with Alicat Mass Flow Controller  (Read 1637 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello All,

I am trying to interface with an Alicat Mass Flow Controller using an Arduino Mega Serial port.  The mass flow controller serial port appears to send out TTL voltage levels (0-5V, I checked via my scope) so I just connected its serial pins to the Arduino serial port directly.  I am able to read something from the MFC, however, the characters are garbled.  I am able to read the data just fine via a PC serial port, however.  I made sure that the Baud rates are matched between the devices.  I tried to switch baud rates, but no luck.

Via PC I am getting repeated streams that look like this:
A +014.66 +028.07 +0000.0 +0000.0 0000.0     Air

On the arduino I am reading (note I read 64 bytes regardless and the MFC constantly sends updated data so I do not know when the frame begins)
¿¿¿}- yjÖv6¿©£¿©£¿©£¿£¿¿¿¿¿}- yjÖv6¿©}

Any thoughts would be appreciated!

Here is my code for the MFC object I am using to communicate:

Code:
#ifndef AlicatMFC_h
#define AlicatMFC_h

#include "Arduino.h"

#define ALI_MULTIPLIER 64000

#define SERIAL_TIMEOUT 500

class AlicatMFC
{
  public:
    AlicatMFC();
    void initSerial();
    void sendCommand(char* in, char* out);
  private:
 
};

#endif

Code:
#include "Arduino.h"
#include "AlicatMFC.h"

AlicatMFC::AlicatMFC()
{
    // NOTES:  No line ends with line feeds
    // There will be two devices A and B
    // To address a given device type: A $$XX or B $$XX where XX is a command
   
    // NOTE: Units should be first set to polled mode (not streaming), this must be done for each unit separately by sending: *@=A and *@=B respectively
}

void AlicatMFC::initSerial()
{
    Serial3.begin(9600); // Baud for Alicat is 19200 default
}

void AlicatMFC::sendCommand(char* in, char* out)

  int i = 0;
 
  for (i=0;i<64;i++)
    out[i] = '\0';
 
  unsigned long t;
 
  // send the message to MFC
  Serial3.println(in);
 
  // read response (if any)
  i = 0;
  t = millis();
 
   // read until carriage return or serial timeout
  do {     
    while (Serial3.available()==0)
      if ((millis()-t) > SERIAL_TIMEOUT) { out[0] = 'R'; return; }
   
    out[i++] = Serial3.read();
  } while ((out[i-1]!=13) & (i<64));
 
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I think I figured out the problem.  The MFC is communicating using RS232.  However, when I measured the output voltage, it went from 0-5V, so I figured it was TTL.  After I inverted the signal from the MFC, I could read the data with no problem.  Now I still cannot send from the Arduino to the MFC, but that could be because the input must be a real RS232 signal, not the weird 0-5V signal it is outputting.  Ordered some RS232 to TTL converters also... so we'll see.
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 5570
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What does the datasheet for the MFC say? Do you have a link to that (my only experience with an MFC was for one that was controlled via voltage level, and not RS-232)?
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well they really did not describe the protocol well on the datasheet.  However, thinks are working just peachy now.  The trouble was that the Arduino uses TTL Serial, but the MFC, while it accepts TTL-level signals, uses the RS232 convention of low voltage = 1 and high voltage = 0.  Simply inverting the signals both to and from the MFC solved all communication issues!
Logged

Pages: [1]   Go Up
Jump to: