Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - mdhill

Pages: [1]
1
Hello.  I am running a program that uses two Arduino units one for the operator HMI and a second for a maintenance display.  While the HMI provides test connection status to the operator, the maintenance display shows temperature, humidity, and test connection status. 

The problem is that the USB communication between the Arduino and the Rasp Pi running Ubuntu 22.04 is intermittent.  I am using a USB A to USB B cable with the settings of 9600,8,N,1.  The Arduino for the Operator HMI uses theses settings with no issues on ttyACM1 while the Arduino for the Maintenance Display uses ttyACM0.  I have also tried 19200,8,N,1 on the Maintenance Display but the issues persists.  I am using the ModbusRTUCom Driver Component. I am using version v399y Beta 38. Has anyone had this issue and found a solution?

I forgot to mention that the error I see on the Maintenance HMI screen states "Read Timeout Error." The message then disappears and after a few seconds to maybe a minute or so, it repeats.

2
Support Questions / Re: C# Dev Kit Error
« on: June 19, 2024, 12:25:10 PM »
The install of mono-vbnc resolved the issue.  I had a previous error when attempting to install
mono-vbnc but it ran with no issues this time.  Thanks.

3
Support Questions / Re: C# Dev Kit Error
« on: June 18, 2024, 04:22:58 PM »
Thank you for reply.  I have started from scratch on the Rasp Pi and it requires me to install Visual Studio Code and the latest full version of Mono.  After the install, I compiled my Advanced HMI program on my Win 11 machine using Visual Studio Community.  I coped the program over to my Rasp Pi machine, opened a terminal window, and typed in the following:

mono AdvancedHMI.exe

After typing the command, I am receiving the following error:

real@raspberrypi4:~/AdvancedHMI/AdvancedHMIv399yBeta40/AdvancedHMI/bin/Debug $ mono AdvancedHMI.exe
The entry point method could not be loaded due to Could not load file or assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

When I run the program on a Win10 / Win11 machine, I  have no errors. Is there another package that I need to install on the Rasp Pi that I have missed?  My last experience with AdvancedHMI projects was after building on a Win machine it was copy over and run with no issues.

Thanks in advance.

4
Support Questions / C# Dev Kit Error
« on: June 13, 2024, 11:33:21 AM »
I am dusting off a program I created in 2022 for use on a Raspberry Pi 4.  After installing Visual Studio Code and Mono on the Pi and trying to run the program, I receive the following error:

2024-06-13 10:34:16.585 [warning] The project file '/home/AdvancedHMI/AdvancedHMIv399yBeta38Display/AdvancedHMICS/AdvancedHMIcs.csproj' is in unsupported format (for example, a traditional .NET Framework project). It need be converted to new SDK style to work in C# Dev Kit.

The project was originally created on a Win10 machine and I have no issues running the program on it.

Thanks in advance.

5
Thank you for the reply.  I am now running 399yBeta 38 and the program is working well on the Pi.

6
Tips & Tricks / Re: AdvancedHMI on a Raspberry Pi
« on: June 22, 2022, 02:03:16 PM »
Afternoon.  I have my Advanced HMI project working on my raspberry Pi using Mono, but I have a question.  On my project,  I have modbus data coming from an Arduino Mega 2560 to the to the raspberry Pi via a single USB cable and using the ModbusRTUCom library to pass the data (/dev/ttyACM0).  I have two displays, but each has a different application on the screen and shares several registers from the modbus data.  Can both programs use the same ModbusRTUCom library to use on the different displays?

7
Good morning,

I'm hoping someone within the community can assist me as I am almost out of hair to pull.  I have created a program with my Arduino Mega to send Modbus data to my Advanced HMI program.  This is to verify various harness' are connected to a motor and also monitor temp and humidity with the Arduino and raspberry Pi 4.  During the trial testing, everything works fine with Windows 10 but when I try using the Advanced HMI program using Mono in my Raspberry Pi (command: mono AdvancedHMI.exe) the displays appear but no data.  I have made changes in the ModbusRTUCom1 setting to use /dev/ttyACM0 as my Port name, and confirmed the baud rate (115200, 8, N, 1).  My PLC address range is from 40000 - 40022.

I have found on some forums that Mono can only read from TCP/IP and not from RTU via Serial.  Is this true and if so is there an alternative to using Mono in Raspberry Pi to run the Advanced HMI application?  I have also tried creating a program in python to act as a translator between the Arduino and the Pi but to no avail.  I hope there is a solution that someone has come across. 

Arduino Code:

#include "DEV_Config.h"
#include <modbus.h>
#include <modbusDevice.h>
#include <modbusRegBank.h>
#include <modbusSlave.h>
#include <SoftwareSerial.h>
#include <DFRobot_DHT11.h>
DFRobot_DHT11 DHT;

//All of the data accumulated will be stored here
modbusDevice regBank;

//Create the modbus slave protocol handler
modbusSlave slave;

// Analog inputs
const int analogPin1 = 0;
const int analogPin2 = 1;
const int analogPin3 = 2;
const int analogPin4 = 3;
const int analogPin5 = 4;
const int analogPin6 = 5;

// Digital outputs
const int outPin1 = 3;
const int outPin2 = 5;
const int outPin3 = 6;
const int outPin4 = 4;

// Temp sensor parameters for Arduino and Pi F & C
#define DHT11_PIN_A 28
#define DHT11_PIN_R 29
float TempF_Ard = 0;
float TempC_Ard = 0;
float TempF_Pi = 0;
float TempC_Pi = 0;
int CabFan;

void setup()
{
  //Assign the modbus device ID. 
  regBank.setId(1);
  /*
  modbus registers follow the following format
  00001-09999  Digital Outputs, A master device can read and write to these registers
  10001-19999  Digital Inputs, A master device can only read the values from these registers
  30001-39999  Analog Inputs, A master device can only read the values from these registers
  40001-49999  Analog Outputs, A master device can read and write to these registers
  Assign the modbus device object to the protocol handler
  This is where the protocol handler will look to read and write
  register data.  Currently, a modbus slave protocol handler may
  only have one device assigned to it.
  */
  slave._device = &regBank; 

  // Initialize the serial port for coms at 9600 baud 
  slave.setBaud(9600);
  delay(250); 
 
  //Add Analog Output registers 40001-40020 to the register bank
  regBank.add(40001); // Connector, Connect LED on Display
  regBank.add(40002); // Connector
  regBank.add(40003); // Connector
  regBank.add(40004); // Connector
  regBank.add(40005); // Connector (Not used for testing 
  regBank.add(40006); // Connector (Not used for testing
  regBank.add(40007); // Not Used
  regBank.add(40008); // Pass Display Indicator
  regBank.add(40009); // Fail Display Indicator
  regBank.add(40010); // Power LED on Display
  regBank.add(40011); // Arduino temp F
  regBank.add(40012); // Arduino humidity
  regBank.add(40013); // Arduino temp C
  regBank.add(40014); // Rasp Pi temp F
  regBank.add(40015); // Rasp Pi humidity
  regBank.add(40016); // Rasp Pi temp C
  regBank.add(40017); // Connector, Raw data
  regBank.add(40018); // Connector, Raw data
  regBank.add(40019); // Connector, Raw data
  regBank.add(40020); // Connector, Raw data
  regBank.add(40021); // Connector, Raw data
  regBank.add(40022); // Connector, Raw data

  System_Init();
  if(USE_IIC)
{
 // Serial.print("Only USE_SPI_4W, Please revise DEV_config.h !!!");
   return;
  Serial.begin(9600);
}
 // Digital Outputs for LED lights
  pinMode(3, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);

  // Digital Inputs for reading continunity
  pinMode(22, INPUT);
  pinMode(23, INPUT);
  pinMode(24, INPUT);
  pinMode(25, INPUT);
  pinMode(26, INPUT);
  pinMode(27, INPUT);
 
  digitalWrite(22, HIGH);
  digitalWrite(23, HIGH);
  digitalWrite(24, HIGH);
  digitalWrite(25, HIGH);
  digitalWrite(26, HIGH);
  digitalWrite(27, HIGH);
  digitalWrite(7, HIGH);
 
}

void loop()
{
  regBank.set(40001,1);  // Connector, Connect LED on Display
  regBank.set(40002,2);  // Connector
  regBank.set(40003,3);  // Connector
  regBank.set(40004,4);  // Connector
  regBank.set(40005,5);  // Connector (Not used. No direct connect)
  regBank.set(40006,6);  // Connector (Not used. No direct connect)
  regBank.set(40007,7);  // Not used. Spare
  regBank.set(40008,8);  // Pass Display Indicator
  regBank.set(40009,9);  // Fail Display Indicator
  regBank.set(40010,10); // Power On Display Indicator
  regBank.set(40011,11); // Arduino temp F
  regBank.set(40012,12); // Arduino humidity
  regBank.set(40013,13); // Arduino temp C
  regBank.set(40014,14); // Rasp Pi temp F
  regBank.set(40015,15); // Rasp Pi humidity
  regBank.set(40016,16); // Arduino temp C
  regBank.set(40017,17); // Connector, Raw Data
  regBank.set(40018,18); // Connector, Raw data
  regBank.set(40019,19); // Connector, Raw data
  regBank.set(40020,20); // Connector, Raw data
  regBank.set(40021,21); // Connector, Raw data
  regBank.set(40022,22); // Connector, Raw data
 
 while(1)
  {
    regBank.set(40010, 1);  // Power LED on Display
   
    // Temp and Humidity sensors for Arduino and Pi
    DHT.read(DHT11_PIN_A);
    TempF_Ard = ((DHT.temperature*1.8)+32); // Arduinio conversion from C to F  "This is a math formula (DHT.Temperature x 1.8+32) not emoji"
    TempC_Ard = DHT.temperature;            // Arduino Temp C
    regBank.set(40011, TempF_Ard);          // Arduino temp F
    regBank.set(40012, DHT.humidity);       // Arduino humidity
    regBank.set(40013, TempC_Ard);          // Arduino Temp C
    DHT.read(DHT11_PIN_R);
    TempF_Pi = ((DHT.temperature*1.8)+32);  // Rasp conversion from C to F  "This is a math formula DHT.Temperature x 1.8+32) not emoji"
    TempC_Pi = DHT.temperature;
    regBank.set(40014, TempF_Pi);           // Arduino temp F   
    regBank.set(40015, DHT.humidity);       // Arduino humidity
    regBank.set(40016, TempC_Pi);           // Arduino Temp C
     
     // C1YE01-EVC Connector, Connect LED on Display
     int reading1 = analogRead(analogPin1);
     float voltage1 = reading1 / 204.6;
     regBank.set(40017, voltage1);
     if (voltage1 < 1)
       {
        regBank.set(40001, 0);
       }
     else
       {
        regBank.set(40001, 1);
       }

     // C1YT04-EV Connector
     int reading2 = analogRead(analogPin2);
     float voltage2 = reading2 / 204.6;
     regBank.set(40018, voltage2);
     if (voltage2 < 1)
       { 
        regBank.set(40002, 0);
       }
     else
       {
        regBank.set(40002, 1);
       } 

     // C44-EV2 Connector
     int reading3 = analogRead(analogPin3);
     float voltage3 = reading3 / 204.6;
     regBank.set(40019, voltage3);
     if (voltage3 < 1)
       { 
        regBank.set(40003, 0);
       }
     else
       {
        regBank.set(40003, 1);
       }

     // C1YT17-EV  Connector
     int reading4 = analogRead(analogPin4);
     float voltage4 = reading4 / 204.6;
     regBank.set(40020, voltage4);
     if (voltage4 < 1)
       { 
        regBank.set(40004, 0);
       }
     else
       {
        regBank.set(40004, 1);
       }
   
    // Actuation of Pass or Fail relays
    if ((voltage1 > 4.7) && (voltage2 > 4.7) && (voltage3 > 4.7) && (voltage4 > 4.7)) // && (voltage5 > 4.7) && (voltage6 > 4.7))
      {
        digitalWrite(outPin1, LOW);  // Fail LED
        regBank.set(40009, 1);       // Fail Display Indicator
        digitalWrite(outPin2, LOW);  // Pass LED
        regBank.set(40008, 1);       // Pass Display Indicator
        digitalWrite(outPin3, HIGH); // Connect to Harness LED
      }
    else if ((voltage1 < 1) && (voltage2 < 1) && (voltage3 < 1) && (voltage4 < 1)) // && (voltage5 < 1) && (voltage6 < 1))
      {
        digitalWrite(outPin1, LOW);  // Fail LED
        regBank.set(40009, 1);       // Fail Display Indicator
        digitalWrite(outPin2, HIGH); // Pass LED
        regBank.set(40008, 0);       // Pass Display Indicator
        digitalWrite(outPin3, LOW);  // Connect to Harness LED
      }
    else
      {
        digitalWrite(outPin1, HIGH); // Fail LED
        regBank.set(40009, 0);       // Fail Display Indicator
        digitalWrite(outPin2, LOW);  // Pass LED
        regBank.set(40008, 1);       // Pass Display Indicator
        digitalWrite(outPin3, LOW);  // Connect to Harness LED
      }
    slave.run();   
   // Driver_Delay_ms(250);   
   }   
}

Thanks in advance.

Pages: [1]