cerbo.gehirn
Hello!
I have a small project (traffic lights) and I'm using arduino UNO.
I have 5 leds and 1 servo motor for a gate. I have some problems:
- How to change the value of the servo motor?
 The servo in %QX0.5, but I don't know how to, in SFC language, change its value, I guess it is type WORD, but how to change the value? Which block should I use? Which type of variable? Which type of Location (analog or digital output)?
 
Thanks for any help!
 
ksnip_20240401-145024.png
Reply 0 0
thiagoralves
%QX0.5 is a digital output, so it only takes boolean values (TRUE or FALSE). You can set the values the same way you are setting your other boolean values for the traffic light LEDs
Reply 0 0
cerbo.gehirn
Thank you for the answer!
Could I use in variable 6 gate, %QW0? And how can I change its value? I would like to change it from 0 to 70 but I could find a way to insert those values in the action box. The gate is a servo motor.
Reply 0 0
thiagoralves
If you locate gate on %QW0, then you would have to change its type to something compatible, like WORD, UINT or INT. 

To change its value, just add an expression and type gate := 70
Reply 0 0
cerbo.gehirn
I tried every combination of %QW0 and %QX0.1 to $QX0.4 with WORD UINT INT BOOL, to try to move the servo motor, but I suspect that it is not possible in OpenPLC. According to https://openplc.discussion.community/post/use-openplc-editor-to-drive-a-servo-motor-10471739 there is no way to make servo work using SFC or Ladder, am I correct?
Reply 0 0
thiagoralves
It depends on what type of motor you have. If  your servo takes in PWM pulses you should be able to control it using the PWM_CONTROLLER block
Reply 0 0
Reply