I would like to send a random binary data sequence to a rpi GPIO at a particular frequency and then read the data stream off a scope. Is there a way of implementing this through python?
what are you using for sending the data to the RPi? – jsotola1 hour ago
I want to write code to send the random data stream to a GPIO to read off on a scope. The binary data will later be used to encode a signal through various modulation schemes. The data stream is generated from the pi and transmitted out through a GPIO. – Ric Turner1 hour ago
Hi @Ric Turner, Welcome and let me see. You can poll or interrupt a input mode GPIO pin for your signal and log the reading results to a text file, together with time stamps, and display them as a scope like wave form. You can also use the scope’ “single trigger mode” to display the waveform within a time period. You can also use a cheapie, US$300 scope to display the Fast Fourier Transform of the components of your random signals. – tlfong011 hour ago
I am a little bit confused. Do you mean you wish to use an output mode GPIO pin to send a random sequence of high low signals, which will be read by an input mode GPIO pin? If what you wish is only to display the signal waveform, you can directly output the signal to a scope, say, cheapie US$100 digital storage oscilloscope. – tlfong011 hour ago
Yes, I’d like to output the random sequence of HIGHs and LOWs from a GPIO pin set as an output. I’d like to clock the data out at a particular frequency. I’ve looked online but most examples include using SPI or I2C. I do not wish to use a master and slave setup with stop, start or acknowledge bits. The end result would be to see the data stream from a digital oscilloscope and to be able to identify the bit period that corresponds with the frequency that the data is sent out at. – Ric Turner1 hour ago
Ah, let me see. That should not be difficult. Suppose we can start with the newbie assignment of using Rpi GPIO to blink a LED, which is a simple loop turning on LED, sleep some time, turn off LED sleep some time. Now you can modify the “sleep some time” statement by a “sleep random time” statement, using the python random function. Actually you can time stamp before and after the blink LED sequence and display a sequence of LED on and off with time stamps in the python output screen (eg Thonny python) or save in a text or Excel file for analysis. In other words, no scope is necessary. – tlfong0146 mins ago
Perhaps you can first try to write such a python program and show me your final version of your newbie program, and I can give you a ninja demo version (how to do random, timestamp, text file etc), and scope screen capture for your to compare and contrast. – tlfong0144 mins ago
I have a couple of answers in this forum on how to make time stamps to record events and write to a text file. The following is a an example. You can just add the random thing and complete your project! 🙂 raspberrypi.stackexchange.com/questions/96716/… – tlfong0138 mins ago
for index in range(len(Pin_array)): GPIO.output(Pin_array[index], 1) time.sleep(1) for index in reversed(range(len(Pin_array))): GPIO.output(Pin_array[index], 0) time.sleep(1) – Ric Turner27 mins ago
Oh my goodness, your program is indeed ninja level, hard for newbies to read. You need to do the following for the mercy of newbies: (1) Structure your program into little functions, (2) Comment your functions. You might like to read my “Find Elapsed Time” demo program on how me, the ninja, write functions and document them, also show a sample output, to prove that your program is indeed almost bug free: penzu.com/p/282e9929. – tlfong0111 mins ago
And in case you LOL at how come the stupid ninja, ie, me, make simple things so complicated, let me tell you my newbie upgrading to newbie story. Once upon a time I wrote “one liner”, unreadable programs like yours. But after only a couple of weeks, I cannot understand my own program, how it works, not to mention how to REUSE it. Since then I have been writing programs with functions i can read easily (even after a year!), understand it in a couple of minutes, and REUSE the functions for complex programs. – tlfong0110 secs ago Edit
Of course it is for complex programs (over 5,000+ lines) then you need to do what I do, “over functionising and over documenting”. Happy Programming. Cheers. – tlfong01just now Edit
for index in range(len(Pin_array)): GPIO.output(Pin_array[index], 1) time.sleep(1) for index in reversed(range(len(Pin_array))): GPIO.output(Pin_array[index], 0) time.sleep(1)
– Ric Turner 27 mins ago