Nolan 1 Posted May 2, 2015 Share Posted May 2, 2015 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. Thanks, Nolan Quote Link to post Share on other sites
abecedarian 330 Posted May 2, 2015 Share Posted May 2, 2015 According to http://energia.nu/pin-maps/guide_msp430fr5969launchpad/, there are about 17 PWM outputs available on that board; 14 from the BP headers. Quote Link to post Share on other sites
L.R.A 78 Posted May 3, 2015 Share Posted May 3, 2015 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. abecedarian 1 Quote Link to post Share on other sites
Nolan 1 Posted May 3, 2015 Author Share Posted May 3, 2015 According to http://energia.nu/pin-maps/guide_msp430fr5969launchpad/, there are about 17 PWM outputs available on that board; 14 from the BP headers. Where does it say that? I only see the one pin labeled PWM (pin 19). Will the servo library work on a motor controller that uses pwm but is not a 0-180 servo? Quote Link to post Share on other sites
abecedarian 330 Posted May 3, 2015 Share Posted May 3, 2015 Where does it say that? I only see the one pin labeled PWM (pin 19). Will the servo library work on a motor controller that uses pwm but is not a 0-180 servo? Find the purple things. Quote Link to post Share on other sites
Nolan 1 Posted May 3, 2015 Author Share Posted May 3, 2015 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. Quote Link to post Share on other sites
abecedarian 330 Posted May 3, 2015 Share Posted May 3, 2015 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? Quote Link to post Share on other sites
Nolan 1 Posted May 3, 2015 Author Share Posted May 3, 2015 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. Quote Link to post Share on other sites
SvdSinner 3 Posted May 6, 2015 Share Posted May 6, 2015 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.) Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.