I am using Node-RED to work on a project which has more than 10 step motor and other 4 kinds of sensors commnicating to pc with serial. To be more specificially, one port(rs232) connected to a weight sensor to calculate the weight of some object, and another port(rs485) connected to 14 step motors(custom protocol), IO module(custom protocol) and a tempature sensor(modbus).
The sensors are pretty simple, Node-RED handle this very well.
I need to do the complicated motion control with these motors. But these motors, I cannot make these motors work well, or write the easy-maintaining code. Because every motor needs to use serial out, to set speed, set position, check the motor status and etc. And in this project every motor movement needs to be synchronized which means when I send the move command, I need to send check status command continuously to watch if the motor is ready in positon for the next movement. So, I need the serial in to receive the data from motor and parse it.
As a result, serial in and serial out are everywhere, the project is coupled tighly.
How can I handle this problem, and code better? I wander If Node-RED is not suitable for this project?
Maybe introduce a MQ into this project? or make a custom node for the motor?
If make a custom node for the motor, how can i share the serial between motors and other rs485 device.
So this seems to be your real issue? And Node-RED isn't really the tool to do that last part of the control because it isn't and cannot be a real-time controller.
The standard approach for this kind of task is to use a microcontroller such as an ESP32 with multiplexed serial connections (as you likely have more serial connections than a standard microprocessor on its own would have available).
You can use Node-RED to do the orchestration. And yes, MQTT is a useful intermediary comms channel.
I've thought about this, but this project doesn't require a lot of real-time, because 3/4 of a process is waiting for a device to perform a long time-consuming operation. I could have waited a while for the motors to move into place after the move command was executed.
My goal at the moment is just to make it work, not to make it efficient, because a second improvement doesn't make much sense before a long time-consuming operation that takes 30 minutes.
As for why I chose Node-RED, it provides a very convenient UI, whereas if I had used Qt or MFC, it would have taken me a very long time to develop the UI alone. At the same time, I don't have a specific UI requirement, the UI will change frequently, and using Node-RED can change the UI at a very low cost, which is a big advantage of Node-RED.
We have done the same. First, everything was implemented in Node-Red and now we started to move time critical things to a microcontroller board because we want the system to be fast and deterministic.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.