nowatkom
Hello!

I just downloaded the latest version of Arduino (1.8.12) and the OpenPLC_v3_Uno.zip.  When I try to "Verify" the code in Arduino, I get a few errors.  Do I have to use an older version of Arduino?

Thanks!

OpenPLC_Uno: In function 'void setup()':
OpenPLC_Uno:90: error: no matching function for call to 'ModbusSerial::config(usb_serial_class*, int, int)'
modbus.config(&Serial, BAUD, TXPIN);
^
In file included from /home/hardware/Arduino/test/OpenPLC_Uno_v3/OpenPLC_Uno/OpenPLC_Uno.ino:39:0:
/tmp/arduino_build_77583/sketch/ModbusSerial.h:42:14: note: candidate: bool ModbusSerial::config(HardwareSerial*, long int, int)
bool config(HardwareSerial* port, long baud, int txPin);
^
/tmp/arduino_build_77583/sketch/ModbusSerial.h:42:14: note: no known conversion for argument 1 from 'usb_serial_class*' to 'HardwareSerial*'
no matching function for call to 'ModbusSerial::config(usb_serial_class*, int, int)'
Quote 0 0
thiagoralves
It worked for me:
Capture.png 
Quote 0 0
nowatkom
ok! so, the problem was at my end.  I am using a Teensy 3.2 instead of an Uno, so Thiago made a couple changes to the code, and for the most part everything works well!  The problem is the way the Teensy handles USB/UART differently than the Uno (if I am understanding things the way Thiago explained it).

Here are the changes from Thiago:
Line 22 in ModbusSerial.cpp should read:
bool ModbusSerial::config(usb_serial_class* port, long baud, int txPin) {

Line 42 in ModbusSerial.h should read:
bool config(usb_serial_class* port, long baud, int txPin);

I am still working out pin assignment changes for the .ino, I'll post those when I find a set that works well.

Thanks for all the help Thiago!!!! 🙂
Quote 0 0
nowatkom
Here are the pin assignments in the .ino that work for me (at least the DIN and DOUT, I haven't tried the analog pins yet): (snipped from the .ino, lines 28-60)

/******************PINOUT CONFIGURATION*******************

Digital In: 2, 3, 4, 5, 6 (%IX100.0 - %IX100.4)

Digital Out: 8, 9, 10, 11 (%QX100.0 - %QX100.3)

Analog In: A0, A1, A2, A3, A4, A5 (%IW100 - %IW105)

Analog Out: 20, 21, 22 (%QW100 - %QW102)

**********************************************************/

#include <Arduino.h>
#include "Modbus.h"
#include "ModbusSerial.h"

//ModBus Port information
#define BAUD 115200
#define ID 0
#define TXPIN -1

//Define the number of registers, inputs and coils to be created
#define NUM_DISCRETE_INPUT 5 // Digital In
#define NUM_INPUT_REGISTERS 6 // Analog In
#define NUM_COILS 4 // Digital Out
#define NUM_HOLDING_REGISTERS 3 // Analog Out

//Create the I/O pin masks
uint8_t pinMask_DIN[] = {2, 3, 4, 5, 6};
uint8_t pinMask_AIN[] = {A0, A1, A2, A3, A4, A5};
uint8_t pinMask_DOUT[] = {8, 9, 10, 11};
uint8_t pinMask_AOUT[] = {20, 21, 22};
Quote 0 0