Jump to content
43oh

Project using the FR2311 and DC Motors


Recommended Posts

Hello I am going to say that I am very new to Embedded systems. I could have started with the arduino as everyone else seems to do but I wanted to really understand how MCUs work so I opted for TIs MSP430 Line. I have read a lot of the documentation for the FR2311 and just have some general questions about how to go about using it most efficiently. 

First what my end goals are, 

I want to be able to control two DC motors that are bidirectional with speed control through a pot for each motor. They will be controlled via a L293DIC. 

I also want two push buttons that turn on or off relays that controls some LEDs. I want this to be done via interrupts and when not in use have the MCU in low power mode.

I have looked through some of the examples that are provided and noticed that the "Analog Input to PWM Output" example they have uses the eCOMP module instead of the ADC. Is this the best/most efficient way to achieve this? Or would the only reason to do that would be A. the MCU doesn't include an ADC (like the FR2000) or B. Code size restrictions. 

My plan is to break it down in to sections that I can work on individually and then assemble together to make a complete program. 

My first goal is to get the ADC or eCOMP module set up with the pots. As I said before I want to be able to go both directions with one pot so I would need to have the value signed (right?) 

Also when reading through the user guide there are many different sampling modes. Which one would be best for sampling a pot? 

I am sure I will have more questions as I go along but I really want to get this done right and the reason I chose TI's products was because of the support behind them. 

Thanks in advance 

Link to post
Share on other sites

I can't address everything you asked (I haven't used the eComp) , but as to bidirectional control, that doesn't matter.

 

Presume you get a value in the range [0..0xfff] as your control value. There are several approaches, but they all boil down do, essentially, subtracting 0x800 from the read value to put half of the range negative, and half positive.

For the PWM, if you have a bidirectional driver (inputs are a direction and a PWM pulse) you use the sign for the direction output and the magnitude (absolute value) to set the PWM, probably with scaling.

For a driver like the 293, you do a bit more in software, but it comes to the same thing. Hold both drives low for stop, Depending on the sign, you pull one high or the other high via PWM.

For a setup like this, I might set a 'dead band' around the stop. After abs value, if it is less than some small value, treat it as zero. This makes stopping MUCH less touchy, and makes it much easier to avoid the condition of PWM too low for the motor to run, but still heating up the motor and driver.

Link to post
Share on other sites

Yes I do plan to have a "dead zone" around the off position. How would I set that in the ADC? 

Also how would I figure out what my control value is? Would I have to hook up the pot i am using and write a program to print the values in the serial monitor? Or what is the best way to do this. 

Again I have taken a few courses on the basics of programming the MSP430 line but this is my first attempt at actually doing a project on my own with no instructions. I really want to learn how to do this and I have already spent countless hours reading and taking classes and now my next step is to learn by doing. Any help you guys/girls can give me will be much appreciated. 

I am still trying to figure out which sampling option would be best for reading the value of a pot. They are as follows. 

ADC SINGLECHANNEL [Default] - one-time
conversion of a single channel into a single memory
buffer
ADC SEQOFCHANNELS - one time conversion of
multiple channels into the specified starting memory
buffer and each subsequent memory buffer up until the
conversion is stored in a memory buffer dedicated as
the end-of-sequence by the memory's control register
ADC REPEATED SINGLECHANNEL - repeated
conversions of one channel into a single memory
buffer
ADC REPEATED SEQOFCHANNELS - repeated
conversions of multiple channels into the specified
starting memory buffer and each subsequent memory
buffer up until the conversion is stored in a memory
buffer dedicated as the end-of-sequence by the
memory's control register
Modified bits are ADCCONSEQx of ADCCTL1
register.
Returns
None
 

 

Link to post
Share on other sites

For the sampling strategy, you probably don't want the repeated strategies.  If it were me, I would  use ADC_SEQofchannels for the two channels.

As for the dead zone, I generally estimate then adjust it during testing. The value I tend to start with is about 5 degrees (2.5 to either side of the zero)or 2 to 3 percent for linear slides, unless the pot has very small mechanical range (less than 180 degrees, shorter than 10mm for linear). You don't set this in the ADC. That is pure arithmetic after reading, with an approach described above. There are other approaches.The one above doesn't do it if you need control all of the way to zero (with motors, you usually don't, as there won't be enough torque at the bottom end to turn the motor unloaded, much less with load).

As an example: 270 degree pot, and 5 degree dead zone: When reading, the range for ADC12 is [0..0xfff]. That gives approximately 0x10 counts per degree. The sequence I would use is:

// n is a signed int to represent the speed
// d is a bool for direction
//PWM_max is a constant for the max PWM value. Presume the desired values are UNSIGNED in the range [0..PWM_max]
scale_val <- PWM_max / 0x800 // this will be computed at compile time. It is more efficient if it is an int

n <- ADC - 0x800           // set center of pot at zero
if n<0 then d <- false else d <- true     
n <- abs(n)     
if n < 0x28 then n <- 0    // dead zone is 2.5 degrees to either side of zero

PWM_value <- n*scale_val //scale PWM
                      

The 0x28 sets the dead zone width. There are other ways, as well, of you need PWM all of the way  to zero, or want independent control of the PWM low end and dead zone width

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.

Guest
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...