Questions tagged [python]

On-topic questions related to Python would include embedded programming, using it as a tool for circuit analysis, or how Python interacts with computational hardware. Questions about libraries, algorithms, syntax, or code optimization should be directed to stackoverflow.com.

Filter by
Sorted by
Tagged with
1 vote
1 answer
52 views

Raspberry PI4 and RS232 adapter cable: how to send serial commands

I would like to use a Raspberry Pi4 to control a syringe pump [(see datasheet here and in particular the quick start manual on page1)][1] The connector cables I used are RJ11 from the Pump to RS232 (...
user avatar
0 votes
0 answers
95 views

How to avoid CPU usage 100% while reading turning direction from an encoder?

I'm trying to read the turning direction from a handheld pulse encoder handwheel. The below code works but it use 100% CPU. I tried to use sleep in the while loop, but even a 0.01s sleep will lead to ...
user avatar
1 vote
2 answers
117 views

Solving electrical network in Python

I have a complicated electrical network. I would like to calculate voltage drop across across the network i.e. nodes 2-15, given V1=10 V and V16=0 V. The values of the resistances are known. Is there ...
user avatar
  • 11
2 votes
1 answer
42 views

Scaling Waveform from LeCroy 4104HD using Python/IEEE488.2

I am automating control of a LeCroy oscilloscope using IEEE488.2 and Python/PyVisa. It seems like it should be relatively straightforward. I use the WF? command to get the waveform + header, I use the ...
user avatar
  • 31
0 votes
1 answer
103 views

SPI transaction weird behavior

Im completely new to this topic so excuse any mistakes I make. I have a MMC5983MA sensor which works well with I2C. However Im having trouble with the SPI protocol. I have all wired up and im trying ...
user avatar
-4 votes
1 answer
48 views

Raspberry Pi 3 motor code gives gpio error

I am trying to code a motor using the GPIO pins on a raspberry pi 3 and for some reason, when I run the code, it gives me this error: GPIO.setup(enable_pin, GPIO.OUT) NameError: name 'enable_pin' is ...
user avatar
  • 19
1 vote
0 answers
87 views

Stepper motor has own encoder, can I connect encoder pins to microcontroller and see feedback?

I am using closed loop stepper motor with motor driver. Here is my driver CS-D808. I am using this with microcontroller. I want to stop this motor always certain location after 5 to 10 turns. I wrote ...
user avatar
0 votes
1 answer
60 views

Restore Image File from an Embedded Linux

I am working a project and I am running python on my SOM module( Variscite DART-6UL ). The libraries installation take too much time that I need. Because of that I want to take an image file after ...
user avatar
1 vote
0 answers
24 views

Get alpha-beta plot of Clarke Transform in Python

For a project I'm working on, I want to use the Clarke Transform to detect faults in a power system. To do this, I already wrote a script in Python which returns the sine wave behavior of the Alpha, ...
user avatar
0 votes
1 answer
214 views

SPI communication problem between Raspberry Pi and STM32

I've spent a couple of days to find answer to my problem. Currently I'm working on a project where an STM32L432KC microcontroller board and a Raspberry Pi 3B need to communicate over SPI. The OS on ...
user avatar
  • 11
2 votes
1 answer
238 views

Bipolar stepper motor spins very slowly and makes a loud noise

I got a custom PCB. I am using DRV8428P driver (here is the datasheet) for a stepper motor. The problem I am facing is not being able to have the stepper rotate ...
user avatar
  • 35
0 votes
3 answers
257 views

Read negative voltage using an ADS1115

I'm currently trying to read a sine voltage between about -5 V and +5 V at 50 Hz using an ADS1115 and a Raspberry Pi. I'm writing the code in Python and using the Adafruit library for the ADC. I have ...
user avatar
0 votes
0 answers
69 views

How to calculate total average power (in dBm) of a distorted voltage signal from power spectral density using scipy.signal.welch?

I am new to signal processing. I have time and voltage data of a signal that is a distorted sine wave and I want to calculate the total average power of the signal given a load of 50 Ohms. I do the ...
user avatar
3 votes
4 answers
623 views

How to calculate resistance from points using linear regression?

I have a lists of current and voltage of one device and I would like to calculate the resistance. There are some errors with the ...
user avatar
  • 41
2 votes
0 answers
59 views

How do I control the speed of a simple DC motor based on the output of a machine learning algorithm using a Raspberry Pi?

Let's suppose there is a simple machine learning algorithm for detecting speed limit signs using image recognition and it detects a 30 km/hr sign. Is there any way to send instructions to my motor ...
user avatar
0 votes
2 answers
118 views

Slow read from IST8308 via I2C using Python and smbus2

I have an Arm64 Linux board and an IST8308 3D magnetometer that I am reading via I2C with the following script: ...
user avatar
  • 103
0 votes
0 answers
102 views

What do the \$E\$ and \$B\$ fields look like around a length of pipe, excited from one end by a Class A amplifier?

Diagram here: I'm looking for help modeling the \$\mathbf{E}\$ and \$\mathbf{B}\$ fields around a length of pipe. One end of the pipe is connected to the collector of a transistor in a Class A ...
user avatar
1 vote
1 answer
111 views

Using more than 2 I2C OLED displays on a pico

I have a pico running circuit python and using the adafruit_ssd1306 library to drive 1306ssd OLED displays. This works very well for two displays but when adding the third it doesn't update the third. ...
user avatar
  • 113
1 vote
1 answer
54 views

RPi Pico not reading a button correctly

I connected a button to my Pico and would like to see if it is pressed in real-time. one end of the button is connected to GPIO 15, other one to ...
user avatar
  • 13
2 votes
0 answers
77 views

Null characters in output from USB

I'm getting null-bytes in the output from an Arduino Mega 2560, when delaying reading from the USB buffer for e.g. 5 seconds. Can anyone explain why this happens and what I can do to mitigate the ...
user avatar
  • 151
-1 votes
0 answers
38 views

is it possible to make cnc without embedded motion controller over CANopen [duplicate]

I want to make CNC software. while doing this, I do not want to use any motion controller, PLC, FPGA, etc... I use three items. 1-USB to CAN converter, 2-servo motors, and their drivers, 3-a computer. ...
user avatar
1 vote
1 answer
93 views

Can't display characters on 16x2 LCD

Currently I'm working on a project where I want to display some data on an LCD. I'm using a MCP2221A to communicate with a PCF8574, which then sends the bits to the HD44780 LCD. How: I'm using the LCD ...
user avatar
  • 31
-1 votes
3 answers
144 views

Can a computer control up to 10 motor drivers directly via the CANopen communication protocol? [closed]

I guess my question was not so clear, so I am editing now. I want to make CNC software. while doing this, I do not want to use any motion controller, PLC, FPGA, etc... I use three items. 1-USB to CAN ...
user avatar
0 votes
0 answers
216 views

How to run LTSpice from terminal in Linux?

I've installed LTspiceXVII on my linux machine and it is running fine, but I cannot get it to run a simulation using the terminal. This is a necessity for me since I want to automate a circuit via ...
user avatar
0 votes
0 answers
41 views

Siglent SDS Oscciloscope VISA disconnection

I'm currently connecting my Siglent SDS1202X-E Digital Storage Oscilloscope to my lab PC using a USB cable. I took advantage of the VISA interface that it has and used PyVISA package to write script ...
user avatar
0 votes
1 answer
80 views

Will this circuit work on a Raspberry Pi?

There a lot of articles on websites regarding the use of LDRs connected to a Raspberry Pi. As an example, using an ADC or using a built in library. I'm interested with my own design below and since I ...
user avatar
  • 427
-1 votes
1 answer
81 views

Stepper motor position control

i currently try to control a stepper motor to position a camera, to keep my face in the middle of the frame. The face detection is working, and my python program(on raspberry pi 3) can determin the ...
user avatar
  • 1
-1 votes
1 answer
38 views

Problem while implementing a n-bit substractor circuit in python

I'm trying to implement the following substractor circuit in python: And below is my code for it: ...
user avatar
0 votes
1 answer
33 views

Logarithmic binning of smartphone sensor measurements

I' measuring linear acceleration (acceleration minus gravity) and gyroscope from Android smartphones on three axis (x,y,z). Becuase the distribution of the measurments is exponential, i.e. there are ...
user avatar
  • 103
0 votes
0 answers
69 views

Custom PCB with ADC for monitoring Lifepo4 battery bank voltages

I designed a custom PCB board to allow me to monitor the individual battery cell voltages in my Lifepo4 48v battery bank. Here is a schematic of the PCB: Basically I'm using a molex micro fit junior ...
user avatar
1 vote
0 answers
34 views

Rx buffer overwrites Tx buffer in spidev xfer2

I'm setting up a comms link between an STM32F407 MCU and the Pi3B+. The code shown below works but when the data is printed out, it looks like the RX buffer overwrites the TX one. How do I stop that? ...
user avatar
  • 1,230
2 votes
1 answer
77 views

Dotstar Light Strip Low Update Frequency

I've built the start of a persistence of vision display. The rotation platform itself is built and I have just mounted the LEDs. After doing some testing, I can only get very slow update speeds of the ...
user avatar
0 votes
0 answers
25 views

How to implement "burst" functionality for bare-bones function generator

Some fancy function generators have a burst feature which gives precise control over on-time and periodicity of the desired waveform. Ex: For my application, I have a 25 MHz sin wave (2.5 Vpp) and, in ...
user avatar
  • 155
0 votes
1 answer
222 views

How do I invoke pymcuprog?

I have successfully created an ATtiny406 binary using avr-gcc in Linux, and I can program it to the device via Atmel-ICE under Atmel Studio in Windows, and it ...
user avatar
0 votes
0 answers
154 views

CircuitPython & ESP32-S2-Saola boards returning code 43 errors

I am currently trying to connect to some ESP32-S2-Saola devboards that are running CircuitPython 6.1.0 via the USB OTG pins, but the device shows up as as "Unknown USB Device (Device Descriptor ...
user avatar
  • 1
0 votes
1 answer
272 views

How to read an already existing NgSpice raw file

This has taken me a couple of days to solve. I have a set of NgSpice raw files that I would like to exploit so as to visualize the voltage distributions in ...
user avatar
0 votes
1 answer
259 views

Run Ngspice in batch mode or with python

For circuit simulations I have mostly been using LTSpice, where the netlist is generated automatically with a python script I ...
user avatar
0 votes
1 answer
98 views

Measurement of delay between two signals using MSO4104 with PyVisa

I need to automate the measurement of delay between two signals using the oscilloscope. I am using MSO4104 from Tektronix. I programmed the oscilloscope for delay measurement, but I am not getting the ...
user avatar
  • 572
0 votes
1 answer
49 views

3.3 V relay switches on/off/on - off fails 2nd switch off connected to Pi4

UPDATE Issue only happens when load is connected, triggers every time without load This 3.3 V .relay, link to the the >>> Datasheet As the title mentions, it works fine until I try to switch ...
user avatar
  • 101
0 votes
1 answer
263 views

Recognizing the COM port used with STLINK

I'm using a STM Nucleo as a bridge to flash a BLE EM9304 module and another ST-LINK from another STM Nucleo to flash a STM32. Both MCU are in a third board. So, I'm integrating the sequence of ...
user avatar
3 votes
1 answer
682 views

HX711 with RaspberryPi and python

I have been working to create a digital scale for IOT project, using HX711 ADC. The problem Since it is crucial to have wifi connection, I use Raspberry Pi, to control the scale. Everything works well,...
user avatar
0 votes
0 answers
25 views

Switching Circuit from Arduino to Raspberry Pi (Reading Analog Values)

I have wired up this circuit from learn.parallax I have wired this up to an Arduino and it works exactly how I want it too. This is the code that I used to get it working (also from parallax): ...
user avatar
0 votes
0 answers
76 views

Tracking location with GSM tower triangulation

I want to track location with GSM tower triangulation. I searched and I found this API for GSM positioning. ...
user avatar
  • 1
0 votes
0 answers
98 views

Unable to read output of a joystick on a Raspberry Pi

I connected my joystick with this tutorial: link However, it does not work. The code runs fine (after changing print "---" to ...
user avatar
  • 1
0 votes
0 answers
41 views

Segments not totally off when multiplexing 7 segments display with CD4051BE

I'm trying to make a display with several 7 segment displays so I decided to use multiplexing to make it work. I use CD4051BE to do that. The circuit is as follow: Circuit of the multiplexing The ...
user avatar
  • 1
2 votes
0 answers
153 views

How to calculate the Samples per second possible of a ADC (MAXIM 11605) using i2c with raspberry pi?

I would like to find out how many samples per second this ADC im using is capable of with a raspberry pi using i2c and python SMBUS2 library, but i dont know where to start. As far as i know this ...
user avatar
0 votes
1 answer
268 views

ESP32 WROOM switching back from MicroPython to Arduino framework

I have recently switched my ESP32's firmware to work with Python (using Thonny IDE) and I want to switch back to work with C++ and the Arduino IDE, but I remember flashing that bin file on the device. ...
user avatar
0 votes
1 answer
200 views

Is there a way to set different sampling frequencies to channels in ADS1256?

In order to acquire 3 analog signals with a Raspberry Pi 4, I want to use Waveshare's ADS1256 AD expansion board (8 channels single-ended, 24 bit.) I was wondering if there's a way to set a different ...
user avatar
2 votes
1 answer
213 views

Problem communicating with UART1 with Python on Beaglebone Black

I am having issues communicatong to UART1 of my Beaglebone Black with python My code on Python3 is as follows: import Adafruit_BBIO.ADC as ADC import Adafruit_BBIO.GPIO as GPIO from time import sleep ...
user avatar
0 votes
1 answer
117 views

problem in parsing LTspice data

I am using the ltspice python package to extract the data from the .raw file as seen in this link. However, when I try to apply it to my raw file I get the following error: ...
user avatar