Author Topic: Pls help with non-robotic electronics project  (Read 1030 times)

0 Members and 1 Guest are viewing this topic.

Offline EddieTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Pls help with non-robotic electronics project
« on: September 22, 2010, 03:12:04 AM »
Hi guys I'm new here, I haven't gotten the chance to start my own robotics projects yet(only experience is Lego Mindstorms :) )
Anyway I need help on building what seems to be a simple project(it will be a gift), and thought this would be a good place to ask for help.

I have SOME experience with electronics but I'm no expert so please bare with me if I sound like a noob.

Basically it will consist of two objects(Object-1 and Object-2), when they are put right next to each other, there will be an audio playback and when they are separated the audio should stop.

Now here is how I intend to do this. I am planning on getting this recording module:

http://www.electronics123.com/s.nl/it.A/id.2841/.f

I will use the software provided to upload an audio clip to it(a song, or part of it at least).

Okay the recording module will be located inside Object-1. The module has a push switch/button for playback & stop. What I plan on doing(this is where I'm probably wrong and I need some advice!) is remove the switch/button and replace is with a Reed Switch like this one:

http://www.sparkfun.com/commerce/product_info.php?products_id=8642

Then inside Object-2 will be a magnet that will activate the Reed Switch inside Object-1 and play the audio. At least thats what I want it to do, but I have a feeling it is more complicated than just replacing the switch.I think this might not work since the original switch works with just one push i guess, and the reed switch is something that will be 'open' or 'ON' the entire time the two objects are placed next to each other??

Like I said, I'm no expert but I really want to get this to work so any help/tips would be GREATLY appreciated. Maybe I should try a different recording module or a different approach to the proximity/magnetic activated switch??

Someone posted a link to this other recording module on this forum, I wouldn't mind paying the extra few bucks for it if you guys think this one might be better:

http://www.sparkfun.com/commerce/product_info.php?products_id=9715

Here is a simple, POORLY drawn diagram of my idea in case I didn't explain myself right.

http://i56.photobucket.com/albums/g171/mrhankeydapoo/ReedSwitch.jpg


One last thing; if there was a way to make it play random mp3s or audio clips every time, that would be awesome lol but I think I got enough on my plate already.

Thanks in advance

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Pls help with non-robotic electronics project
« Reply #1 on: September 22, 2010, 09:02:08 AM »
About the reed switch:  You're right, you'd have some difficulty making the reed switch a drop-in replacement for a pushbutton switch.  What you can do instead would be to have a microcontroller output connected to the pushbutton lines, and then have the reed switch as an input, you can XOR in software.  Lastly, I don't know if a reed switch has the sensitivity to have some range, so you may have to put them in the almost-touching range.

Offline EddieTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
Re: Pls help with non-robotic electronics project
« Reply #2 on: September 22, 2010, 11:52:55 AM »
About the reed switch:  You're right, you'd have some difficulty making the reed switch a drop-in replacement for a pushbutton switch.  What you can do instead would be to have a microcontroller output connected to the pushbutton lines, and then have the reed switch as an input, you can XOR in software.  Lastly, I don't know if a reed switch has the sensitivity to have some range, so you may have to put them in the almost-touching range.

Thank you for your response.
About the range, yea they will be separated only by cardboard or a similar material so they would be almost touching except for the cardboard once the two objects are placed next to each other.

And thanks I see what you mean. I am not experienced with microcontrollers though, in fact I literally just ordered my first one online a few minutes ago. I got this kit from nerdkits;
http://www.nerdkits.com/kits/

So can you recommend a microcontroller that i can buy for this project? Also what do you mean by 'XOR in software? Lastly, how would I program the microcontroller? Sorry for all the questions. Perhaps I can use the "USB to Serial TTL Cable" that comes with the kit I just ordered to program the microcontroller?

Thanks a lot again

Offline rbtying

  • Supreme Robot
  • *****
  • Posts: 452
  • Helpful? 31
Re: Pls help with non-robotic electronics project
« Reply #3 on: September 22, 2010, 09:06:53 PM »
The Nerdkit looks fine, it comes with its own programmer/bootloader combo, I think.  The AVR ATMega128 is one of the more popular microcontrollers around here, as it's pin-equivalent to its smaller brother ATMega8 and bigger brother ATMega328.  Only thing you might want to get (later, of course, not necessary) is an AVR ISP2, or other 6-pin programmer, so you don't depend on a bootloader.

About the XOR, its because a reed switch will read HIGH (5v, logical true) while the magnet is within range, while the pushbutton reads HIGH for a moment, then releases back down to LOW (0v, logical false) afterward to start your MP3.  It's just C, so here's some pseudocode:
Code: [Select]
int prevState = 0;
int state = 0
...
(inside your loop)
prevState = state;
state = // read the pin
if (state != prevState && state) // if the state has changed AND state is TRUE
  // set output pin high, as this is the reed switch's first HIGH
else if (state) // prevState == state, and state is TRUE, eed must have already been pressed
  // set output pin low

// do other stuff, like light up leds or print out to LCD.


What you're trying to do is make the output HIGH if and only if this is the rising edge (LOW -> HIGH) of the input pin, and LOW all other times, emulating a pushbutton (HIGH when you press it, and then LOW when you release it a moment later).  You reset the switch by driving the input LOW, such as taking the magnet out of the reed switch's range.  Sorry about calling it an XOR, it's not really one, as XOR would be something like this:

1st HIGH output HIGH, 2nd HIGH output LOW, 3rd HIGH output HIGH... not really useful for your application.

Actually, when you mention the random song, it's not particularly hard to do with a controller.  You'll want a random input (easy one would be a disconnected pin set to input, which reads random charges in the air), and then just have a constant array of the track nums.  You would output the next song via UART (serial) to the MP3 Trigger, and have 256 to choose from. 
« Last Edit: September 22, 2010, 09:11:11 PM by rbtying »

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Pls help with non-robotic electronics project
« Reply #4 on: September 24, 2010, 10:19:31 PM »
Hi,

Basically it will consist of two objects(Object-1 and Object-2), when they are put right next to each other, there will be an audio playback and when they are separated the audio should stop.
You have to go with another module for this. The module you linked to is either push-on/push-off or push-to-start-and-play-entire-song-once.


Okay the recording module will be located inside Object-1. The module has a push switch/button for playback & stop. What I plan on doing(this is where I'm probably wrong and I need some advice!) is remove the switch/button and replace is with a Reed Switch like this one:
[Snip]
Then inside Object-2 will be a magnet that will activate the Reed Switch inside Object-1 and play the audio. At least thats what I want it to do, but I have a feeling it is more complicated than just replacing the switch.I think this might not work since the original switch works with just one push i guess, and the reed switch is something that will be 'open' or 'ON' the entire time the two objects are placed next to each other??
Several modules can do this, but I'd advice you to go with a better sound quality. To get the full 50 seconds with thee module you have in mind, you need to use the 8kHz sample rate and that means that you will only get sound up to 4kHz - i.e. a rotten sound - the 12kHz sample speed gives you ~33s and a slightly less bad sound up to 6kHz.

Quality depends on the purpose of course, but 8kHz samples doesn't sound good on even the best stereos - and the speaker (and probably the rest of the sound circuit, amplifier and such) is Lo-Fi^2

A Reed switch is fine for a momentary contact if a capacitor is included, but you don't want one with a momentary switch, you want one that keeps going while the switch is depressed.
You might have to place the Reed in the power lead to a module that can be set up to play whenever power is applied.

Forget adding a Ácontroller, then you could just as well build an MP3 player from the bottom up.
Regards,
S°ren

A rather fast and fairly heavy robot with quite large wheels needs what? A lot of power?
Please remember...
Engineering is based on numbers - not adjectives

 


Get Your Ad Here

data_list