LED POV Clock using ATMEGA 164P

Go To Last Post
27 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi all, this is my first post to the forum. I am an electrical and electronoic engineering student in my final year of study. 

 

I have proposed the idea to make an LED POV Clock for my final year project, with some extras. Along with my extras the module director has added in his own extras which is proving even more difficult.

 

First of I didn't know how hard this project would before til I had proposed it.

 

I have searched around the internet loads, but haven't found anything to my spec. Also on top of that, the AVR and electronics taught to us, isn't to this level.

 

Right so the specs

 

POV Clock

 

Analogue and Digital Display (switchable)

Text Display

Alarm Function

Power saving (switch on via motion detection)

 

This is the overall design I want to go for, with the micro chip and RTC around the centre to try to keep it as balanced as possible.

 

To get power to the PCB i will use a slip ring.

 

Not entirely sure on the RPM i would need, from what I can see it should be around 600-1000rpm.

 

The character matrix will be 10x6 

 

Now, that image above shows 20 LEDS, can the 164p support 20 leds, each coded separately?

 

How do i code the RTC?

 

and how do i even get started with the schematic for my clock.

 

This is what I have so far which is NOT a lot i appreciate that.

I will be powering the clock via USB so 5v 2.1a 

I will be using ultra bright LEDs so they are more efficient.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have no means of limiting the current to the leds - refer to the datasheet of the leds to determine what current should flow then apply ohms law. Then refer to the Atmel datasheet and find out what current the port pins can source and what the total current can be sourced. This may force you to redesign your circuit.

 

Personally, I would not even consider the RTC at this point - you have yet to light a led yet. How are you going to measure the rpm? I gather you need to sync the led update with the rotational speed. I'm surprised that there is not something close to what you want to achieve on the interwebs. Have you considered using devices like the ws2812 rgb leds with drivers? - this cleanly works around the current issue with the AVR as these leds have their own drivers and give you a 1bit digital interface.

Another thing to consider is your power supply. Since you're going through slip rings, this may cause some noise on the power. The AVR will not like this. You will need some bulk capacitance and maybe a voltage regulator.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Have you considered using devices like the ws2812 rgb leds with drivers?
This might work, but it has its own challenges.

 

With the 800 kHz data clock, 16 twenty-four-bit LEDs will take 480 µS to update.  At the OP's 600 rpm (which is only 10 updates per second... the display will flicker) that's 100 ms per revolution, so the radial 'pixels' will be 1.728 degrees thick, for about 208 radial display lines over 360 degrees.  And that will leave zero cpu cycles to do anything else, so it's an upper limit.

 

At 1200 rpm (for 20 updates per second), that limit drops to 104 radial display lines.

 

Complicating this will be the fact that the WS2812B uses PWM on each of its R, G, and B elements.  I've not measured the PWM frequency, but I expect it will be less than 2 kHz, which is the rate at which radial display lines will be flying by, and I'd guess this would result in some pretty strange strobe-like beat artefacts.  I'd also expect a spiral shear effect as each LED is updated 30 µs after the previous one.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Welcome to the Forum.

 

Cool project, very doable, but it has several learning curves associated with it, and it will take some time and persistence.

 

For me at least, a big part of the project would be getting the mechanical parts built.

 

Mounting a motor and getting a well balanced spinning platform, with slip rings, will take some work.

 

I saw one POV clock on the web that used an old HDD as the basis for the device, I thought that was rather clever.

 

First question is what projects have you completed so far in class?  And with which micros?

The next important question is how long do you have to complete the project?

 

There are many ways to design this project, and others may present differing approaches, but I have a few thoughts to share.

 

For a stable display one needs a pretty stable rotational speed, and a way to synchronize your display timing to the position of the platter.

One could use a pretty heavy duty motor with some sort of speed control and just let it run, open loop, not controlling its speed.

The platter would detect its own reference point, and re-synch itself on each revolution.

Theoretically, the motor speed isn't likely to change to much within the time of one revolution.

An LED on the base, shinning up at the back side of the platter, hitting a photo diode on the platter, would give the platter a reference signal.

This could be done magnetically, also.

 

Or flip it around, and have one uC running the motor and providing the motor with its own, feedback loop controlled, controlled speed.

This would give you the stable platform speed needed to prevent the display from "wandering".

This, of course, would be a sub-project on its own, and that is why the time frame for the project is an issue.

Not much time?  Go the open loop motor speed, and accept a little wandering in the display.

 

If one of your class lessons was on motor speed control, then this part of the project is something you are already familiar with.

 

The next "easy" part to think about and then put on the back burner is the switch on via motion detection?

Again, there are several ways to detect the presence of a human, but the easiest has to be a $1 USD HC-SR04 ultrasound module.  (That's an eBay price, $1 to $5 USD per module!)  You simple "ping" it, and measure the time for an echo to come back.  Use a threshold to "detect" someone nearby.  Of course there are several Threads from individuals who have needed help in making this sensor work. 

Anyway, that's how I would tackle the motion sensing for your project, EASY!

That, however, is not the core of the project, so I'd order the sensor, and then put that part of the project on the back burner while you work on the main part, the POV.

In the end, if you run out of time, and don't have the motion sensing done/working, you can at least show that you have a process in mind to complete that requirement, and hopefully you don't lose many points.  You obviously lose lots of points if the POV part of a POV project isn't done and working on time!

 

You will need the ability to flash LEDs on and off, and that hopefully is something you did in class.  As already noted, you need a resistor in series with each LED to limit its current.  Look in the data sheet, near the back, for the electrical characteristics and you will find a section telling how much current each pin can source, how much current each port can source, and how much current the V+ and Ground pins can sink and source.

 

You would like your design to be in spec so that even with all of the LEDs on, at the same time, the circuit is in spec.

 

You might consider adding a Real Time Clock chip to make time keeping easy.  You can certainly do it all on the uC, but with power outages it is easier to have the RTC chip there.  Either way you will need a couple of push button switches to set the time and the alarm.  You can think about how you want to turn the alarm off, another push button switch, shine a flashlight at the device, wave your hand in front of the ultrasonic sensor, etc.

 

The point is, you will need to start counting up I/O pins and seeing just what the project will need.

 

One item that is worth mentioning is that it is generally wise to start with a large micro, so that you won't run out of memory, variable space, or timers, etc., 1/2 way through the project. 

 

The M164P is pin compatible with the 324P, so I'd start with the larger one.  Even so, depending upon how much the uC is handling, you might find yourself pretty tight on the pin count.  One can double up on the functions / pin, but you probably don't want to add any extra complexities to the project.

 

A big part of this project is learning about using interrupts, and hopefully that was also part of your classes.  Either way, you need to start learning about them, or brush up on them.  Just flashing an LED via an interrupt would be a good start.

 

At some point you will have to decide if you are going to get a PC board made, or hand wire it all on a protoboard of sorts.  Either is possible, but yet another learning curve for laying out a PCB if you go that route.

 

Feel free to post your design schematic, and PCB layout if you go that route.  You will get lots of suggestions, and hopefully avoid making a serious blunders.

 

Cool project!

 

JC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ha! 'Will take some time and persistence'!

Joey - you definitely poked holes in my suggestion!

Last Edited: Thu. Feb 12, 2015 - 06:58 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
you definitely poked holes in my suggestion!
On the contrary, your suggestion got me thinking.  I think the only difficulty would be dealing with the PWM internal to the WS2818.  The answer there may simply be 'don't use it'.  It would still give you 8 separate colours, commanding R, G, and B as either full on or full off.

 

The other issues of resolution v.s. frame rate, and spiral shear, can be reduced if the LEDS are updated more than one at a time.  It should be fairly straightforward to update 8 (or all 16) at once by pre-processing the RGB data into the final bitstreams.  Using 8 data lines to drive 8 pairs of LEDs would increase resolution and/or frame rate by a factor of 8, and/or reduce spiral shear, not counting a bit of overhead for the preprocessing.

 

The pay-off starts to dwindle however.  A single data line has now become 8 data lines

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sohal89 wrote:
I have searched around the internet loads, but haven't found anything to my spec.

You shouldn't expect the internet to just give you a complete finished project! Just handing-in a verbatim copy of someone else's work is not going to get you very many marks!

 

Rather, you should be looking at how others have solved the various issues, and applying the techniques in your own design.

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would use PIR rather than ultrasonics. No sense in starting the thing up if a zombie walks by.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:

I would use PIR rather than ultrasonics. No sense in starting the thing up if a zombie walks by.

Sigh.

 

What if a zombie walked by wanting to know the time? I didn't expect such blatant vilification of zombies on avrfreaks.

 

- S

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, sorry about that, but seriously, you can get small, fairly reliable PIR sensors that I would favour over ultrasonics.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, I've opted for using shift register as I don't think the 324 will provide enough current to power all 32 LEDs. 

I would like to add in an IR receiver to work with a remote which I will design also which will be using an AT TINY (undecided yet), would a standard IR LED work for this? And also would I connect it to any port on the 324 (so long as the AVR code is designed to read/write to it.

 

I also need to add in the motion sensor. What would be the best sensor to use for this? It needs to be fairly small ish. PCB will be 8" by 2" (+ or - 0.5")

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also if anyone has any ideas as to how to get power to the PCB while it is spinning, please help me out. I am thinking of modifying a PC fan and adding in some kind of brushed mechanics.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you only need 7 leds. You can make all letters and numbers in 5x7.  Lets say you want to show 4 characters, numbers or letters, scrolling in an arc at the top of the spinning stick. We know it needs to spin about 70 times a sec to not flicker. Thats 14ms. Now you need to draw 4 chars x 5 colums, plus 3 colum times between chars in the top third or so of the rotation, so 23 colums in 3ms, or 130usec per column. I'd do it with an arduino and a battery pack as a counter balance. You just need 1 input to test where top or bottom or somelocation is per rev.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I also need to add in the motion sensor. What would be the best sensor to use for this?

 

Did you even bother to read the replies above?

 

JC 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did mate. Your reply in particular.

 

Answer to your first question is quite frankly, we haven't done a whole lot on AVR but we are required to complete a final year project with AVR. I did ask if I could use Arduino as it would be easier but not a whole lot more flexible but I was denied that request by my project supervisor.

 

How long do I have, well as of this week about 6 weeks. 

 

PIR sensor is what I was looking at using, just wondering if there were other means such as LDR? PIR would be the better option though. Also, would that need a separate amplifier to determine distance or can that just be left as the sensor on its own straight into one of the pins on the uController?

 

As you can see from my latest circuit design, I have added in the resistors to limit the current to each LED (100 ohm)

 

 

In order to set the time, alarm and text I will be using a remote (hopefully) with 7 buttons. Which TINY chip can I use for this? 84P?

 

H = cycles through hours in ascending order

M = cycles through minutes in ascending order

 

 

I am still unsure as to which RTC to use and how to wire it in.

As mentioned above, we are just expected to know how to do all of this after doing a few sessions on AVR coding a 7 segment display. So my knowledge is VERY limited.

 

Now, the main issue(s), is obviously the coding and the mechanics.

 

I want to use a slip ring, the only thing is, I need the PCB to be spinning aswell without using an onboard supply. I will be using USB to power it. 2.1a at 5V.

 

So far I have thought of hacking apart a slip ring an modifying it to house a motor 

OR

modify a PC fan

OR

make my own motorized slip ring

 

Option 2 is my preferred method, but if any of you know an easier, better, more reliable way please let me know.

 

AVR coding I will leave until I have fully completed the schematics and PCB design.

 

(hopefully that has answered your question regarding the pcb question)

I am using ISIS to design my schematics and ARES in ISIS for the PCB design. I have to stick to T30 track size because well... because my technician said so. 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, so I've done a bit more research and I have managed to come up with this...

 

I haven't connected the RTC just yet. The question here is, how do I control the individual LEDs from the I2C expanders?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sohal89 wrote:
how do I control the individual LEDs from the I2C expanders?

You study the datasheets for those expanders - they will tell you how you control the IO lines...

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AVcc should be connected directly to Vcc, not through the 100 ohm resistor as you have shown above.

The Vcc and AVcc pins on the uC all need a 0.1 uF cap connected to Ground.

This should be mounted very close to the microcontroller.

 

The other chips should also have 0.1uF caps on their V+ pins, connected to Ground.

Also mounted right next to the chips.

 

JC

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hardware guys go right for the chips on the pc board. Software guys sit down at the editor and start typing in c statements. Couple msgs back I mentioned that you could use 7 leds to paint 5x7 letters and numbers. This would be Real Easy to prototype with an arduino uno. If it worked like a champ, THEN I'd layout the custom board with lots more leds.

 

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

DocJC wrote:

AVcc should be connected directly to Vcc, not through the 100 ohm resistor as you have shown above.

The Vcc and AVcc pins on the uC all need a 0.1 uF cap connected to Ground.

This should be mounted very close to the microcontroller.

 

The other chips should also have 0.1uF caps on their V+ pins, connected to Ground.

Also mounted right next to the chips.

 

JC

 

 

 

Ok thanks, was unsure on both the 100 ohm and 10k. Also, is the 0.1uF or 100n used as a decoupling capacitor?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

bobgardner wrote:

Hardware guys go right for the chips on the pc board. Software guys sit down at the editor and start typing in c statements. Couple msgs back I mentioned that you could use 7 leds to paint 5x7 letters and numbers. This would be Real Easy to prototype with an arduino uno. If it worked like a champ, THEN I'd layout the custom board with lots more leds.

 

 

Hi, unfortunately I don't have the time to do it that way. 

 

My specification from uni is to build it using AVR not an Arduino UNO or Mega =[

 

Initially I did only want 8 LEDs but again, my supervisor said it would be better to go full whack with 16LEDs for the clock 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So a font that is 16 dots hi is probably 11 dots wide. Alternatives to using 8 bit i2c expanders.... regular old 8 bit latch with 8 data bits fom a port and one output to strobe the latchdata line. PlanB might be a 74595 8 bit serial in parallel out shift reg on the spi. A 16mhz avr can clock the spi at 8mhz, so it takes a microsec to clock the byte out. You need to clock out 2 bytes of a column x 11 colums+1 space x 5 chars = 60 colums 70 times a sec. This is 4200 cols per sec, 238usec per col. No prob. The avr can send out a col, go out back for a smoke, come back, do the next col. Rinse and repeat. The whole thing spins on a stick. Battery box counterbalances the small board with the avr and latches/shiftregisters/i2cexpanders.

 

 

Imagecraft compiler user

Last Edited: Sat. Mar 14, 2015 - 12:46 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I need for full file and shematics this project please. Tankyou

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AHMADARAZ wrote:
I need for full file and shematics this project please. Tankyou
If you are asking the original poster "you are out of luck". He has not been here for 5 years. He got tired of waiting for you to ask and left.

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I need for full file and hex file and software and shematics this project please. Tankyou

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Read my post AGAIN!

Ross McKenzie ValuSoft Melbourne Australia

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

here's one for some idea for you...there are many

 

http://www.microsyl.com/index.php/2010/03/18/propeller-clock/#more-29

 

You can modify things to use any AVR

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!