Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: tzankoff on August 14, 2010, 12:23:29 AM
-
Hi guys. This is my first post. Please be gentle. I admit I don't know everything. ::)
I am looking to see if I can control an MP3 Trigger from SparkFun via an Axon 2.
I was thinking of hooking up a push button switch (input) and servos to the unregulated power headers of the Axon with a Hitec header connecting a regulated 5v output to the MP3 Trigger card as shown in my little diagram below. The output of the regulated pins is 5v and according to the documentation (link below), the MP3 Trigger card trigger inputs can take 5v.
When pushing the button, I was thinking of code along the lines of this:
if(button_pressed())
{
PORT_ON(PORTA,6);
delay_ms(100);
PORT_OFF(PORTA,6); // triggers MP3 card. (is this part even right?)
servo(PORTA,7,360); // represents the series of servo events
}
Go ahead and rip on me if I am thinking dumb things. Axon is very new to me. Looks relatively simple though I admit I have much to learn. Just help me out here if you don't mind. Thank you.
(http://web5.twitpic.com/img/145376568-097811835064bfce4ebaca8905f79a8a.4c6630e0-full.png)
MP3 Trigger Datasheet:
http://www.sparkfun.com/datasheets/Widgets/MP3Trigger/MP3TriggerV2UserGuide_2010-07-30.pdf (http://www.sparkfun.com/datasheets/Widgets/MP3Trigger/MP3TriggerV2UserGuide_2010-07-30.pdf)
-
Hi,
The trigger inputs are active low, so you need to keep the I/O line high until you want the trigger and then pull it low (to 0V)
If you want the possibility of triggering with a switch as well as from the µcontroller, you need a transistor (w. a base resistor) mounted as "open collector" - that will keep you from shunting the I/O line of the µcontroller when the switch is activated. If you use an o.c. transistor, it will invert the logic, so it's then active high (as your code snippet will drive).
-
Hello Soeren.
The use of transistors is new to me. Never had to use them before and I do not have any kind of electrical engineering degree. However, there are a couple of things that you said that I would like to clarify.
1) When you said "If you want the possibility of triggering with a switch as well as from the µcontroller..." implies to me that I will use one *or* the other, but I was under the impression that triggering the switch would utilize whatever code is associated with that input. (i.e.: if button 1 is pressed, do this. if button 2 is pressed, do that. if button 3 is pressed, do a third thing, and so on).
2) I read the trigger input levels are active low just after posting. I guess I overlooked that part earlier. Would I invert the PORT_ON and PORT_OFF commands in the code (change to PORT_OFF, DELAY, PORT_ON) to correct that?
P.S.: It's 3:30am over here and I just might not be thinking straight. I just wanted to post my initial question before going to bed. I wasn't expecting any kind of response so quickly. :-)
-
Using the Trigger Inputs:
PORT_ON brings the pin high, to 5V
PORT_OFF brings the pin low, to 0V
read here:
http://en.wikipedia.org/wiki/Transistor (http://en.wikipedia.org/wiki/Transistor)
Especially the part that says 'Transistor as a switch'.
For Serial Control Protocol (I recommend this):
"a full-duplex serial control port that provides full transport control, remote triggering for up to 256 tracks, and fast real-time volume control."
Just send the Command byte followed by the Data byte as shown in the pdf datasheet using rprintf("").
I recommend this as you only hook up three wires: power, ground, and Rx
-
Gosh! An admin...and I didn't even do anything wrong. Thanks for responding none the less. :)
Using the Trigger Inputs:
PORT_ON brings the pin high, to 5V
PORT_OFF brings the pin low, to 0V
I know. I just put them down in the wrong order in the original post without realizing until afterward that they were in the wrong order. Somebody else, in the meantime, sent me an e-mail confirming the answer to my question about OFF, DELAY, ON so I think that part of my entire question is resolved...I hope.
I am now looking into the rest (which is mostly new to me). ;D
-
Gosh! An admin...and I didn't even do anything wrong. Thanks for responding none the less.
Personal support from admin himself comes with the price of every Axon ;D
-
Wait a sec. I just realized something. Can you PORT_ON/OFF pins in the ADC row? If so, how? I know the whole row can be turned on and off (a2dInit() and a2dOff()), but what about individual pins?
This will make something of a difference as I would like to power a couple of RGB LEDs. As I understand it, there are two ways I can go about this...assuming I am understanding this correctly.
1) Plug them into the regulated power and use... a2dSetReference(ADC_REFERENCE_256V); ...to use the 2.56V configuration and just switch on/off whatever color I wanted to use.
-OR-
2) plug LEDs into unregulated power and provide resistance to bring things down to the (roughly) 3V that I will need.
I plan on using the first method if I can ON/OFF individual pins in the regulated power row and the second method if I cannot.
In the meantime, I am still pondering about my previous dilemma. Some are telling me that using push button switches on the Axon to control the MP3 card would be fine and some are telling me serial or bluetooth control is the way to go. There are pros and cons to both and I am still trying to figure some stuff out.
-
Ack! I think I see now. The ADC row is for sensors. Input, not output. Darn. Oh, well. The second method it is then. ::)
-
All pins are I/O, meaning input and output. The ADC can be configured to do output.
That said, with all the other pins already available, no need!
However, my Axon code is really really old/outdated. I recommend using WebbotLib.
-
All pins are I/O, meaning input and output. The ADC can be configured to do output.
Please tell me how. I'm looking through the source code. Sor_Utils.h seems to have the configuration stuff, but I don't want to change anything since I am not exactly sure what I am doing and don't want to screw things up.
That said, with all the other pins already available, no need!
Using the regulated 5V pins help suit a specific purpose. While unregulated I/O pins can be used (with a little extra hardware) as well, I would like to eliminate that extra hardware obstacle, if at all possible.
However, my Axon code is really really old/outdated. I recommend using WebbotLib.
As long as things work and I understand it, I could care less how old or outdated it is. Its not like I am refusing to apply security updates to my computer OS.
-
Sor_Utils.h seems to have the configuration stuff, but I don't want to change anything since I am not exactly sure what I am doing and don't want to screw things up.
All instructions are in that .h file. Just read through the notes carefully, it'll make sense eventually :P
(if you're still stuck, post your best guess here and we'll verify it)
As long as things work and I understand it, I could care less how old or outdated it is. Its not like I am refusing to apply security updates to my computer OS.
Its the difference between a square wheel and a round wheel, really :P
-
Damn! I did not see the little F and the little K on the Axon board. No wonder I could not tell what the port letter was. I was just focusing on the numbers. ::)
In my case, I believe I would have to do this:
DDRA = 0b00000000; //configure ports for input
DDRF = 0b11111111; //configure all F ports for output
DDRK = 0b11111111; //configure all K ports for output
PORTF = 0b00000000; //make sure pull-up resistors are turned off
PORTK = 0b00000000; //make sure pull-up resistors are turned off
Then to trigger the MP3 card...
if(bit_is_set(PINA, 1)) // set via push button switch
PORT_OFF(PORTF,6); // sends 0V to MP3Trigger (active low inputs); plays the track
delay_ms(200); // wait a bit to make sure it starts
PORT_ON(PORTF,6); // reset
servo(PORTA,7,360); // represents the series of servo events
I don't know where my shabby little artwork from my initial post went, but here is a visual representation of what I am trying to accomplish. (Ports and pins in drawing for illustrative purposes only.)
http://twitpic.com/2ejxa0 (http://twitpic.com/2ejxa0)
Please tell me I am at least partially right on this. :P
-
Your configuration code is correct.
You should also initiate the pin as high, so it doesn't do its thing during an Axon reset.
-
Yay! I knew I would get something right sooner or later.
Updated initialization now shows:
DDRA = 0b00000000; // configure A ports for input
DDRF = 0b11111111; // configure F ports for output
PORTF = 0b11111111; // make sure pull-up resistors are turned on