casychow / DesktopPet_Eui

A small, mobile desk robot that helps alleviate the physical, emotional, and mental problems frequently faced by desk workers. This is my NYU Tandon Senior Design Project.
0 stars 0 forks source link

testing edge detection subsystem #4

Closed qyc206 closed 3 years ago

qyc206 commented 3 years ago
qyc206 commented 3 years ago

Tested ADC MCP3004 with known reference voltages (gnd and 3.3V) Code:

Screen Shot 2021-03-31 at 5 06 30 PM

Result:

Screen Shot 2021-03-31 at 5 06 48 PM

CURRENT STATUS: does not seem to be sensing/detecting changes in distance (only detects one value... 0V when ADC read value is converted to voltage)

Code:

Screen Shot 2021-03-31 at 5 09 46 PM

Current wiring: IMG_4341

Resource:

Screen Shot 2021-03-31 at 4 57 13 PM

https://www.instructables.com/Using-IR-Sensor-TCRT-5000-With-Arduino-and-Program/

qyc206 commented 3 years ago

Current status: still doesn't work.. :'( Wiring has been changed to the following

IMG_4355

casychow commented 3 years ago

Needed to find my pi's new ip address before accessing VNC viewer. This is the output when the C0 is connected to 3.3V. image

This is the output when C0 is connected to GND. image

Followed CompEDP1 lab 12 manual instructions and used the MCP3004 datasheet to wire the circuit.

I only get the following message even after adding an LED like most online tutorials recommend. This value is consistent no matter if I shine light directly onto the digital sensor or not. image

I added a LED to the input of the digital sensor and wired the digital sensor output as the input to the ADC. image

casychow commented 3 years ago

My current code: image

casychow commented 3 years ago

Moved circuit onto a bigger breadboard yesterday and started testing it today. The values on the distance sensor works but the values seem inconsistent.

This is my current circuit as of yesterday. The green wire is only for for testing purposes. It usually holds a value of 23mV. The voltage drop across the distance sensor is 0.2-0.3mV. image

This is the circuit schematic as of now. I think the issue lies in the 5kΩ I used to power the distance sensor's collector pin and/or the A pin of the digital sensor. Many resources say to connect it to a GPIO input, but I'm still not sure why. IMG_DCD2A914D7DF-1

casychow commented 3 years ago

Tried to change the pull down resistor but when using the following code, the digital sensor's readings dropped lower than expected. image image

Replaced 5x 1kΩ resistors with a 4.7kΩ resistor. Replaced GPIO16 and 100Ω resistor input to the A pin on the digital sensor with 100Ω resistor to ground and then removed a connected to the A pin altogether.

Resources: spidev documentation - https://pypi.org/project/spidev/ spidev and ADC example - https://learn.sparkfun.com/tutorials/python-programming-tutorial-getting-started-with-the-raspberry-pi/experiment-3-spi-and-analog-input distance measurement - https://tutorials-raspberrypi.com/infrared-distance-measurement-with-the-raspberry-pi-sharp-gp2y0a02yk0f/ https://jeremyblythe.blogspot.com/2012/09/raspberry-pi-distance-measuring-sensor.html?m=1 enable SPI - https://www.raspberrypi-spy.co.uk/2014/08/enabling-the-spi-interface-on-the-raspberry-pi/ tcrt5000 datasheet - https://www.vishay.com/docs/83760/tcrt5000.pdf pull_up_down resistor - https://www.14core.com/wiring-with-tcrt5000-reflective-optical-sensor-module-on-raspberry-pi/

Asking prof for help on piazza Current code image image image

casychow commented 3 years ago

New circuit: IMG_997828A15854-1 distancesensor

Voltage and ADC values change as objects move closer/further away

Code: image image