Pages: [1] 2   Go Down
Author Topic: Tacit Modification for Blind Friend  (Read 5132 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

http://arduino.cc/playground/uploads/Learning/solenoid_driver.pdf
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
int Pingreturn=   //i dont know this part in your setup
int speed = map (Pingreturn,Min,Max,255,);
analogWrite(Motorpin,speed);
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
/*
  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 otherwise
const 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?
« Last Edit: December 05, 2012, 01:04:05 pm by Hackmodford » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-grin Since the motor should be fine I don't need the transistor but should I use anything else?)
« Last Edit: December 05, 2012, 04:01:09 pm by Hackmodford » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-grin Since the motor should be fine I don't need the transistor but should I use anything else?)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
« Last Edit: December 06, 2012, 09:43:53 am by Hackmodford » Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26632
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

"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.

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* schemeit-project.png (4.29 KB, 379x146 - viewed 42 times.)
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 362
Posts: 17307
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: December 06, 2012, 02:04:18 pm by retrolefty » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley I believe that's all I needed. And you guys have my code so if anyone wants to make one feel free smiley

Here's some pics for the project





Logged

Pages: [1] 2   Go Up
Jump to: