Jump to content

Recommended Posts

I am using an MSP430fr5969. The board only has one hardware pwm available and it located on P1.2. 


For my application, I need to generate two different pwm signals to control two different motors. One of those is a servo, the other is a linear actuator but it is controlled through a motor speed controller that uses a pwm input (replicating that of an RC receiver). 


Can I use the servo library and attach a servo to any pin or does that pin have to have hardware pwm? I looked through the Servo.cpp file and it seems to be doing software serial.


When i run servo examples, and hook the pin up to an oscilloscope I do not get nice square waves being generated as an output. Currently I am using pin 9, the defualt for the servo libraries.




Link to post
Share on other sites

If I am not mistaken the servo library does use software PWM.

You could make hardware PWM though I am not sure it would be able to get down to 50Hz at full clock speed (at 16Mhz), I am not familiar with the MSP430 timers. Give it a try, as abecedarian said, the board has plenty of PWM outputs.

Link to post
Share on other sites

Find the purple things.



Oh, ok. So you are referring to software pwm as well. Maybe I have an error in my pwm values somewhere else. I tried using analogWrite() but it was not generating results on my motors. When i used a rc receiver the motor preformed fine. 

Link to post
Share on other sites

The purple things should be fine with analog outputs, a.k.a. PWM.


Maybe I should have asked you first, your board shows in the Energia list and you have selected that?


Yes, I can upload code to the board fine. I have used the servo sweep example in the past. It moves the servo back and forth but it is very jumpy.


As for the motor controller (https://www.pololu.com/product/1373/specs) I am trying to connect the RC control pin on the motor controller to the output of an analogWrite() pin on the MSP430 board. The controller will not even allow me to run because it determines it has a fault of the pwm signal coming it. The error is that the pwm signal has to large of a range (it is jumping between 30 and 3604. This is with me only using one value in the analogWrite() function and not varying it at all in the code. 

Link to post
Share on other sites

Servos need their PWM not only to have a given duty cycle, but they also need a specified frequency (typically 50hz or 100hz). This fairly easy to do via the Timer system, and is much easier to debug without the abstractions of the AnalogWrite libraries. (IOW, coding against the registers is easier here)

Just make sure you test each step of the timing with your scope. Make sure your source clock is the frequency you think it is, then make sure the CCR has the right frequency, and then confirm your duty cycle. (Sounds like a lot of work, but is much faster one step at a time rather than writing it all at once and wondering where in the chain something went wrong.)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...