Skip to content

C++ Program Seems to Overload PLC?

I am working on a project and the goal is to create a waterfall that can change the flow of the water to look like a user imported image, similar to the one here

In order to channge the flow of the water we are using solenoids, about 200 of them. I wrote a c++ program that takes a user uploaded image and converts into a 2d array of 1s and 0s. Then using a for loop it reads to each solenoid row by row the value in the array. if the value is 1 it will send TRUE to the solenoid so it can open or stay open then if its 0 it will send FALSE to the solenoid so it can close or stay close.

After building the program in eclipse and trying to run it on the plc we ran into an issue where all of the connected outputs would turn on then turn off then display a BF-D error. After this we tried to run a simple code that uses structured text to just turn on and off all of the solenoids and we were not getting any responce(this code usually works). When turned the plc off and back on it seemed to try and run the PLC program again but just ended up doing the samething turning on then turning off.

Attached below is the code for the program that we tried to run on the plc, this code is motified version that used the array from the start instead of using opencv for the image converion and also a gif of what happened to the PLC is attached as well, in this video we did not connect all of port to an output on the I/O module because we were trouble shooting to see if it was power problem.

The I/Os being used are two DO16/1 five DO32/1 and one DI8/1 DO8/1

edit: Tried to upload the code in a .txt file but it said unsupported format. Also the code is set to wait 20ms before reading the next row.

Comments

  • If you unplug all the front connectors from the I/O modules (except the power connectors), does the program run OK - i.e. do you see the LEDs on the modules light up correctly?
    I'm wondering if there is some sort of power issue, which might be "solved" by unplugging all the output devices.
    Do you have a diagram showing the DC power distribution to the PLC and all the I/O modules?
    How much current is drawn by each solenoid?
    How are the solenoids wired to the I/O modules? Are there any interposing relays, or back-emf suppression devices? (a diagram might be useful)
    Are there any clues in the Output.log file on the PLC, that might indicate a problem?
    If you would prefer to send us this information directly by email, please let us know.
    Also, it would be worth contacting a technical specialist from your local Phoenix Contact office. They can usually give personal support on application-specific issues like this.
  • So when we run program to run on all outputs then close again after 100ms then repeats this process everthing seems to work fine(one problem with this program is that it doesnt open and close on consitent intervals but I will ask about this in another thread). This program is made through stuctured text and not the C++ route but when we run the C++ program the same thing ends up happening again do you still think this a power problem or could it be the programming and setting up of the project.

    Though attached or some schematics on how we set everything up

    The diagram shows the old plc we are now using a plcnext controller
  • when we run program to run on all outputs then close again after 100ms then repeats this process everthing seems to work fine
    but when we run the C++ program the same thing ends up happening again
    do you still think this a power problem
    If the logic in the ST and C++ programs is identical (i.e. exactly the same sequence & timing of solenoid activations in both), then it is less likely to be a power issue, and more likely to be (for example) an error in the C++ program.
    Is there any information in the Output.log file on the PLC that indicates what the problem might be?
  • When we run the program it doesnt show any errors in the Output log the only que that we get that something is wrong is the bf-d light on the plc is flashing.

    Also for the C++ code I used "usleep(20000)" in order to set a delay before reading another row could this be a possible error?
  • could this be a possible error?
    Yes. Someone will address that in an answer to your other question about the sleep function.
    I can highly recommend getting in touch with a technical specialist in your local Phoenix Contact office. They can usually offer personal support on application-specific issues like this.
Sign In or Register to comment.