Go Down

Topic: Tacit Modification for Blind Friend (Read 9998 times)previous topic - next topic

Hackmodford

Dec 04, 2012, 06:52 pm
I'm using this project as the basis for my idea

http://grathio.com/2011/08/meet-the-tacit-project-its-sonar-for-the-blind/

But what I want to do is use 1 ping range sensor and use a vibrator motor. And put this inside a flashlight for the case.

Where can I learn how to control the vibration of the motor and have it spin faster the closer an object is?

Any help would be appreciated

Hackmodford

#1
Dec 04, 2012, 11:42 pm
Well... I've managed to create my own library that works (yay!)
It will read the PING))) sensor and return distances in inches or centimeters.
Now I need to figure out how to vary the vibration on a motor...

retrolefty

#2
Dec 05, 2012, 12:09 am
Quote
Where can I learn how to control the vibration of the motor and have it spin faster the closer an object is?

Should be pretty simple to interface a small vibration motor as they draw little current. You would use a pwm output pin and use the analogWrite(pin#, value); to set the motor speed in your sketch code where value = 0 would be off and value = 255 full speed. The following circuit would show you the electrical connections you would need (the motors two terminals would replace the solenoid shown in the picture). You may have to find the actual pwm value where the motor just starts to turn as starting at 0 might be too low a starting value.

ash901226

#3
Dec 05, 2012, 02:10 am
Hello there,Hackmodford
i read your project and i think what you are trying to do is awesome let me try to help you as much as i could,
urm first of all i think you are able to make the ping)) sensor to work rite, in what range is the max and the min that it can return. use that as a source of your mapping,then translate that to your motor. why not use a pager motor. its small and i think it provide a good vibrational force.

anyway this may help you a bit on the programming part
Code: [Select]
`int Pingreturn=   //i dont know this part in your setupint speed = map (Pingreturn,Min,Max,255,);analogWrite(Motorpin,speed);`

AWOL

#4
Dec 05, 2012, 12:31 pm
Be careful what sort of vibra motor you buy.
Some require an H-bridge to drive them.
Make sure you buy the simple DC motor type with eccentric weight.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Hackmodford

#5
Dec 05, 2012, 06:58 pmLast Edit: Dec 05, 2012, 07:04 pm by Hackmodford Reason: 1
Okay thanks guys,
I've managed to get it working... I found someone else that's essentially done the same thing and took their code and slightly modified it. Here's what I came up with.

Code: [Select]
`/*  Tacit Flashlight/Vibration Code  Created by Brandon Butler, December 4, 2012.  Released into the public domain.*/#include <Ping.h>#include <DebugUtils.h>//#define debug //debug for debugging, anything else otherwiseconst int pingPin = 7;const int vibPin = 3;int pulseOut = 0;Ping ping;void setup() { // initialize serial communication:  #ifdef debug  Serial.begin(9600);                Serial.println("Testing");  #endif  pinMode(vibPin,OUTPUT);}void loop() {          long inches; // get inches from PING))) inches = ping.pingInches(pingPin); //vibrate proportionally to closeness pulseOut = inchesToPulse(inches); analogWrite(vibPin,pulseOut); DEBUG_PRINT (inches); DEBUG_PRINT (pulseOut); delay(100); analogWrite(vibPin,0);}float inchesToPulse(float inches) { //curved function so closer distances have more variation int MaxInches = 240; int minPulseOut = 100; //vib motor won't spin below ~50-70 //(3 was way too steep) Only felt motor within a foot or two float powerConst = 2; //steepness 1 for line >1 for steeper int pulseOut; pulseOut = (int)(pow(((MaxInches - (float)inches)/MaxInches),powerConst) * (255.0-minPulseOut)) + minPulseOut; if (pulseOut <= minPulseOut) { pulseOut = 0; } return pulseOut;}`

I took a motor from a gamecube controller. I assume it uses either 3.3V or 5V to run.
I have the arduino pin wired directly to the motor and it seems to work fine. Should I do anything else?

AWOL

#6
Dec 05, 2012, 07:35 pm
Quote
Should I do anything else?

Yes, you should remove the motor before it damages your Arduino. (it may already be too late)
Some of these motors can draw more than twice the maximum current allowed from an I/O pin.
Use a transistor to buffer the motor, and add a snubber diode.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Hackmodford

#7
Dec 05, 2012, 09:50 pmLast Edit: Dec 05, 2012, 10:01 pm by Hackmodford Reason: 1
I'm not exactly sure how to do this. I'm more of a software guy than hardware...

Can you provide a link to the transistor and diode I would need? And also a schematic I can follow?

(edit: I suppose the schematic provided for the solenoid is what you're referring too? So would I just use the regulated 5V line off of the arduino (that is powering the ping) to also power the motor? And then use a data line to go to the transistor? If so what transistor and diode do I need?)

I am using the Arduino Pro Mini 5V.

So far the project has been a real success!

Thanks for all your help.

(edit2: Going from this site http://www.akeric.com/blog/?tag=arduino the author claims that the motors only draw 20ma. My pins can provide 40ma each so I should be good. Also I just realized that only 6 of the 14 pins can be used for PWM and I got lucky and picked #3 for the motor Since the motor should be fine I don't need the transistor but should I use anything else?)

retrolefty

#8
Dec 05, 2012, 11:42 pm

I'm not exactly sure how to do this. I'm more of a software guy than hardware...

Can you provide a link to the transistor and diode I would need? And also a schematic I can follow?

(edit: I suppose the schematic provided for the solenoid is what you're referring too? So would I just use the regulated 5V line off of the arduino (that is powering the ping) to also power the motor? And then use a data line to go to the transistor? If so what transistor and diode do I need?)

Depends on the current requirement of the vibration motor you are using. Most are very small motors so powering them from the arduino 5v pin should be fine. Note that some vibration motors are rated at 3.3vdc max and might end life early if operated at 5 volts. The size of the transistor again depends on the current draw of the motor, the one shown in the solenoid drawing is probably an overkill but it would work. A simple and common 1N4001 diode is fine.

I am using the Arduino Pro Mini 5V.

I've never used that board, just check what it's maximum rated current draw from the 5volt is to see if it matches what your ping and motor require together.

So far the project has been a real success!

Thanks for all your help.

(edit2: Going from this site http://www.akeric.com/blog/?tag=arduino the author claims that the motors only draw 20ma. My pins can provide 40ma each so I should be good. Also I just realized that only 6 of the 14 pins can be used for PWM and I got lucky and picked #3 for the motor Since the motor should be fine I don't need the transistor but should I use anything else?)

Hackmodford

#9
Dec 06, 2012, 03:17 pmLast Edit: Dec 06, 2012, 03:43 pm by Hackmodford Reason: 1
So my next question, if I skip the transistor part how do I wire the diode?

Edit:
I found this diagram on this site http://www.coactionos.com/embedded-design/39-motor-control.html

In my case is that what I should do?

AWOL

#10
Dec 06, 2012, 03:54 pm
Quote
So my next question, if I skip the transistor part how do I wire the diode?

You don't skip the transistor part until you've proven that the motor doesn't draw more than about 30mA when you clamp the output shaft.
With or without the transistor, you wire the diode in parallel with the motor, with the cathode to the positive side.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Hackmodford

#11
Dec 06, 2012, 05:59 pm

Quote
So my next question, if I skip the transistor part how do I wire the diode?

You don't skip the transistor part until you've proven that the motor doesn't draw more than about 30mA when you clamp the output shaft.
With or without the transistor, you wire the diode in parallel with the motor, with the cathode to the positive side.

LOL... I'll get my multimeter and double check.

And will just use a diode as you suggest.

Thanks

Hackmodford

#12
Dec 06, 2012, 07:48 pm
I've attached a schematic. I assume this is what I should do?

retrolefty

#13
Dec 06, 2012, 07:51 pmLast Edit: Dec 06, 2012, 08:04 pm by retrolefty Reason: 1

I've attached a schematic. I assume this is what I should do?

First the diode is wired backwards creating a short circuit, reverse it. Then test the motor current draw.
Only if the current draw from the motor is around 30ma or less should you wire it directly to a output pin without using a switching transistor. You should first wire it to the arduino 5V pin and then with your multimeter wired in series take a current measurement. Only then if under 30ma or so should you wire it to a arduino pwm digital output pin.

Lefty

Hackmodford

#14
Dec 06, 2012, 08:07 pm

I've attached a schematic. I assume this is what I should do?

First the diode is wired backwards creating a short circuit, reverse it. Then test the motor current draw.
Only if the current draw from the motor is around 30ma or less should you wire it directly to a output pin with using a switching transistor. You should first wire it to the arduino 5V pin and then with your multimeter wired in series take a current measurement. Only then if under 30ma or so should you wire it to a arduino pwm digital output pin.

Lefty

Excellent I believe that's all I needed. And you guys have my code so if anyone wants to make one feel free

Here's some pics for the project

Go Up