- This topic has 1 reply, 2 voices, and was last updated 13 years ago by .
Viewing 2 posts - 1 through 2 (of 2 total)
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.
|
I need to control the speed of a stepper motor. I have the PIC16f84A microcontroller, MPLAB IDE v8.53, HI-TECH C PRO v9.60PL3 compiler, and PICSTART Plus programmer. I have a driver for the motor as well. My motor and driver are here: http://catalog.orientalmotor.com/item/stepping-motor-driver-packages-0-9-1-8-/-microstep-cmk-series-2-phase-microstepping-motors/cmk264apa-sg7-2?&plpver=11&origin=keyword&by=prod&filter=0.
I am struggling with the coding, as I am relatively new to it. The code that I have now is:
#include <htc.h>
#include <pic.h>
__CONFIG(WDTDIS);
double _XTAL_FREQ = 4000000;
unsigned long tdelay, * dvip = 5;
unsigned long milleseconds, * ddvip;
void main(void)
{
TRISB = 0b00000000;
TRISA = 0b11111;
PORTB = 0b01000000;
while(1)
{
milleseconds = tdelay;
RB1=1;
while(milleseconds > 0)
{
__delay_ms(1);
milleseconds–;
}
RB1=0;
milleseconds = tdelay;
while(milleseconds > 0)
{
__delay_ms(1);
milleseconds–;
}
}
return;
}
Am I headed in the right direction? Can you give me any suggestions as to why this isn’t working?
Thank You.
whats the output of this code. Are there any movements or not.