Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Need to store a PAL signal...

Status
Not open for further replies.

Chris P

New Member
I have a deadline approaching fast and i seem to have hit a wall with a current project. I need to store a PAL (black and white) signal onto a compact flash card. I am using a PIC (16F777) to interface with the card, which has a 10bit A/D converter. I do not need to capture moving video just still frames every second or so. Would the A/D converter on the PIC be good enough for this? Do I need to compress the image? I found some info on JPEG compression but none from PAL (not supprisingly) How can I go about this.

Please help, a lot rides on this working...

Cheers
 
With a black and white signal for PAL, i don't
think you need to worry about the colour burst phasing,
but you do need to worry about the interlacing.

And you may need to check that the signal strength is
logically correct, white is low, and high is black, (well,
thats my recollection, but ive not checked for years ... )

If the signal is just a digital file,
you say its not active live movement,
then i would think ordinary file compression techniques
would do ...

John :)
 
Yhe built in A/D converter in the PIC is probably too slow. Its a simple calculation to find how many samples pre second you need for your image. I'm in the US so i don't know PAL very well but here's the idea for the calculation.

25 Frames/sec * 600 lines per frame * 320 samples per line = 4.8Ms/Sec - way to fast for the PIC A/D and to much data for the PIC to Process. You have to choose what data to ignore : fewer samples per line, sample on fewer lines etc. in order to cut down your data rate. Image compression is probably not an option unless you use hardware compression; the PIC will have a hard time just sampling the incoming data let alone processing the data.

Once you sample the image it becomes a digital image- a bitmap. So looking for "PAL compression" doesn't make any sense.

Hope this helps
Brent
 
Cool, thanks for the advice. I dont need to store the full 25 frames per second, just 1 (or one every other second at a push) would this make it feasable to do using a PIC? Would simply sampling the PAL signal give me a bitmap image? Surely not?
 
The problem is that even though you are only capturing one frame the data is still coming in at 25 frames per second. So you need to be able to sample fast enough to capture the data as it comes in. You won't be able to capture the frame at high quality. You should be able to do a fair job of capturing so that you will have an identifiable image. Do a Google on PAL to find out what the format looks like. My experience is with NTSC (the US equivalent). NTSC has pulses that separate the frames and the even/ odd fields. In each frame there are 512 viewable lines. You can buy ICs that will separate out the Sync pulses to give you a nice digital pulse at the beginning of each frame and the beginning of each line.

Sampling the PAL signal wont give you a windows bitmap file but what you will have is a digital representation of the image which can be called a bitmap. You image will be represented by a two dimensional array of pixel intensities. Windows bitmaps are basicly the same thing sometimes with a little bit of very simple compression. Its quite easy to make a C program to open Windows bitmap files. You arnt sampling the whole PAL signal you want to sample it in such a way that gives you an image (sample the analog voltage between the sync pulses that represent intensity of the image). So the digital information that you end up with is a digital representation of the image and not of the PAL signal itself.
 
well,
if you just want straight black&white,
like text,
or line drawings,
then you might capture it as a single shot
with the units sampling unit.

But if you want shades of grey,
that increases the requirements by a factor
of the number of shades of grey,
so i don't think a single shot could dump it
to memory that quickly.

See what others say, i have heard there are
units made for this job, but i have no
experience of them.

You might be better off trying to buy a
ready made device for this job,

Regards, John :)
 
Thanks Brent and John, you've both been very helpful. It does need to be a greyscale image, at a high enough quality to recognise a face. (The project is a sort of Security Camera. Unfortunetly it's for a university project not a real application so i cant just buy one!!!
I cant seem to find much information on PAL or these chips that will isolate the frames and lines, does anyone know where i could purchase some? (UK) Thanks for your time

Chris
 
Chris P said:
Thanks Brent and John, you've both been very helpful. It does need to be a greyscale image, at a high enough quality to recognise a face. (The project is a sort of Security Camera. Unfortunetly it's for a university project not a real application so i cant just buy one!!!
I cant seem to find much information on PAL or these chips that will isolate the frames and lines, does anyone know where i could purchase some? (UK) Thanks for your time

You can buy the LM1881N from Maplin, it's a sync seperator chip, and provides all the sync information you need.

Your problem seems to be far more serious though, you need to digitise a complete frame of video - you're not going to do it with a PIC, you need a very fast 'flash' A2D converter. I would suggest you look at TV cards for PC's, these are usually based on a BT848 (or something like that), you may be able to control one of those outside of a PC.
 
Digikey.com is a great place to buy things. Take a look at AD9280ARS 32MHz 8 bit sample rate - way overkill but for $5 it will certainly do the job. You could look at using a hardware FIFO to store the samples as they come out of the AtoD so the PIC just generates the start conversion signals for the AtoD. When you have digitized a frame you can read it out of the FIFO when the PIC has time. Also the Compact Flash might not be fast enough to store the samples as they come in. This set up will allow you to sample as fast as the PIC can generate the start conversion signal.
 
Again many thanks to both Nigel and Bmcculla for useful replies. The LM1881N looks exactally what i need! The AD9280ARS also looks like a good idea. However do you know just how fast the PIC (16F777) would be able to sample and write to the flash. I only ask because the deadline is hurtling towards me and I only have to prove the concept...
Since there seems to be no "correct" sampling rate of the horizontal lines, will sampling it slower just lead to a lower resolution image?

For example, if I was to collapse all the information on a single scanline into only ten pixels? (Not going to produce a great image i know) but then as there 52 µs worth of squiggly analog waveform to sample, dividing that time into ten segments will give me 5.2 µs for each sample, which would mean 1 / 5.2 µs = 192.308 kHz sampling rate. So I'll need to sample it at around 200kHz, is this possible (is this correct?) the PIC runs at 20MHz.

Thanks again guys

Chris

PS Just looked at Digikey.com
Yes the ADC's are only £2.86, but then they want to charge me a £10.00 handling charge and £12.00 shipping. Making £24.86 ($44.95)
 
I would suggest sampling along a line at least the same as
the number of lines. ( a bit more if you can )
That should give a reasonable resolution.

PAL (Phase Alternate Line) doesn't necessarily have to be
used in conjunction with interlacing, but it usually is.
You dont have to worry about the PAL set-up for black&white.

Where interlacing is used,
the digital readout would have to be modified accordingly to
be shown on a PC.

But it should go straight to a television just as it came in.

(ps. sampling horizontally at a lower rate than vertically,
vertically being about 620 and fixed, will make the picture
look 'smeared' or 'smudged' horizontally.)

Best of luck with it, John :)
 
Chris P said:
For example, if I was to collapse all the information on a single scanline into only ten pixels? (Not going to produce a great image i know) but then as there 52 µs worth of squiggly analog waveform to sample, dividing that time into ten segments will give me 5.2 µs for each sample, which would mean 1 / 5.2 µs = 192.308 kHz sampling rate. So I'll need to sample it at around 200kHz, is this possible (is this correct?) the PIC runs at 20MHz.

The A2D will only operate upto a certain speed, if you check the datasheet it explains it - you actually set it to work at a proportion of the main clock in one of the registers. Another thing to be aware of is the 'sample and hold' circuit inside the chip - this takes time to charge up, and is dependent on the source impedance feeding the chip, you need to make sure it's fed from a low impedance source for maximum speed.

Ignoring your A2D speed for the moment, 5.2uS only gives time for 21 instructions at 20MHz - this will be reduced by any A2D convertion time, and the time taken to write to FLASH memory.
 
Ok, looks like Im going to have to use a seperate A2D and a FIFO as you guys suggested. Does anyone know where I could get a fast enough A2D in England cheaply? I think sampling around 2MSPS would be plenty. 8, 10 or 12Bits would be fine.

I have a MP0820JN which i think is a fairly new A to D converter. I cant find a datasheet for it however, can anyone help me out with this?

Cheers again guys.

Chris
 
PAL sampling

If the image is static (you said it is) why are you trying to grab a whole image in a single PAL frame ?
Take your time (the image aint going anywhere!) and ...
Synch seperator chip says "Start of frame"
... PIC starts counting line pulses (again from synch sep IC)
... PIC counts to about 10 (to ignore crap at top of picture)
... PIC starts timing (now we get critical !)
... PIC waits for 5us and samples waveform (critical bit over !)
take your time dealing with this sample ...
... PIC repeats above but waits for 10us before sampling waveform
etc, etc

so even if it takes 20 frames to produce one sampled line and you only worry about the odd frame and ignore the even frame (or vice-versa) who cares!
A full picture may take a few seconds and only have 20 samples per line but it could be done. The limit here is how fast the ADC can sample, it may average the voltage while trying to read or 'junk' a sample. Prefixing a sample-and-hold circuit would fix that sort of issue, you just make the S&H fast enough, close its gate at the aprropriate moment and the voltage is there, frozen, while a cheapo ADC chews away on it.

NASA had a camera on an early Mars mission (I think it was Mars!) that took over a minute to transmit a static image back to earth and you are probably on a lower budget.
:wink:
 
Again thanks for the info.
Its probably me not being clear enough but no, the image is not static. It will be moving, it's just that i dont need to capture the movement. Just a couple of stills. So yes, unfortunately I do need to capture the entire image from a single Pal frame.
I found the LM1881N on National Semiconductors website and ordered a couple as a sample, I also found some fast A2D converters, but they all seem to be surface mount. Has anyone ever ordered some DIL A2D's from national (**broken link removed**) as a sample? If so what was it?

Chris
 
Mechie thats a great idea. Chris- What mechie is saying is you break the sampling of the image over 20 frames so you only have to sample one 20th of the image each frame. This reduces the sample rate by a lot. Static is a relative term too. think about it at 25 frames per second 20 frames is still less than a second. Even if you use 50 frames (2 sec)an object will have to be moving fairly fast to be blurred much.

Brent
 
Yes I do understand, and appreciate the help, but there will probably be fast movement. The camera is going to be mounted in the dashboard of a car so that if the car is broken into the alarm will start the circuit and after a few seconds the camera will take a couple of pictures of the drivers seat. The idea being that if a thief steals the stereo/ tries to hot-wire the car he will probably be sitting in the drivers seat...
Thus when you return to your car and see it has been broken into you remove the flash card and you have an image of the scum responsible (along with date, exact time etc) So unfortunatly I dont think a note asking him to sit still while his picture is taken will work :?

Thanks for the idea though...

Still after some fast non-surface mount A2D's (preferably that I can oreder as samples) if anyone has any ideas?
 
Chris P said:
Yes I do understand, and appreciate the help, but there will probably be fast movement. The camera is going to be mounted in the dashboard of a car so that if the car is broken into the alarm will start the circuit and after a few seconds the camera will take a couple of pictures of the drivers seat. The idea being that if a thief steals the stereo/ tries to hot-wire the car he will probably be sitting in the drivers seat...
Thus when you return to your car and see it has been broken into you remove the flash card and you have an image of the scum responsible (along with date, exact time etc) So unfortunatly I dont think a note asking him to sit still while his picture is taken will work :?

Why not just use a digital camera, just modify it to take a picture triggered by an external input?.

I've also got a Sony Mavica recorder - it's not a camera (like the Sony Mavica cameras) - instead it's a small unit which accepts 3.5" floppies and a video signal. You simply press a button on the unit and it stores a freeze frame (in colour) on the floppy disk - it's pretty cool 8)
 
Yes, i know this would be the simple solution, but as i said it's for a uni project not for real use. I get marks for research and providing a technical solution, i get very little extra marks if it works, hense using a solution which requires some technical knowledge rather than the simplist which would get me very little marks.
Cheers

Chris
 
Chris P said:
Yes, i know this would be the simple solution, but as i said it's for a uni project not for real use. I get marks for research and providing a technical solution, i get very little extra marks if it works, hense using a solution which requires some technical knowledge rather than the simplist which would get me very little marks.

Cheers

Chris
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top