View previous topic :: View next topic |
Author |
Message |
mdemuth
Joined: 16 Apr 2007 Posts: 71 Location: Stuttgart, Germany
|
Using ECCP for unipolar stepper control |
Posted: Mon Apr 16, 2007 8:17 am |
|
|
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 |
|
|
Ttelmah Guest
|
|
Posted: Mon Apr 16, 2007 8:42 am |
|
|
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
|
|
Posted: Mon Apr 16, 2007 8:52 am |
|
|
How about the pulse steering mode? See chapter 11.4.7.1 |
|
|
mdemuth
Joined: 16 Apr 2007 Posts: 71 Location: Stuttgart, Germany
|
|
Posted: Mon Apr 16, 2007 1:24 pm |
|
|
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
|
|
|
mdemuth
Joined: 16 Apr 2007 Posts: 71 Location: Stuttgart, Germany
|
|
Posted: Mon Apr 16, 2007 2:03 pm |
|
|
No it does not help much, I have read through these topics....
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
mdemuth
Joined: 16 Apr 2007 Posts: 71 Location: Stuttgart, Germany
|
|
Posted: Mon Apr 16, 2007 2:34 pm |
|
|
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.
|
|
|
ChrisL
Joined: 16 Apr 2007 Posts: 26 Location: Arizona
|
|
Posted: Mon Apr 16, 2007 3:03 pm |
|
|
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
|
|
Posted: Mon Apr 16, 2007 3:05 pm |
|
|
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
|
|
Posted: Mon Apr 16, 2007 3:15 pm |
|
|
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
|
|
Posted: Tue Apr 17, 2007 2:58 am |
|
|
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!
|
|
|
|