Jump to content
43oh

Recommended Posts

Here's my msp430 annying thingy.

http://imgur.com/4AZYD

http://imgur.com/S5Nm3

Sorry for the really terrible pictures.. i couldn't get a good camera phone picture to save my life.

 

every 12 minutes.. ish it chirps a high pitched noise that's hard to locate and find in a room. I might upgrade it to a random timeframe later. The button batteries are held in place by earth magnets that have wires soldered to them.. And as you can expect, soldering to magnets with a metal soldering iron is hard! get a big metal tool to attach the magnets to or you'll have one hot magnet!

all of the parts are stuck together with hot glue and fit into an old marker with the bottom cut out (no picture of that yet)

 

I made this for my brother's birthday.. something to annoy him and later he can use it to annoy his friends :)

 

Really simple.. I reused the piezo code from TI http://processors.wiki.ti.com/index.php/Playing_The_Imperial_March

 

and as for a schematic:

 

QcMuI.jpg

llaaaazy me :).. a schematic fit for the level of my maturity.

 

heres the code

//Tophathacker
//annoying .. thingy

#include "msp430g2231.h"
unsigned int count = 0;

void beep(unsigned int note, unsigned int duration);
void delay_ms(unsigned int ms );

void main(void)
{
   WDTCTL = WDTPW + WDTHOLD;		// Stop WDT
   P1DIR |= 0xFF;					//All outputs
   P1OUT = 0;
   BCSCTL3 = LFXT1S1;				//Select VLOCLK for ACLCK (i.e. 12khz intosc)
   P1OUT |= BIT5+BIT6;
   TACCTL0 = OUTMOD_2 + CCIE;		// TACCR0 interrupt enabled
   TACCR0 = 32768;					//Compare to Timer_A register (approx. 25 sec for VLOCLK & 1/8 divider)
   TACTL = TASSEL_1 + ID1 + ID0 + MC_1;    // ACLCK, 1/8 DIVIDER, upmode to TCCR0 value

for(;
{
	beep(700,50);

  __bis_SR_register(LPM3_bits + GIE);    //Enter LPM3 w/interrupt
  __no_operation();		// For debugger, executes next instruction just like a PIC
}
}

void delay_ms(unsigned int ms )
{
   unsigned int i;
   for (i = 0; i<= ms; i++)
      __delay_cycles(500); //Built-in function that suspends the execution for 500 cicles
}

void delay_us(unsigned int us )
{
   unsigned int i;
   for (i = 0; i<= us/2; i++) 
      __delay_cycles(1);
}

void beep(unsigned int note, unsigned int duration)
{	
   int i;  
   long delay = (long)(10000/note);  //This is the semiperiod of each note. 
   long time = (long)((duration*100)/(delay*2));  //This is how much time we need to spend on the note.
   for (i=0;i    {    
       P1OUT |= BIT5;     //Set P1.5...
       delay_us(delay);   //...for a semiperiod...
       P1OUT &= ~BIT5;    //...then reset it...
       delay_us(delay);   //...for the other semiperiod.
   }  
   delay_ms(20); //Add a little delay to separate the single notes
}

#pragma vector=TIMERA0_VECTOR		// Timer A0 interrupt routine
__interrupt void Timer_A (void)
{
count += 1;
TACCR0 = 32768;			// reset TACCR0 register
if (count==24){			//24 * 25sec is 10 minutes...ish		
	beep(700,50);
	count = 0;
}
}

Link to post
Share on other sites

hmm, would be a handy prank to pull on some well deserving room mates.

 

As for the source of randomness that is an interesting topic. For my EE based probability class were suppose to come up with some related project. Mine was using the ADC LSB as a random number and then pull it say 100k times and see if the distribution is actually a uniform distribution. Haven't had time to do that quite yet but an interesting topic of how you get a random number and how truly random is that number.

Link to post
Share on other sites

Just an update, i guess my brother was rummaging around in his room.. about every 10 minutes for hours last night until he went and slept on the couch. success. I could not have hoped for a better outcome. i do think though that things could be changed:

better/different piezo so you can hit higher frequencies

different sine/square wave for better piezo response

multiple pwm waves? on each pin? i heard something about that somewhere...

better enclosure/ use smt parts

random function, or at least seemingly random. i would much rather have 100 different time intervals, then use up extra power to look at the adc to generate a 'true' random number. its not that important, not as important as battery life.

Link to post
Share on other sites
ust an update, i guess my brother was rummaging around in his room.. about every 10 minutes for hours last night until he went and slept on the couch. success. I could not have hoped for a better outcome.

Poor thing.

 

This thing is going to cost less in parts and programmable than the original Annoyatron + programmable.

Link to post
Share on other sites
Uniform distribution alone isn't really telling anything.

 

Make a quick app that samples ADC, something that reads it off the LP, and feed the raw bitstream into Dieharder. Lots of info about random numbers at this URL too.

 

hmm.... im not so good at probability... so if you have uniform distribution that would mean that each number within your distribution would have equal probability. So if I use my msp430 adc to generate a number between 0-9 and each number has a equal chance of happening, how would that not be random? I suppose if all the numbers occurred in the same order it wouldn't be random but it could be a uniform distribution. However, I would highly doubt that specific case is the normal case.

Link to post
Share on other sites

You got me in that I have probably thought more of CSPRNGs than PRNGs, bad habit :).

 

The flaw in your argument is the "each number has a equal chance of happening" part. This may be true for certain period of time or at a certain place, but vary these and you almost surely end up knee-deep in trouble.

 

You are right in that ADC (specifically ADC noise, as oPossum helpfully pointed out) is highly likely (not the first phrase you want to see in this context ;)) to be random, but even then, there may be properties (of the silicon and neighbouring stuff outside my comfort zone) as well as environmental issues that skew the ADC. Say you deployed your kit in an office of sorts -- filled with folks during the day, empty at night. Folks tend to want to be in a comfy warm space and use cell phones. Building management wants to save on heating bill, so it's off for the night.

 

Temperature changes surely, specifically cell phone radiation probably doesn't but let's assume for the sake of argument that it does, affect the noise ADC picks up from the environment.

 

Add these up, suddenly you have a random number generator that is not so random anymore -- it just developed an observable pattern. There are methods to smooth and smear this and other issues that arise (Neumann described some algorithm to that effect IIRC, probably others too since), but still -- not one day passed yet and you already have to massage your numbers for them to appear random

 

Now, there are random number generators that we haven't yet figured out how to predict, but to the best of my knowledge they tend to operate on principles of particle physics (again, outside my comfort zone), but at the very least on a complexity level much away from "hang two wires off an ADC10 of a 20

Link to post
Share on other sites
  • 2 weeks later...

I used the same PRNG on a project involving a clock [ i will post it as soon as i get the pictures ready ], it was a clock going at random intervals but in on average it was accurate. the PRNG i used works quite well, and has a good distribution, at least for BIT0.

 

It would be intersting to use some code to collect "true" random data from s.th. like a floating pin or the adc, using it to source the prng [ in my case a lfsr ] and then work with this.

an annoyatron using this would not be predictable, not even by the person who has built it [ i knew the pattern of my annoyatron after 2 days of debugging ].

 

-lastaid

Link to post
Share on other sites
  • 3 weeks later...
  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...