Digital Loggers IoT PLC - Machine Control & Monitoring with Mega 2560

Hi everyone,

I am currently working on a project where I will be using the following Mega 2560 based device in a control that I am building for a laser marking application: Digital Loggers IoT PLC

First off...this is my first go with Arduino and I am looking for some guidance on how to program the logic. I have experience programming PLCs using ladder, but I have to say getting my feet wet with this device has been a bit intimidating. I do not have any experience programming in C/C++

Here's a brief description of what I am looking to achieve and this is the device that I will be monitoring: USC-1 controller card

I would like to monitor 3x digital inputs (start cycle, stop cycle, cycle in progress) to control a 24VDC LED stack light (red, yellow, green) via the relays. I already have most of the power/control circuits wired up. I used a 120vac to 12/5vdc transformer for the control power and a 120vac to 24vdc transformer for the LED lights. I can manually operate the LEDs by triggering the relays using the touchscreen via a test program for the unit that I found on github. I will also have a magnetic switch on the enclosure door that I need to monitor. Start & Stop signals are triggered via rising edge and In-Progress signal is ON during the process.

Here are the conditions that I would like to begin with:

  • Red LED is ON when power is applied to the control card, door is either open or closed, and machine is not in a cycle or has been stopped/reset. OFF when cycle is in-progress, waiting for door to open after cycle completed, and control card is off.
  • Yellow LED is ON/flashing when cycle has completed, but the door has not been opened yet. OFF when operator opens the door to remove the completed work piece and reset the control.
  • Green LED is ON when door is closed and the machine is in a cycle. OFF when cycle has completed.

Once I have grasped the basic programming concepts I plan to add some data logging functionality and possibly email alerts.

Any help with this would be greatly appreciated!

I had a go at RLL once and found it hard - I'm used to 'C'...! The inverse of your problem..

A good start : try it as a machine with various states, and draw a state transition diagram.

What triggers the state changes ? what does the machine do in each state? on entry? and while there?

regards

Allan

Ladder logic and C are not different in the series of events. but much different in how you write the logic.

in Ladder you preface the coil. if switch A is open and switch B is closed, then power will pass to the coil.

we do that same, just use different way of wrting.

your IDE, the software you down loaded, has a lot of sample 'shetchs' or programs.
each will teach you how to do that one thing.

I am not a trained programmer, but someone with a lot of experinace told me to write all your inputs in the first part of loop()
and then in the next section, do your logic, and in the third set your outputs.

this really helps becase as a new user, it is not uncommong to turn a switch on after one line, then turn it off on the next and you think it never turned on because the end result is that it is off most of the time and on for an instant.

one of the great things about C is that you can have odd but meaningful names

switch_on_wall_by_tank
HighLimitSwitchOnOverflowTank

get some LED's and resistors and play around a bit. asking foolish questions is better than wasting days on foolish mistakes ! we really don't mind.

dave-in-nj:
Ladder logic and C are not different in the series of events. but much different in how you write the logic.

I am not a trained programmer, but someone with a lot of experinace told me to write all your inputs in the first part of loop()
and then in the next section, do your logic, and in the third set your outputs.

this really helps becase as a new user, it is not uncommong to turn a switch on after one line, then turn it off on the next and you think it never turned on because the end result is that it is off most of the time and on for an instant.

get some LED’s and resistors and play around a bit. asking foolish questions is better than wasting days on foolish mistakes ! we really don’t mind.

This is exactly the kind of nudge in the right direction that I was looking for. Thanks for the reply!

one of the first posts on every forum is ‘how to use this forum’

#7 shows how to post code.

if you want to post some simple ladder logic, you can attach a file, or post in ‘code tags’

We can walk you through C version of programming the same thing.

Having ( a long time ago!) built a project using ladder logic, I'd say it's different to C/C++ in a fundamental aspect - it's inherently multithreading. To do this in C you need a finite state machine.

regards

Allan

I see ladder logic as running a full control secquence for each ladder rung. just as C had if() else(), or a multile if() statements, you have a similar sequential operation with both.

I think the depth of programming is based more on your ability and someone highly trained in LL will be able to do much more than a new person in the Arduino world. however, I also think that the C++ of the arduino world offers a larger possibility of more complex programming at a lower experience level.

I think the OP's project is not beyond a novice for an Arduino as so many sketches are available and piecing them together is not that difficult once you understand some of the barriers.

I was able to piece some code together to test the basic functions of this device in my application after wiring up the control card to the PLC. Right now I have the green LED lighting up when the machine is in process by using:

// Read digital pin D35 = Laser marking cycle in progress. Green LED On during cycle.
 int state = digitalRead(35);
 // Set RELAY6 state according to D35
 digitalWrite(PLDuino::RELAY6, state);

Is there anyone out there that has had experience with this particular device? I am now getting somewhat versed with the arduino IDE and language reference, but still have some questions about what the “firmware” for this device is doing.

Github repository for the device firmware: Digital Loggers PLDuino