Driving DC motor (fwd, rev, stop) Random Operation

nick12ab

Senior Member
Thanks for the source code. Im getting a syntax error on this line ---------> do : loop untilswitch input = 1
You change 'switchinput' to whatever pin you're using for the input switch (pin variable e.g. pinC.1) and the '4' in the servo/servopos commands to whatever pin you're using for the servo (pin constant e.g. C.0).
 

oneshot

Member
Apparently im not familar with PICAXE programming. I edited and wrote ---> do : loop until switchinput = pinc.1 and I still get an syntax error. Im using a PICAXE 08M2 for this servo project and only will be using one servo. They can be on channel one since im using only one channel input for the switch and one servo. Can you re-write me the code for this application? THANKS
 

oneshot

Member
OK I got rid of of the syntax error and now its working. The servo is moving a bit fast how can and modify the code to slower down the servo a bit?
 

oneshot

Member
Another thing I wanted to point out. My small E-Flite micro RC servo works but my Savox Digital servo is not. I've tried the Savox RC servo with another source code on another project I was doing and worked fine. Do I have to add something to this source code to make my Savox digital RC servo work?


ONESHOT
 

oneshot

Member
Nick12ab this code below you suggested is working but I need to slow down the servos movement to about 5ms can you edit this code below to make it slow down? I want to be able to edit the servo speed if i need to just by changing the number like 5 for 5ms or 10 for 10ms. Can you redo the code to make it do this? THANKS


------------------------------------------

init: servo 4,75 ; initialise servo
main:
do
random w0
loop until w0 <= 10000 and w0 >= 3000
pause w0
servopos b.4,75 ; move servo to one end
pause 2000 ; wait 2 seconds
servopos b.4,150 ; move servo to middle
do : loop until pinc.1 = 1
goto main ; loop back to start
 

SAborn

Senior Member
Im not sure what or where you want to slow the servo operation down, or if this is correct as i have not worked with a servo, but you could try this code, to adjust the servo speed you would change the "Pause 5" as this is giving a 5ms delay between each step.

Code:
init: servo 4,75 ; initialise servo
main: 
do
random w0
loop until w0 <= 10000 and w0 >= 3000
pause w0
servopos b.4,75 ; move servo to one end
pause 2000 ; wait 2 seconds

for b6 = 75 to 150
servopos b.4,b6 ; move servo to middle
pause 5
next b6

do : loop until pinc.1 = 1
goto main ; loop back to start
 

oneshot

Member
SAborn im trying to slow down the servo turning speed. Your code is partially working. When i press the momentary push button the servo goes from 0 to 90 degrees at fast servo speed which its still not right but when I release the switch it goes from 90 degrees to 0 degrees at the 5ms speed im needing, so when its returning back from 90 to 0 degrees its turning slow just like I want it. I need it slow to when it goes from 0 to 90 degrees. Can you redo the code?
 

SAborn

Senior Member
I dont know if a for/next loop will count backwards like this, but you can try it.

Code:
init: servo 4,75 ; initialise servo
main: 
do
random w0
loop until w0 <= 10000 and w0 >= 3000
pause w0

for b6 = 150 to 75
servopos b.4,b6; move servo to one end
pause 5
next b6

pause 2000 ; wait 2 seconds

for b6 = 75 to 150
servopos b.4,b6 ; move servo to middle
pause 5
next b6

do : loop until pinc.1 = 1
goto main ; loop back to start
 

SAborn

Senior Member
Ok, it pays to read the manual, i quickly threw the previous code together as needed to go out.
Try this code as it should work correctly now

Code:
init: servo 4,75 ; initialise servo
main: 
do
random w0
loop until w0 <= 10000 and w0 >= 3000
pause w0

for b6 = 150 to 75 step -1
servopos b.4,b6 ; move servo to one end
pause 5
next b6

pause 2000 ; wait 2 seconds

for b6 = 75 to 150
servopos b.4,b6 ; move servo to middle
pause 5
next b6

do : loop until pinc.1 = 1
goto main ; loop back to start
 

westaust55

Moderator
If you wish to have a single place where you can define the pause length then depending how you wish to change that delay period the options are:

1. Define a constant value which is fixed at download time
SYMBOL Speed = 5

Then change the &#8220;pause 5&#8221; lines to read
PAUSE Speed

2. Define a variable that can be changed during program execution.
SYMBOL Speed = b5
Speed = 5

And again change the &#8220;pause 5&#8221; lines to read
PAUSE Speed

With the second option, if for example you connect a potentiometer to an ADC input and use the READADC command, you can read in a value from 0 to 255 which you could say scale from 0 to 15 or some other value then assign the scaled READADC input value to the variable speed.

So you might have
SYMBOL Speed = b6
SYMBOL Entry = b7
Init:
Speed = 5 ; set a default value

Then depending how often you wish to permit Servo speed changes place the following lines accordingly inside or outside the FOR&#8230;NEXT loop
READADC Entry
Speed = Entry / 17 ; gets a result between 0 and 15 &#8211; divide by 25 gives 0 to 10 for example
 
Last edited:

oneshot

Member
I have not tried SAborn's code yet but will try soon. Anyone that comes up with a similar code similar to post #45 would be great. I want to be able to easily edit the servo moving speed on the code If i need to make future changes.
 

SAborn

Senior Member
I have not tried SAborn's code yet but will try soon
So where have you been, as its been 4 weeks since i posted a revised set of code, yet to be tested.

Once you have some code that works, then its easy for anyone to adjust the code to change the speed, as Westy implied in his last post.
 

oneshot

Member
SAborn I tried your last code and the RC servo's movement speed is working like it should at 5ms when triggered by the input. When not triggered by its input the servo has a little bit of a nervous tick every second, which is not normal. I tried 3 different servos. A mini analog servo, a standard size analog servo and a digital servo and it behaves the same on all 3 of them with the nervous tick about every other second when on standby. When I use Nick12ab code below the one second nervous tick is not present so I know my filtering on my circuit is fine.

Nick12ab code works below but have 2 problems with his code. 1st problem servo moves too fast I needed slowed down to about 5ms when its moving. Second problem the code does not work with my digital servo, it does not move. Only works with my analog servos.

Here is Nick12ab basic code that he wrote, I need someone to help me to rewrite the code. I need the code to work with my analog and digital servo's and I need to slow down its moving speed to 5ms when moving. If someone can supply me the code for this would greatly appreciated. I really don't understand basic code, so need some help.



Nicks Code:

-----------------------------------------------

init: servo 4,75 ; initialise servo
main:
do
random w0
loop until w0 <= 10000 and w0 >= 3000
pause w0
servopos b.4,75 ; move servo to one end
pause 2000 ; wait 2 seconds
servopos b.4,150 ; move servo to middle
do : loop until pinc.1 = 1
goto main ; loop back to start

--------------------------------------------
 

boriz

Senior Member
"...I needed slowed down to about 5ms..."

What does that mean? The standard frame rate for a servo is 20mS.

'Nervous tick' Might be cured with 330uF cap across servo power wires.

Changing servo movement speed is not supported directly by Picaxe firmware. But it can be done by issuing progressive position instructions.
 

oneshot

Member
Boriz what I mean is the servo movement speed needs to be slower. It spins too fast. Also with Nicks code only analog servos will work not a digital servo. I have tried a digital servo with different codes and my digital servo has worked fine but with Nick's code my digital servo does not work only my analog servos.

I would really just like to slow down the speed movement what would I have to chance to this code below to slow it down? Can you suggest a new code?



Here is Nick's code again, Nicks code is fine I just need to slow down a bit the movement speed to about half



init: servo 4,75 ; initialise servo
main:
do
random w0
loop until w0 <= 10000 and w0 >= 3000
pause w0
servopos b.4,75 ; move servo to one end
pause 2000 ; wait 2 seconds
servopos b.4,150 ; move servo to middle
do : loop until pinc.1 = 1
goto main ; loop back to start
 

oneshot

Member
westaust55 im getting a syntax error on the last code you sent to me. Can you resend the correct code?

-----------------------

Here is your code:
Code:
SYMBOL shortdelay = 10 ; adjust this for desired speed
SYMBOL posn = b5
SYMBOL orig = b6

init:
        orig =75
        servo 4,orig ; initialise servo

main:
        DO

                DO
                        random w0
                LOOP until w0 <= 10000 and w0 >= 3000
                pause w0

                FOR posn = orig to 75 step *-**1* ; can also adjust the step size try 1 if still too fast
                        servopos b.4,posn ; move servo to one end
                        PAUSE shortdelay
                NEXT posn

                pause 2000 ; wait 2 seconds

                FOR posn = 75 to 150 step ]*1*
                        servopos b.4,posn ; move servo to middle
                        PAUSE shortdelay
                NEXT posn

                orig = 150
                do
                loop until pinc.1 = 1

        LOOP ; loop back to start
----------------------------------------
 
Last edited by a moderator:

oneshot

Member
Nick12ab how can I make this code below work for for a PICAXE 08M2 instead of the 20M2


Can you remake me this code to work for a 08M2


Thanks


-------------

init: servo 4,75 ; initialise servo
main:
do
random w0
loop until w0 <= 10000 and w0 >= 3000
pause w0
servopos b.4,230 ; move servo to one end
pause 2000 ; wait 2 seconds
servopos b.4,75 ; move servo to middle
do : loop until pinc.1 = 1
goto main ; loop back to start
 

westaust55

Moderator
Does this code help you:

You may need to adjust the values for ExtremeLeft and extreme right as I have some Servo's that have working range
of 60 to 200 and they do not respond/act if the commend tried to set them out of range

Code:
SYMBOL ExtremeLeft = 75
SYMBOL Midposition = 150
SYMBOL Extremeright = 225
SYMBOL ServoPositn = b5
init: 
	servo 4,Midposition ; initialise servo
main: 
	do
		random w0
	loop until w0 <= 10000 and w0 >= 3000
	pause w0
	
	FOR ServoPositn = Midposition TO ExtremeLeft STEP -1
		servopos b.4,servoPositn ; move servo to one end
	NEXT ServoPositn
	
	pause 2000 ; wait 2 seconds
	FOR ServoPositn = ExtremeLeft TO Midposition 
		servopos b.4,servoPositn ; move servo to one end
	NEXT ServoPositn
	
	do 
	loop until pinc.1 = 1
	goto main ; loop back to start
 
Last edited:

westaust55

Moderator
westaust55 im getting a syntax error on the last code you sent to me. Can you resend the correct code?

It would be helpful if you used the Reply with Quote button when re-posting someones code so they see it exactly including where it came from. Just cut out any unneccessary text to keep the core part you wish to refer to.

In the case of the code by me it came from a different thread at post 8 here:
http://www.picaxeforum.co.uk/showthread.php?23228-Controlling-the-speed-movement-of-a-RC-servo
that has no syntax errors.

Code:
SYMBOL shortdelay = 10 ; adjust this for desired speed
SYMBOL posn = b5
SYMBOL orig = b6

init: 
	orig =75
	servo 4,orig ; initialise servo
 
main: 
	DO

		DO
			random w0
		LOOP until w0 <= 10000 and w0 >= 3000
		pause w0

		FOR posn = orig to 75 step -1 ; can also adjust the step size try 1 if still too fast
			servopos b.4,posn ; move servo to one end
			PAUSE shortdelay
		NEXT posn

		pause 2000 ; wait 2 seconds

		FOR posn = 75 to 150 step 1
			servopos b.4,posn ; move servo to middle
			PAUSE shortdelay
		NEXT posn

		orig = 150
		do 
		loop until pinc.1 = 1

	LOOP ; loop back to start
Now look at your code it has some extra characters in a few lines which I highlight below in bold red:
FOR posn = orig to 75 step *-*1* ; can also adjust the step size try 1 if still too fast
and
FOR posn = 75 to 150 step ]*1*

with those extra characters removed the code passes a syntax check.
 
Last edited:

westaust55

Moderator
@Oneshot,

not getting angry - I have fixed some of your posts, but for future reference, when posting program code of more than a few lines, you should use [code] and [/code] tags so it appears in its own sub window within your post.

These code tags can be easily access in a few ways:
1. type them in

2. When using cut and past from the program editor use the sequence:
.. (a) Edit/Select All - if appropriate otherwise select the part you want to post
.. (b) Edit/Copy for Forum - this then includes the [code] and [/code] tags.
.. (c) past into the forum post window

3. if already in a post window,
.. (a) select the Go Advanced button at the bottom right of the post window
.. (b) select the code as already exists within your post window
.. (c) click on the hash icon (#) to the right side in the midle row of the post window toolbar

hope that information helps you and other readers (third time today to give this information).
 

SAborn

Senior Member
hope that information helps you and other readers (third time today to give this information).
Ahrr! the mess and basic information a moderator needs to fix or do on a forum is never ending for an unpaid job, its a lot of work our respected members do for the better service of us all.

Its a credit to Westy and all moderators for the service they do so tireless here to maintain such a great forum.
 

nick12ab

Senior Member
Nick12ab how can I make this code below work for for a PICAXE 08M2 instead of the 20M2


Can you remake me this code to work for a 08M2
Could you please explain what the issue is?

Also there is no need to send me a private message each time you post in this thread.
 

nick12ab

Senior Member
OK I just need the code re-written so it can work with a PICAXE 08M2 thats all.
I won't rewrite it for you.

Please, at least show an interest in doing this by saying which pin you want to do what...

...then change the code yourself to use these pins.
 

westaust55

Moderator
@oneshot,

did you look at the posts 59 and 60 on the previous code?

What you have been given before worked and the typos you introduced into earlier code have been highlighted for you to easily remove and get it working.

Why do you think it needs to be re-written to work on the 08M2? :confused:

Why not run the code, and if it does not work, then look at how you might modify it yourself rather than vague comments about it moves too fast - I had given a comment in the code how to slow it down previously.

Folks here are quite happy to help you but, YOU must do some of the work yourself - not just ask someone to do your project for you.

as nick12ab has indicated, if use on the 08M2 requires a change, then state clearly what needs changing (ie pin IO allocations) and indicate (post code) to show what you have tried to achieve this goal.
 

techElder

Well-known member
All of this code flying around for a servo drive to raise a steel target after it's been put down seems to have ignored the question, "Is a servo powerful enough to raise a steel target?"

From my experience with typical "steel targets" used at practice shooting ranges, a high-powered gear motor would have some trouble raising the target.
 

oneshot

Member
OK Westaut55 will try to use "reply with quote" and the new sub window for putting code # I will try the code you just wrote. Some servos I used using Nicks code did not work like you have explained.



It would be helpful if you used the Reply with Quote button when re-posting someones code so they see it exactly including where it came from. Just cut out any unneccessary text to keep the core part you wish to refer to.

In the case of the code by me it came from a different thread at post 8 here:
http://www.picaxeforum.co.uk/showthread.php?23228-Controlling-the-speed-movement-of-a-RC-servo
that has no syntax errors.

Code:
SYMBOL shortdelay = 10 ; adjust this for desired speed
SYMBOL posn = b5
SYMBOL orig = b6

init: 
	orig =75
	servo 4,orig ; initialise servo
 
main: 
	DO

		DO
			random w0
		LOOP until w0 <= 10000 and w0 >= 3000
		pause w0

		FOR posn = orig to 75 step -1 ; can also adjust the step size try 1 if still too fast
			servopos b.4,posn ; move servo to one end
			PAUSE shortdelay
		NEXT posn

		pause 2000 ; wait 2 seconds

		FOR posn = 75 to 150 step 1
			servopos b.4,posn ; move servo to middle
			PAUSE shortdelay
		NEXT posn

		orig = 150
		do 
		loop until pinc.1 = 1

	LOOP ; loop back to start
Now look at your code it has some extra characters in a few lines which I highlight below in bold red:
FOR posn = orig to 75 step *-*1* ; can also adjust the step size try 1 if still too fast
and
FOR posn = 75 to 150 step ]*1*

with those extra characters removed the code passes a syntax check.
 
Last edited:

oneshot

Member
I will try this code too. I know nothing about basic programming. I just know how to build a circuit the hardware part. Can this code as it is be used for a PICAXE 08M2 Rick wrote it specifically for a 20M2 PICAXE I need to know what is will my input pin will be on the 08M2 and what pin to the output servo will be for the 08M2



It would be helpful if you used the Reply with Quote button when re-posting someones code so they see it exactly including where it came from. Just cut out any unneccessary text to keep the core part you wish to refer to.

In the case of the code by me it came from a different thread at post 8 here:
http://www.picaxeforum.co.uk/showthread.php?23228-Controlling-the-speed-movement-of-a-RC-servo
that has no syntax errors.

Code:
SYMBOL shortdelay = 10 ; adjust this for desired speed
SYMBOL posn = b5
SYMBOL orig = b6

init: 
	orig =75
	servo 4,orig ; initialise servo
 
main: 
	DO

		DO
			random w0
		LOOP until w0 <= 10000 and w0 >= 3000
		pause w0

		FOR posn = orig to 75 step -1 ; can also adjust the step size try 1 if still too fast
			servopos b.4,posn ; move servo to one end
			PAUSE shortdelay
		NEXT posn

		pause 2000 ; wait 2 seconds

		FOR posn = 75 to 150 step 1
			servopos b.4,posn ; move servo to middle
			PAUSE shortdelay
		NEXT posn

		orig = 150
		do 
		loop until pinc.1 = 1

	LOOP ; loop back to start
Now look at your code it has some extra characters in a few lines which I highlight below in bold red:
FOR posn = orig to 75 step *-*1* ; can also adjust the step size try 1 if still too fast
and
FOR posn = 75 to 150 step ]*1*

with those extra characters removed the code passes a syntax check.
 

oneshot

Member
OK for the 08M2 I will be using pin C.1 as the input pin and pin C.4 to replace pin B.4 as the output pin. I've read the manual on Basic Commands page 211 if using M2 PICAXE servo commands only function on port B. PICAXE 08M2 don't have port B only port C. does this make any sense?? So would a PICAXE 08M2 drive my servo?

Im having issues with different RC servos. I have RC servos that work with Nicks code and some that don't even move. Why? How is a digital servo different from an analog servo and how does it affect the code and why? By the way my wiring is correct that is one thing I do know is how to wire up a circuit. Im using 6V (4 AA batteries) like explained in the PICAXE manuals with cap and all for filtering. Both supplies ground tied to 0V. Im using the "Aztec MCU Prototyping Starter Kit for PICAXE microcontrollers. My 5V to the PICAXE is being supplied from my laptops 5V. I have 0V from my 5V tied to my 0V of my external power 6V (4 AA batteries) to power up my servo.

The pulse position I need to move is between start 225 to 75 using a PICAXE 08M2 using Nicks code.


Im currently using a 08M2 Picaxe now. Im no longer using a 20M2 for this project.



@oneshot,

did you look at the posts 59 and 60 on the previous code?

What you have been given before worked and the typos you introduced into earlier code have been highlighted for you to easily remove and get it working.

Why do you think it needs to be re-written to work on the 08M2? :confused:

Why not run the code, and if it does not work, then look at how you might modify it yourself rather than vague comments about it moves too fast - I had given a comment in the code how to slow it down previously.

Folks here are quite happy to help you but, YOU must do some of the work yourself - not just ask someone to do your project for you.

as nick12ab has indicated, if use on the 08M2 requires a change, then state clearly what needs changing (ie pin IO allocations) and indicate (post code) to show what you have tried to achieve this goal.
 

oneshot

Member
Just tested code with a PICAXE 08M2 using Pin C.4 as the output and Pin C.1 as the input. Works great with Nicks code at normal speed and Westaust55 code at slower speed. Westaust55 how can Invert / rev. the rotation? What do I have to change on the code to reverse direction?

Im wondering why the code does not work on some of my RC servos and some do? Im using this analog servo which does not work with the code for some reason and I know for sure servo is good ---> Servo
 

nick12ab

Senior Member
I've read the manual on Basic Commands page 211 if using M2 PICAXE servo commands only function on port B. PICAXE 08M2 don't have port B only port C. does this make any sense?? So would a PICAXE 08M2 drive my servo?
That was probably written before the 08M2 came out.

On the PICAXE-08M2, the pin constants for port B and port C are the same (B.1 = C.1 = 1; B.2 = C.2 = 2; etc.) and the servo will work on 'port C'.

Westaust55 how can Invert / rev. the rotation? What do I have to change on the code to reverse direction?
Which code are you referring to?

This one?
Code:
SYMBOL shortdelay = 10 ; adjust this for desired speed
SYMBOL posn = b5
SYMBOL orig = b6

init: 
	orig =75
	servo 4,orig ; initialise servo
 
main: 
	DO

		DO
			random w0
		LOOP until w0 <= 10000 and w0 >= 3000
		pause w0

		FOR posn = orig to 75 step -1 ; can also adjust the step size try 1 if still too fast
			servopos b.4,posn ; move servo to one end
			PAUSE shortdelay
		NEXT posn

		pause 2000 ; wait 2 seconds

		FOR posn = 75 to 150 step 1
			servopos b.4,posn ; move servo to middle
			PAUSE shortdelay
		NEXT posn

		orig = 150
		do 
		loop until pinc.1 = 1

	LOOP ; loop back to start
That doesn't contain 'inv'/'invert' but neither does any other code in this thread.
 

oneshot

Member
Nick yes on Westaust55's code since his code slows down the servo and moves at a slow speed. what I mean is reverse the direction so instead of starting at 75 then moving to position 225, I want it to start at position 225 then move to 75. Thats what I mean when i mean reverse the servo direction. On the code I want to be able to change the position only one time if possible on top of the code page instead of changing all the numbers on the entire code page several times. Is that possible?

By the way I found the problem why my other analog servos were not working is because my 4 AA batteries were going low so I guess some RC servos have a shutdown when voltage on batteries are going low and won't operate. Now I tried a digital servo with new batteries installed and did not move. So im thinking these codes wont work with digital servos, it will only work with analog servos.





That was probably written before the 08M2 came out.

On the PICAXE-08M2, the pin constants for port B and port C are the same (B.1 = C.1 = 1; B.2 = C.2 = 2; etc.) and the servo will work on 'port C'.

Which code are you referring to?

This one?That doesn't contain 'inv'/'invert' but neither does any other code in this thread.
 

nick12ab

Senior Member
Nick yes on Westaust55's code since his code slows down the servo and moves at a slow speed. what I mean is reverse the direction so instead of starting at 75 then moving to position 225, I want it to start at position 225 then move to 75. Thats what I mean when i mean reverse the servo direction. On the code I want to be able to change the position only one time if possible on top of the code page instead of changing all the numbers on the entire code page several times. Is that possible?
The westaust55 code looks wrong to me as at the start of the code orig is set to 75 then this loop is executed soon after:
Code:
FOR posn = orig to 75 step -1 ; can also adjust the step size try 1 if still too fast
			servopos b.4,posn ; move servo to one end
			PAUSE shortdelay
		NEXT posn
Do you understand what would happen if you changed orig to 150?
 

westaust55

Moderator
The westaust55 code looks wrong to me as at the start of the code orig is set to 75 then this loop is executed soon after:]Do you understand what would happen if you changed orig to 150?
while it might look wrong, keep in mind that the first pass orig is set to 75 at the start so the FOR...NEXT loop drops through on one pass but thereafter in the outer DO...LOOP structure, near the bottom orig = 150 so thereafter the servo will move in the opposing direction (is steps down from 150 to 75 ) followed by a direction change (75 to 150)
 

oneshot

Member
A while back you recommended to use this current sensing device which i did purchase to test out current sensing stop on my DC motors here is a link to the device ---> http://www.ebay.com.au/itm/5A-range-...item3a7adae1a8

I purchased a few of these. The mini board has 3 pins for gnd, vcc and out and has 2 screws to attach wires to.

I want to do a simple test where i can power a 6V or 12V DC motor connected to this current sensing mini board and then stop the motor with some plyers. Hopefully in the test when the mini board detects too much current draw it will stop until triggered again. Thing I will use to do this test will be a 6V DC battery, a DC motor and the mini current sensing board.

My question is how to I wire it up? I know Gnd and VCC to go 6V DC battery where do I attach the OUT and the 2 screw mount connector? A diagram will help.


Thanks

ONESHOT


For current sensing i would simply use one of these boards with the allegro chip already mounted on it.

http://www.ebay.com.au/itm/5A-range-Current-Sensor-Module-ACS712-Module-/251169268136?pt=LH_DefaultDomain_0&hash=item3a7adae1a8

The board listed is a 5 amp board which should be more than enough for the motor in use, if not there is other boards up to 30 amp.
 

SAborn

Senior Member
I know Gnd and VCC to go 6V DC battery where do I attach the OUT and the 2 screw mount connector?
You are part correct, Vcc goes to the 5 volt supply from the picaxe board and Gnd is also the same as picaxe board, out connects directly to a picaxe input ADC pin.

ONE of your motor wires will connect to one screw terminal and the other screw terminal goes to the 6v battery, the other motor wire goes direct to the 6v battery, the device reads current both ways so wont matter which battery/motor wire is used, you also need to have your motor switching device fitted to.

Use Readadc10 to monitor the current with the picaxe, with no current draw the allegro output will be at 2.5v and the adc reading will be about 512, as the current draw increases the adc reading will either go up or down, depending which way around the motor wire is attached to the screw terminals.


Picaxe and Allegro.jpg
 
Last edited:

oneshot

Member
What is the 9 pin connector above the diagram go connect to? Im not familiar with the 9 pin connector, what is it?


ONESHOT

You are part correct, Vcc goes to the 5 volt supply from the picaxe board and Gnd is also the same as picaxe board, out connects directly to a picaxe input ADC pin.

ONE of your motor wires will connect to one screw terminal and the other screw terminal goes to the 6v battery, the other motor wire goes direct to the 6v battery, the device reads current both ways so wont matter which battery/motor wire is used, you also need to have your motor switching device fitted to.

Use Readadc10 to monitor the current with the picaxe, with no current draw the allegro output will be at 2.5v and the adc reading will be about 512, as the current draw increases the adc reading will either go up or down, depending which way around the motor wire is attached to the screw terminals.


View attachment 14995
 

SAborn

Senior Member
Its a 9 pin programming socket.

I only adapted a schematic to show how the allegro current sensor is connected, and its not a complete schematic for your entire project.
 
Top