I'm using Micro python to try and generate an RGB signal for a TFT screen such as the:
Screen
The timings i need the follow are:
CLKIN: 3.33Mhz
Horizontal is 800 clock cycles up and 1 clock cycle down
Vertical is 480 Horizontal Clock cycles up and
Ive already got this code that spits out the clock but i cant chnage the square function or add a second state machine, how would i go about bit bashing the pins at the required times.
from machine import Pin
from rp2 import PIO, StateMachine, asm_pio
import time
#asm_pio(set_init=PIO.OUT_LOW)
def square():
wrap_target()
set(pins, 1)
set(pins, 0)
wrap()
sm = rp2.StateMachine(0, square, freq=33300000, set_base=Pin(2))
sm.active(1)
Your frequency is 3.33mHz, but each cycle uses 2 cpu cycles so each rising edge is only at 1.665mHz.
Related
Here is my code:
#define LED_BUILTIN 12
// the setup function runs once when you press reset or power the board
void setup()
{
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop()
{
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW);// turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
The above code works perfectly fine for GPIO_2 but fails for GPIO_12. I want to ask whether it is giving fault because I am using touchpad pin or there is some other error?
I have attached an LED to GPIO_12 of ESP32 and after program uploading, my led is not blinking. I have tried to connect voltmeter to GPIO_12 and it is giving 0.5 volts with minor fluctuation. I was expecting a change of voltage after each second as per HIGH/LOW conditions of my code but unfortunately, I am not getting the desired result. What could be the possible reason?
Now I have found out the solution so let's share so that others can also get benefit. The code for which I was following the reference website contained 36 pins which mean 18 pins on each side but in my version of the board there were total 30 pins on my board which mean 15 pins on each side. Now that I have got pin out reference of that board and my board also, everything is fine, aligned and makes perfect sense. Problem was that the hardware which the reference website referred to had different hardware version with 36 pins and my hardware contained 30 total pins and was a different version of ESP32.
i have application ic which needs to write on rising egde and read on falling edge . Write now i get both on rising egde?
I am using bidirectional mode so only 3 wires
Thanks
needs to write on rising egde and read on falling edge
Look at the SPI timing diagram in the Reference Manual. (This is for the F4 series, but AFAIK other series have compatible SPI controllers)
It does what you want when CPHA == 1 and CPOL == 0. Data lines are written at the rising edge, and captured at the falling edge of SCK.
For a night vision camera, I bought NoIR Pi camera and IR leds(Can be attached to both sides of the camera).
But I found that my Pi camera doesn't have metal part on the attaching part. So I cannot use my IR leds with pi camera. Can I use it with pi's gpio? Actually I only need to turn on the leds, so I wonder if I can supply power to leds with raspberry pi or arduino's pins.
Additionally If I connect the leds with jumper cable or something, should I solder it or is it okay just tying it.
You can connect your leds to any DC power source, just be sure to limit the current by using a suitable series resistor to avoid destroying your leds. And don't look into them to prevent eye damage, as your eyes will not accomodate to invisible light.
In good approximation:
I = U / R
with:
I is maximum allowed current trough LED (ampere)
U is power supply voltage (volt)
R is value of resistor (ohm)
Or more exact:
https://www.sparkfun.com/tutorials/219
I have a microbit project where the microbit is inserted into a kiktronics robot vertically.
I would like to get the heading of the robot, but the
compass.heading()
only works if the microbit is horizontal. I have tried reading the x,y,z co-ordinates of the compass using get_x(), get_y(), get_z()
But the ranges of numbers I am getting are scaled differently for the z axis and the x,y axis.
Does anyone know what the ranges are for the different sensors?
I used the test code below. I can get an accurate compass reading if I run the compass_calibrate() function first, even with the magnetometer vertical.
After commenting out the compass_calibrate() line, when moving the board around 3 axis in free space, I can see that the z value does not vary as much as x and y. So I got a small magnet. Moving that around the magnetometer makes the x,y,z values appear to change within roughly the same limits - this is a rough eyeball experiment.
Looking at the data sheet for the MAG3110 magnetometer, I can't see any indication that the 3 magnetometer axis are different. So why are the z-readings different without an external field? I hypothesise that there is a ground plane in the PCB. This is common in PCB construction. This could be acting as a shield for the z-axis.
from microbit import *
# compass.calibrate()
while True:
sleep(250)
# c = compass.heading()
x = compass.get_x()
y = compass.get_y()
z = compass.get_z()
print('x:{} y:{} z: {}'.format(x,y,z))
For those who are working with micro:bit v2, you can get the compass readings by using compass.heading() function too.
Code example:
from microbit import *
while True:
if button_a.was_pressed():
display.scroll(str(compass.heading()))
At the first time after running this code, the micro:bit board will ask you to tilt the board in different directions, and then it will start providing you with the required directions.
According to your questions about the compass ranges, here is a quick summarization for them as in the image below:
I am trying to read a thermistor with the beagle bone black.
I have a voltage divider circuit that feeds a unity gain Opamp. The O/P of the opamp is connected to a simple RC Low pass filter that feeds voltage to the ADC pin.
The problem I have noticed is that the voltage sensed by the beagle bone is always 0.02V higher than the actual voltage at the opamp output.
At first I thought this was a software issue, but on further investigation I found out that the voltage at the ADC pin is actually raised by 0.02V. If I feed the ADC pin directly from the opamp, without the RC filter I do not have this issue.
Has anyone else experienced anything similar?
Thanks in advance!
The resistance in the RC filter is too high which is causing a voltage drop because of the internal impedance of the ADC pin. You can use an active low pass filter to resolve this problem:
http://en.wikipedia.org/wiki/Low-pass_filter#Active_electronic_realization