AMJ00 / final-project

0 stars 0 forks source link

assembling electronics for anhinga final #1

Open AMJ00 opened 5 years ago

AMJ00 commented 5 years ago

I'm stuck on how to assemble the electronics.

A couple of major issues:

1) I purchased an Adafruit motor shield, but I'm not understanding what the advantage is to using it, as opposed to wiring the motors directly to the Arduino. I'm also concerned it may create an obstacle to connecting the proximity sensors.

2) I'm getting inconsistent readings from the proximity sensors, and I'm not sure why that is. It may be that the connections aren't solid enough? In which case soldering might help, but I wanted to consult about how to structure the electronics before I do that, and see what other issues might top the troubleshooting list.

And another less complicated one:

3) Can I just use the pins that came with the motor shield to solder my own shield for the Arduino? Are these a standard size, and can I buy more of them to use with the motor shield on a later date?

andydoro commented 5 years ago

right away from your code, you should move your sensors to A0 to A3. A4 and A5 are used for I2C communication and could interfere.

soldering could also probably help.

the shield is supposed to help simplify the connections to the Arduino. In the case of servo motors, since these rely on specific pulses from the Arduino, there can be trouble when trying to control multiple servos from the Arduino. The motor shield uses a dedicated PWM chip to send these pulses to avoid timing conflicts.

the pins are a standard 0.1" spacing and should match breadboards, perfboards, protoboards, etc. you could design your own shield if you like.

AMJ00 commented 5 years ago

Ah, ok, thanks so much for your reply!

So...do I have to write the code differently to address this PWM chip? All the instructions I found relied on the Arduino servo library, but I haven't found a resource to figure out what the functions in that library are doing, so I don't know how to modify any of it to deal with different hardware. I can't really see the schematics on the back of the shield, either (the etching seems to trail off), so my efforts to deduce what pin is connecting to what haven't been fruitful so far.

Can discuss this evening if that's easier.

Thank you!

On Tue, Dec 11, 2018 at 2:04 PM Andy Doro notifications@github.com wrote:

right away from your code, you should move your sensors to A0 to A3. A4 and A5 are used for I2C communication and could interfere.

soldering could also probably help.

the shield is supposed to help simplify the connections to the Arduino. In the case of servo motors, since these rely on specific pulses from the Arduino, there can be trouble when trying to control multiple servos from the Arduino. The motor shield uses a dedicated PWM chip to send these pulses to avoid timing conflicts.

the pins are a standard 0.1" spacing and should match breadboards, perfboards, protoboards, etc. you could design your own shield if you like.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AMJ00/final-project/issues/1#issuecomment-446321784, or mute the thread https://github.com/notifications/unsubscribe-auth/AozZWLKI4q90G_ZCIl7nlkRJrc9tzDiUks5u4AGngaJpZM4ZN960 .

andydoro commented 5 years ago

Nope, that's fine- the point of the library and shield is to have those more or less handle all those functions. You just have to be careful that because the library and circuitry relies on I2C that it'll be using your A4 and A5 pins. As far as I can tell those are the the only pins used by the Arduino.

andydoro commented 5 years ago

For the segment where you're trying to determine the highest "zone" value, Servo.write needs an argument. So it should look like servo1.write(zone1) , etc.

There are also methods to smooth out spikes in analog readings: https://www.arduino.cc/en/Tutorial/Smoothing

You can also just throw away values that are too out of range.

AMJ00 commented 5 years ago

Ah, interesting. Thank you for this as well! I had the cycle of reading the sensor slowed down so I could read the printouts, but maybe this would help when it's operating at normal speed?

On Tue, Dec 11, 2018 at 2:48 PM Andy Doro notifications@github.com wrote:

For the segment where you're trying to determine the highest "zone" value, Servo.write needs an argument. So it should look like servo1.write(zone1) , etc.

There are also methods to smooth out spikes in analog readings: https://www.arduino.cc/en/Tutorial/Smoothing

You can also just throw away values that are too out of range.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AMJ00/final-project/issues/1#issuecomment-446337487, or mute the thread https://github.com/notifications/unsubscribe-auth/AozZWA8Tt4la2lzl3G-eNEkGxIlHe2Gxks5u4AwWgaJpZM4ZN960 .

andydoro commented 5 years ago

I meant that the Servo write function requires a value- the angle to which the Servo is meant to turn to: https://www.arduino.cc/en/Reference/ServoWrite

AMJ00 commented 5 years ago

Yes, thank you! That makes sense. I hadn't found a tutorial yet that indicated what the range of values was to control the servo, or whether it differs for different motors, so I hadn't entered anything yet. So extra thanks for this reference.

Regarding my previous email, I meant that I wasn't sure if the smoothing code would work, because I'm not sure how long the spikes in the sensor readings last, because I was only printing them once a second. I don't want too much lag time for the sensor values to change, because then it won't seem like the head is following the movement in front of it.

Thanks for taking the time to deal with this, I hope I am not interrupting your work day too much! Again, happy to discuss during office hours if that's easier.

On Tue, Dec 11, 2018 at 3:38 PM Andy Doro notifications@github.com wrote:

I meant that the Servo write function requires a value- the angle to which the Servo is meant to turn to: https://www.arduino.cc/en/Reference/ServoWrite

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AMJ00/final-project/issues/1#issuecomment-446353106, or mute the thread https://github.com/notifications/unsubscribe-auth/AozZWMuyrvczv3l6cq6Cvl15jbUOYYfjks5u4BezgaJpZM4ZN960 .