SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
#179194
Hi! I am a super newbie here...

I've followed this excellent tutorial - https://learn.sparkfun.com/tutorials/xb ... e-overview - and have had gotten it all to work.

I would now like to take it a step further, but am not sure how. Here is what I would like to do:

Connect Velostat to analog pin DIO0 on the XBee which is connected to the computer, and have that activate a vibrating motor which is connected to pin 13 on the Arduino.

I'm able to type in dd1/dd0 in XCTU to get the vibrating motor to turn on and off (like with the LED in the tutorial), but the part I don't know how to do is hook up the velostat, make the XBee read the compression, and then activate the vibrating motor accordingly.

I've found several tutorials about how to hook up potentiometers, etc, but not using the same Arduino code as in the tutorial listed above, and none with force resistors. And so, I am totally lost!

Any advice?

Thanks!
By Mee_n_Mac
#179226
Perhaps you could start by giving us some more info. How did you connect the velostat to the Xbee and/or ground and/or the power supply ? Usually there's another resistor involved in order to make a voltage divider that will transform varying resistance into varying voltage to be read by an ADC. Also do you have some idea of the range of resistance you expect from the velostat ?
#179239
What he said!

But in addition, if you want to have an analog reading on a remote xbee turn on a pin on a local xbee (virtual wire). Then the xbees must be a series 1, and the output must be one of the 2 pwm pins. AD0 matches PWM0, and AD1 mathces PWM1. Driving the motor directly from a digital PWM pin is not likely to work. It would need some amplification, and Im sure it must start to run only when the analog value is above some set value.
#179267
Thanks both!

I haven't connected the velostat to the Xbee because I'm not sure how to do that. Would it work to put a jumper into DIo0 and one into GND, and attach those to the Velostat?

I'm using series 1 Xbees and have attached photos of my current set up. I really have no idea about the range of resistance from the velostat...sorry, so super new at this.

But, it seems like I need to change where I have the vibe motor connected to the Arduino? The PWM pins are digital, and so they wouldn't be able to make the vibe motor have varying levels of vibration, just either on or off...do I understand that correctly? Maybe I have that backwards.

Thanks again, your help is truly appreciated. I apologize again for my lack of knowledge here.
remotexbee_reduced.png
ardvibe2_reduced.png
You do not have the required permissions to view the files attached to this post.
#179335
As the motor is an inductive device, it may potentially damage the output pins of the Xbee and/or the Arduino when the current to the motor is shut off. Infact, the current might not even be sustainable by the Xbee or Arduino pin. Even if this is only a small motor. It's like a flywheel, if you disconnect the torque that made it spin, it wants to keep going. And if you also applied a brake on the load it is driving(like the current flow is interrupted in the circuit), then something is going to break sooner or later. A lot of force on the load is generated when this happens. I suggest you switch it on with a (npn) transistor (to alleviate the current supply from the pwm pin) and use a flyback diode to prevent the inductive voltage spike when the transistor (or output pin) turns off. See this youtube video for info why: (pay attention to the direction of the diode!!)

https://www.youtube.com/watch?v=LXGtE3X2k7Y

The PWM pins are digital, but they change very quickly, many times a second (15kHz or so ...whoops, that's Xbee PWM pin repetition frequency). Too quick for the motor to come to a stop again. The average hight of the pulse allows the motor to run at lower speeds. But these fast changing edges come with the problem as suggested above. Also, the lower PWM widths might not be enough to get the motor running right away. There may be a threshold to overcome due to friction or other losses.
Last edited by Valen on Sun Feb 01, 2015 6:27 am, edited 1 time in total.
#179370
Thanks Valen! I will watch that video and play with it a bit more based on your suggestions.

Here are details I've got about the Velostat:
Dimensions: 11" x 11" (280mm x 280mm)
8 mil / 0.2mm thick
Weight: 18.66g
Temperature Limits : -45°C to 65°C (-50°F to 150°F)
Heat Sealable : Yes
Volume Resistivity : <500 ohm-cm
Surface Resistivity : < 31,000 ohms/sq.cm