I am working in a project which requires me to read the velocity of a DC motor with a quadrature encoder. I am using the Arduino UNO board and for some weird reason the motor just works if it is connected to the pins 2 and 3. However this pins are reserved for the interruption (where I intended to connect the encoder). How could I solve this problem?
Assuming the arduino can provide enough current, you should be able to run the motor from any output pin, check out this diagram for reference. You should also make sure you have the necessary protection circuits in place. This is a good starting point: https://create.arduino.cc/projecthub/licensedGeek/controlling-a-dc-motor-from-an-arduino-101-board-f4954b
Related
I'm currently trying to burn the pinguino bootloader in a pic32mx250f128b which is 5V tolerant with an arduino uno. I'd want to try pic32 chips, but I haven't a pickit3 now, I can only access to pickit2.
So to burn the bootloader I'm using an arduino uno, and use the bitbang sketch from pic32prog to try to burn it.
For the wiring I did this :
All VDD and the VUSB3V3BUS pins are wired to the 3V3 regulator of the arduino uno.
All VSS pins are connected to the ground of the arduino uno.
Arduino D2 (PGC) is directly connected to PGEC1
Arduino D3 (PGD) is directly connected to PGED1
Arduino D4 (MCLR) is directly connected to MCLR
But actually, when I launch pic32prog I always have this output :
Programmer for Microchip PIC32 microcontrollers, Version 2.0.218
Copyright: (C) 2011-2015 Serge Vakulenko
(ascii ICSP coded by Robert Rozee)
Adapter: ... OK1 OK2 - ascii ICSP v1E
No target found.
I tried also with the couples PGEC2/PGED2 and PGEC3/PGED3.
I haven't tried to use a crystal yet, but I think from what I read it's not needed for ICSP programming.
For now here is what I've done on my breadboard :
photo of the pic on the breadboard
I don't know what could cause this detection problem,
Thank you very much for your help :)
Edit : I tried several things and here is where I am :
I added the pull-up on MCLR, capacitors on VDD pins, and others recommended : Still the error No target found.
I saw that pic32prog add compatibility with pickit2 so I tried it : this time the pic is detected but I get this error : Unknown CPUID : ffffffff. I tried also with a new pic32mx250 on the pickit2 to be sure it wasn't the first which was damaged.
Finally to recheck my connections I found another version of the datasheet. In this one it seems that PGECx and PGEDx pins aren't 5V compatible... -> So I'll test with 3.3v compatible circuit this time
you need 3k3 pullups to the 3v3 supply rail on both PGC and PGD. these two outputs are 'open collector' (simulated) and the 3k3 resistors define the logic '1' voltage fed to the PGC and PGD pins of the target PIC32.
as mentioned by others, you also need a 10k pullup on MCLR. in addition, you need to ensure that all Vcc pins (13 and 28) are connected together, all ground pins (8, 19 and 27) are connected together, and that there is a 10uF low ESR ceramic capacitor from pin 20 to ground (a 22uF tantalum will do).
see the "ascii ICSP construction guide" article here:
http://www.thebackshed.com/docregister/Browse.asp
the article includes a schematic of what is required.
cheers,
rob :-)
the 10uF low ESR ceramic capacitor on pin 20 is crucial. pin 20 connects ONLY to this capacitor, nothing else. without it, the core of the PIC32 will not run and programming will be impossible.
the reason for this is that the core of the PIC32 runs at 1.8 volts, and the capacitor on pin 20 is part of the circuitry that generates this supply. in your photo it looks like pin 20 is not connected to anything.
cheers,
rob :-)
Got this board cheap from Banggood, but there are minimal details on how to use it.
There is a manual here https://www.gitbook.com/book/smartarduino/user-manual-for-2-way-motor-16-way-servos-shield/details , but it is a long way from detailed, and what I need are some details on how to drive the I2C PWM servos.
After some poking around, I have a partial answer.
The Adafruit libraries seem to work fine for the servos.
https://learn.adafruit.com/16-channel-pwm-servo-driver/using-the-adafruit-library
Motors on this version of the board have the following controls:
D6 PWMB - speed channel B
D7 DIRB - Direction Channel B
D8 PWMA - Speed Channel A
D9 DIRA - Direction Channel A
... which may explain why the speed control is working on channel B but not A, since pin 8 is not PWM on a UNO. (May also explain why it is cheap)
Also note that you need to supply a separate 5V to 18V power to the VS connector to drive the servos. I used a 6v battery pack.
Also note that the on-board power switch did not appear to affect power to servo, so a power switch for the servo power is probably also useful.
External power source is required only at VM & GND terminals if jumpers are shorted both at VM+VIN and VS+5V, VM will have the same voltage as input power and VS (servo voltage) will be 5V derived from VM input, not from UNO board. That is what the user manual means by single power source, which input is at VM terminal. OPEN all the jumpers will need individual power source for VM and VS separately.
On Adafruit there was an example on how to connect a ledstrip to an arduino, but it said "For longer strips requiring more than 1A, wire power directly to the strip, then run power and ground wires back to the Arduino." I didn't fully understand it so i made a sketch on circuits.io . Since there isn't a normal ledstrip in there i used a RGB to show my sketch, but i can't test it. So before i fry my arduino or ledstrip can someone explain if this is correct or if it needs to be changed? Also can i connect everything on a breadboard or not, since the higher voltage and amp.
https://i.gyazo.com/27e9a6527805b6e4e898a8f32f66de61.png
That would work.
I believe this is the same as this https://learn.adafruit.com/rgb-led-strips/usage
about the breadboard it really depends on the breadboard they can vary from cheap ones 0.5A to 2A is usually the maximum current rating for a good solderless breadboard
Here are what you need:
Your Arduino.
An external power supply. Get something like this for your external power suply.
You led strip.
Connect:
PWM pulse of Arduino -> Data IN of led strip
All GND togheters
5V output of external power supply-> VCC of led strip
Computer -> USB -> Arduino
External power supplies give you high current levels, perfect for many leds. Dont worry about your breadboard melting, it should be able to handle it.
I am having a hard time troubleshooting this project build of mine. I am trying to utilize a DS18B20 temperature sensor in conjunction with an ESP8266 to create a temperature beacon.
The problem I'm running into pertains to the data interpreted by the ESP8266. I am using the Arduino IDE to program the HUZZAH ESP8266 breakout.
The WiFi client is behaving as supposed to, but the temperature sensing is not. When I upload the same sketch to an Arduino Mega2560 (recompiled obviously), and plug the data line into a digital pin of the 2560, the probe temps come in perfectly, changing according to the temp. If I unplug the data lead, I get -196.80, what I assume is a ground value.
Simply moving the data line into the ESP8266 pin, I receive a temp of 262.29 and this does not change in between reads, regardless of sensor temperature.
I have ensured all of the cables are wired properly, there is no weird grounding or anything. I have tried changing the baud rate of the serial interface maybe thinking the clock had something to do with it, but that seems to have affected nothing.
Any idea/direction is always appreciated!
I have wired the circuit according to a diagram located at this link here.
Here is a Gist to the code that I have been uploading to the ESPs. The code is designed to setup a WiFi Client (attached to a local AP, which works totally fine), request the temps, and submit up to a host that has a listening server. The pin (2) refers to GPIO2 on ESP8266 [i think]
So I found A solution to this. I'm not sure if this particular problem has been replicated for everyone, however, in my situation, the parasitic power on the data line was not charging the IC enough to finish the proper calculation.
All I had to do was unground the VDD pin and hook it up to the 5V rail. Leave the 4.7kOhm resistor on the data line also pulled up to the 5V rail. After doing so, the program reports PARASITIC POWER: OFF, and reports temperatures as I hoped!
I changed my post above to include a working solution!
The DS18B20 device can operate in 2 power modes (normal and parasitic). In the case of parasitic power, the VDD pin is jumped to GND and the IC receives power from the data line that is connected back to a micro-controller.
An interesting quality of the DS18B20 is the power draw during temperature sensing. While operating in parasitic mode, the host device needs to be able to supply the IC with enough power to complete the calculation, otherwise the device will return a bad answer.
The solution for me (using an Adafruit HUZZAH ESP8266 micro-controller) was to not use parasitic power. I cannot say for sure what the problem with this setup is, however, when configuring the circuit in normal mode, the probe worked as expected. I imagine the data line isn't getting enough power.
To change the circuit from the diagram linked above:
Remove the jumper between VDD and GND pins
Connect VDD to 5V rail
Keep GND to GND rail
Keep 4.7kOhm resistor pulling data line up to 5v rail
I have an external power source (6v) that is connected to a motor and a servo, and on my arduino board I have a couple of LEDs which are powered by the onboard 5v. The external power is connected to a switch so I can turn on the motor and servo (to save battery). My main board just blinks the different LEDs. What I want to happen is that the moment my external power is switched on, the LEDs stop blinking and the code to move the servo and motor is executed. As a result I have a boolean called intro. When it is true, the LED code executes, when it is false the motor and servo code will execute. The only problem I am having is that how can the Arduino know if the external power is switched on so that the boolean can be set to false? Is there a way that the arduino can detect if the external power is on (for example checking the pins of the motor/servo?)?
The general idea is to connect the external power to an I/O pin so you can read its status. You'll also want a pull-down on the I/O pin so that it doesn't float and give random values when power is not connected.
Don't connect 6V directly to an Arduino I/O pin, it will be far enough above Vcc that the clamp diodes on the pin will activate. A series resistor like 10K to reduce the clamp current will probably be OK but still isn't the best design practice. I'd recommend a 3V3 zener diode clamp such as that on this page:
http://www.kevinmfodor.com/home/My-Blog/microcontrollerinputprotectiontechniques
Check the max input voltage on the IO pins, but you should be able to connect the external power to a pin and drive an interrupt.
The interrupt can then be used to decide if the power is on (rising edge) or off (falling edge).