• AVR Freaks

AnsweredHot!Controlling a bipolar stepper with my PIC16F1825

Page: < 123 > Showing page 2 of 3
Author
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/05/31 03:15:53 (permalink)
0
Thanks a lot for your massive efforts!!!
 
I implemented your suggestion as follows. So the motor now turns in both directions BUT I have a problem with altering the "delay" values.
 
When the delay values used for cw and ccw turn are not equal (e.g. 50,100 or 100,200) then the motor shaft doesn't end up at the starting point but the overall direction of the shaft keeps moving with every cycle. This is quite strange. As long as the number of steps is the same in both direction I would expect the shaft to end at exactly at the strating point. And with delays of 100ms I would not expect that this is too fast for the ramp up?! So how does the waiting delay controll the step widht? (as long as I do not reach limits)
 
regards
Michael
 
step_cw(10,100);
step_ccw(10,200);
 
void step_cw (int count, int delay) {
    dir = 1;    
    while (count > 0)
{
        LATC = StepArray[stepidx]; // out put byte
        stepidx += dir;     // move to next table pos
        stepidx &= 0x3;   // make sure index stays 0..3 (might give warning it is signed)
        delayMS(delay);             // Do your delay
        count--;   // One step done
}
}

void step_ccw (int count, int delay) {
       
       dir = -1;
     
       while (count > 0)
{
        LATC = StepArray[stepidx]; // out put byte
        stepidx += dir;     // move to next table pos
        stepidx &= 0x3;   // make sure index stays 0..3 (might give warning it is signed)
        delayMS(delay);             // Do your delay
        count--;   // One step done
}   
post edited by kart - 2019/05/31 05:10:41
#21
LdB_ECM
Senior Member
  • Total Posts : 164
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/05/31 07:04:48 (permalink)
+1 (1)
First you can just merge the two routines to one by simply passing in the direction
void step_eitherway (int count, int delay, int dir)
 
Second you can slightly improve it it by moving to half step sequence which is 8 rather than full step being 4 the sequence was given above I will put it after this ... you do the "AND" with 0x7 rather than 0x3. The half stepping is slightly less vibration and not as prone to losing steps.
static uint8_t StepArray[8] = { 0b1001, 0b1000,  0b1010, 0b0010, 0b0110, 0b1000, 0b0101,  0b0001 };
 
On modern stepper motors you will still have issues the motors these days are really designed to run high frequency choppers and they have low resistance and low induction and will say a low voltage on the motor typically 3-5VDC. These sorts of motors are designed for to run on choppers that limit the current themselves on the coil they are not anything like ideal for an old 100% duty cycling you are setup for. You have never really talked about the characteristics of you stepper motor and what it's ratings are but like it is designed for a bipolar chopper drive.
 
Like all things in electronics there is a difference between hacking something roughly and getting it work flawless. 
So for flawless operation I need to know a lot more about the motor. Basically for an old 100% duty cycle operation you want a high voltage stepper with high inductance.
So something like this
https://core-electronics.com.au/stepper-motor-200-steps-rev-12v-350ma.html
A motor designed for bipolar choppers has different characteristics for example this
https://core-electronics.com.au/stepper-motor-bipolar-200-steps-rev-57-56mm-2-5v-2-8-a-phase.html
 
See the second one it is only 2.5V we don't really drive steppers at that voltage we use 24,40 or even 96V DC and we run choppers on them to limit the current. The voltage is really meaningless it is really telling you the coil resistance at the rated drive current so you can factor the heat loss. The second motor is not something you want to try and put in your circuit.
 
So at a guess you have a low voltage stepper motor designed for a chopper drive and it will be problematic on your circuit.
#22
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/03 06:07:43 (permalink)
0
Hi,
 
I did a quick test today with changing to half step ... but then the motor is jerking back and forth as if the 8 steps would be out of order ...?! You are sure regarding the pattern?
 
I am using a NEMA17,12V, 26Ncm, 0,4A
#23
LdB_ECM
Senior Member
  • Total Posts : 164
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/03 07:47:18 (permalink)
0
You are correct typo on 4 :-)

 

                                                9           8           A           2            6          4*          5          1
static uint8_t StepArray[8] = { 0b1001, 0b1000,  0b1010, 0b0010, 0b0110, 0b0100, 0b0101,  0b0001 };

#24
LdB_ECM
Senior Member
  • Total Posts : 164
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/03 07:53:08 (permalink)
0
Site won't let me edit and spacing is horrible above .. 3rd last entry should be 4 as per below
static uint8_t StepArray[8] = { 0b1001, 0b1000,  0b1010, 0b0010, 0b0110, 0b0100, 0b0101,  0b0001 };
#25
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/05 03:03:18 (permalink)
0
Hi,
 
 
This very short code keeps driving me crazy.
 
1) I do not get the delay of 5000ms between the turn cycles?! I use this delay setup in all other projects and it works there
2) both functions move in the same direction, while one cycle goes forward smothly the other cycle goeas forward too but "vibrates, stubmbles" ...
 
I have deleted out everything possible to shorten the code to the max.
 
thanks
Michael

#include <xc.h>
#define _XTAL_FREQ 500000  //define clockspeed used for calculating __delay_ms

void delayMS(int max);
void step_cw(int count,int delay);
void step_ccw(int count, int delay);

int dir  = 0;    // 1 = forward, -1 = backward
int stepidx = 0; // step index
unsigned stepping_seq[8]={0b00001001, 0b00001000, 0b00001010, 0b00000010, 0b00000110, 0b00000100, 0b00000101, 0b00000001};
int stepcounter;


void main(void) {
   
    ANSELCbits.ANSC0 = 0;
    ANSELCbits.ANSC1 = 0;
    ANSELCbits.ANSC2 = 0;
    ANSELCbits.ANSC3 = 0;
    
    TRISCbits.TRISC0 = 0;   // setze RC0 auf output
    TRISCbits.TRISC1 = 0;   // setze RC1 auf output
    TRISCbits.TRISC2 = 0;   // setze RC2 auf output
    TRISCbits.TRISC3 = 0;   // setze RC3 auf output
   
    LATC=0b00000000;
    
    while (1)
    {
       
    step_cw(10,300);
    delayMS(5000);
    step_ccw(10,300);    
    }  
    }
    
    

void delayMS(int max){
    do {
      __delay_ms(1);
   } while (--max);
}

void step_cw (int count, int delay) {
    dir = 1;    
    while (count > 0)
{
        LATC = stepping_seq[stepidx]; // out put byte
        stepidx += dir;     // move to next table pos
        stepidx &= 0x7;   // make sure index stays 0..3 (might give warning it is signed)
        delayMS(delay);             // Do your delay
        count--;   // One step done
}
}

void step_ccw (int count, int delay) {
       
       dir = -1;
     
       while (count > 0)
{
        LATC = stepping_seq[stepidx]; // out put byte
        stepidx += dir;     // move to next table pos
        stepidx &= 0x7;   // make sure index stays 0..3 (might give warning it is signed)
        delayMS(delay);             // Do your delay
        count--;   // One step done
}    
    
}
#26
LdB_ECM
Senior Member
  • Total Posts : 164
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/05 12:18:55 (permalink)
+1 (1)
You need two delays otherwise there is no pause between one of the changes
 

 while (1)
 {
      step_cw(10,300);
      delayMS(5000);
      step_ccw(10,300); 
      delayMS(5000);   
 } 

 
You can also simplify the code to simply take the direction
void step (int count, int delay, int dir)
{
       while (count > 0)
        {
            LATC = stepping_seq[stepidx]; // out put byte
            stepidx += dir;     // move to next table pos
            stepidx &= 0x7;   // make sure index stays 0..7 (might give warning it is signed)
            delayMS(delay);             // Do your delay
            count--;   // One step done
        }    
}

Main then becomes

 while (1)
 {
      step(10,300, 1);
      delayMS(5000);
      step(10,300, -1); 
      delayMS(5000);   
 }

post edited by LdB_ECM - 2019/06/05 12:23:49
#27
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/06 07:37:34 (permalink)
0
Hi,
 
Thanks ... but still some strange things are happening (sorry, haven't seen your post regarding simplifying the provedure.
 
What did I change/what is happening.
 
-) I added the 2nd delay(5000) as you noticed, but it didn't change anything.
 
It looks like follows ... the stepper turns 10 steps in one direction ... then it halts for 10 stepps (I feel the motor pulsing 10 times but no movement ...  then it goes 10 steps in the same directions.
 
So it looks like the timeouts of 5 seconds is ignored totally and the backward turining doesn't work.
 
I event implemented lines releasing all coils from the stepper before the delay ... so during the delay time I should be able to manually move the stepper, but it is never released.
 
The interesting thing is that if I swith to "Simulator" instead of PICkit 3 and do a debugging session the code works totally as desired ... send the correct pattern 10 times ... do the delay ... send the correct patter backwards 10 times ...
 
So for some reason the behaviour changes a soon as I go live ...
 
One additional change that I did was to relocate the increment of the stepidx before the next pattern is sent to LATC as otherwise I would loose one stept whenever calling the procedure again ...
 
Latest code:

#include <xc.h>
#define _XTAL_FREQ 500000  //define clockspeed used for calculating __delay_ms

void delayMS(int max);
void step_cw(int count,int delay);
void step_ccw(int count, int delay);

int dir  = 0;    // 1 = forward, -1 = backward
int stepidx = 0; // step index
unsigned stepping_seq[8]={0b00001001, 0b00001000, 0b00001010, 0b00000010, 0b00000110, 0b00000100, 0b00000101, 0b00000001};
int stepcounter;


void main(void) {
    
    
    
    
    ANSELCbits.ANSC0 = 0;
    ANSELCbits.ANSC1 = 0;
    ANSELCbits.ANSC2 = 0;
    ANSELCbits.ANSC3 = 0;
    
    TRISCbits.TRISC0 = 0;   // setze RC0 auf output
    TRISCbits.TRISC1 = 0;   // setze RC1 auf output
    TRISCbits.TRISC2 = 0;   // setze RC2 auf output
    TRISCbits.TRISC3 = 0;   // setze RC3 auf output
    
    
    LATC=0b00000000;
    
    while (1)
    {
        

    step_cw(10,300);
    LATC=0b00000000;
    delayMS(5000);
    step_ccw(10,300);
    LATC=0b00000000;
    delayMS(5000);
    
    }  
    }
    
    

void delayMS(int max){
    do {
      __delay_ms(1);
   } while (--max);
}

void step_cw (int count, int delay) {
    dir = 1;    
    while (count > 0)
{
        stepidx += dir;     // move to next table pos
        stepidx &= 0x7;   // make sure index stays 0..3 (might give warning it is signed)
        LATC = stepping_seq[stepidx]; // out put byte
        delayMS(delay);             // Do your delay
        count--;   // One step done
}
}

void step_ccw (int count, int delay) {
       
       dir = -1;
     
       while (count > 0)
{
        stepidx += dir;     // move to next table pos
        stepidx &= 0x7;   // make sure index stays 0..3 (might give warning it is signed)
        LATC = stepping_seq[stepidx]; // out put byte
        delayMS(delay);             // Do your delay
        count--;   // One step done
}    
   
#28
LdB_ECM
Senior Member
  • Total Posts : 164
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/06 08:42:06 (permalink)
0
I don't use the 16F but just dragging down some samples from the Microchip site I am seeing some issues
You are putting the XTAL speed after the include they always put it before, I am thinking the include may look for the value and so after it won't work. That probably explains why your delay doesn't work

#define _XTAL_FREQ 500000
#include <xc.h>


[/code]I just also pulled up the datasheet
http://ww1.microchip.com/downloads/en/DeviceDoc/40001440E.pdf
Page 133  .. REGISTER 12-15: PORTC: PORTC REGISTER
 
You set the tristate buffer and you are driving the latch port but I don't see you set the port bits themselves.
 
Long hand I think you need to do this
PORTCbits.RC0 = 1;
PORTCbits.RC1 = 1;
PORTCbits.RC2 = 1;
PORTCbits.RC3 = 1;
Short hand
PORTC = 0xF;
 
I am guessing that register needs to be set, put it in anyhow after the tristate ones are set
 
Also you might want to put the normal pragmas at the top like they do in samples so you can be sure what is set

// PIC12F1825 Configuration Bit Settings
#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config MCLRE = ON       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
#pragma config BOREN = OFF      // Brown-out Reset Enable (Brown-out Reset disabled)
#pragma config PLLEN = OFF      // PLL Enable (4x PLL disabled)
#pragma config LVP = OFF        // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)
[/code]
#29
LdB_ECM
Senior Member
  • Total Posts : 164
  • Reward points : 0
  • Joined: 2019/04/16 22:01:25
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/06 08:44:57 (permalink)
0
Site drives me crazy .. sometimes it wont let you edit post and the format is all wrong above .. just a repost of above
 
I don't use the 16F but just dragging down some samples from the Microchip site I am seeing some issues
You are putting the XTAL speed after the include they always put it before, I am thinking the include may look for the value and so after it won't work. That probably explains why your delay doesn't work
#define _XTAL_FREQ 500000
#include <xc.h>


I just also pulled up the datasheet
http://ww1.microchip.com/downloads/en/DeviceDoc/40001440E.pdf
Page 133  .. REGISTER 12-15: PORTC: PORTC REGISTER
 
You set the tristate buffer and you are driving the latch port but I don't see you set the port bits themselves.
 
Long hand I think you need to do this
PORTCbits.RC0 = 1;
PORTCbits.RC1 = 1;
PORTCbits.RC2 = 1;
PORTCbits.RC3 = 1;
Short hand
PORTC = 0xF;
 
I am guessing that register needs to be set, put it in anyhow after the tristate ones are set
 
Also you might want to put the normal pragmas at the top like they do in samples so you can be sure what is set

// PIC16F1825 Configuration Bit Settings
#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config MCLRE = ON       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
#pragma config BOREN = OFF      // Brown-out Reset Enable (Brown-out Reset disabled)
#pragma config PLLEN = OFF      // PLL Enable (4x PLL disabled)
#pragma config LVP = OFF        // Low-Voltage Programming Enable (High-voltage on MCLR/VPP must be used for programming)

#30
mbrowning
USNA79
  • Total Posts : 1564
  • Reward points : 0
  • Joined: 2005/03/16 14:32:56
  • Location: Melbourne, FL
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/06/06 08:54:18 (permalink)
+1 (1)
LdB_ECM
You are putting the XTAL speed after the include they always put it before, I am thinking the include may look for the value and so after it won't work. That probably explains why your delay doesn't work
Not true - it doesn't matter the order and I always put it after the xc8.h include. I believe_XTAL_FREQ just has to be defined before it's used (in the delay macro).
LdB_ECMYou set the tristate buffer and you are driving the latch port but I don't see you set the port bits themselves.
 
I am guessing that register needs to be set, put it in anyhow after the tristate ones are set
Bad guess. Don't guess, read the datasheet which is clear that a write to PORT and a write to LATCH is the same thing. They only differ on reads.
LdB_ECM
Also you might want to put the normal pragmas at the top like they do in samples so you can be sure what is set
Now this is good advice, especially when posting code. For newer devices the config bit pragmas are so numerous that I keep them in a separate include file. But when posting code you should always include them at the top so it is clear how the chip is configured.
 

Go Navy! Beat Army!
#31
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 02:50:32 (permalink)
0
Hi,
 
Due to school season I didn't have time to pick up this project before now ... and I still have problems
Trying to pinpoint the problems I have made the code simpler and simpler to pinpoint my problems.
 
But I still have 2 issues.
 
Main issue:
 
Both step_cw and step_ccw result in the motor truning in the same direction?! I even am using 2 different arrays now.
 
2nd anoying issue:
 
While delayMS works in any other project I have done so far it refuses to work here?! Only direct __delay_ms() calls work?!
 
Any feedback is welcome:
 
Actual code:


#include <xc.h>
#define _XTAL_FREQ 500000  //define clockspeed used for calculating __delay_ms

void delayMS(int max);
void step_cw(int count,int delay);
void singlestep_cw(void);
void step_ccw(int count, int delay);

int dir  = 0;    // 1 = forward, -1 = backward
int stepidx = 0; // step index
unsigned stepping_seq_cw[8]={0b1001, 0b1000, 0b1010, 0b0010, 0b0110, 0b0100, 0b0101, 0b0001};
unsigned stepping_seq_ccw[8]={0b0001, 0b0101, 0b0100, 0b0110, 0b0010, 0b1010,0b10000,0b1001};
//unsigned stepping_seq[4]={0b1001, 0b1010, 0b0110, 0b0101};
int stepcounter;


void main(void) {
    
    
    
    
    ANSELCbits.ANSC0 = 0;
    ANSELCbits.ANSC1 = 0;
    ANSELCbits.ANSC2 = 0;
    ANSELCbits.ANSC3 = 0;
    
    TRISCbits.TRISC0 = 0;   // setze RC0 auf output
    TRISCbits.TRISC1 = 0;   // setze RC1 auf output
    TRISCbits.TRISC2 = 0;   // setze RC2 auf output
    TRISCbits.TRISC3 = 0;   // setze RC3 auf output
    
    TRISAbits.TRISA4 = 0;    // set RA4 to output = status LED
    
    
    LATC=0b00000000;
    LATAbits.LATA4= 0;       //status LED off
    
    while (1)
    {
        

    step_cw(10,200);
    LATAbits.LATA4= 1;      //status LED on
    __delay_ms(2000);
    step_ccw(10,200);
    //delayMS(4000);
    LATAbits.LATA4= 0;      //status LED off
    __delay_ms(2000);
    //delayMS(4000);
    }  
    }
    
    

void delayMS(int max){
    do {
      __delay_ms(1);
   } while (--max);
}

void step_cw (int count, int delay) {
     
    stepidx = 0;
    for (int i=0; i<=count; i++)
{
        stepidx++;     // move to next table pos
        stepidx &= 0x7;   // make sure index stays 0..3 (might give warning it is signed)
        LATC = stepping_seq_cw[stepidx]; // out put byte
        __delay_ms(100);
        //delayMS(delay);             // Do your delay
        //count--;   // One step done
}
}


void step_ccw (int count, int delay) {
       
    stepidx = 0;   
    for (int i=0; i<=count; i++)
{
        stepidx++;     // move to next table pos
        stepidx &= 0x7;   // make sure index stays 0..3 (might give warning it is signed)
        LATC = stepping_seq_ccw[stepidx]; // out put byte
        __delay_ms(100);
        //delayMS(delay);             // Do your delay
       // One step done
}    
    
}
 
#32
ric
Super Member
  • Total Posts : 24605
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 02:59:01 (permalink)
0
kart
While delayMS works in any other project I have done so far it refuses to work here?! Only direct __delay_ms() calls work?!

I can't see anything wrong with your delay function. What happens when you try it?
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#33
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 03:04:39 (permalink)
0
it works in prinicpal but a delayMS(4000) last below 2 seconds ... roughly as long as a __delay_ms(2000)
#34
ric
Super Member
  • Total Posts : 24605
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 03:08:42 (permalink)
0
Maybe try putting a 10ms delay rather than 1ms in the function, and rename it delay10MS()
(so naturally you would pass 400 rather than 4000).

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#35
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 04:23:19 (permalink)
0
/ CONFIG1
#pragma config FOSC = INTOSC    // Oscillator Selection (INTOSC oscillator: I/O function on CLKIN pin)
#pragma config WDTE = OFF       // Watchdog Timer Enable (WDT disabled)
#pragma config PWRTE = OFF      // Power-up Timer Enable (PWRT disabled)
#pragma config MCLRE = OFF       // MCLR Pin Function Select (MCLR/VPP pin function is MCLR)
#pragma config CP = OFF         // Flash Program Memory Code Protection (Program memory code protection is disabled)
#pragma config CPD = OFF        // Data Memory Code Protection (Data memory code protection is disabled)
#pragma config BOREN = OFF      // Brown-out Reset Enable (Brown-out Reset disabled)
#pragma config CLKOUTEN = OFF   // Clock Out Enable (CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin)
#pragma config IESO = OFF        // Internal/External Switchover (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON       // Fail-Safe Clock Monitor Enable (Fail-Safe Clock Monitor is enabled)

// CONFIG2
#pragma config WRT = OFF        // Flash Memory Self-Write Protection (Write protection off)
#pragma config PLLEN = OFF       // PLL Enable (4x PLL enabled)
#pragma config STVREN = ON      // Stack Overflow/Underflow Reset Enable (Stack Overflow or Underflow will cause a Reset)
#pragma config BORV = LO        // Brown-out Reset Voltage Selection (Brown-out Reset Voltage (Vbor), low trip point selected.)
#pragma config LVP = ON         // Low-Voltage Programming Enable (Low-voltage programming enabled)
#36
ric
Super Member
  • Total Posts : 24605
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 05:22:32 (permalink)
0
The second last value in your "stepping_seq_ccw" array has too many zeroes.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#37
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 05:25:25 (permalink)
0
Hi,
 
Found it already but doesn't make any difference ... the motor turns in one direction stops for the delay and continues to turn in the same direction (looks like it would jump back the first step and than go forward in the "old" direction with the rest of the steps).
 
So is there anything else to take into account to reverse the direction of movement of a stepper BESIDES the coil patterns?
 
regards
Michael
#38
kart
Starting Member
  • Total Posts : 54
  • Reward points : 0
  • Joined: 2016/12/01 07:55:28
  • Location: 0
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 06:48:53 (permalink)
0
I shortened the code to the following extremly simple code ... and still the direction doesn
t change (after 1000 going back to 0010) ?!
 
 
while (1)
    {
    PORTC = 0b00000001;
    delayMS(500);
    PORTC = 0b00000100;
    delayMS(500);
    PORTC = 0b00000010;
    delayMS(500);
    PORTC = 0b00001000;
    delayMS(500);  
    PORTC = 0b00000010;
    delayMS(500);
    PORTC = 0b00000100;
    delayMS(500);
    PORTC = 0b00000001;
    delayMS(500);
#39
mpgmike
Super Member
  • Total Posts : 332
  • Reward points : 0
  • Joined: 2014/01/23 17:27:06
  • Location: NJ
  • Status: offline
Re: Controlling a bipolar stepper with my PIC16F1825 2019/10/23 07:51:53 (permalink)
0
Just an observation, you #define _XTAL_FREQ 500000 (MFINTOSC) yet you don't show the OSCCON register.  Default is 4 MHz.

I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
#40
Page: < 123 > Showing page 2 of 3
Jump to:
© 2019 APG vNext Commercial Version 4.5