Craft
Craft is a demo running on its own minimalistic demo platform. The demo platform is based on an ATmega88 microcontroller.
Having successfully built a soundchip out of a microcontroller together with my friends in kryo, I wanted to tackle the greater challenge of generating a realtime video signal along with the sound. This is the result:
Download
- lft_craft (Original video clip, Xvid, 89.4 MB)
- lft_craft_capture (Full screen video capture, H.264, 85.5 MB)
- Linus Akesson - Craft (Soundtrack, MP3, 3.3 MB)
- lft_craft_src (Schematics, firmware binaries and source code, 70.5 kB)
Scene reaction
Craft won the Console / Real Wild compo at Breakpoint 2008. I will never forget the overwhelming reaction from the audience!
Here's the Pouët page for Craft.
How does it work?
Just like your average 80's home computer, the entire design is centered around the timing of the video signal.
A typical VGA-based, low-resolution CRT monitor will redraw the screen 60 times per second using an electron beam, which is sweeping across the screen one line at a time. TFT monitors work differently, but the VGA signal is still based on the idea of an electron beam. Timing is crucial: One display line takes 24 μs, and is followed by a 7.75 μs break called the horizontal blanking period. After 480 such lines, there's a longer break (1428.75 μs, equal to 45 full display lines) before it all starts over. Two digital signals are used to synchronize the sender (graphics card, custom demo hardware etc.) and the receiver (monitor). They are called the horizontal sync and the vertical sync signals. It's OK to deviate a bit from the standard timing values as long as you keep the sync signals steady.
The microcontroller is clocked at 20 MHz. If we convert the figures above into clock cycles, we get 480 cycles of visible pixels, 155 cycles of horizontal blanking and 45 full display lines worth of vertical blanking — but during those lines you need to keep generating the horizontal sync pulses. Due to rouding errors, we get a frame rate of 59.99 Hz, but that is well within the tolerance range of a computer monitor.
Music
Sound is generated during the horizontal blanking periods. That gives a sample rate of 31.496 kHz. Of course, only the really timing critical part (waveform generation) is performed during the horizontal blanking. Melody, rhythm, amplitude envelopes, arpeggios etc. are handled by a playroutine which gets called once for every video frame, during vertical blanking.
There are four sound channels in total, each with its own fixed waveform. The waveforms are 4-bit triangle, 50% pulse, 75% pulse and white noise. The noise is generated by means of a 15-bit shift register. The volume of each channel can be individually controlled, except for the triangle channel, which is always playing at full volume. This minimalistic softsynth was of course inspired by the NES sound chip.
Video
Apart from the sync signals mentioned above, a VGA signal contains three analog voltage lines — red, green and blue — that vary between ground and 0.7 V during the visible parts of the video frame. As you can see in the schematic below, I perform a two-bit digital-to-analog conversion for each of these signals, using R-2R resistor ladders. That way, the software can change the current colour in a single clock cycle using the out PORTC,register instruction.
In addition to this, I've hooked up a couple of diodes and a PNP transistor in such a way, that when the MOSI pin is low while the OC2B pin is high, the three color signals will be pulled to a high voltage, corresponding to white. This is used to generate high resolution scroll text: The MOSI pin is connected to a shift register internally in the AVR (it is typically used for serial data transmission), and this shift register can be programmed to emit a sequence of 8 bits with a single instruction, thus offloading the CPU. Smooth scrolling is then implemented by inserting variable delays before and after each display line, but that alone is not enough, because characters would appear and disappear suddenly at the edges of the screen. So additionally, the output comparator connected to timer 2 in the chip is set up to create a visibility window using the OC2B pin.
Schematics
This is how it all fits together, hardware-wise. If you are interested in the physical layout used on the breadboard, you can find it along with firmware and source code near the top of the page.
The variable 1K resistor can be used to adjust the brightness of the scroll texts.
.---[ 1K ]-+------- E (PNP) C -------------------+---+---. | /|\ | B _|_ _|_ _|_ | `----' | \ / \ / \ / | | --- --- --- | .---__---. | | | | (to programmer) --- RESET | | PC5 ----[ 442 ]-----------+---+---|---|--- Red | | | | .-[ 220 ]-' | | (n.c.) PD0 | | PC4 ----[ 442 ]-+-[ 442 ]--- GND | | | | | | | | .----------+-[ 2K ]----- PD1 | | PC3 ----[ 442 ]-----------+-------+---|--- Green | .-[ 1K ]-' | | | | .-[ 220 ]-' | | `--+-------[ 2K ]----- PD2 | | PC2 ----[ 442 ]-+-[ 442 ]--- GND | | `-[ 2K ]-- GND | | | | | | `- OC2B | | PC1 ----[ 442 ]-----------+-----------+--- Blue `---[ 1K ]-. | | | .-[ 220 ]-' .--------+-[ 2K ]----- PD4 | | PC0 ----[ 442 ]-+-[ 442 ]--- GND | | | | | VCC | | GND `-[ 1K ]-. | | | | | GND | | AREF (n.c.) | | 22pF | | | | GND -||--+- XTAL1 | | AVCC (n.c.) | | 20 MHz [ ] | | | | GND -||--+- XTAL2 | | SCK -------------- (to programmer) `-[ 1K ]-. 22pF | | | .--------+-[ 2K ]----- PD5 | | MISO ------------- (to programmer) `-[ 1K ]-. | | | .--------+-[ 2K ]----- PD6 | | MOSI ---------+--- (to programmer) + `-[ 1K ]-. | | ----)|------------+-[ 2K ]----- PD7 | | OC1B ------------------------------------- HSync Audio 10uF | | --------- GND (n.c.) PB0 | | PB1 -------------------------------------- VSync `--------'
If you want to learn more, I suggest you dive into the source code, starting with boot.S, mainloop.S and asm.S. The most interesting part is probably the cycle-accurate code in asm.S.
Posted Thursday 27-Mar-2008 20:33
Discuss this page
Disclaimer: I am not responsible for what people (other than myself) write in the forums. Please report any abuse, such as insults, slander, spam and illegal material, and I will take appropriate actions. Don't feed the trolls.
Jag tar inget ansvar för det som skrivs i forumet, förutom mina egna inlägg. Vänligen rapportera alla inlägg som bryter mot reglerna, så ska jag se vad jag kan göra. Som regelbrott räknas till exempel förolämpningar, förtal, spam och olagligt material. Mata inte trålarna.
Fri 28-Mar-2008 19:31
Sat 29-Mar-2008 05:23
Hey, that's a *really* neat trick--makes me wonder what I could use that for. :-)
--Phil. (http://code.rancidbacon.com/)
Sun 30-Mar-2008 10:29
Mon 31-Mar-2008 10:46
Mon 31-Mar-2008 13:03
Mon 31-Mar-2008 15:01
A job really well done. :-D
Mon 31-Mar-2008 16:13
Jeff
warrantyvoidifremoved.com
Mon 31-Mar-2008 16:41
Mon 31-Mar-2008 21:23
Thumbs Up !!!
Keep going, it's really awesome !!!!
Mon 31-Mar-2008 22:18
Tue 1-Apr-2008 14:38
Would using 2 or 3 chips like this produce even more impressive results?
I notice there is some horizontal jitter in the lava field section, between 1:42 and 2:02.
I guess you are running short on the time needed to do the calculations accurately.
Tue 1-Apr-2008 21:28
Thu 10-Apr-2008 22:44
autoscatto
Wed 16-Apr-2008 08:51
Thanks for your good work!!! (and excuse my bad english)
Linus Åkesson
Wed 16-Apr-2008 16:39
Autoscatto wrote:
Hola! I'm working (for now copying =]) on your project but i have problems... What kind of diode do you use in this board?Thanks for your good work!!! (and excuse my bad english)
Glad you like it! =) I'm using 1N4148 diodes, but anything with a forward drop somewhere around 0.7 V should work.
Wed 23-Apr-2008 08:46
-- Yann Vernier / LoneTech
Wed 30-Apr-2008 06:24
Thu 1-May-2008 07:45
arun -
India
Linus Åkesson
Thu 1-May-2008 12:21
arun -
India
If you want to, feel free to draw the schematic using such a program, and I'll put it on the page.
Thu 1-May-2008 16:19
Thu 1-May-2008 23:54
I must say this is a very good demo. Great work on the hardware too !
Linus Åkesson
Fri 2-May-2008 09:46
I must say this is a very good demo. Great work on the hardware too !
Yeah, I've already got it bookmarked. =) Some day I'll probably attempt something similar. The tradeoff between VGA and composite is of course that the VGA signal has a higher pixel clock, but in the composite signal you've got to modulate the colour signals. But when one tries to build something generic, such as your console, one needs external ram, and then it's not such a big deal to add further external components.
Sun 4-May-2008 21:48
Best Regards
George2002 from Poland
Wed 7-May-2008 16:06
Will it run on ATMEGA8 overclocked to 20MHz?
Any hardware/registers specifed only for ATMEGA88 are used there?
Mon 16-Jun-2008 18:32
Eddy-B wrote:
I've been working on something simular for a few months (on and off, when i got the time) but i have not yet taken the time to create a full demo. (see www.electronicspit.com)I must say this is a very good demo. Great work on the hardware too !
lft wrote:
Yeah, I've already got it bookmarked. =) Some day I'll probably attempt something similar. The tradeoff between VGA and composite is of course that the VGA signal has a higher pixel clock, but in the composite signal you've got to modulate the colour signals. But when one tries to build something generic, such as your console, one needs external ram, and then it's not such a big deal to add further external components.It will still have a few external 8pin chips (i use a Tiny13 as my keyboard controller -heh! compare THAT to the standard 40-pin controller you find in XT's and AT's), and 1 external EEPROM for storing the BASIC program. The prototype PCB has already been desinged and should be 45x45mm only, but it requires SMD.
Cheers!
Eddy-B
Thu 19-Jun-2008 20:56
you rule, dude
8 bits is enough!
Graham Cole
Fri 27-Jun-2008 20:23
I'd be interested to see what you can do with a Parallax Propeller 32 Bit 8 Cores 32K RAM MCU :-)
Coley
Tue 15-Jul-2008 05:32
Tue 15-Jul-2008 23:46
Great demo!
Tue 22-Jul-2008 11:03
Congratulations for your great work :)
Wed 23-Jul-2008 09:06
Nice work!
-- George Laskowsky Ziguilinsky
Wed 23-Jul-2008 09:44
Wed 23-Jul-2008 11:03
I feel 20 year younger now :)
Tue 29-Jul-2008 06:04
I was doing something similar, but I've only generated VGA signal and no sound... and my scheme involves two memory chips (page switching), a CPLD to control sync pulses and memory, and a PIC to write data into the memory.
Anyway, props to you for doing this all in software on one chip!
TSM
Wed 30-Jul-2008 14:53
After this, build your own OS.
Then automations...
oash82@yahoo.com
Thu 31-Jul-2008 09:08
I was wondering what software do u use to draw the stripboard layout ?
Thanks
Fri 1-Aug-2008 12:29
Fri 1-Aug-2008 12:45
Fri 1-Aug-2008 12:52
Fri 1-Aug-2008 14:00
Fri 1-Aug-2008 16:03
Fri 1-Aug-2008 23:26
Sat 2-Aug-2008 03:03
AtomicZombie
Sat 2-Aug-2008 05:19
Sat 2-Aug-2008 10:18
http://www.bramsonderdelen.nl/vga_gen_m8.png
or as eagle sch:
http://www.bramsonderdelen.nl/vga_gen_m8.sch
contact me:
bram at atasco dot nl
what kind of transistor did you use?
Sat 2-Aug-2008 11:04
Sat 2-Aug-2008 17:27
Sat 2-Aug-2008 19:14
Respect!
Mon 4-Aug-2008 08:40
Man får en riktig resa tillbaka till den tid då dataspelen var som roligast och även oskyldigast. Jag måste säga att jag är mycket imponerad av det du gjort, det är alltid svårare att ha få resurser och utnyttja dessa till 100% än att ha den senaste tekniken och bara utnyttja delar av den.
Respekt från 40-årig gammal räv!
Henrik
Mon 4-Aug-2008 10:32
Linus Åkesson
Tue 5-Aug-2008 05:41
metal wrote:
Hi,I was wondering what software do u use to draw the stripboard layout ?
Thanks
Hi! Those are written in a text editor, in the PostScript language. Have a look in the .eps file and you'll see what I mean.
Tue 5-Aug-2008 20:19
Thu 7-Aug-2008 11:10
I would congratulate you, but there are no words to describe how amazing that was.
Sat 9-Aug-2008 00:24
Tue 12-Aug-2008 01:59
I have this half baked idea of having a challenge where you take a standard pc keyboard and video connector and add $20 worth of parts to make the best computer you can. (you can use volume pricing for your price calculations though because the idea is to imagine if you made thousands of them)
Wed 27-Aug-2008 17:10
many, many kudos to you.
Sat 30-Aug-2008 21:05
Mon 1-Sep-2008 06:11
Linus Åkesson
Tue 2-Sep-2008 05:50
That would be the AVR port of the GNU toolchain. During early development I used C routines (compiled with avr-gcc) along with the assembly code. Have a look in the makefile for all the details.
Fri 5-Sep-2008 11:36
I'm very much impressed by your work! I would like to ask a question:
Since you obviously have the knowhow to produce graphics and the VGA signals at the same time, would it be possible to create some kind of simple vga-driver for the MEGA88 in a way that you can set some graphic elements on the screen using a I²C or RS232 interface?
What I would like to see is a lib for the MEGA8. We just flash it and can do the following for example:
- setPixel(x,y,color)
- setCircle(x,y,radius, color, bfill)
- setText(x,y,cString, color, ...)
- other handy stuff
I know that communication between µC use a lot of time, but there is no need to have an ultra steady vga signal using a TFT? So we could transfer some instructions and the MEGA8 would display the data on the VGA-Panel. A couple of FPS per second would be enough.
Would that be possible?
Fri 5-Sep-2008 17:28
-> http://belogic.com/uzebox/
Linus Åkesson
Sat 6-Sep-2008 12:24
What I would like to see is a lib for the MEGA8. We just flash it and can do the following for example:
- setPixel(x,y,color)
- setCircle(x,y,radius, color, bfill)
- setText(x,y,cString, color, ...)
- other handy stuff
Hi! The main problem with this approach is that the chip would have to keep track of a frame buffer. 1 kB of RAM is not a lot. Even if we opt for a simple black and white bitmap, there would only be room for 128 x 64 pixels. One alternative would be to use a tiled display, but without external RAM it would still be very limited.
Once we start using external RAM, we can do lots of things, and that area has been explored by others in several projects.
Sat 6-Sep-2008 15:56
lft wrote:
What I would like to see is a lib for the MEGA8. We just flash it and can do the following for example:
- setPixel(x,y,color)
- setCircle(x,y,radius, color, bfill)
- setText(x,y,cString, color, ...)
- other handy stuff
Hi! The main problem with this approach is that the chip would have to keep track of a frame buffer. 1 kB of RAM is not a lot. Even if we opt for a simple black and white bitmap, there would only be room for 128 x 64 pixels. One alternative would be to use a tiled display, but without external RAM it would still be very limited.
Once we start using external RAM, we can do lots of things, and that area has been explored by others in several projects.
If the problem with the above is just the 1K RAM, would a larger chip with, say 4K RAM, be enough to do some basic text and graphics? Thank you for your participation.
Sat 6-Sep-2008 16:14
Sat 6-Sep-2008 17:43
If you want to set a pixel you check if the pixel should be painted by searching some kind of ObjectPaintInstruction-stack or something.
I have to add that this approach would loose speed the more objects are to be displayed.... hmmm... maybe a dedicated VGA driver chip would be the easier choice ;)
Fri 19-Sep-2008 13:40
Full marks!
Joey
Fri 19-Sep-2008 16:25
Sun 21-Sep-2008 19:19
Mon 22-Sep-2008 01:20
Mon 22-Sep-2008 11:59
Linus Åkesson
Fri 26-Sep-2008 16:18
It's for adjusting the intensity of the white high-res overlay used for text, so the text won't bleed (too high) or turn grey (too low). Different transistors have different hFE factors, which also vary with temperature, so it's convenient to be able to fine tune the system after it has been assembled.
Tue 30-Sep-2008 21:04
Thu 9-Oct-2008 05:35
Now get an ATmega1284p (16K RAM) clocked at 20 MHz and do some REALLY fancy stuff! :-)
klaxon44
Thu 9-Oct-2008 05:45
Now get an ATmega1284p (16K RAM) clocked at 20 MHz and do some REALLY fancy stuff! :-)
klaxon44
Tue 28-Oct-2008 16:36
Fri 7-Nov-2008 03:47
I saw this on http://www.demoscene.tv
It reminded me so much of my commodore c=64 pure genius!!!!!
Add me on http://www.myspace.com/stuckinfremont510 is my personal site, I've allways loved the demoscene, I've been a fan since I was six years old, all of the demoscene coders are Brilliant Minds that creative abilities and talents cannot be measured for you do this out of the love of the hobby in itself, which no engineer out of profession could compare.
Tue 25-Nov-2008 21:21
i've just finished to make a little game for 2 players for the Atmel ATtiny13 connected to a TV (BAS signal generation) so i can imagine what you've programed.
Craft is really fantastic.
Fri 12-Dec-2008 15:26
Hur lång tid tog det att implementera?
Återigen riktigt snyggt!
Sun 4-Jan-2009 15:53
I really loved this piece of Art when I saw it first, and I'm still in love. Being an Electrical Engineer I smile like hell when I see this demo. :))
Only one bug report:
This should be 31496 Hz, or 31.496 kHz I think:
""Sound is generated during the horizontal blanking periods. That gives a sample rate of 31496 kHz.""
Cheers....
NTAmi
Linus Åkesson
Thu 8-Jan-2009 19:13
This should be 31496 Hz, or 31.496 kHz I think
Well spotted! I've fixed it now. Thanks!
Wed 14-Jan-2009 15:41
Best Regards
Ruben Täufer
Germany
Wed 14-Jan-2009 22:30
How can it be decompressed?
Any help would be appreciated.
Thu 15-Jan-2009 23:47
How can it be decompressed?
Any help would be appreciated.
Download winRAR or 7-zip =)
Tue 24-Feb-2009 01:17
Linus Åkesson
Mon 2-Mar-2009 07:31
Yeah, actually I think there's something strange going on, because I realize I haven't connected the AVcc pin, which powers port C according to the datasheet. So presumably port C is severely current limited. When you calculate signal levels, you have to take into account the input impedance of the VGA monitor (75 Ohm), but that still gives you a signal range from ground to 1.27 V, which is clearly out of spec. The proper theoretical value for R would be 460 Ohm. Anyway, I learned the hard way in another project: Always connect AVcc!
Thu 12-Mar-2009 06:10
Sat 28-Mar-2009 22:52
Fri 3-Apr-2009 08:14
How to force it to display data from UART (or other interface).
Anyway, awsome work. I'm highly impressed.
I apologize for my English.
Wed 8-Apr-2009 11:23
It kicks ass!
Thu 9-Apr-2009 01:32
I have some questions. This is really one of the most amazing things i have seen, and since you have uploaded the source and schematics i wanted to build my own copy of your demo board to see if it actually works. (I REALLY want to see it with my own eyes and show it to my friends)
So,
I have an atmega168 lying around, which almost is identical to atmega88, but with more flash. My board is ready and built according to your ASCII description, but I can't make it work for some reason. Im quite new to microcontrollers and im not familiar enough with assembler to understand most of your code (I have tried for hours, really). Linux is my main OS and i have avr-gcc, avrdude, the build-essential metapackage and so on installed, so compiling your sources went without problems. The hex-file is uploaded and the fuses are set as you described. But as mentioned, it does not work.. there is no signal on any pin.
I think this is because the source is unchanged, and written for atmega88, so there are most likely some things that need to be changed in order to run it on atmega168, but i dont even know where to start. Usually i use eclipse with the avr plugin, so i dont really know how most things actually work. Here is a comparision between atmega48, 88 and 168: http://www.atmel.com/dyn/resources/prod_documents/doc2554.pdf
Would you pleeease help me getting started, i really want to make this work. I will upload my eagle schematics and board layout once im sure it works, together with the atmega168 hex file in case someone is interested.
Wed 22-Apr-2009 07:41
Thu 23-Apr-2009 01:13
lft wrote:
arun -
India
If you want to, feel free to draw the schematic using such a program, and I'll put it on the page.
I will take this up.
Ill draw it in eagle
Thu 23-Apr-2009 03:16
lft wrote:
arun -
India
If you want to, feel free to draw the schematic using such a program, and I'll put it on the page.
I will take this up.
Ill draw it in eagle
Finished!
I replaced the pnp transistor with a P-Mosfet
I can Make the PCBS for these, but they will cost about $40-$60 a board fully assembled.
I used axle resistors and diodes in the schematic
Here is the schematic: http://dump.no/files/de4e5c2db4de/craft-sch.7z
In it is a High Contrast and Low Contrast Image of the Schematic, Also an Eagle CAD schematic file.
Eagle CAD is Freeware, many people use it: http://www.cadsoft.de/
Enjoy :3
Thu 23-Apr-2009 03:24
I have some questions. This is really one of the most amazing things i have seen, and since you have uploaded the source and schematics i wanted to build my own copy of your demo board to see if it actually works. (I REALLY want to see it with my own eyes and show it to my friends)
So,
I have an atmega168 lying around, which almost is identical to atmega88, but with more flash. My board is ready and built according to your ASCII description, but I can't make it work for some reason. Im quite new to microcontrollers and im not familiar enough with assembler to understand most of your code (I have tried for hours, really). Linux is my main OS and i have avr-gcc, avrdude, the build-essential metapackage and so on installed, so compiling your sources went without problems. The hex-file is uploaded and the fuses are set as you described. But as mentioned, it does not work.. there is no signal on any pin.
I think this is because the source is unchanged, and written for atmega88, so there are most likely some things that need to be changed in order to run it on atmega168, but i dont even know where to start. Usually i use eclipse with the avr plugin, so i dont really know how most things actually work. Here is a comparision between atmega48, 88 and 168: http://www.atmel.com/dyn/resources/prod_documents/doc2554.pdf
Would you pleeease help me getting started, i really want to make this work. I will upload my eagle schematics and board layout once im sure it works, together with the atmega168 hex file in case someone is interested.
My guess is the registries for the timer interrupts are different on the 88 then the 168.
You should see some signals on the pins tough.
Read the atmeag168 manual and the atmega88 manual
Look at the registries on the chips
Compare them, to what he is setting in code, make changes...
here is my email: (godberg[at]gmail{Dot}com)
I am also the one who posted the eagle schematic...
I'll help you out.
Mon 4-May-2009 00:31
I have some questions. This is really one of the most amazing things i have seen, and since you have uploaded the source and schematics i wanted to build my own copy of your demo board to see if it actually works. (I REALLY want to see it with my own eyes and show it to my friends)
So,
I have an atmega168 lying around, which almost is identical to atmega88, but with more flash. My board is ready and built according to your ASCII description, but I can't make it work for some reason. Im quite new to microcontrollers and im not familiar enough with assembler to understand most of your code (I have tried for hours, really). Linux is my main OS and i have avr-gcc, avrdude, the build-essential metapackage and so on installed, so compiling your sources went without problems. The hex-file is uploaded and the fuses are set as you described. But as mentioned, it does not work.. there is no signal on any pin.
I think this is because the source is unchanged, and written for atmega88, so there are most likely some things that need to be changed in order to run it on atmega168, but i dont even know where to start. Usually i use eclipse with the avr plugin, so i dont really know how most things actually work. Here is a comparision between atmega48, 88 and 168: http://www.atmel.com/dyn/resources/prod_documents/doc2554.pdf
Would you pleeease help me getting started, i really want to make this work. I will upload my eagle schematics and board layout once im sure it works, together with the atmega168 hex file in case someone is interested.
My guess is the registries for the timer interrupts are different on the 88 then the 168.
You should see some signals on the pins tough.
Read the atmeag168 manual and the atmega88 manual
Look at the registries on the chips
Compare them, to what he is setting in code, make changes...
here is my email: (godberg[at]gmail{Dot}com)
I am also the one who posted the eagle schematic...
I'll help you out.
Thanks for the reply!
I tried compiling it for the atmega 168 and it did not work. The problem seems to be related to many relative branch instructions. They did not work with 16 kb memory in some places for some reason. I tried simply replacing them with jmp instructions, but that seems to consume too many clock cycles, so the timing was way off after that. The registers used by this project however seemed to be the same on both mcus.
Well, i have replaced the atmega168 with an atmega88, and now it works perfectly!
Another thing i was thinking about is the way the sound is generated. As one 8-bit timer is free it should be possible to generate sound by running the timer in fast pwm with no prescale and simply adjusting the duty cycle by writing to OCRXX for the timer. Then the output from the OCXX pin for the timer could be used to simulate the analog sound value with a 78 kHz frequency with variable duty cycle. Doing this would be easier in software and much easier in hardware as one of the DA-converters is not needed any more, and i think it would give almost the same sound.
Wed 3-Jun-2009 05:04
Just awesome.
I don't have any other words.
Sat 6-Jun-2009 19:08
I am really impressed!
Need to learn some assembler, i think....
Mon 8-Jun-2009 20:53
first, I must say that I'm really in awe, and that reading the craft source code was possibly the most educational AVR experience I've ever had.
However, I've got a problem with getting my own copy to work - basically, the video is there, perfectly stable and all correct, but there's no sound. I've already octuple-checked (is that even a word?) all the connections, resistor values, polarity of the capacitor and so on, and still I've got no clue as to why wouldn't it work. There's a silent "knock" in the speakers when the microcontroller kicks in after reset, some interference from the video signal can be heard (the sound fluctuates with the "waves" in the opening screen and changes completely witch each screen), but absolutely no signs of music - and, most importantly, the "analyzer" screen (the one with a 3D cube and Manderbolt) indeed shows the vertical stripes completely motionless (save for the moment when they slide off to make more space for the cube).
I'm using a new ATmega88, with the fuses programmed correctly (well, the video wouldn't be there otherwise), and the circuit was built on a breadboard.
Any hints?
Tue 9-Jun-2009 21:43
Enleth wrote:
Hello,first, I must say that I'm really in awe, and that reading the craft source code was possibly the most educational AVR experience I've ever had.
However, I've got a problem with getting my own copy to work - basically, the video is there, perfectly stable and all correct, but there's no sound. I've already octuple-checked (is that even a word?) all the connections, resistor values, polarity of the capacitor and so on, and still I've got no clue as to why wouldn't it work. There's a silent "knock" in the speakers when the microcontroller kicks in after reset, some interference from the video signal can be heard (the sound fluctuates with the "waves" in the opening screen and changes completely witch each screen), but absolutely no signs of music - and, most importantly, the "analyzer" screen (the one with a 3D cube and Manderbolt) indeed shows the vertical stripes completely motionless (save for the moment when they slide off to make more space for the cube).
I'm using a new ATmega88, with the fuses programmed correctly (well, the video wouldn't be there otherwise), and the circuit was built on a breadboard.
Any hints?
Hi
I have also rebuilt craft, and it works perfectly for me. I think you forgot to program the eeprom from eeprom.raw. I tried uploading flash.hex only, and i got the same behaviour you described.
Try downloading both flash.hex and eeprom.raw to the avr, and it should work. I'm using AVRDude from the command line, and i noticed i have to upload both files at the same time. If you are using AVRISP mkii with avrdude, try something like
<code>
avrdude -c avrispmkII -P usb -p m88 -e -U flash:w:test.hex -U eeprom:w:eeprom.raw
</code>
I'm not sure the command above is 100% correct, but i think it works.
Good luck!
Fri 12-Jun-2009 16:58
You got it right there - thanks. As always, the problem is both in the most obvious and the most obscure place at the same time.
Now, it works perfectly.
Sat 25-Jul-2009 16:24
Wed 29-Jul-2009 21:54
Mon 7-Sep-2009 12:41
i'm just fooling around with one square wave and a rgb led...
Thu 1-Oct-2009 23:59
I have rebuilt craft for the second time this evening, and i wanted to contribute with something as this project is amazing and i really appreciate the effort of making it open source. I have made a PCB using the open source software KiCad under Linux. Here is a link to the files needed to recreate it (most components are smd, but making this by hand should be easy as the resistors and capacitors are 0805 and the pcb is single-sided):
http://dl.getdropbox.com/u/1026013/Projects/Craft_PCB.zip
Included are the KiCad project files and some other files:
* 3d rendering of the top and bottom of the PCB as jpg.
* The schematic as ps and pdf.
* The copper layer as ps and pdf.
* The copper silkscreen as ps and pdf.
* The component silkscreen as ps and pdf.
The board is 48mm x 55mm.
Hope this helps someone, feel free to use it however you like. I could make the pcb smaller, but i did not have much time as i made everything this afternoon/evening.
Linus, feel free to add these files to the download section and to use the included schematic in the description if you like, as it is a bit easier to read than the ascii one.
Thu 26-Nov-2009 14:21
Linus Åkesson
Thu 26-Nov-2009 15:56
True, but "easier" was not my intention. =)
Ashley Fraser
Wed 9-Dec-2009 15:21
I happened upon this page accidently as I have been spending the entire day trying to find enough documentation to do some VGA stuff and I have to say that I am glad I did, you made my day.
Sun 13-Dec-2009 09:32
Sun 13-Dec-2009 09:37
Tue 15-Dec-2009 11:57
Linus Åkesson
Mon 21-Dec-2009 09:27
There is a known error, namely that AVcc has been left floating in my design. Since AVcc powers port C, this will cause current limiting on the RGB outputs.
However, I haven't had any trouble with the sync levels. Have you verified that there are no cuts or shorts?
Tue 12-Jan-2010 10:27
-Dingo_aus
Tue 19-Jan-2010 01:03
Exceptional work. Well done!
Sun 4-Apr-2010 22:51
One question: I also tried using the MOSI pin to generate a video signal, but after the 8th bit is shifted out, the MOSI line stays high for a short time, before the next byte gets shifted out. How did you solve this?
Markus
Linus Åkesson
Tue 6-Apr-2010 13:47
I decided to live with it. The MOSI trick is used when displaying text, either statically or in the sine scroller. In the font, every character is eight pixels wide, and the extra delay after the eighth bit forms the space between characters. The pin is connected to the video signal in such a way as to make it white when low and transparent when high.
Sun 13-Jun-2010 03:09
Thu 17-Jun-2010 20:14
Linus Åkesson
Tue 22-Jun-2010 17:29
Did you connect AVcc? In the original design, AVcc was left floating (by mistake), and this probably affects the amount of current that can be sourced from PORTC. Otherwise I really don't know.
Fri 25-Jun-2010 11:21
lft wrote:
Did you connect AVcc? In the original design, AVcc was left floating (by mistake), and this probably affects the amount of current that can be sourced from PORTC. Otherwise I really don't know.At first I also connected the AVcc Pin, but then I disconnected it again since I found out that there's something wrong with the colours and I thought it could have something to do with AVcc but disconnecting it didn't change anything.
Anyway I also don't know what's the Problem here but I let you know what's wrong when I get it solved.
Tue 20-Jul-2010 12:25
This is really amazing,
I am into digital electronics as well, therefore it's a mine of information for me.
Thank you for such a great avr project.
Fri 23-Jul-2010 09:08
Hate to admit it, but the only word I can think of: awesome!
Fri 23-Jul-2010 16:48
Mon 9-Aug-2010 12:45
The best I have seen so far video & audio with AVR with such minimal parts and no overclocking...
I'd wait for this to download over 300bps, :P
Sun 24-Oct-2010 03:32
DIY Layout Creator (written in Java -> Free)
http://www.synthdiy.com/show/?id=2489
Lochmaster
http://www.abacom-online.de/html/lochmaster.html
I'm currently testing Lochmaster, and I must say that it's way better than nothing. It is certainly limited but one shouldn't wish a full-featured suite for simple circuit prototyping.
These two taken from this site:
http://www.sphere.ws/blog/?p=139
I hope this links are useful.
- Netshark
Wed 3-Nov-2010 11:17
can i get the correct schematic as i a a begineer to micro controller i am unable to get the schematic which u have did in text format. i read the comments someone has given the schematic in eagle format but unfotunately io didnt found that. so can u or anyone else mail me the schematic
My mail id is azhar.karnalkar@gmail.com
thanks in advance. and a great work man.
Sat 13-Nov-2010 18:39
Just so you know, Craft is now the ringtone of my cellphone and Turbulence is the alarm tone :-)
Tue 7-Dec-2010 04:45
And i am scared when i realize that 'bad' programming a modern processor to do the same thing can probably waste 100 times the same energy. buh...!!!
thank you!
i'm italian so i can't speak/write in good english. eheh bye.
Fri 17-Dec-2010 23:41
And the Soundtrack of Craft is beautiful :)
Wed 29-Dec-2010 10:25
I am addicted to needlework and crafting too....check it out my site http://www.oxima-homemade.com/en.html
Fri 28-Jan-2011 03:16
Sat 29-Jan-2011 21:08
Tue 22-Feb-2011 15:09
Sun 5-Jun-2011 07:01
Tue 12-Jul-2011 11:16
Tue 26-Jul-2011 01:40
-- Yann Vernier / LoneTech
Tue 26-Jul-2011 01:42
lft wrote:
What I would like to see is a lib for the MEGA8. We just flash it and can do the following for example:
- setPixel(x,y,color)
- setCircle(x,y,radius, color, bfill)
- setText(x,y,cString, color, ...)
- other handy stuff
Hi! The main problem with this approach is that the chip would have to keep track of a frame buffer. 1 kB of RAM is not a lot. Even if we opt for a simple black and white bitmap, there would only be room for 128 x 64 pixels. One alternative would be to use a tiled display, but without external RAM it would still be very limited.
Once we start using external RAM, we can do lots of things, and that area has been explored by others in several projects.
Fri 29-Jul-2011 01:45
Sat 31-Dec-2011 10:33
gmail wkp1517@gmail.com. Thank you!!! >_<
Wed 4-Jan-2012 18:28
Thomas
Thu 12-Jan-2012 11:20
Sat 11-Feb-2012 15:07
When did you do electronically?
Sun 12-Feb-2012 12:21
this from 1 microcontroller. I feel tempted to just rebuild this as a standalone hehe
Did ya ever make more demo's on this hardware?
Thomas
Sun 12-Feb-2012 21:35
Tue 13-Mar-2012 12:40
tesla1980 wrote:
Please help me ! Can anyone tell me how to change the c - code to make that the whole program loops itself ? Where i must change the code. I`m absolutely a c-code noop - i have no idea ! PLZ HELP ME !#include <stdio.h>
int main() {
printf("This text will be looped");
main();
}
Wed 21-Mar-2012 22:40
#include <stdio.h>
int main() {
printf("This text will be looped");
main();
}
Uuh, that's a really bad idea..
Mon 9-Apr-2012 21:09
tesla1980 wrote:
Can anyone tell me how to change the c - code to make that the whole program loops itself ? I`m absolutely a c-code noop!There is absolutely no C-code in Craft. It's pure assembly language.
Try having a look at mainloop.S, there's a label called "mainloop", which is the central loop.
Now, to understand the code, you need to know a few things...
Registers:
r0,r1,r2,r3....r30,r31 are all registers. A register on the AVR contains a value between 0 and 255.
x, y, z:
x register is two registers, r26:r27 combined
y register is two registers, r28:r29 combined
z register is two registers, r30:r31 combined, and is the only register that can be used with LPM
Instructions:
lpm,lds,ldi: these are LoaD instructions. LPM=Load from Program Memory, LDS=LoaD from SRAM, LDI=LoaD Immediate value
ST=STore
STS=STore in SRAM
CP,CPC=ComPare,ComPare with Carry
BRxx=BRanch if condition xx. xx could be for instance CS (Carry Set), NE (Not Equal), EQ (EQual), CC (Carry Clear) and a few more.
RCALL=call some subroutine
RET=RETurn (from a subroutine)
JMP=JuMP to address
RJMP=Relative JuMP
IJMP=Indirect JuMP (jumps to the value of the Z-register, which is two registers, r30:r31 combined)
LSL=Logically Shift Left
LSR=Logically Shift Right
CBI=Clear Bit
SBI=Set Bit
AND=logical AND
OR=logical OR
EOR=logical Exclusive OR
ADD=ADD two registers
ADDI=ADD Immediate value to register
ADC=ADd with Carry
SUB=SUBtract two registers
SBC=SuBtract with Carry
SUBI=SUBtract Immediate value from register
OUT=change the value of a port
IN=read the value of a port
Only one instruction is allowed per line, execution is top->down.
Here's your job now: Go and figure out what's going on in the program. :)
If there are instructions, that I did not mention, you can search the Web.
You may find help in the full datasheet for the ATmega8, the datasheet can be downloaded from Atmel.com (remember: There are two versions, a short and a full, download the full version)
Tue 24-Apr-2012 04:57
So,lol,Help!SOS!
Thhhhhhhhhhhank you!
^ ^
Wed 20-Jun-2012 22:40
Mon 3-Sep-2012 22:16
Max Porshnev
Mon 19-Nov-2012 10:41
tesla1980 wrote:
Please help me ! Can anyone tell me how to change the c - code to make that the whole program loops itself ? Where i must change the code. I`m absolutely a c-code noop - i have no idea ! PLZ HELP ME !Sun 6-Jan-2013 06:05
Have you dug into the XMega yet? It has serious juice and can overclock up to 64MHz easily.
I did a bitbanged NTSC color and sound system all in software using an XMega384...
https://www.youtube.com/watch?v=CXFOTpM2Jn4
XMega must be the greatest 8 bit micro yet!
Cheers,
Brad
Thu 28-Mar-2013 07:05
Fri 29-Mar-2013 21:41
I saw your code. Mega respect!
Sat 8-Jun-2013 03:44
Also something even more intriguing is that his name was displayed on the screen as well!
I'm glad that acid head is still getting his "wobbly legs" and licking windows.
Hail the Analord!
Sat 8-Jun-2013 03:45
Also something even more intriguing is that his name was displayed on the screen as well!
I'm glad that acid head is still getting his "wobbly legs" and licking windows.
Hail the Analord!
Tue 11-Jun-2013 05:09
Have you dug into the XMega yet? It has serious juice and can overclock up to 64MHz easily.
I did a bitbanged NTSC color and sound system all in software using an XMega384...
https://www.youtube.com/watch?v=CXFOTpM2Jn4
XMega must be the greatest 8 bit micro yet!
Cheers,
Brad
Please release your source i lové your work
I h
Sun 16-Jun-2013 10:18
Gaz Liddon
Fri 6-Sep-2013 13:26
Big thank you this, I'm now taking faltering steps playing with microcontrollers and digital electronics because of the great write up you posted here :D
I have a question, not sure if you read this and answer them but:
What are you using timer B for? In boot.s It -looks- like it would act like a reset and looks like if enabled it'll trigger every 72 * 8 cycles (just over a lines worth). I'm new to this so couldn't figure our exactly what you're doing :D Were you using it as a watchdog during dev?
Ones again many thanks for making a project so inspirational to me :D
Sun 20-Oct-2013 10:28
Mon 16-Nov-2015 02:34
I am experimenting with a r2r dac myself with a atmega16. and trying to make a synth :).
Reha Bicer
Sun 3-Jan-2016 15:55
Mon 4-Jan-2016 21:12
I am confused here - every place i read about 640x480@60hz VGA timings, the display line takes 25.17 us, the front porch 0.94us - the actual sync itself (pin down) is 3.77us and the remaining back porch, 1,89 us. Im pressuming you are aiming at the standard 25.175 mhz ?
Also, in your code you are correcting for some jitter or missing timing-precision - is this because you use prescaling ?
Linus Åkesson
Tue 5-Jan-2016 21:04
I am confused here - every place i read about 640x480@60hz VGA timings, the display line takes 25.17 us, the front porch 0.94us - the actual sync itself (pin down) is 3.77us and the remaining back porch, 1,89 us. Im pressuming you are aiming at the standard 25.175 mhz ?
Yeah, the standard allows for some deviation, so I picked some values that worked. Summing the values above, you get 31.77 μs for a standards-compliant scanline, but 31.75 μs in my implementation. At 20 MHz, each clock cycle is 0.05 μs, so it would not be possible to achieve 31.77 μs.
The jitter correction is necessary because even though the interrupts fire at just the right moment, the CPU will complete the currently executing instruction before jumping to the interrupt handler. AVR instructions are 1, 2 or 3 cycles (and reading from EEPROM will hold off interrupts for 4 cycles).
Mon 28-Mar-2016 14:36
Looking at the ASCII-drawing compared to the images of the craft, I see only 1 10uF capacitor, but there are two (seemingly) identical capacitors on the images of the 'real' craft?
I'm attempting to build one of these beauties, so I need to figure out what parts I need :-)
Amazing work, btw!
Linus Åkesson
Tue 29-Mar-2016 22:44
Looking at the ASCII-drawing compared to the images of the craft, I see only 1 10uF capacitor, but there are two (seemingly) identical capacitors on the images of the 'real' craft?
I'm attempting to build one of these beauties, so I need to figure out what parts I need :-)
Amazing work, btw!
You are right; I have forgotten to include the decoupling capacitor to the schematic. It's a 10 uF electrolytic that connects to Vcc on the plus side, and Gnd on the minus side. Its purpose is to stabilise the power supply against transients in the demand.
Wed 18-May-2016 19:31
https://youtu.be/c4DS-8IRLls?t=145
Ali Seyedof
Thu 2-Jun-2016 22:52
lft wrote:
Did you connect AVcc? In the original design, AVcc was left floating (by mistake), and this probably affects the amount of current that can be sourced from PORTC. Otherwise I really don't know.
Is AVcc mandatory while you are using PORTC for digital IO, not the ADC functionality? I guess AVcc is needed for A/D conversion and you don't need them while using PORTC as digital IO (which is the case with your impressive demo).
I'm trying to implement your demo on ATtiny13 as an even cheaper version, but with less color depth and no music:)
Great work dude
Mon 14-Aug-2017 08:43
JJ
Fri 1-Jun-2018 16:43
Is it possible to rip it like a .mod or .ay music module?
Sat 4-May-2019 19:39
Mon 13-May-2019 18:19
Wed 14-Aug-2019 14:39
Wed 14-Aug-2019 14:40
Minecrafter wrote:
Linus, can you make a standalone emulator of your various demos like Craft?Thu 29-Aug-2019 14:59
Tue 12-Nov-2019 16:58
I see this project. i search a video generator with avr.
this is very nice.
but do this protect data is update?
the pic and schematic is low quality.
Martin
Thu 20-Feb-2020 20:31
Could you compile your Version for the Atmega168 or the Atmega328? Until now I was not able to compile your code with the software I use (AVR Studio 7)
Thx & Greetz
Uni
Thu 4-Jun-2020 15:31
http://www.bramsonderdelen.nl/vga_gen_m8.png
or as eagle sch:
http://www.bramsonderdelen.nl/vga_gen_m8.sch
contact me:
bram at atasco dot nl
what kind of transistor did you use?
Links are broken!...
Tue 13-Oct-2020 03:01
arun -
India
Tue 13-Oct-2020 03:45
Most impressive is .. 1K of ram. Not enough for a video buffer.
Amazing work !
Mon 28-Nov-2022 21:25
Greetings from Moscow, God bless!
Michael Shigorin / ALT Linux Team
Wed 28-Feb-2024 08:43
Will it run on ATMEGA8 overclocked to 20MHz?
Any hardware/registers specifed only for ATMEGA88 are used there?