How to to send out a pwm signal from the serial port with linux? (With python or c++)
I want to connect a motor directly to change the speed rotation.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The idea is possibly ill-advised unless you really know what you are doing with the interfacing. Any signal driven from those pins if used at all should only supply signal level drive – you would have to use this to control a motor controller or amplifier actual motor drive, do not connect a motor directly. Moreover the signals out of a serial port swing -ve and +ve rather than zero/+ve.
One possibility is to use the DTR signal since that can normally be independently controlled (as described in Set serial port pin high using python for example), however through software you may not get the frequency or precision required to control a motor accurately or efficiently, and if the software fails you could leave the motor running at full-speed – so some care is required.
A better solution is to get a dedicated digital and/or PWM I/O card or USB device, or even a purpose build motor controller interface. Industrial computer suppliers such as Advantech will have something suitable, and at lower cost perhaps, any number of robotics hobby suppliers.