Updating the MiniPOV design

MiniPOV4 and previous versions

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am

Updating the MiniPOV design

Post by magician13134 »

Hey everyone, the MiniPOV3 was my first kit and I absolutely loved it, but the problem was that you could hardly read it without a camera. I know there's a sensor port on the MiniPOV, but there doesn't seem to be a comprehensive guide to getting a good tilt switch, installing it, rewriting the code, etc. so I was thinking of making a few tweaks to the PCB to make it better for a tilt-switch and modifying my program to generate code so that you could shake it back and forth to see one steady image. I know a lot of people want this and I know Ladyada is busy, but I think if there's enough demand and I can get a design working, we may be able to convince her to sell it as a MiniPOV4. I just think that this would be a nice improvement to the design.

Here's the layout that I've been toying around with:
Image
Fixes:
-Oriented the tilt switch horizontally
-Allowed for space for tilt switch
-Removed unnecessary + terminal for tilt switch
-Cleaned up layout by grouping LED resistors and serial resistors/diodes

Proposed changes:
-Use diffused LEDs (offer different colors)
-Use this tilt switch
-Make two more holes in circuit board for screwing the battery case on (the foam tape just doesn't cut it)

Does this look Ok? Can anyone see any glaring errors? Anything that would make this not work? I think I'll send this off to either batchpcb or barebones to make sure it works because I've only got 2"x2" single-sided PCBs...

magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am

Re: Updating the MiniPOV design

Post by magician13134 »

Alright, I got some tilt-switches in the mail today (for those of you out there mailing components, please PLEASE never just throw them in a regular envelope! It's a wonder they didn't fall out where it got torn). Anyway, I soldered one in and tried to get some code working on it. I set lfuse to 0xe4, burned "test_sensor.hex" and it worked fine, so I added that code to "minipov.hex" and tried it out, but unfortunately, it's a no-go. The message was just as hard to read as before. Can anyone see anything obvious in this code that's wrong?

Code: Select all

#include <avr/io.h>      // this contains all the IO port definitions
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <util/delay.h>

void delay_ms( uint16_t milliseconds)
{
   for( ; milliseconds > 0; milliseconds--)
   {
      _delay_ms( 1);
   }
} 

#define TIMER1_PRESCALE_1 1
#define TIMER1_PRESCALE_8 2
#define TIMER1_PRESCALE_64 3
#define TIMER1_PRESCALE_256 4
#define TIMER1_PRESCALE_1024 5

// We use these macros because binary constants arent always supported. ugh.
#define HEX__(n) 0x##n##UL
#define B8__(x) ((x&0x0000000FLU)?1:0)  \
               +((x&0x000000F0LU)?2:0)  \
               +((x&0x00000F00LU)?4:0)  \
               +((x&0x0000F000LU)?8:0)  \
               +((x&0x000F0000LU)?16:0) \
               +((x&0x00F00000LU)?32:0) \
               +((x&0x0F000000LU)?64:0) \
               +((x&0xF0000000LU)?128:0)
#define B8(d) ((unsigned char)B8__(HEX__(d)))

const static int image[] = {
  B8(00111100),
  B8(00000100),
  B8(00111000),
  B8(00000100),
  B8(00111000),
  B8(00000000),
  B8(00111101),
  B8(00000000),
  B8(00111100),
  B8(00000100),
  B8(00000100),
  B8(00111000),
  B8(00000000),
  B8(00111101),
  B8(00000000),
  B8(11111100),
  B8(00100100),
  B8(00100100),
  B8(00011000),
  B8(00000000),
  B8(00011000),
  B8(00100100),
  B8(00100100),
  B8(00011000),
  B8(00000000),
  B8(00000100),
  B8(00111000),
  B8(00010000),
  B8(00001100),
  B8(00000000),
  B8(00101111),
  B8(00000000),
  B8(00000000),
  B8(00000000),
  B8(00000000),
  B8(00000000),
  B8(00000000),
};

#define NUM_ELEM(x) (sizeof (x) / sizeof (*(x)))
int imagesize = NUM_ELEM(image);

// this function is called when timer1 compare matches OCR1A
uint8_t j = 0;
SIGNAL( SIG_TIMER1_COMPA ) {
	if (PIND & 0x4) {
		if (j >= imagesize) 
			j = 0;

		PORTB = image[j];
 
		j++;
	}else{
		if (j <= 0) 
			j = imagesize;
		
		PORTB = image[j];
		
		j--;
	}
}

int main(void) {

  DDRB = 0xFF;       // set all 8 pins on port B to outputs
	
  DDRD = 0xFB;        // one input on pin D2
  PORTD = 0x04;       // turn on pullup on pin D2

  /*
    the frequency of the interrupt overflow is determined by the 
    prescaler and overflow value.
    freq = clock_frequency / ( 2 * prescaler * overflow_val)
    where prescaler can be 1, 8, 64, 256, or 1024
    clock_freq is 8MHz
    and overflow_val is 16bit

    the overflow value is placed in OCR1A, the prescale is set in TCCR1B
    so for example:
    A good POV frequency is around 400Hz
    desired freq = 400Hz
    clock freq = 8MHz
    8MHz / (400Hz * 2) = 10000
    since 10000 is less than 655536 (largest 16 bit number)
    OCR1A = 10000 and the prescale is 1
  */

  TCCR1B = (1 << WGM12) | TIMER1_PRESCALE_1;
  OCR1A = (uint16_t)10000;

  TIMSK |= 1 << OCIE1A;   // Output Compare Interrupt Enable (timer 1, OCR1A) 

  sei();                 // Set Enable Interrupts

  while (1);
}

sparr
 
Posts: 196
Joined: Tue Nov 04, 2008 5:21 pm

Re: Updating the MiniPOV design

Post by sparr »

Removing the sensor positive contact seems counterproductive. It saves you a single trace and contact, but now you cannot use any but the simplest of sensors. There are many sensor options (binary accelerometers, etc) that require Vcc to operate.

Also, I had no problem using a mechanical (ball in a tube) tilt sensor on the existing MiniPOV3 design, and there are already two firmwares available here on the forum that use that sort of sensor.

magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am

Re: Updating the MiniPOV design

Post by magician13134 »

Alright, I'll look into those firmwares, and I didn't know there were other sensors that people used.

Locked
Please be positive and constructive with your questions and comments.

Return to “MiniPOV”