Video Stuff PWM8
Hi Everyone,
I'm trying to figure out the PWM DAC "PWMx8" object.· It uses the VGA mode in the video processor to create 8 DACs output.· Very nice object, but I want to be able to have the DAC run at 1khz bandwidth minimum for a project Im doing for the Navy.· However I need to modify this object to run faster.· In order to do that I need to understand the video processor a bit more.
Is there a decent write up on the video processor anywhere?· I found a couple of pages in the data sheet, but it's alittle too brief for this simple minded fella.· Anything else out there?
Thanks,
Greg
I'm trying to figure out the PWM DAC "PWMx8" object.· It uses the VGA mode in the video processor to create 8 DACs output.· Very nice object, but I want to be able to have the DAC run at 1khz bandwidth minimum for a project Im doing for the Navy.· However I need to modify this object to run faster.· In order to do that I need to understand the video processor a bit more.
Is there a decent write up on the video processor anywhere?· I found a couple of pages in the data sheet, but it's alittle too brief for this simple minded fella.· Anything else out there?
Thanks,
Greg
Comments
http://forums.parallax.com/showthread.php?p=735672
OBC
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Feature Projects: PropellerPowered.com
Visit the: PROPELLERPOWERED SIG forum kindly hosted by Savage Circuits.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,
1. Configure the video output mode, and this is a write of a value to VCFG. The propeller data sheet details how this works, and what the options are.
2. You need to setup counter A to operate in PLL mode, so that it operates at your desired frequency. The video generators use PLLA as the basis for their pixel timing and frame size specification.
One write instruction to CTRA sets the mode. Another to FRQA starts it running at that desired frequency. The cycles of that frequency are used to determine the pixel timing, and a sum of all the pixels is used to determine the frame timing.
(more on that in a second)
3. Set your output pins, with a write to DIRA.
There will be some time consumed after operation number 2, and that allows for the PLL to settle, when it's done in this order. That time is 4096 PLLA. During this time, you can do the other setup tasks, which are to setup your waitvid loop variables, and set the VSCL to be used by the next waitvid.
4. Set the VSCL by figuring out what multiple of PLLA your pixel clock is. Let's say that's 16 PLLA. Shift that value by 12 to the left, then add the frame value. Say you want 10 pixels. That's 160 PLLA total, which is added to the value you shifted earlier. Write that to VSCL, and the waitvid instruction to follow closely will be setup and ready to run!
5. Once you've got the thing running, you need to keep data streaming to it via the waitvid instruction. Typically this is done in a loop, where you fetch the pixel and color data for the waitvid. The idea is to keep the loop execute time shorter than the frame time, so that you get your computation done, while the waitvid in process is streaming pixels, arriving at the next one before it completes, so that the Propeller can just take the next data load, streaming uninterrupted.
Waitvid operates off of a pixels long, and a colors long. The number of bits shifted out of the pixel long, is equal to your frame timing, divided by the pixel timing, with each pixel being one or two bits per pixel. So, that's either 10 or 20 bits used up every waitvid frame, depending on the bits per pixel set in the VCFG. The colors long is all about the output color assigned to the pixels, with the two together resulting in the signal data needed by the video DAC in use, be it TV or VGA. That output depends on whether or not the generator is in TV or VGA mode.
I've not looked at how the PWM object works. But, what I just wrote should take you though the code, leaving you with figuring out how they mapped the pixel and color data into useful outputs. In general, the video generator can be used to send on / off bit patterns to a pin, based on the data in the color and pixel longs. The nice thing is once it's streaming, you get control of the COG back, so that the data can be updated in real time.
You can stop the video generators by writing a 0 to VSCL, and by stopping PLLA. If you want to start again, you need to init both, waiting that 4096 cycles for it all to stabilize.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Propeller Wiki: Share the coolness!
8x8 color 80 Column NTSC Text Object
Wondering how to set tile colors in the graphics_demo.spin?
Safety Tip: Life is as good as YOU think it is!
To do what you want to do, you don't need to know anything about how the video mode works. As I mentioned in your other thread on the same subject, all you have to do is mimic the operation of the duty routine in PWMx8, but in assembly. And, instead of sending it an argument for an individual channel, let it monitor an eight-channel array of PWM values in the hub, which you can update any way you want. From there, your assembly code just needs to build and update the bit slice array that the PWMx8's assembly code uses to keep the PWM outputs refreshed. You do not need to -- nor should you -- touch the existing PWM assembly code.
As I explained before, each byte in the bit slice array represents the values of all eight PWM outputs at a particular moment during the PWM cycle. For example, if your duty cyle is 50% for output 0, bit 0 in the bit slice array will have ones in half the array and zeroes in the other half. Updating this array has to be done in such a way that you don't introduce glitches. Basicially, if you're lengthening the duty cycle, you update from the first "0" bit working forward through the array. For shortening, work backwards from the last "1" bit.
-Phil
Phil I must have missed your posts somehow. Let me dig through this to see if I can figure it out. My biggest problem I have at the moment is trying to understand what resides in the pwmdata array. Phil your code is impressive, but I was having trouble with the duty routine and knowing how the whole thing works. After what you told me here I will conjugate a bit and see if I can figure out duty.
Thanks,
Greg