HankMcSpank
New Member
Hello There,
I'm trying to make a little hobby coil winder...I was going to use logic gates & switches to control a stepper motor with a 'wire feed helix' (ie traversing back/forward after after x counts - to see what I mean, have a look at this YouTube - Guitar pickup winder, coil winder, automatic traversal 27secs in .... albeit, he's using an AVR). But someone made a good point that I really ought to move with the times & start learning about PICs to do this!
Well, let me declare....wrt to the PIC tutorials, I feel I may as well be reading the Hubble Space telescope service manual... I'm still at "Hello World" & just not getting it!!
I really do need to push on & get a coil wound (so I can in turn crack on with another project that uses them!), so I'm throwing open an appeal for a program that I can at least make a start with!
I'd imagine for someone PIC literate it won't be a lot of effort (esp if modding another donor program they may already have). It's a hard sell becuase I don't have much to offer....except it'll be cool & I will make a youtube video of the results and credit anyone that helps me!
Here are my simple requirements.....
Assume an incoming 'stream of pulses' - for the purposes of me being able to play with/decipher any program it might be handy is you assume the pulses are coming in on pin RA0 on a PIC16F690/P - this is the PIC that came with my PICKit 2. (The pulse stream will actually be from a reed switch opening/closing triggered by magnets attached to the perimeter of a motor - there'll actually be 7 magnets glued around the motor, therefore 7 pulses = main motor has turned one revolution)
First set some states....
Set counter 1 = 0 (this will be used to move the wire feed stepper motor one step)
Set counter 2 = 0 (this will be used to change the direction of the stepper motor - thereby traversing the feed wire in the opposite direction)
Set counter 3 = 0 (this will be used to stop the program)
Set output pin RC1 low (changing this pin from low to high will change the direction of the stepper motor)
Set output pin RC2 low (changing this later to to high will ultimately trigger a relay which will stop & brake the main motor)
Switch 0 (RA0) = incoming pulse simulation
Switch 1 (RA1) = reset all counters
Switch 2 (RA2) = run program
Ok now to the requirements...
1) After each incoming pulse, increment counter 1, counter 2, & counter 3.
2) When counter 1 equals "1", send a short pulse to the output pin RC0 (at this stage I'm not sure of the pulse width needed - like I say, it'll be driving a stepper motor, but for testing it might be worth making the pulse width big enough to visibly see an LED light up - therefore useful if the pulse width can be set easily with a variable)
3) clear counter 1. continue this cycle ad infinitum. (in case you're wondering why I need a one in one out counter, it may well be that at a later stage some wire thickness might need 2 pulses in & one pulse out)
4. When counter 2 equals "700" set output pin RC1 high (this will reverse the direction of the stepper - ie the wire feeding onto the main motor will start traversing the other way)
5. clear counter 2.
6. When counter 3 equals 2,000, halt the program & set output pin RC2 high.
Perhaps I'm asking too much...if so, then if anyone could even give a sample bit of code for setting up even part of ithe above (say RA0 as an input to sense a switch & RC0 as an output going high when switch is closed x times)
Many thanks in anticipation!
I'm trying to make a little hobby coil winder...I was going to use logic gates & switches to control a stepper motor with a 'wire feed helix' (ie traversing back/forward after after x counts - to see what I mean, have a look at this YouTube - Guitar pickup winder, coil winder, automatic traversal 27secs in .... albeit, he's using an AVR). But someone made a good point that I really ought to move with the times & start learning about PICs to do this!
Well, let me declare....wrt to the PIC tutorials, I feel I may as well be reading the Hubble Space telescope service manual... I'm still at "Hello World" & just not getting it!!
I really do need to push on & get a coil wound (so I can in turn crack on with another project that uses them!), so I'm throwing open an appeal for a program that I can at least make a start with!
I'd imagine for someone PIC literate it won't be a lot of effort (esp if modding another donor program they may already have). It's a hard sell becuase I don't have much to offer....except it'll be cool & I will make a youtube video of the results and credit anyone that helps me!
Here are my simple requirements.....
Assume an incoming 'stream of pulses' - for the purposes of me being able to play with/decipher any program it might be handy is you assume the pulses are coming in on pin RA0 on a PIC16F690/P - this is the PIC that came with my PICKit 2. (The pulse stream will actually be from a reed switch opening/closing triggered by magnets attached to the perimeter of a motor - there'll actually be 7 magnets glued around the motor, therefore 7 pulses = main motor has turned one revolution)
First set some states....
Set counter 1 = 0 (this will be used to move the wire feed stepper motor one step)
Set counter 2 = 0 (this will be used to change the direction of the stepper motor - thereby traversing the feed wire in the opposite direction)
Set counter 3 = 0 (this will be used to stop the program)
Set output pin RC1 low (changing this pin from low to high will change the direction of the stepper motor)
Set output pin RC2 low (changing this later to to high will ultimately trigger a relay which will stop & brake the main motor)
Switch 0 (RA0) = incoming pulse simulation
Switch 1 (RA1) = reset all counters
Switch 2 (RA2) = run program
Ok now to the requirements...
1) After each incoming pulse, increment counter 1, counter 2, & counter 3.
2) When counter 1 equals "1", send a short pulse to the output pin RC0 (at this stage I'm not sure of the pulse width needed - like I say, it'll be driving a stepper motor, but for testing it might be worth making the pulse width big enough to visibly see an LED light up - therefore useful if the pulse width can be set easily with a variable)
3) clear counter 1. continue this cycle ad infinitum. (in case you're wondering why I need a one in one out counter, it may well be that at a later stage some wire thickness might need 2 pulses in & one pulse out)
4. When counter 2 equals "700" set output pin RC1 high (this will reverse the direction of the stepper - ie the wire feeding onto the main motor will start traversing the other way)
5. clear counter 2.
6. When counter 3 equals 2,000, halt the program & set output pin RC2 high.
Perhaps I'm asking too much...if so, then if anyone could even give a sample bit of code for setting up even part of ithe above (say RA0 as an input to sense a switch & RC0 as an output going high when switch is closed x times)
Many thanks in anticipation!