EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Motor control with PIC16f84A. Coding problem.

Motor control with PIC16f84A. Coding problem.

|

Projects › Projects › Motor control with PIC16f84A. Coding problem.

  • This topic has 1 reply, 2 voices, and was last updated 13 years, 8 months ago by nikhiljain.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 25, 2012 at 4:04 am #1548
    Rose Palmer
    Participant

    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.

    March 30, 2012 at 9:15 am #7358
    nikhiljain
    Participant

    whats the output of this code. Are there any movements or not.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Ceramic capacitors voltage rating December 17, 2025
  • What is involved to convert a small town to fiber optic? December 17, 2025
  • How do I choose the right stepper motor for my DIY 3D printer? December 17, 2025
  • What is this called and what was it for December 17, 2025
  • high voltage December 17, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise