Carl Herman
Hello! I am new for OpenPLC, and now I have a very primary question about OpenPLC editor, it has stuck me for several days. I want to know how to write a ladder logic diagram to drive a servo motor. I want to output a signal with a period of 20ms and a high level of 1ms. Can anybody show me the correct ladder logic diagram?My slave device is nodemcu.
Reply 0 0
thiagoralves
https://openplc.discussion.community/post/generator-ats-10140949?pid=1308690230
Reply 0 0
Carl Herman
I tried to write 3277 on the %QX100.0 by MOVE block(I connect the servo to the D1 pin on NodeMCU), but when I uploaded the .st file to OpenPLC Runtime, there appeared an error called "Bit size of data type is incompatible with bit size of location", why this error occurred?
Reply 0 0
thiagoralves
https://openplc.discussion.community/post/editor-error-10472080?pid=1311123686
Reply 1 0
Carl Herman
Hello, I have one more question now. I use Nodemcu for my slave device, so which kind of OpenPLC Hardware Layer should I choose? I am keeping it as the default option, should I change it to another one?
Reply 0 0
thiagoralves

https://www.openplcproject.com/getting-started-esp8266

The hardware layer is only used to control the host IOs, it has nothing to do with slave devices. If your host has no IOs then you should use Blank

Reply 0 0
Carl Herman
  Thank you sir, you have resolved the problem that bothered me, but when I connected as shown below, the servo still didn't work, could you please give me some advices?
{C7YZ%WZ2G~EK_O9P]1%~RC.png 
Reply 0 0
thiagoralves
I have no idea. How is the servo connected? Where is this "servo" variable attached to? Which platform is OpenPLC running on?
Reply 0 0
gfine
I put this in the sample code section. Maybe it will help others using the PWM instruction with the S90 or S51 servos. Please refer to the PDF for the program and the snapshot for the Data Table usage of variables.
 
 
 
Reply 2 0
damoney27
I put this in the sample code section. Maybe it will help others using the PWM instruction with the S90 or S51 servos. Please refer to the PDF for the program and the snapshot for the Data Table usage of variables.
 
 
 
Hi can you tell me the other channels I can use besides channel 1 and what pins they are on? 
Reply 0 0
gfine
It has been awhile since I have used the R3
board. Let me check and get back to you. Is there a reason you can't use Ch1?
Reply 0 0
damoney27
It has been awhile since I have used the R3
board. Let me check and get back to you. Is there a reason you can't use Ch1?
I want to use 2 servos
Reply 0 0
thiagoralves
The channel and pin allocation is platform dependent as it varies according to the hardware PWM present in the silicon. For the 328 and 32u4 AVR:
#define PWM_DEFAULT_FREQ 490
#define PWM_CHANNEL_0_PIN 9
#define PWM_CHANNEL_1_PIN 10
#ifdef __AVR_ATmega32U4__
#define NUM_OF_PWM_PINS 2
#else
#define NUM_OF_PWM_PINS 3
#define PWM_CHANNEL_2_PIN 11
#endif
You can check the source code for each platform here:  https://github.com/thiagoralves/OpenPLC_Editor/tree/master/editor/arduino/src/hal
 
Reply 1 0
damoney27
The channel and pin allocation is platform dependent as it varies according to the hardware PWM present in the silicon. For the 328 and 32u4 AVR:
  1. #define PWM_DEFAULT_FREQ 490
  2. #define PWM_CHANNEL_0_PIN 9
  3. #define PWM_CHANNEL_1_PIN 10
  4. #ifdef __AVR_ATmega32U4__
  5. #define NUM_OF_PWM_PINS 2
  6. #else
  7. #define NUM_OF_PWM_PINS 3
  8. #define PWM_CHANNEL_2_PIN 11
  9. #endif
You can check the source code for each platform here:  https://github.com/thiagoralves/OpenPLC_Editor/tree/master/editor/arduino/src/hal
 
Thanks much.
Reply 0 0
gfine
There is a book on Amazon that references the Ardriuno with OPEN_PLC. this is a snapshot of one page depicting the I/O layout. I think someone else also replied to this and i do not have my log in to replay on the website. That answer is correct also. Hence pin 10 is Channel 1. Pin 9 is Channel 0 and Pin 11 is Channel 2. This is a bit contrary to the instruction's description saying that the pin number corresponds directly to the Channel. If C=0 you are on pin 9. If C=2 you are on pin 11. I guess the least significant number applies to the channel.

I hope that helps.

Regards,
Gary
Reply 1 0
Reply