Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
LinkBack Thread Tools Display Modes
Old 19th April 2004, 09:33 AM   (permalink)
Default how do i count pulses using timer 0?

i need a pulse counter software in picbasic so i could implement a clock/direction stepper motor driver using pic16f84.i want my pic board to be like allegro's 5804 stepper motor driver. 5 inputs: direction,clock or step(pulse for this input.every high to low transition the stepper motor would increment step),mode (2 pin input) 00 for 2 phase,01 for full,10 for half and 11 for step inhibit,output enable.

i dont know how to go about the counting and incrementing part.should interrupt be used?

help pls.
-vortech
vortech1 is offline  
Old 19th April 2004, 10:19 AM   (permalink)
Default Re: how do i count pulses using timer 0?

Quote:
Originally Posted by vortech1
i need a pulse counter software in picbasic so i could implement a clock/direction stepper motor driver using pic16f84.i want my pic board to be like allegro's 5804 stepper motor driver. 5 inputs: direction,clock or step(pulse for this input.every high to low transition the stepper motor would increment step),mode (2 pin input) 00 for 2 phase,01 for full,10 for half and 11 for step inhibit,output enable.

i dont know how to go about the counting and incrementing part.should interrupt be used?

help pls.
-vortech
I don't see why you need to count anything - from what I can gather you want two input pins on the PIC, one for direction (so, for example, when high it steps CW, when low it steps CCW), and the other to step the motor - where you input a pulse and the motor moves one step, in the direction set by the other pin.

All that's ever entering the micro is a single pulse - all you need to do is read that input line like you would a switch - when it goes high move the motor on one step (using a data table of moves), then wait for the input pin to go low before going back to wait for a high input again. The direction setting is easily done by checking if the pin is high or low, and reading from the relevent data table (one for CW, one for CCW).
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 20th April 2004, 05:32 AM   (permalink)
Default

thanx for the suggestion but........(follow up question)

pulsing happens very fast i think. is it possible to code in such a way that it reads the port like just a switch?
vortech1 is offline  
Old 20th April 2004, 09:28 AM   (permalink)
Default

Quote:
Originally Posted by vortech1
thanx for the suggestion but........(follow up question)

pulsing happens very fast i think. is it possible to code in such a way that it reads the port like just a switch?
The pulsing can't happen very fast, it's one pulse per step of the motor, and a stepper motor can't step every fast - certainly not compared with the speed of a PIC!. If you pulse the motor at 1000 steps per second (which is too fast, and it wouldn't move) that gives 1mS between pulses, a 4MHz PIC can execute 1000 instructions in that time, or a 20MHz PIC can execute 5000 instructions.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 05:14 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker