25 Mhz Input ...
LustInBlack
Posts: 22
I'm currently trying to figure out how I could synchronize the cogs to sample a 25 Mhz signal in the Prop..
The signal is a digital camera.. I want to record the samples (YUV samples) to an external memory..
But right now, I would be satisfied if it could read 1 bit of that YUV signal..
The camera is clocked at 25 Mhz, and it is feeding me it's clock on one prop pin.
I could use waitpeq to wait for a change on the CAM-clock line. WaitPeq have a latency of 5 clock..
If I understand correctly, each cog gets a maximum of 80 mhz clock, I am currently set a 8mhz ext + PLL16x..
I believe I could wait for a clock transition, but would'nt have time to read the data in the short window it would be
available..
My question is, the update of the input (INA) memory value is done after a complete cycle of the hub, or is it made
between cog transition !? .. (If so, I should be able to synch many cogs to treat the value...)
?
*** OR, I could directly write the YUV data into memory with digital gates .... ***
The signal is a digital camera.. I want to record the samples (YUV samples) to an external memory..
But right now, I would be satisfied if it could read 1 bit of that YUV signal..
The camera is clocked at 25 Mhz, and it is feeding me it's clock on one prop pin.
I could use waitpeq to wait for a change on the CAM-clock line. WaitPeq have a latency of 5 clock..
If I understand correctly, each cog gets a maximum of 80 mhz clock, I am currently set a 8mhz ext + PLL16x..
I believe I could wait for a clock transition, but would'nt have time to read the data in the short window it would be
available..
My question is, the update of the input (INA) memory value is done after a complete cycle of the hub, or is it made
between cog transition !? .. (If so, I should be able to synch many cogs to treat the value...)
?
*** OR, I could directly write the YUV data into memory with digital gates .... ***
Comments
However cogs execute an instruction once every 4 cycles, this means cogs execute 20 MIPS. So sampling at 25 MHz in a cog isn't posible. To exacerbate things further the tightest store-to-cog-meory loop takes 3 instructions to execute (and the number of smaples is limited by cog memory) and 4 instructions for the store-to-hub-memory version (but actually acts like it takes 8 instructions because of hub synchronization), or sampling rates of 6.667 MHz and 2.5 MHz.
But there is a silver lining to the dark cloud, it is possible to scynchronize multiple cogs and offset them so they work in round robin to sample at higher frequencies. So if you used two cogs and synchronize them so that each takes sample halfway between the other cog's samples the datarate is doubled to 13.3MHz and 5 MHz. So with 4 cogs running you can get to 26.67 with 4 cogs.
Lastly, now that I think about it I'm afraid given you application it won't be possible. The above number doesn't take into account the need to move the data to hub memory, while it's doing this it can't sample, and I think you need to sample more than 2000 times which is the practical limit for store-in-cog.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Are you really running at 128 Mhz!
You do not need "funny effects" when you are debugging COG syncs
As Pauls says you have to start with your data storage bandwidth!
So you most likely will need a "burst" technique: sampling 1k data -> storing it.
This is not even difficult:
Sync each HUB to X, X+1, X+2, X+3
Then you have to find a nice scheme that allows bit shift and local LONG storage. I think repeated code will do best:
Just multiply 32 loops as:
INA
RCL
DJNZ
This will input 1000 bits @150ns /bit
You should exchange the crystal so it will take 160 ns (or 120ns if very brave)
Post Edited (deSilva) : 3/8/2008 10:32:34 AM GMT
I didn't have any problem tho, but for keeping things in synch, I'll set the pll to 8x..
I thought about the problem, I believe I can do it externally, by storing the image in a framebuffer..
Using 8-bit binary counters (Probably three 74hc590 for 12 bit addressing) that increment the address of an external SRAM at each clock edge, and a buffer that will latch the 8-bit data from the camera for the SRAM ..
In fact, I would use 2 SRAM since I only have in my possession 70ns SRAM chips..
So, by using the bit 0 of the binary counters, I would select which SRAM to use, this would share the load between the
2 SRAM modules.. I will need another Buffer for each SRAM modules to store the temporary address received from the
binary counters..
I never did such a thing yet, I always worked with microcontrollers before, trying to keep the external part
count to a minimum... But I believe my idea will work...
To synch this with the prop, I would only have to use a cog to compare the 12th bit of that binary counter, when it reads high, I
reset the counter, then send the data in memory to my computer using an USB cable, wait for vertical synch of camera, then repeat...
This would free the MCU from the burden of loading the data, I would then have plenty of power left for other things, like,
video-overlay, or an artificial vision system..
I understand that the power of the propeller is it's internal ability of processing 32bit words in parallel, thus, I believe it's
quite capable of performing high speed computation on an image; I could use that for a robotic application . .
DeSilva, how do you keep the COGs in synch, when a condition appear in one COG, it will need to resynch, how do you do it
without wasting clock cycles?! .. I would rdlong a shared variable to keep the state of each COG, not unlike a COG state-machine,
but this sounds slow ..
You can then run at 100 Mhz and be synched.
Next, if the camera is an uncompressed video camera, you can use interlaced sampling
over as many frames as necessary to access the full Resolution image.
I was thinking of a "burst" mode, which means reading only a part of the data (1k Byte per COG), and then dumping it to HUB or PC
This "dumping" will take CONSIDERABLE time, so an external syncronisation will be needed anyhow.
If all the COGs are awaiting this external event, they will be perfectly synchronized again.
Another way is that one of the COGs (or a master COG) can define a specific CNT for the next wave.
COGx will then grab the signals starting at CNT+x , e.g.
Also: Have a look here: http://forums.parallax.com/showthread.php?p=689325
This describes a hardware system similar to your ideas ("external DMA")
Post Edited (deSilva) : 3/9/2008 7:20:40 AM GMT
For the moment, I'll continue my initial project, which is, a low resolution vision system..
I'm currently learning the propeller, and I see the potential now!
It's very pleasant to play with, I like the prop very much!
I conencted the prop to a VGA screen and now I can debug quite easily..
I'm still at 128MHz, and I don't see any "funnyness" yet.. What is it supposed to do!?
Any timing related problem or things like that?!
Btw, what I'm doing right now, is making a 4 bit ADC using capacitors and reading the value from
photoresistors, then displaying them to the VGA screen.
I have a question, I'm using the VGA screen in text mode.. I know that the character map is useful, but I don't
like it, the chars are too big, and I want a font similar to the one DOS use..
I changed the resolution of the screen to 640x480 (using the vga demo) and I'm trying to fiddle with the fonts
at $8000 .. well, it's not working, the memory must be read-only (most probably a ROM that isn't shadowed in RAM) ..
Anyways, I wondered if I could change that memory location with my own font format, but seems unlikely...
I'll code a new VGA driver with external font support..
You can display any character as long as its 32x32, just set it's address in the tile..
There are also some activities by Steven and me to beef-up GRAPHICS, but it will take to Easter at least for me...
I am having some results using the vga_512_384 demo . ..
Post Edited (LustInBlack) : 3/9/2008 8:56:41 PM GMT
I have this setup, DOSFont is an array of 8x8 fonts..
Ptr is supposed to be a pointer to DOSFont, I'm playing with Ptr to point to the font I want ...
So, Ptr++ etc..
I tried all this :
mov ptr, DOSFont ' Nein!
mov ptr, @DOSFont 'Nein !
mov ptr, #DosFont 'Nein ! .. I thought this one would work, but NO !
So I tried :
mov ptr, #@DosFont ' NOO it doesn't work!
Then, I decided to do it in spin, and bingo, it's working..
I took me all day long to figure out this one.. Damn ..
Post Edited (LustInBlack) : 3/10/2008 1:37:53 AM GMT
The section of the Propeller manual t about the '@' operator discusses some of this. One option would be to include a bit of spin code like this before you start the cog.
This is my DAT section, for the moment, my rendering is pretty dumb and slow..
I'll optimize that in time, for the instant, I'm plotting in X and Y by parameter..
The PTR is loaded with the address of DOSFont, which does only work when I do as you said..
I want to do the same inside the Asm Code!
I also tried this :
in Spin :
FontBackUpPtr := @DOSFont
Ptr := @DOSFont
in asm :
mov Ptr, FontBackUpPtr
'WRONG, it doesn't work !!!! ??????
I must miss something quite obvious...
[noparse][[/noparse]I'm used to code for AVR, this is quite different, but I like it alot!!!]
Your right, with that code the DOSFont will get copied into the cog. The pointer to DOSFont is used like this
I think the problem is elsewhere. Have a look at the comments in the code below.
This code actually works, the problem is when I remove the line ptr := @DOSFont and replace it in assembly
at Draw label with : mov Ptr, #DOSFont
It then send garbage to the screen..
The pointer is invalid for some reason .. .
at LoopW Tis reading from the hub. You want to change it to read from the cog like this
Than if you do the
at draw it should work.
And a note, if you post some code and some of it is in italics than the forum has eaten the [noparse][[/noparse] i ] (without spaces) from your code. Just put a space after the opening bracket and this won't happen or else use Phil's code formatter.
I retried to be sure, and it doesn't work !
I had to change my logic, as the SHL 24 was on a byte, now it's on a dword..
I simply removed the shl and replaced shl in the loop with a shr..
Do not work either way..
I am out of guess!
I had a bug in the incrementation of PTR
I did this:
PtrChg: mov tmp, ptr
and when I inc Ptr I do :
add PtrChg, #1
Then I'll have to change the affection of tmp so it points on a byte...
I think it will work that way, since I can almost distinguish the characters on screen now !
Thanks ! ..
However, I'm trying to implement a String routine, and when I rol the CharPtr, it gets to a null value!
However, it's supposed to contains "ABCD"
I can print the A, then .. it's equal to 0 !
How come ?!
I supposed it would do it :
"ABCD"
"BCDA"
"CDAB"
"DABC"
I know it's not DrawGlyph,I've put it in comment and it's still doing it..
Post Edited (LustInBlack) : 3/11/2008 5:00:34 AM GMT
TESTCHAR long "A"
long "B"
long "C"
long "D"
Try doing
TESTCHAR long byte "ABCD"
The long makes it byte aligned and the byte tells the compiler to only allocate a byte instead of a long for each character.
Easy to do and hard to find
("SIZE OVERRIDE MUST BE LARGER")
There is the well known work-around to split sizer and alignement
It works as expected though if you put it on the next line. Either like deSilva has or like this.
You can actually put in as many longs, words and bytes in between like this and it doesn't change the size.
All very strange to confuse those who haven't met it before. Well thats my new thing for the day
Most people are not even aware of the difference between sizer and alignment
Will be one of the surprises for Fletch
I thought the compiler would take care of alignment.. That's good to know !!!
Back to the original subject..
What about using CTRA and CTRB to detect a Positive Edge of the Clock line of the camera!?
Wouldn't that be extremely fast and work at clock speed (or selected speed of the PLL) !?
Is the VCO adjustable!? What is the VCO exactly and how is it configured!? ..
This chip ROCKS I completely love it! I am almost throwing my avr stuff away !!!! ... (Just kidding... But seriously!) 8]
Now back to your question about using the counters. The counters can detect the positive edge but all they can do is add FRQx into PHSx which is not useful for this. The best way would be to use a waitpeq or waitpne. I think that these only have a delay of 1 clock cycle between a change in pin state and the cog resuming. So you will have a delay of 1 clock cycle between receiving the input and doing something about it. Try to do that using interrupts on an AVR. As was suggested ealier, why not clock the propeller at 100MHz? Than you could use 4 cogs and each cog would have 4 instructions for each bit.
Now for the VCO. The propeller has several VCOs but you can't get directly at any of them. They are all parts of the PLLs so there are two in each cog and one for the main system timer. What you are probably more interested in is the PLL modes for the timers. Using these it is possible to get almost any frequency you want between 64MHz and 128MHz out of the propeller. However, because of the way the counters work you will sometimes get a glitch. There have been a couple of threads about this recently and they shouldn't be hard to find. Again, have a look in the AN001 notes. Also, the data sheet has some info on the counters and so does the hydra book.