Composite (complex) Video 100% Straight C on a One-Dollar MCU!

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
You should also add a base return resistor to speed the turn-off of Q1.
The schematic: http://forum.allaboutcircuits.com/attachment.php?attachmentid=37289&stc=1&d=1322976657 -- has been updated. Wrong crystal value shown and there is now a base resistor to aid with turn-off.

When you say base return, do you mean emitter to base? I agree that this would help switch it off much quicker, but pretty sure that it would cause chaos with the DAC. The Sync line would be providing a path to forward bias Q1.

Could go a bit lower on the 47K I guess. What are your thoughts?
 

joeyd999

Joined Jun 6, 2011
4,477
For me, VB has been totally relevant.
Sorry, I think you took this the wrong way. I was not implying that VB was irrelevant to *you*. I meant that (IMHO) VB is irrelevant to PIC ASM programming. It is too far abstracted to give any insights into actual workings of the CPU. C, on the other hand, was originally (and purposefully) designed to easily apply to physical hardware.
 

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
Fair enough.

I guess my question is still why? Why use ASM if there is enough ram and speed as it is likely to be the case with most modern MCUs. Some guys are even claiming on par performance with these high-end C compilers.
 

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
C, on the other hand, was originally (and purposefully) designed to easily apply to physical hardware.
True, but how many Java programmers could dive in and code and not have to know very much about the hardware? My guess is many. Java is 99% C minus the memory pointers.
 

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
Actually, Java on OOP level is harder than C.

Either way, what most people fail to see is that, you cannot use any language if you cannot produce algorithms.

You'll send yourself around the twist otherwise.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,221
The schematic (on page 1 of thread) -- has been updated. Wrong crystal value shown and there is now a base resistor to aid with turn-off.
When you change your schematic as a thread progresses, it's a good idea to leave the prior version where it was alone, and simply add the updated schematic to the most current reply. If it makes sense to do so, a final schematic might be added to the 1st post in the thread, but not replace the original schematic. If the original is changed, it disturbs the continuity of the thread; one can't see how the circuit progressed.

When you say base return, do you mean emitter to base?
Yes, but actually I was referring to when/if the OR gates were replaced with diodes; then a base return resistor would become essential.

If you want to leave it with OR gates, then a small cap (say, a 30pF ceramic) in parallel with the base resistor will cause the transistor to switch on and off far more quickly, as the edges will be AC coupled directly to the base.

I agree that this would help switch it off much quicker, but pretty sure that it would cause chaos with the DAC.
I don't see how, as the resistor would be across the base-emitter junction. If that proves to cause problems with the DAC, you could try placing a bypass cap from the transistors' collector to GND; 10nF to 100nF should work OK.
The Sync line would be providing a path to forward bias Q1.
If the Sync line is not causing Q1 to be forward biased presently, adding a base return resistor certainly would not cause it to do so.

Could go a bit lower on the 47K I guess. What are your thoughts?
I usually suggest starting with somewhere around 3 to 5 times the value of the base resistor, and then see how it works with real components. Depending on tests, one might find it optimal to be higher or lower than that; it's a reasonable starting place though.
 

MrChips

Joined Oct 2, 2009
24,608
What a great idea! I never thought of it. I am working on an ARM Cortex-M4 development with huge amount of processing capabilities. It can generate the video stream and still do the other processing at the same time.

RB, I will contact you to get the VGA details. The possibilities are endless.
 

joeyd999

Joined Jun 6, 2011
4,477
I guess my question is still why? Why use ASM if there is enough ram and speed as it is likely to be the case with most modern MCUs. Some guys are even claiming on par performance with these high-end C compilers.
Like I said earlier, there are things I can do in asm that cannot be done in C. In the end, a language is just a tool. For me, asm is like a precision screwdriver (and the apps I write have lots of small, interacting parts).

Also, I've written apps that use 99% of the available program memory (and nearly all available instruction cycles). Using C would force me to use the next higher capability part, which would increase my resulting BOM costs and decrease my margins.

Re compilation performance: anyone can say almost anything, especially if they design their own benchmarks upon which to base a comparison. One major limitation of PICs wrt C is the lack of a native software stack. C requires at least the simulation of such a stack, necessarily adding additional overhead to the resulting code.

In the end, writing asm is like breathing for me. It's something I've been doing continuously for over 35 years. And it works for me.
 

joeyd999

Joined Jun 6, 2011
4,477
True, but how many Java programmers could dive in and code and not have to know very much about the hardware? My guess is many. Java is 99% C minus the memory pointers.
Java (or any other language) programmers who don't know hardware shouldn't be writing system level code for embedded processors (at least not at the professional level). I've seen the results....it ain't pretty!
 

joeyd999

Joined Jun 6, 2011
4,477
Actually, Java on OOP level is harder than C.
This is entirely subjective. Similar to C++, it depends on whether or not one can make the conceptual leap to an object oriented programming model. Some can, some cannot.

Either way, what most people fail to see is that, you cannot use any language if you cannot produce algorithms.
I would assume that one would not be a programmer in that case...
 

MrChips

Joined Oct 2, 2009
24,608
Joey, I'm with you. Anyone who is going to try to argue C over asm doesn't know what they're talking about. I wouldn't waste my breath.
 
Last edited:

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
In the end, writing asm is like breathing for me. It's something I've been doing continuously for over 35 years. And it works for me.
How much do you charge?

I would actually like to see this project done in ASM, using THIS one-dollar part. If done in ASM, I feel that the resolution could be doubled, and it would produce a technically more accurate video signal.
 

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
Yes, but actually I was referring to when/if the OR gates were replaced with diodes; then a base return resistor would become essential.
Because the diodes could only swing high. There isn't much current available in these CD chips. I feel that either way the resistor would help switch it off quicker.

If you want to leave it with OR gates, then a small cap (say, a 30pF ceramic) in parallel with the base resistor will cause the transistor to switch on and off far more quickly, as the edges will be AC coupled directly to the base.
Capacitive reactance. I give this one a go.
 

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
This is entirely subjective. Similar to C++, it depends on whether or not one can make the conceptual leap to an object oriented programming model. Some can, some cannot.
Yeah it is a big jump. Most of the VB6 coders never managed to do anything in .NET, which is by large and far a much better language.
 

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
I personally had a blast making the transition from VB6 (procedural-based programming) -- to OOP .net The thing I liked most about it was, if you can use VB.net the right way, then migrating to C# was a snack.

Basic version:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=7715&lngWId=10

C# version:
http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=7723&lngWId=10

It is a shame that the GDI+ graphics libs are a bit slow, otherwise the language is purrrfect for making 2D video games. Better to use .net than a specific game only programming language, this way you're not trapped into something. There is no money making video games.
 
Last edited:

Thread Starter

T.Jackson

Joined Nov 22, 2011
328
Just to confirm my suspicions, that ASM could do close to double res -- how many asm instructions required to do these
Rich (BB code):
PORTB = cache[0][segmentColumn] & 128;
C instructions in assembly?

Bit mask / compare a bit to a byte and write to port.
 
Top