xale12
Hello, Thiago It is me again. I do this open plc editor for PWM motor speed project but When I launch It in openplc webserver It said " Optimizing ST program...
Generating C files...
./st_files/642038.st:5-6..5-26: error: Bit size of data type is incompatible with bit size of location.
1 error(s) found. Bailing out!
Error generating C files
Compilation finished with errors!"
This is my project can u find my error 
thiagoralves
This error means that you're trying to use a variable that is bigger (or smaller) than the location you're putting it on. In your program, out_put is of type REAL (4 bytes) and you assigned it to %QW0 which is a 2 bytes location. For %QW0 you should use UINT or INT only.
Reply 0 0
xale12
Thank a lot for your helpful answer. I can use It in openPlc now but I can not control it by node-red contribs modbus . I have a modbus sim and I can easily control it with node red contrib modbus but I can not use FC6 of Modbus for openplc 🙁(
Reply 0 0
thiagoralves
You definitely can use FC06 with OpenPLC, but you just need to keep in mind that OpenPLC is a PLC, not a simulator. Therefore, it has built in programmability. This means that if you’re using FC6 to write to a register that is manipulated (written) by your ladder logic, than your ladder logic will prevail. A thumb rule is to only write to registers/coils that are read (not written) on the ladder logic
Reply 0 0
xale12
Do you have any suggestion for me . I just have change the out_put into coil but It still can not control by modbus . Untitled.png 
Reply 0 0
thiagoralves
Coil is a digital element. You can't put an analog location as %QW0 in a coil. That's why the red lines showed up on your editor. If you want to manipulate %QW0 from modbus, just don't use %QW0 in your ladder logic. Delete that line and it will work fine.

Now, if you want to manipulate %QW0 from ladder logic and modbus, well, then you will have to write that condition on your program. Ideally you should have a memory location for the ladder logic to manipulate (ex %MW0) and another memory location for modbus to manipulate (ex %MW1). Then on the ladder logic you define the condition for when ladder logic or modbus should operate %QW0 and then move either %MW0 or %MW1 (depending on the condition you defined) to %QW0. If you do that, keep in mind that from modbus you won't write to %QW0 directly, you will be writing to %MW1 instead (modbus holding register 1025) 
Reply 0 0
xale12
Thank you sir . I will try It.
Reply 0 0
xale12
Hello sir. I still have a confliction by Modbus and open plc editor can you tell me where Why. When I change into auto mod when I write to  1024 address ( %MW0)  I can see it work for a milisecond by debug window but It immediately reset to 0 value . Here is my open PLC editor program and my node red configuration . Untitled.png 
Reply 0 0
xale12
Maybe I see the error , When I write the value by slider It is not working maybe It  is affected by the timeout . Any way when I write an exactly value It run perfectly .
Reply 0 0
thiagoralves
I'm not familiar with node-red. But you can check the behavior with any Modbus simulator tool like Radzio.
Reply 0 0
xale12
It is OK now I know my problem. When I write the value into Modbus address I used slider with continuous mode, So I have a thousand control commands just for a second -> Modbus server can not receive my command. I change the slider control became send output only when I release the slider. After that, It runs perfectly. Sorry It is my false and thank for your kindness . ^^
Reply 0 0
ehsan4
HI THIAGORALVES i m ehsan shahid to controll servo motor and stepper motor with  openplc can u guide me 
Reply 0 0
pk07
ehsan4 wrote:
HI THIAGORALVES i m ehsan shahid to controll servo motor and stepper motor with  openplc can u guide me 


Hi @ehsan4, you can follow this thread. I am currently working on this and I've made some real progress.

https://openplc.discussion.community/post/industrial-grade-plc-12331810?pid=1332552516
Reply 0 0
Reply