Servo Motor with fixed angle

Hi. I am making a smart home prototype where I connected the door with Servo-motor and I wanna rotate the motor on one fix position (95°) then it can open my door. Now I switch from the dashboard and connect it with GPIO out (PWM) with frequency 100 Hz and it is rotating 180°. I think I need to add on function node between them but I am not sure what I need to write in it. Anyone can suggest to me.
Regards,

It is not really clear what you want. You say you only want the motor positioned at one position (95°) but that doesn't make sense. What exactly are you trying to do with the servo?

Well, first of all, thanks for your response.
I connected motor with door and I need to open and the door while at 95° of my door will completely open then I wanna delay for 5 seconds and then the door will close at 0°. Actually, I am using RFID Module and I wanna connect it with the motor. So, after scanning the card the motor will open the door.

OK, how far have you got? Are you able to control the position by sending the gpio node values between 0 and 100 as described in the description?

Yes, you mean to say the frequency?

In the information tab it tells you what it expects in msg.payload. In particular it says
"PWM mode - expects an input value of a number 0 - 100. It can be floating point."
So you send the node a message with a value between 0 and 100 and that should send the servo to the appropriate position. To test either connect some inject nodes to it or wire it to a dashboard slider set to generate 0 to 100 and see what happens.

Slight aside - the pi-gpiod node https://flows.nodered.org/node/node-red-node-pi-gpiod - provides much better timing accuracy for servo positioning (for normal RC model servos), but does need some more setting up.

One other thing to keep in mind, a servo motor can usually only turn 90 degrees in either direction for a total of 180 degree movement. Therefore you will probably have to set it up so home as -45 and open as 50 to get your 95 degree swing.

Thanks for your reply, I didn`t get your point how I can set the home and where I need to set 50 degree

First find the range of numbers that gives you the angles you need.
Next what signal or input are you using to decide what position you want it set to?

I am using range and GPIO out nodes but it is not work:

[{"id":"8777601e.137e5","type":"range","z":"675ddecd.d7a01","minin":"0","maxin":"100","minout":"100","maxout":"0","action":"scale","round":false,"property":"payload","name":"","x":380,"y":300,"wires":[["d11fc2.f6d1204"]]},{"id":"d11fc2.f6d1204","type":"rpi-gpio out","z":"675ddecd.d7a01","name":"","pin":"40","set":"","level":"0","freq":"100","out":"pwm","x":560,"y":340,"wires":[]},{"id":"696237de.1eb568","type":"inject","z":"675ddecd.d7a01","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":280,"wires":[["8777601e.137e5"]]}]

Please read this link and edit your previous post so that we can import the flow.
Also tell us what about it does not work.

1 Like

And what does not work? Your flow only has the the nodes to inject one value (1).

Actually, I mounted Servo motor with smart home door and wanna to open and close the door with servo movement.

So if you put different values in inject nodes are you able to make it move the right points?

Different values in inject node means. Yes, I know I can add 0 to 9 as mention payload number.

So what inject values give you the two positions from the servo that you need?

Actually, in my case, I wanna open and close the servo motor mounted door with RFID ( which is already connected and working fine). And I wanna node as shown in picture.error

So we need to know two things.

  1. The answer to my previous question, which you haven't answered, do you know what values you need to send to the servo node?
  2. Assuming you do know (or have now worked it out) what are they
  3. Put a debug node showing the output of the RFID node and show us what it shows for the open and closed position.

Well, I am not sure what values I need to assign and where I need to assign for Servo. But physically, I need 0 to 95°.