Data Acquisition by Adduino Mega

Hi,

Hope you do very well.

I am doing research with 7 electric actuators controlled by Aduino Mega 2560 simultaneously. Here Hall effect sensors send digital pulses detecting revolutions of DC motor shaft. For single actuator, Arduino Mega 2560 send all the pulses received from Hall sensor to Labview. But when 7 actuators are connected to Arduino Mega 2560 simultaneously, only 1/10 pulses are send to Labview. I have also used 10K pull up Resistor. Can this problem be resolved ?

Any feedback will be much appreciated.
Thank you,
Have a nice day

Quite possibly. Once you include a complete sketch properly enclosed in <CODE/> tags, annotated schematic, and links to the technical data on your electric actuators and Hall effect sensors, of course. We're not mind readers.

1 Like

When you post your annotated schematic that shows all connections, power, ground, power sources and any other hardware please include links to technical information on each of the hardware devices.

give details of the data received when testing the single actuator? e.g. frequency of pulses?
it may give some indication of the Mega's ability to handle seven actuators

a problem is unless you have accurate source of pulses how do know results are anywhere near correct
this code counts rising edge interrupts due to pulses on pins 2 and 3 using a Mega

// UNO/Mega count interrupts

#define sw1Pin 2
#define sw2Pin 3

void setup() {
  Serial.begin(115200);
  Serial.println("interrupt test\n");
  attachInterrupt(digitalPinToInterrupt(sw1Pin), sw1Trig, RISING);
  attachInterrupt(digitalPinToInterrupt(sw2Pin), sw2Trig, RISING);
}

volatile int counter1 = 0;
void sw1Trig() {
  counter1++;
}

volatile int counter2 = 0;
void sw2Trig() {
  counter2++;
}

void loop() {
  static unsigned long timer1 = millis();
  if (millis() - timer1 >= 1000) {
    Serial.print("counter1 ");
    Serial.print(counter1);
    Serial.print("  counter2 ");
    Serial.println(counter2);
    counter1 = counter2 = 0;
    timer1 = millis();
  }
}

results

100Hz & 300Hz
counter1 101  counter2 302
counter1 101  counter2 302
counter1 101  counter2 303
counter1 101  counter2 302
counter1 101  counter2 303
counter1 101  counter2 303

1KHz and 3KHz
counter1 1008  counter2 3024
counter1 1009  counter2 3027
counter1 1008  counter2 3026
counter1 1007  counter2 3024
counter1 1009  counter2 3027
counter1 1008  counter2 3023


10KHz and 30KHz
counter1 10072  counter2 30231
counter1 10082  counter2 30263
counter1 10073  counter2 30231
counter1 10082  counter2 30262
counter1 10072  counter2 30232
counter1 10083  counter2 30262
counter1 10082  counter2 30263

one can see errors in the counts due to delays in executing the code

using similar code on an ESP32 counting rising edge interrupts on eight inputs (GPIO 16 17 18 19 5 21 22 and 23) - the pulse generator only has two output which are connected to multiple inputs

300Hz and 100Hz
counter 1 300 2 100 3 300 4 300 5 300 6 100 7 100 8 100
counter 1 300 2 100 3 300 4 300 5 300 6 100 7 100 8 100
counter 1 300 2 100 3 300 4 300 5 300 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100
counter 1 299 2 100 3 299 4 299 5 299 6 100 7 100 8 100

3KHz and 1KHz
counter 1 3000 2 1000 3 3000 4 3000 5 3000 6 1000 7 1000 8 1000
counter 1 2999 2 1000 3 2999 4 2999 5 2999 6 1000 7 1000 8 1000
counter 1 2999 2 1000 3 2999 4 2999 5 2999 6 1000 7 1000 8 1000
counter 1 2999 2 1000 3 2999 4 2999 5 2999 6 1000 7 1000 8 1000
counter 1 2999 2 1000 3 2999 4 2999 5 2999 6 1000 7 1000 8 1000
counter 1 2999 2 1000 3 2999 4 2999 5 2999 6 1000 7 1000 8 1000
counter 1 2999 2 1000 3 2999 4 2999 5 2999 6 1000 7 1000 8 1000
counter 1 2999 2 1000 3 2999 4 2999 5 2999 6 1000 7 1000 8 1000
counter 1 2999 2 1000 3 2999 4 2999 5 2999 6 1000 7 1000 8 1000

30KHz and 10KHz
counter 1 29995 2 9999 3 29995 4 29995 5 29995 6 9999 7 9999 8 9999
counter 1 29995 2 9999 3 29995 4 29995 5 29995 6 9999 7 9999 8 9999
counter 1 29996 2 9999 3 29996 4 29996 5 29996 6 9999 7 9999 8 9999
counter 1 29996 2 9998 3 29996 4 29996 5 29996 6 9998 7 9998 8 9998
counter 1 29996 2 9998 3 29996 4 29996 5 29996 6 9998 7 9998 8 9998
counter 1 29995 2 9998 3 29995 4 29995 5 29995 6 9998 7 9998 8 9998
counter 1 29995 2 9998 3 29995 4 29995 5 29995 6 9998 7 9998 8 9998
counter 1 29995 2 9998 3 29995 4 29995 5 29995 6 9998 7 9998 8 9998
counter 1 29996 2 9998 3 29996 4 29996 5 29996 6 9998 7 9998 8 9998
counter 1 29996 2 9998 3 29996 4 29996 5 29996 6 9998 7 9998 8 9998
counter 1 29995 2 9998 3 29995 4 29995 5 29995 6 9998 7 9998 8 9998

or using the ESP32 Pulse Counter (PCNT)

300Hz and 100Hz
GPIO 16 count 300   || status OK
GPIO 17 count 100   || status OK
GPIO 18 count 300   || status OK
GPIO 19 count 300   || status OK
GPIO 5 count 300   || status OK
GPIO 21 count 100   || status OK
GPIO 22 count 100   || status OK
GPIO 23 count 99   || status OK
GPIO 16 count 300   || status OK
GPIO 17 count 100   || status OK
GPIO 18 count 300   || status OK
GPIO 19 count 300   || status OK
GPIO 5 count 300   || status OK
GPIO 21 count 100   || status OK
GPIO 22 count 100   || status OK
GPIO 23 count 99   || status OK
GPIO 16 count 300   || status OK
GPIO 17 count 100   || status OK
GPIO 18 count 300   || status OK
GPIO 19 count 300   || status OK
GPIO 5 count 300   || status OK
GPIO 21 count 100   || status OK
GPIO 22 count 100   || status OK
GPIO 23 count 99   || status OK

3KHz and 1KHz
GPIO 16 count 3000   || status OK
GPIO 17 count 1000   || status OK
GPIO 18 count 2999   || status OK
GPIO 19 count 3000   || status OK
GPIO 5 count 3000   || status OK
GPIO 21 count 1000   || status OK
GPIO 22 count 1000   || status OK
GPIO 23 count 990   || status OK
GPIO 16 count 3000   || status OK
GPIO 17 count 1000   || status OK
GPIO 18 count 2999   || status OK
GPIO 19 count 3000   || status OK
GPIO 5 count 3000   || status OK
GPIO 21 count 1000   || status OK
GPIO 22 count 1000   || status OK
GPIO 23 count 990   || status OK
GPIO 16 count 3000   || status OK
GPIO 17 count 1000   || status OK
GPIO 18 count 2999   || status OK
GPIO 19 count 3000   || status OK
GPIO 5 count 2999   || status OK
GPIO 21 count 1000   || status OK
GPIO 22 count 1000   || status OK
GPIO 23 count 990   || status OK


30KHz and 10KHz
GPIO 16 count 29999   || status OK
GPIO 17 count 10000   || status OK
GPIO 18 count 29999   || status OK
GPIO 19 count 29999   || status OK
GPIO 5 count 29999   || status OK
GPIO 21 count 9999   || status OK
GPIO 22 count 10000   || status OK
GPIO 23 count 9898   || status OK
GPIO 16 count 30000   || status OK
GPIO 17 count 10000   || status OK
GPIO 18 count 29999   || status OK
GPIO 19 count 29999   || status OK
GPIO 5 count 29999   || status OK
GPIO 21 count 9999   || status OK
GPIO 22 count 10000   || status OK
GPIO 23 count 9898   || status OK
GPIO 16 count 29999   || status OK
GPIO 17 count 10000   || status OK
GPIO 18 count 29999   || status OK
GPIO 19 count 30000   || status OK
GPIO 5 count 29999   || status OK
GPIO 21 count 9999   || status OK
GPIO 22 count 10000   || status OK
GPIO 23 count 9898   || status 

I have included the details. Please consider

(Attachment Arduino form.docx is missing)

(attachments)

Honeywell-ss41f-ss41g-datasheet.pdf (271 KB)

(attachments)

Arduino form.pdf (489 KB)

  

ACTUATOR DETAILS:  Zoom Industrial - Heavy Duty Linear Actuator - 330 Pound Max Lift DC 12v/24v - Position Feedback - Weather Resistant.

ARDUINO MEGA IS INTERFACED WITH LABVIEW 2020 COMMUNITY EDITION THROUGH “LIFA” PROGRAMMING OF ARDUINO SOFTWARE WITH FOLLOWING CODES:
/*********************************************************************************
 **
 **  LVFA_Firmware - Provides Basic Arduino Sketch For Interfacing With LabVIEW.
 **
 **  Written By:    Sam Kristoff - National Instruments
 **  Written On:    November 2010
 **  Last Updated:  Dec 2011 - Kevin Fort - National Instruments
 **
 **  This File May Be Modified And Re-Distributed Freely. Original File Content
 **  Written By Sam Kristoff And Available At www.ni.com/arduino.
 **
 *********************************************************************************/


/*********************************************************************************
 **
 ** Includes.
 **
 ********************************************************************************/
// Standard includes.  These should always be included.
#include <Wire.h>
#include <SPI.h>
#include <Servo.h>
#include "LabVIEWInterface.h"

int relay1 = 40;
int relay2 = 41;
int relay3 = 42;
int relay4 = 43;
int relay5 = 44;
int relay6 = 45;
int relay7 = 46;
int relay8 = 47;
int relay9 = 48;
int relay10= 49;
int relay11= 50;
int relay12= 51;
int relay13= 52;
int relay14= 53;



int sensor1 = 22;
int sensor2 = 23;
int sensor3 = 24;
int sensor4 = 25;
int sensor5 = 26;
int sensor6 = 27;
int sensor7 = 28;


int va11 = 2;
int va12 = 3;
int va13 = 4;
int va14 = 5;
int va15 = 6;
int va16 = 7;
int va17 = 8;



/*********************************************************************************
 **  setup()
 **
 **  Initialize the Arduino and setup serial communication.
 **
 **  Input:  None
 **  Output: None
 *********************************************************************************/
void setup()
{
  // Initialize Serial Port With The Default Baud Rate
Serial.begin(250000);


pinMode(sensor1,INPUT);
pinMode(sensor2,INPUT);
pinMode(sensor3,INPUT);
pinMode(sensor4,INPUT);
pinMode(sensor5,INPUT);
pinMode(sensor6,INPUT);
pinMode(sensor7,INPUT);

pinMode(va11,OUTPUT);
pinMode(va12,OUTPUT);
pinMode(va13,OUTPUT);
pinMode(va14,OUTPUT);
pinMode(va15,OUTPUT);
pinMode(va16,OUTPUT);
pinMode(va17,OUTPUT);

pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);

pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);

pinMode(relay5,OUTPUT);
pinMode(relay6,OUTPUT);

pinMode(relay7,OUTPUT);
pinMode(relay8,OUTPUT);

pinMode(relay9,OUTPUT);
pinMode(relay10,OUTPUT);

pinMode(relay11,OUTPUT);
pinMode(relay12,OUTPUT);

pinMode(relay13,OUTPUT);
pinMode(relay14,OUTPUT);



syncLV();

  // Place your custom setup code here

}


/*********************************************************************************
 **  loop()
 **
 **  The main loop.  This loop runs continuously on the Arduino.  It
 **  receives and processes serial commands from LabVIEW.
 **
 **  Input:  None
 **  Output: None
 *********************************************************************************/
void loop()
{

checkForCommand();
  // Place your custom loop code here (this may slow down communication with LabVIEW)


if (acqMode == 1)
  {
sampleContinously();
  }

}



Connection with single actuator is shown here, similarly 7 actuators are connected.

There is no ground connection between the 5V supply and the Mega
There is no ground connection between the motor driver and the Mega
Jumper on motor driver MUST be removed, otherwise you will damage the Mega and/or driver.

There is no need for a separate 5V supply. Connect the 10K pull-up to the Mega 5V

1 Like


Thank you so much for your suggestion.
But, Ground connection between motor driver and Mega was provided but it was missing in the image.
Jumper on motor driver was also removed as power supply to motor driver more than 12 V.
10K pull up connected to Mega 5V but here it was shown separately because of less space.

I'm not familiar with Labview LIFA so I don't think I can help.

OK. Thank you.

It seems that the main part of the code is in the file:

so we need it in case you expect the help

[quote="mintu, post:8, topic:1353801"]

ACTUATOR DETAILS: Zoom Industrial - Heavy Duty Linear Actuator - 330 Pound Max Lift DC 12v/24v - Position Feedback - Weather Resistant.

ARDUINO MEGA IS INTERFACED WITH LABVIEW 2020 COMMUNITY EDITION THROUGH “LIFA” PROGRAMMING OF ARDUINO SOFTWARE WITH FOLLOWING CODES:
/*********************************************************************************
**
** LVFA_Firmware - Provides Basic Arduino Sketch For Interfacing With LabVIEW.
**
** Written By: Sam Kristoff - National Instruments
** Written On: November 2010
** Last Updated: Dec 2011 - Kevin Fort - National Instruments
**
** This File May Be Modified And Re-Distributed Freely. Original File Content
** Written By Sam Kristoff And Available At LabVIEW Interface for Arduino (LIFA) - NI Community.
**
*********************************************************************************/

/*********************************************************************************
**
** Includes.
**
********************************************************************************/
// Standard includes. These should always be included.
#include <Wire.h>
#include <SPI.h>
#include <Servo.h>
#include "LabVIEWInterface.h"

int relay1 = 40;
int relay2 = 41;
int relay3 = 42;
int relay4 = 43;
int relay5 = 44;
int relay6 = 45;
int relay7 = 46;
int relay8 = 47;
int relay9 = 48;
int relay10= 49;
int relay11= 50;
int relay12= 51;
int relay13= 52;
int relay14= 53;

int sensor1 = 22;
int sensor2 = 23;
int sensor3 = 24;
int sensor4 = 25;
int sensor5 = 26;
int sensor6 = 27;
int sensor7 = 28;

int va11 = 2;
int va12 = 3;
int va13 = 4;
int va14 = 5;
int va15 = 6;
int va16 = 7;
int va17 = 8;

/*********************************************************************************
** setup()
**
** Initialize the Arduino and setup serial communication.
**
** Input: None
** Output: None
*********************************************************************************/
void setup()
{
// Initialize Serial Port With The Default Baud Rate
Serial.begin(250000);

pinMode(sensor1,INPUT);
pinMode(sensor2,INPUT);
pinMode(sensor3,INPUT);
pinMode(sensor4,INPUT);
pinMode(sensor5,INPUT);
pinMode(sensor6,INPUT);
pinMode(sensor7,INPUT);

pinMode(va11,OUTPUT);
pinMode(va12,OUTPUT);
pinMode(va13,OUTPUT);
pinMode(va14,OUTPUT);
pinMode(va15,OUTPUT);
pinMode(va16,OUTPUT);
pinMode(va17,OUTPUT);

pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);

pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);

pinMode(relay5,OUTPUT);
pinMode(relay6,OUTPUT);

pinMode(relay7,OUTPUT);
pinMode(relay8,OUTPUT);

pinMode(relay9,OUTPUT);
pinMode(relay10,OUTPUT);

pinMode(relay11,OUTPUT);
pinMode(relay12,OUTPUT);

pinMode(relay13,OUTPUT);
pinMode(relay14,OUTPUT);

syncLV();

// Place your custom setup code here

}

/*********************************************************************************
** loop()
**
** The main loop. This loop runs continuously on the Arduino. It
** receives and processes serial commands from LabVIEW.
**
** Input: None
** Output: None
*********************************************************************************/
void loop()
{

checkForCommand();
// Place your custom loop code here (this may slow down communication with LabVIEW)

if (acqMode == 1)
{
sampleContinously();
}

}

[/quote]

ACTUATOR DETAILS:  Zoom Industrial - Heavy Duty Linear Actuator - 330 Pound Max Lift DC 12v/24v - Position Feedback - Weather Resistant.

ARDUINO MEGA IS INTERFACED WITH LABVIEW 2020 COMMUNITY EDITION THROUGH “LIFA” PROGRAMMING OF ARDUINO SOFTWARE WITH FOLLOWING CODES:
/*********************************************************************************
 **
 **  LVFA_Firmware - Provides Basic Arduino Sketch For Interfacing With LabVIEW.
 **
 **  Written By:    Sam Kristoff - National Instruments
 **  Written On:    November 2010
 **  Last Updated:  Dec 2011 - Kevin Fort - National Instruments
 **
 **  This File May Be Modified And Re-Distributed Freely. Original File Content
 **  Written By Sam Kristoff And Available At www.ni.com/arduino.
 **
 *********************************************************************************/


/*********************************************************************************
 **
 ** Includes.
 **
 ********************************************************************************/
// Standard includes.  These should always be included.
#include <Wire.h>
#include <SPI.h>
#include <Servo.h>
#include "LabVIEWInterface.h"

int relay1 = 40;
int relay2 = 41;
int relay3 = 42;
int relay4 = 43;
int relay5 = 44;
int relay6 = 45;
int relay7 = 46;
int relay8 = 47;
int relay9 = 48;
int relay10= 49;
int relay11= 50;
int relay12= 51;
int relay13= 52;
int relay14= 53;



int sensor1 = 22;
int sensor2 = 23;
int sensor3 = 24;
int sensor4 = 25;
int sensor5 = 26;
int sensor6 = 27;
int sensor7 = 28;


int va11 = 2;
int va12 = 3;
int va13 = 4;
int va14 = 5;
int va15 = 6;
int va16 = 7;
int va17 = 8;



/*********************************************************************************
 **  setup()
 **
 **  Initialize the Arduino and setup serial communication.
 **
 **  Input:  None
 **  Output: None
 *********************************************************************************/
void setup()
{
  // Initialize Serial Port With The Default Baud Rate
Serial.begin(250000);


pinMode(sensor1,INPUT);
pinMode(sensor2,INPUT);
pinMode(sensor3,INPUT);
pinMode(sensor4,INPUT);
pinMode(sensor5,INPUT);
pinMode(sensor6,INPUT);
pinMode(sensor7,INPUT);

pinMode(va11,OUTPUT);
pinMode(va12,OUTPUT);
pinMode(va13,OUTPUT);
pinMode(va14,OUTPUT);
pinMode(va15,OUTPUT);
pinMode(va16,OUTPUT);
pinMode(va17,OUTPUT);

pinMode(relay1,OUTPUT);
pinMode(relay2,OUTPUT);

pinMode(relay3,OUTPUT);
pinMode(relay4,OUTPUT);

pinMode(relay5,OUTPUT);
pinMode(relay6,OUTPUT);

pinMode(relay7,OUTPUT);
pinMode(relay8,OUTPUT);

pinMode(relay9,OUTPUT);
pinMode(relay10,OUTPUT);

pinMode(relay11,OUTPUT);
pinMode(relay12,OUTPUT);

pinMode(relay13,OUTPUT);
pinMode(relay14,OUTPUT);



syncLV();

  // Place your custom setup code here

}


/*********************************************************************************
 **  loop()
 **
 **  The main loop.  This loop runs continuously on the Arduino.  It
 **  receives and processes serial commands from LabVIEW.
 **
 **  Input:  None
 **  Output: None
 *********************************************************************************/
void loop()
{

checkForCommand();
  // Place your custom loop code here (this may slow down communication with LabVIEW)


if (acqMode == 1)
  {
sampleContinously();
  }

}


type or paste code here

@mintu
As I see, you inserted a main .ino file twice instead of showing the LabVIEWInterface.h

Why are you using LIFA? LIFA was replaced by LINX about 12 years ago. LINX is faster and offers more functionality. The LINX Install Wizard can be found under LabView MakerHub.

With that said, I suspect your 16Mhz Mega can't acquire and stream the data as fast as you demand. Your potential limitations are the Mega, USB interface, your computer processor. You may have to upgrade to a cDAQ or cRIO system running on ethernet or something similar.

Thank you so much for your kind response. In my experiment I need to access both Analog and digital data. Initially I have tried with Arduino Due and LINX. But I found difficulty with Analog data acquisition to Labview. For this reason I am using LIFA.