I am designing an FPGA for a college project and we need to send data to an FPGA, so we wanted to use USB cords and a python program to manage sending/receiving/displaying information on the computer sending/receiving data from the FPGA.
I've never really written anything to send data to external devices other than when using putty and an atmel avr microcontroller for a previous class, so i'm not familiar with how USB works. If anyone knows how to do this in python, as well as any issues i need to be aware of that would be great. I'm using Python 3.7 and working on a windows 10 laptop.
Edit: some clarification on the project itself. We are using the FPGA as an encoder. The fpga will have modules that perform the encoding and other stuff, but the python program itself only needs to ask the user for an encoding method and get said data to be encoded, then append bits to the data that will allow the FPGA to identify the encoding method, then send the data out to a usb.
Related
I've created a receiver design for a UART. Testing with stimuli on the testbench does indeed show correct functionality. What I am now to try is to test it on real hardware, but I am not sure how to be able to send data serially from the PC to the FPGA with a specific baud rate.
Desired output data_out_sim (shown as ASCII) for binary input data_in_sim
People have been mentioning using pySerial but I am not sure how to make the connection between code and hardware design.
This is not a particularly well formulated question.
A common way to do this is with an FTDI cable or similar USB to UART bridge
I have an RGB LED strip hooked to an Arduino Uno and I want to sync that LED strip to the effects currently sent from Razer Synapse to my keyboard/mouse on Windows 10.
Since Razer Synapse only sends RGB data to their hardware and 3rd party hardware (NZXT, Corsair, etc) my other options are to either snoop the RAM for the RGB data that is sent to the devices, or snoop the USB data sent by Synapse to the devices so I don't have to process animations since all will be done by Synapse.
I've tried to use Device Monitoring Studio to read USB data and I did manage to find what I wanted but I am not sure what kind of data that is and how to get the same data into Python programatically.
I've tried to use pywinusb and the raw_data.py example to read raw data from the keyboard itself but I don't get anything. Maybe I'm not using the proper library for my task.
How do I get that (assuming binary) data with Python to send it via serial to my Arduino ?
I'm new to using a RaspberryPi. Until now I was experimenting with an Arduino.
If I connect an Arduino by usb it is recognized as COM device and with the Arduino serial plot software it was easily possible to live plot sensor data.
For my next project I want to work with an Raspberry Pi Zero W and Python.
Is it possible to send serial data from a python script over the charging usb-cable like with the Arduino? If not, what would be the easiest way to send sensor data e.g. to matplotlib to plot the data directly?
It is possible. However I would not recommend using the USB serial port profile. While it works, it is severely limited in comparison to the alternative. Which is using one of the various ethernet gadget modes.
One tutorial for setting this up is e.g. http://www.circuitbasics.com/raspberry-pi-zero-ethernet-gadget/
The result of this is a full network interface that you can not only use to transfer data over a TCP/IP socket but at the same time run a SSH-connection to start and monitor your application. Even to develop by using a SSH-enabled editor such as Emacs. So the possibilities are much bigger than over the single-stream serial setup.
If it absolutely has to be serial, that's of course possible too - follow e.g. this tutorial: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/serial-gadget
I am working on a student project involving a drone which runs on the Pixhawk platform but has a 'companion computer' in the form of a Raspberry Pi. The Pi runs its own Python software and uses DroneKit (and therefore MAVLink?) to communicate with the Pixhawk via USB - giving it commands, transferring data and so on. Additionally, we have a 'ground station' laptop running ArduPilot Mission Planner which can view and interact with the aircraft remotely and also view it's telemetry. I noticed a 'Messages' tab which essentially acts like a remote console, showing 'logged' messages from the Pixhawk - this is what the question is referring to.
For debugging and information purposes, I would like to be able to add to this from Python on the Pi. I assumed this would be easily achievable through DroneKit but it does not seem trivial - send_mavlink and message_factory looked hopeful but I have found nobody else trying to do this specifically.
How can I easily redirect my 'console messages' from Python to the ground station? I realise there are alternative methods but going through the Pixhawk's existing telemetry system seems a much better option.
Thanks
One thing you can do is to create a bridge (proxy) between Pixhawk and GCS with your RPi, similar to this question.
Then in the middle of that you can send your own text messages with:
gcs_conn.mav.statustext_send(mavutil.mavlink.MAV_SEVERITY_INFO, "your message here")
Be careful not blocking too much the telemetry transmission, otherwise you could have intermittent connection to the drone from your GCS.
I have a GPS module connected through serial port(USB->Virtual COM port). A measurement software is using this port, so with other software I can't access to the data. I would like to create two virtual COM port and share this data through that. Is it possible using Python? Is there any opensource example written in Python?
I don't think you can do that if you cannot modify the sources of the measurement software.
Serial port protocols are written as "point to point" protocols, so there's no general way to multiplex them. You can write a program that shares the access to the GPS module (handling it exclusively and exposing an API to multiple programs), but every program that wanted to use the GPS module should be written to talk to your API and not directly to the serial port - and in this case it can be done only if you can change the measurement software.
Notice that probably it's not impossible to implement your "virtual port" solution, but it would be an ad-hoc hack (it would work just with that specific protocol) and it may be quite complicated: you would need to emulate two GPS modules and multiplex the requests to the real GPS module; depending on how does it work (e.g. if it has a "complicated" persistent state) it may be simple or very complicated. But surely Python wouldn't be enough, to emulate serial ports you have to go in kernel mode.
Do you need two-way communication, or just reading? You could build or buy hardware to physically split the Rx data line so you could use two COM ports, each of which would read the same data. You could do this with Tx data as well, but you would have to be careful about trashing the data if both ports tried to write at the same time.