Author Topic: Controlling MP3 Trigget via Axon 2  (Read 1734 times)

0 Members and 1 Guest are viewing this topic.

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Controlling MP3 Trigget via Axon 2
« 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:
Code: [Select]
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.



MP3 Trigger Datasheet:
http://www.sparkfun.com/datasheets/Widgets/MP3Trigger/MP3TriggerV2UserGuide_2010-07-30.pdf

Offline Soeren

  • Supreme Robot
  • *****
  • Posts: 4,672
  • Helpful? 227
  • Mind Reading: 0.0
Re: Controlling MP3 Trigget via Axon 2
« Reply #1 on: August 14, 2010, 12:39:28 AM »
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).

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

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: Controlling MP3 Trigger via Axon 2
« Reply #2 on: August 14, 2010, 01:23:09 AM »
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. :-)

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Controlling MP3 Trigget via Axon 2
« Reply #3 on: August 14, 2010, 07:14:22 AM »
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
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

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: Controlling MP3 Trigget via Axon 2
« Reply #4 on: August 14, 2010, 07:26:08 AM »
Gosh! An admin...and I didn't even do anything wrong. Thanks for responding none the less. :)

Quote
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

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Controlling MP3 Trigget via Axon 2
« Reply #5 on: August 14, 2010, 08:19:15 AM »
Quote
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

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: Controlling MP3 Trigget via Axon 2
« Reply #6 on: August 15, 2010, 09:21:50 AM »
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...
Code: [Select]
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.

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: Controlling MP3 Trigget via Axon 2
« Reply #7 on: August 15, 2010, 09:27:55 AM »
Ack! I think I see now. The ADC row is for sensors. Input, not output. Darn. Oh, well. The second method it is then.  ::)

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Controlling MP3 Trigget via Axon 2
« Reply #8 on: August 15, 2010, 07:12:35 PM »
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.

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: Controlling MP3 Trigget via Axon 2
« Reply #9 on: August 16, 2010, 12:18:24 PM »
Quote
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.

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

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

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Controlling MP3 Trigget via Axon 2
« Reply #10 on: August 16, 2010, 12:44:26 PM »
Quote
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)

Quote
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

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: Controlling MP3 Trigget via Axon 2
« Reply #11 on: August 16, 2010, 02:00:48 PM »
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:

Code: [Select]
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...

Code: [Select]
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

Please tell me I am at least partially right on this.  :P
« Last Edit: August 16, 2010, 02:03:47 PM by tzankoff »

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Controlling MP3 Trigget via Axon 2
« Reply #12 on: August 16, 2010, 02:14:17 PM »
Your configuration code is correct.

You should also initiate the pin as high, so it doesn't do its thing during an Axon reset.

Offline tzankoffTopic starter

  • Robot Overlord
  • ****
  • Posts: 122
  • Helpful? 0
Re: Controlling MP3 Trigget via Axon 2
« Reply #13 on: August 17, 2010, 08:20:55 AM »
Yay! I knew I would get something right sooner or later.

Updated initialization now shows:
Code: [Select]
DDRA = 0b00000000; // configure A ports for input
DDRF = 0b11111111; // configure F ports for output
PORTF = 0b11111111; // make sure pull-up resistors are turned on
« Last Edit: August 17, 2010, 12:05:16 PM by tzankoff »