Outputting video in parallel on clock - python

I'm trying to output video in parallel format to a display using a Raspberry Pi.
To accomplish this, I need to set 8 pins to YUV422 data, and then clock them in at 54 MHz via the GPIO.
I've read that it's unlikely this is possible using a high-level library like Python's GPIO library, so I'll need to go down to a C-level library to get the performance that I need.
As someone with a C++ background, setting the GPIO pins to a a YUV422 color is pretty straightforward; what I've found intimidating so far is how to set the clock.
I know this feels like a simple question, but I'm having trouble figuring out how to set the clock to such a high speed, or even finding out if it's possible with a library like WiringPi or if I'll need to go straight to the hardware clock.
Can anyone provide me with a pointer to either documentation or a code snippet that can help me?
thanks!

This is not a good application for a Raspberry Pi. It is probably impossible to generate 432 Mbit/sec of output at a consistent clock rate from any userspace application, Python or otherwise.
You should probably consider using a different development board which explicitly supports parallel video output.
That being said, it might be possible using the parallel display interface, which will generate parallel video output (as a Linux video device!) directly on a set of the Pi's pins. It's really intended for RGB video output, but it can probably be repurposed for YUV output with an appropriately modified image.

Related

Call a C/C++ program with WiringPi in Python - Raspberry

I am creating a mobile robot at my work using a Raspberry 3b+ as microcontroller. To determine the robot displacement I am using a motor with encoder sensors.
The problem is: I need to read the Encoder channel changing to count the pulses and also determine the direction. To do this I was using a callback to read the pulses edge, but the callback it is not fast enough to get all the edges and I lost information because of that.
A solution that I could think it was to use a C program using the WiringPi library to read the encoder, I tested it and it worked. Now I need to use this C program in my Python project.
Any idea in how I can do that?

How to make python talk to puredata?

This is my first post. I am trying to make a drum kit using a raspberry pi. The drum triggers are some peizoelectric sensors. I have used pygame inside python to play sounds. When the script detected gpio inputs, it played drum sounds. It was fine for the most part but due to latency issues, I took another approach and decided to use puredata.
I want python to detect gpio inputs and then send signals to puredata, which will play the desired sounds.
My question is, how can I get python to send simple signals to puredata??? I am running both python and pd on the same pi.
Also, what do you think of this approach i.e. using puredata directly from gpio inputs? Can having a microcontroller like arduino to send the signals as midi signals to pd affect anything???
Thank you in advance!
I'm going back about a decade but I used Python to send data from the 3d modelling software Blender to PureData using the socket library.
This article might help a bit more with packaging up and sending across.
If you know what your components within PD are expecting as an input that will help you know how best translate your input triggers into packages to ship over socket to PD.

Connect microcontroller with display (Parallalax with Black Swift + Python)

I am trying to connect the Black Swift with an display from Parallalax[1]. I have been reading lots of tutorials about that but with the displays being used on the tutorials there is always a difference to the pins on my display. The displays that are being used usually have lots of pins where you can choose the ones you need, but the display I have just has 3 pins (5V, GND, RX). Now I assume that with this RX pin I can control the display (like when I use lots of pins on other displays). But I dont know where to connect that RX pin on my Black Swift. The next thing is,
I have also read the manual on that display I have (the link I provided) but the examples they use there are all built up on some boards that are being sold on the website (for example nothing about how to connect a raspberry or arduino). When reading a tutorial everything seems pretty easy, but I guess I didnt choose my hardware wisely :(
Now my question, since I am new to this, is it possible to connect that display to some random microcontroller (in my case Black Swift) ? If yes, where should I connect that RX pin? What is this RX pin doing, (didnt find anything in the manual about that)? Since they are using some special way (PBasic?) to control the display (is inside the manual), is it be possible to control the display with pythong?
Thanks for the help
EDIT:
So far I have managed to turn on/off the UART mode, and it seems that this is not the issue bcz I am getting same results (weired characters on te display).
[1] https://www.parallax.com/sites/default/files/downloads/27979-Parallax-Serial-LCDs-Product-Guide-v3.1.pdf
The linked PDF tells the story pretty conclusively. You need a UART from your controller with the matching bps-rate as set up by the DIP-switches.
Following http://www.black-swift.com/wiki/index.php/File:BlackSwift-1.0-pinout.png you should connect GPIO10/UART_TX to the RX, and then program your uC in whatever language it supports.

How to structure my Python code?

I apologize in advance for this being a bit vague, but I'm trying to figure out what the best way is to write my program from a high-level perspective. Here's an overview of what I'm trying to accomplish:
RasPi takes input from altitude sensor on serial port at 115000 baud.
Does some hex -> dec math and updates state variables (pitch, roll, heading, etc)
Uses pygame library to do some image manipulation based on the state variables on a simulated heads up display
Outputs the image to a projector at 30 fps.
Note that there's no user input (for now).
The issue I'm running into is the framerate. The framerate MUST be constant. I'd rather skip a data packet than drop a frame.
There's two ways I could see structuring this:
Write one function that, when called, grabs data from the serial bus and spits out the state variables as the output. Then write a pygame loop that calls this function from inside it. My concern with this is that if the serial port starts being read at the end of an attitude message, it'll have to pause and wait for the message to start again (fractions of a second, but could result in a dropped frame)
Write two separate modules, both to be running simultaneously. One continuously reads data from the serial port and updates the state variables as fast as possible. The other just does the image manipulation, and grabs the latest state variables when it needs them. However, I'm not actually sure how to write a multithreaded program like this, and I don't know how well the RasPi will handle such a program.
I don't think that RasPi would work that well running multithreaded programs. Try the first method, though it would be interesting to see the results of a multithreaded program.

Measuring USB live-transfer speed with Python

I'm trying to find out the speed of a live data-transfer via USB on a Mac run from the command line with Android Debug Bridge.
Is there a way to do this with any Python-packages ?
Basically, I just want to the script to show me the speed as-is shown at the bottom of a file-transfer window. If not with Python, any command-line utility for the same are welcome.
Are you doing the file transfer inside python?
With a reader and writer?
If so, you can read a piece into a buffer, write it out, update a progressbar and repeat this until the file is completely transfered.
The progressbar module has options to calculate and display the transfer rate just by giving it updates on the writing progress.
See http://code.google.com/p/python-progressbar/ for more info and examples of the progressbar module.
edit:
fixxer, you can use python to check the file size of the file(s) on the usb device and update the progressbar when the file grows.
This is not really measuring the transfer speed of the usb bus, but if you're transfering files it will give an indication of how fast this is going.
If you are streaming a movie, or flashing a chip you'd have to talk to the usb bus directly.
Maybe look into http://www.libusb.org/ and it's python wrapper https://github.com/walac/pyusb

Categories