Motor timer- forward/reverse control * PLEASE Help!

j0563

New Member
I am trying to have current sent to a dc motor for a set amount of time (in hours)- say 2 hours- then have the current reversed (make the motor spin backwards) for 2 hours, then have the whole cycle repeat itself over and over.

I think I can accomplish this with just an 08M, but I can't seem to get the code down right.

Could anyone help me out on this? It would be greatly appreciated!!!
 

BeanieBots

Moderator
You need to be more specific with your question.
What are you having a problem with?
Generating a 2 hour delay, pin assigments or both?

How does your hardware work?
Is it one pin for direction and one pin for on/off?
Are you using an H-Bridge which requires two pins to be toggled?

A circuit as well as your code so far would be useful.
 

Rickharris

Senior Member
I am trying to have current sent to a dc motor for a set amount of time (in hours)- say 2 hours- then have the current reversed (make the motor spin backwards) for 2 hours, then have the whole cycle repeat itself over and over.

I think I can accomplish this with just an 08M, but I can't seem to get the code down right.

Could anyone help me out on this? It would be greatly appreciated!!!
It may depend on your application and how accurate you need the 2 hours to be. Internal timers are not very accurate and temperature variable.

To drive the motor you need an H bridge - this is covered well in the manuals.

To wait for 2 hours (approx) wait 7200 will stop and do nothing for 2 hours approx (7200 seconds)

It may be more accurate to wait for a shorter period say 10 seconds and then count these to make 2 hours.

More information about your application and current status needed.
 

SilentScreamer

Senior Member
The above wait option doesn't work, wait can not have a value higher than 65 you can replace the "pause 60000" with "wait 60" in the below solution if you wish.

If the two hours can be accurate to within about 3 minutes then this would work to archive a 2 hour pause.

Code:
for b0 = 1 to 120
	pause 60000 'pause for one minute
	next 'loop round 120 times
 

j0563

New Member
The above wait option doesn't work, wait can not have a value higher than 65 you can replace the "pause 60000" with "wait 60" in the below solution if you wish.

If the two hours can be accurate to within about 3 minutes then this would work to archive a 2 hour pause.

Code:
for b0 = 1 to 120
	pause 60000 'pause for one minute
	next 'loop round 120 times
I'll try starting with something like this. I am currently reading up on how to use an H-bridge as I don't have any experience with these. I am just trying to keep things as simple as possible.

To test things out, I would just like to use a basic small 9 or 12v DC motor and just try to get it to spin one way for 2 hours then automatically spin the other way for 2 hours. Nothing too complicated, but I'm sort of at a loss as to where to begin.
 

eclectic

Moderator
j0563

There's some excellent information in
Picaxe Manual 3, pages 11-12.

Access from P.E. or the "Picaxe Manual" link above.

e


ps
What Picaxe kit do you own?
 
Last edited:

Wrenow

Senior Member
If you do not need to adjust the speed, just change direction, you may be in luck. Someone pointed out some latching relays that are such low draw that they can be driven directly from the picaxe. You can use the relay for an H=bridge and just toggle back and forte. Timing accuracy, of course, is as noted above.

Cheers,

Wreno
 

Rickharris

Senior Member
The above wait option doesn't work, wait can not have a value higher than 65 you can replace the "pause 60000" with "wait 60" in the below solution if you wish.

If the two hours can be accurate to within about 3 minutes then this would work to archive a 2 hour pause.

Code:
for b0 = 1 to 120
    pause 60000 'pause for one minute
    next 'loop round 120 times
YEs - My fault for expressing it badly I was just showing the general principle involved.
 
Top