CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Using ECCP for unipolar stepper control

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mdemuth



Joined: 16 Apr 2007
Posts: 71
Location: Stuttgart, Germany

View user's profile Send private message Visit poster's website

Using ECCP for unipolar stepper control
PostPosted: Mon Apr 16, 2007 8:17 am     Reply with quote

Hello,

I am trying to use the ECCP unit of a PIC16F690 to control the current by PWM. I need the 4 pins which are set and unset by using the output_c(0x??) command to be controlled by one PWM.

My code:
setup_CCP1(CCP_PWM;
setup_CCP1(CCP_PULSE_STEERING_SYNC | CCP_PULSE_STEERING_A | CCP_PULSE_STEERING_B | CCP_PULSE_STEERING_C|CCP_PULSE_STEERING_D);

does not work.
Can anybody help me?

Thanx,

Michael Sad
Ttelmah
Guest







PostPosted: Mon Apr 16, 2007 8:42 am     Reply with quote

Look at the available output patterns on the ECCP. None bear any resmblance to the drives needed for a unipolar motor...
You would need to use another four pins, as the drives for the stepper, and use the PWM, as a 'simple' single channel output, to modulate the current being delivered (by gating the signals driving the motor).
It cannot be setup to drive the motor directly.

Best Wishes
mdemuth



Joined: 16 Apr 2007
Posts: 71
Location: Stuttgart, Germany

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 16, 2007 8:52 am     Reply with quote

How about the pulse steering mode? See chapter 11.4.7.1
mdemuth



Joined: 16 Apr 2007
Posts: 71
Location: Stuttgart, Germany

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 16, 2007 1:24 pm     Reply with quote

The problem is still not solved.
How is this module to be set up fully and correctly?
How does the pulse steering module work?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 16, 2007 1:50 pm     Reply with quote

Microchip appnote AN906 is about using the 16F684 to drive a bipolar
stepper motor. It might help. The source code is in MPASM, but it
could still be useful for setup information.
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en012150

There are threads on other forums that discuss it:
http://www.cnczone.com/forums/archive/index.php/t-17856.html

http://forum.microchip.com/printable.aspx?m=200211
mdemuth



Joined: 16 Apr 2007
Posts: 71
Location: Stuttgart, Germany

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 16, 2007 2:03 pm     Reply with quote

No it does not help much, I have read through these topics....


Crying or Very sad Sad
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 16, 2007 2:29 pm     Reply with quote

More links to resources:

Microchip website:

Basic diagram of circuit for controlling a unipolar stepper motor:
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2125&param=en026726&pageId=64

"Recommended Products for Stepper Motor Control":
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2125&param=en026706
Scroll down to this link on the page above:
Stepper Motor Design Flowchart
mdemuth



Joined: 16 Apr 2007
Posts: 71
Location: Stuttgart, Germany

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 16, 2007 2:34 pm     Reply with quote

I have been through these things. Therefore I am still confident that there is a way, by just setting up the ECCP module right.
There is not much documentation on the CCS site nor on the microchip site for this case.
I still dont't know what to do. I tried some combinations today without any success.
Question Question Question
ChrisL



Joined: 16 Apr 2007
Posts: 26
Location: Arizona

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 16, 2007 3:03 pm     Reply with quote

We did stepper motor interfaces for years. It is very simple... Each pole of the motor has a constant relationship to every other pole that determines the pattern of ON-OFF states of the windings. There is a pattern for 1/2 step (if the motor supports it) and full step and a secondary relationship for Forward and Reverse. These are all in the datasheet for every motor. Put the patterns in 2 4x[n] arrays (forward and reverse) in FLASH memory or EEPROM and use a delay command to control the loop speed in your code of how fast the pole states change to regulate speed (step through the arrays). Remember also there is a maximum speed that any stepper motor can be stepped. If you exceed that you will loose step count/shaft position relationships if you system is open-loop. You must also consider shaft torque/load relationships in your stepping routines.
_________________
Thank you,
Chris
Ttelmah
Guest







PostPosted: Mon Apr 16, 2007 3:05 pm     Reply with quote

I'm sorry, but it just is not do-able without external hardware.
Again as I said, look at the available drive patterns. Fine to drive a bipolar motor,but the required pair patterns for a unipolar drive, just are not do-able by the hardware. If you call the four pins 1,2,3,4, you need to be able to do:

1+2
2+3
3+4
4+1

(for full step), or

1
1+2
2
2+3
3
3+4
4
4+1

for half step modes. Now the outputs available, with pulses are:

1
1+2
4
2
/1
/1+/2
/4
/2

You can see that the patterns are just not there.
The way to do this, is to use an external driver which has two logic inputs feeding each driver output, with an AND, or NAND function, and then feed the required bit pattern out on four pins, and combine this with the single PWM feed to give the current control.

Best Wishes
ChrisL



Joined: 16 Apr 2007
Posts: 26
Location: Arizona

View user's profile Send private message Visit poster's website

PostPosted: Mon Apr 16, 2007 3:15 pm     Reply with quote

In the "old" days we use to do this with a external EPROM where the processor simply clocked sequential addresses in the PROM and fed it's outputs to the inputs to the motor through the electrical interface. We never had any problems. If you divide each clock phase into several elements you can control the motor without issue. Said another way, there is no pattern you cannot reproduce using the logic of the processor.

This link really says it all, very simple stuff..

http://www.eio.com/jasstep.htm#operation
_________________
Thank you,
Chris
mdemuth



Joined: 16 Apr 2007
Posts: 71
Location: Stuttgart, Germany

View user's profile Send private message Visit poster's website

PostPosted: Tue Apr 17, 2007 2:58 am     Reply with quote

Idea

P1M0=0; // Single Output
P1M1=0;
CCP1M2=1;
CCP1M3=1;
PSTRCON=0x0f;

setup_timer_2(T2_DIV_BY_1,0x65,2);
set_pwm1_DUTY(150);

=> PWM on the four channels (believe it or not).

To control the states I tried had to use the DDR register:

SET_TRIS_C(stepper_state);

So far so good, my problem is solved so far!
Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group