Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC 16F877A and a Stepper Motor

Status
Not open for further replies.

Musicmanager

Well-Known Member
Hi Guys

Remembering I'm a novice and a bit of an old fart .. ... .

I'm having a play with stepper motors at the moment - I want to get some experience of how they work etc .. . I've got some steppers I saved from some old printers etc and I've identified them to type and found datasheets, so far so good.
I found a schematic to drive a stepper with a PIC 16f877A which I've now part built but the narrative says there is a 'switch' on the 16f877a which at logic high will drive in one direction and logic low the opposite direction. I've looked at the schematic and studied the datasheet but I cannot identify which pin is this switch - I find some of the abbreviations to pin labels a bit odd - .. .. ..

Can someone help me please .. .

Thanks S
 

Attachments

  • Bipolar schematic 1.pdf
    229.1 KB · Views: 223
The switch pin will be set in the code, and it could be almost any one of them. Do you have the link to the entire article?
 
Hi House

Thanks for your help .. .

I saved the article for my reference so it's here .. .. .

S
 

Attachments

  • Interfacing Stepper Motor with PIC Microcontroller.pdf
    565.1 KB · Views: 2,105
That code is in MikroC, so I can't help with that. As House said, it is a software switch. Here is an example from the code I posted recently http://www.electro-tech-
online.com/threads/driving-stepper-motor-gauges.144733/page-2#post-1226483
) :

upload_2015-7-26_6-26-31.png


FWD_REV is the software flag. It could just as easily be a physical switch that the user controls; although, in that case you would probably want it set to toggle so it didn't have to be held in a particular position.

When it is "clear", the the sequence of drive signals are 1,2,3,4 ... (i.e., "incf State") ; when it is "set", the sequence is 4,3,2,1 ... (i.e, decf State). That later sequence is what I call "reverse, and the spindle of the motor rotates CCW.

John
 
Hi John

You're up early today ?

That raises another issue for me .. .

That code is in MikroC

I haven't done any coding yet, barring copying a .hex into my programmer and loading to a chip - if it doesn't work I practice my drop kicks ready for Sept. and try another one ! :) Is MikroC not the accepted or usual code for PICs then ?

Good to hear from you

S
 
I have had a look at the list file and did a search for "PORT" I could not find any instruction that read any port so I think the code is just a sample to modify to suit your requirements. The code also steps very slowly as there is a delay of 500 mS between steps.

Les.
 
Oh 'eck !!

I think the code is just a sample to modify to suit your requirements. The code also steps very slowly as there is a delay of 500 mS between steps.

Re-arrange these letters to make a well known phrase ATF HNCEA !

Thanks Guys - back to the drawing board for me !

S
 
:) Is MikroC not the accepted or usual code for PICs then ?

Quite the contrary. I think several members here use it in preference to other versions. A dwindling few of use use Assembly, including myself.

In my link, I even link to the Mikro site. There is also a link to two Microchip application notes that use Assembly. That code is quite straight forward.

John
 
"Fat Chance"

Anyone who can create such puzzles will really enjoy coding in Assembly. ;)

Do a flashing LED for a simple start (See: Nigel's tutorials).

John
 
Yes, thanks John ..

I'm just reading your article now .. and I've got Nigel's tutorials on my todo list ..

Trouble is .. there is so much I want to do - I end up spending most of my time trying to decide which to do first .. .. EDC !

I'm sure I'll find some code in a library somewhere that will make this work for now .. . Coding is a major issue for me at the moment and slightly away from my current goal - but I'll get there in the end .. .. .. and I'm consoled by the fact that it's such a lovely place to get there !! :)

S
 
Is your motor Bi-polar or Uni-polar? 4,5 or 6 wires?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top