Arduino & PLC communication

srsicard3

Member
Join Date
Jun 2020
Location
CT
Posts
16
I am working on a project that had originally started on a sparkfun redboard artemis.

Through some testing I've pushed to utilize a PLC for the project.


the project requires 4 RS232 communications to work with scales, PWM output to control a servo (RC car style), DC output to run a small DC motor to run a pump, and must read from 2 encoders to count number of revolutions.


I struggled with getting RS232 communications established for 4 scales which is why I am pushing for a PLC now.


My question is, is there a way to have some communications between the redboard artemis and the PLC? I plan on using a Productivity 2000 series PLC.
Since all the hardware was already bought, I am trying to reuse as much as we can, rather than purchasing all new hardware and re-designing.


Anyone done anything like this before? basically i would leave the encoder inputs, servo, & DC motor on the redboard artemis, and put the RS232 communications, and data output (to SD card) in the PLC. the PLC would need to tell the artemis when to toggle the servo, when to start the DC motor, and read back number of cycles the encoders read per cycle.


Let me know what you guys think!
 
1) modbus (rtu? tcp?) Is not a complex protocol, but seriously signal timing could be an issue.

2) a custom protocol of limited scope is not complex.

What physical comms are available to the Artemis.
 
drbitboy said:
1) modbus (rtu? tcp?) Is not a complex protocol, but seriously signal timing could be an issue
Not sure what you mean by "signal timing"... perhaps you could elaborate?

srsicard3 said:
I am working on a project that had originally started on a sparkfun redboard artemis.
The reboard is a cool board, I've been wanting one for awhile.
I have connected to a few PLCs and HMIs via MODBUS TCP with the Arduino UNO and MEGA. It is pretty simple to setup although figuring out the MODBUS mapping can sometimes be tricky. If interested I could probably dig up some sample code.
 
Have you calculated the cost that getting some of this stuff will be? The 4 RS232 cards will not come cheap, and that's before we look at some of the other stuff which isn't quite standard across the board on PLCs.
 
Not sure what you mean by "signal timing"... perhaps you could elaborate?


The Modbus specification (cf. http://modbus.org*) has very specific timing requirements for Modbus RTU (serial) communications. I suspect many Modbus RTU-capable devices have UARTs with a buffer and exceed, or don't care about, those specifications, but we don't know what devices OP is working with at this point.

* Technical Resources, Modbus Serial Line Protocol and Implementation Guide V1.02, section 2.5.1.1.

I agree the Modbus protocol itself is simple; mapping is an exercise in careful bookkeeping, although even that seems to be too challenging for many vendors. If you have an example of an Arduino Modbus application it will provide a path that should solve OPs task nicely; it would also be an excellent resource if added to the Downloads section of this website.

P.S. I was on my phone when I made my first response to this thread; I have no idea what "seriously" was supposed to be, but suspect it was a result of the ever humorous autocorrect.
 
Attached is the sample project files. The Arduino is a off-brand MEGA and the ethernet shield is from Sunfounder. The HMI is a 10" LSIS I had laying around. I tested everything out this afternoon and it all works great. The communication is very speedy and seems to be reliable.
The software for HMI is available for free download if you wish to view the program file.

Also as a side note... Google is actually quite helpful in this matter, just search "Arduino Modbus TCP".

Have fun!!:)

HMI Software: https://www.ls-electric.com/products/view/Smart_Automation_Solution/HMI/XGT_Panel/XP-Builder

Edit: Video file was too big too attach. Had to compress it severely which resulted in rather bad quality, but it is still "seeable"
 
Update:
End user wants to move to an industrial controller since this project will become a test stand that will run daily for them.


one more question:
can a PWM output card from a PLC, Productivity2000, control an RC stepper motor? In theory it should, right? I just have never tried.


using an Automation Direct P2-04PWM, trying to control a
https://www.amazon.com/dp/B07L83M8SM?psc=1&ref=ppx_yo2ov_dt_b_product_details


the other option is to get a stepper motor and stepper driver from automation direct.






P.S. Thank you everyone for the input! good to know for future applications.
 


P.S.

  • the servo-relevant code, that scales an output value to the PWM infrastructure inputs, is in the LAD 3 DRIVESERVO routine.
    • N.B. the math is in the comment on the last (END) rung.
  • The PWM frequency spec for the RC (Radio Control; also Really Cheap) servos is 20-50Hz, but I had success with up to at least 100Hz.
    • The advantage of the higher frequency is more resolution in the output duty cycle:
      • PWM output "widths| of 0 and 1000 are 0% and 100% duty cycles, respectively, and the usable range of duty cycles, in time, for the servo is 1-2ms nominal, 0.5-2.5ms actual.
  • a lot of the rest of the code, including the PID, is more or less unused in that example; it was planned for later use.
 
Have you calculated the cost that getting some of this stuff will be? The 4 RS232 cards will not come cheap, and that's before we look at some of the other stuff which isn't quite standard across the board on PLCs.

Dual slot CLICK+ PLC from AD with two DCM cards can handle the 4 scale ASCII streams for pretty cheap. Brutal to do the rest of the work though.
 

Similar Topics

I'm trying to write a data in Arduino using MODWR function block .I used the code I got from online for both PLC and Arduino. I made the wiring...
Replies
4
Views
119
Hello i am trying to make a connection between my arduino uno and plc delta ss2 using rs232 com1 RTU protocol. The problem here that i did all the...
Replies
0
Views
1,722
Hello everyone, I want to make a serial communication using Siemens S7-1200 with CM 1241 (RS-232) and communicate with my Arduino. Here is the...
Replies
13
Views
9,818
Hello, I have been getting more and more requests for Real Time Clock (RTC) sensitive automation from my clients. I know that there is a Modbus...
Replies
13
Views
2,750
https://www.arduino.cc/pro/software-plc-ide Diving in when I get home. With its full IEC language support, object-oriented programming...
Replies
65
Views
19,708
Back
Top Bottom