How to control a stepper motor using Infrared IR Receiver? - arduino

Hi im new to Arduino Uno
My question is how to turn a stepper motor 90 dgree clockwise only when the infrared censored a something and turn anti-clockwise when the second infrared censored something is pressed again?
Stepper motor
Infrared transmitter/receiver pair
your help will be much appreciated
Thanks

Software and hardware my friend, software and hardware.
First, you'll need to connect your sensors to the Arduino and make sure you can read them reliably. You can write a sketch that outputs the values to the serial port and monitor them on your computer.
Second, you'll need to connect your motor. A stepper motor is going to need a driver, such as the "Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit" (link). This kit has sample code you can use to figure out how to drive the motor.
Then you'd connect these two independent pieces together. Write logic that puts the motor in one position when your sensor is sensing, and another when it's not, or use your second sensor to make the second motion.
Note: Stepper motors and the drivers are expensive and maybe not what you really want. For one thing, they use relative motion, not absolute position. If they miss steps (due to hitting something or being manually moved) then they remain in the wrong position until you fix them.
A cheaper and perhaps better solution is to use a hobby servo. They are cheap and use absolute positioning, which means that when you tell them to go somewhere they will always try to get to that position. Also, you can drive them directly from the Arduino without a driver board. One of the built-in Arduino sketches shows how to run them.

Related

is there a way to do plugnplay for arduino?

First Thanks in advance.
Is there a way for an Arduino board to detect what other boards are attached (such as infrared, or servo motor etc) or simple things such as led or push buttons? Basically is there a way to do Plug N Play?
I would like to design a system using an Arduino were the user can mix and match infrared sensors, motors, led. The script would recognize what is attached to the board and respond accordingly. Currently one is forced to hard code in the script identifying what pin is attached to what. Hence if the user pulls out a servo motor and adds an infrared, then the script must be rewritten. This is what I want to avoid.
Thanks.
You started with
user mix and match sensors, motors, led. The script would recognize
what is attached
and later added
Arduino for model railroads, to dynamically add servos, lights and
sensors
These are not the same, narrowing the scope makes all the difference. See my comment for first option. As for building a specific model that will recognize elements, sure, this can be done in couple of ways depending on the topology you intend to implement and in that case the main concern should be:
How will elements/nodes be connected to each other and / or the main board?
If you intend to run seperate wires for each element you could identify them by dedicating one wire for ID and use a different resistor on each, That's complicated and limited and I wouldn't do that.
On the other end you could create a parallel bus that runs from node to node and can be extended as needed, it will have a small number of wires that will implement I2C for instance, and for identification but also as local drivers you would add an ATtiny on each node.

Using an Arduino as EMG sensor

When I search online for EMG sensors, I often see these sensors are just made of a few transistors, resistors and sometimes diodes. Also I once read on a site that EMG sensors are some kind of modified voltmeters. But while I managed to make a voltmeter from an Arduino, I haven't been able to make an EMG sensor from an Arduino.
Does someone know whether it is possible to make an EMG sensor from an Arduino and how they did achieve this?
I think the biggest problem here is that of dynamic range. EMG signals are AC voltages typically in the low mV range and would need a gain of 100 or so to get them up to +/-2.5V, then a simple offset circuit to convert that to 0-5V for the Arduino analog inputs. However, that's not the whole story, since the small EMG signals can ride up and down on large low-frequency background voltages. Your AC amplifier would need a high-pass filter to remove those, or they could drive it off-scale which would prevent the EMG from getting through. If you reduce the gain to keep things in range, the EMG will be a rather small part of the 10-bit ADC range on the Arduino.
So the thing to ask is what is the point of using the Arduino in the first place? If you are going to connect it to a computer in order to look at the EMG signals, then why not just skip the Arduino and use the computer's sound card? The Mic input probably has enough gain already, and you get at least 16-bit resolution to handle any large non-EMG background that wasn't filtered out.
IMPORTANT! EMG measurements require direct electrical connection to the body. For safety, you should make certain that your recording equipment is electrically isolated. If you use only a standalone Arduino, you should power it from batteries. If you use a computer, it should be a laptop running on batteries, with no other connections to ground.
I often see these sensors are just made of a few transistors,
resistors and sometimes diodes.
That's true for pretty much all electronics devices...
Does someone know whether it is possible to make an EMG sensor from an
Arduino and how they did achieve this?
You cannot build an EMG sensor from an Arduino. But you read sensor values with an Arduino either through serial interfaces or by measuring voltages.
With a bare Arduino you can neither measure negative voltages nor can you amplify small signals. (we're in the µV range here...)
Just buy something ready or learn more on electronics

How to stop an Arduino Servo from moving during the myservo.attach() command

I'm using the default Servo library in Arduino. When my Arduino Uno starts up and it attaches the servo the motor will move a good portion of its range. I can't have this happen for my project, I need it to turn and stay in its current position.
Also I have seen this post but if I am reading it correctly its for a different library.
Why the problem occurs?
RC servos set their position accordingly to width of a pulses sent to them. Usually this width changes in range of ~500 - 2500us, with a frequency of 50Hz. When a servo receives such a signal, it goes to a corresponding position. For example - if it receives pulses 1500us wide, it would go to middle position. When you invoke servo.attach(), Arduino will start sensing pulses of DEFAULT_PULSE_WIDTH which happens to be 1500us.
What can be done about that?
The solution from the linked question applies also to standard Arduino servo library. Find DEFAULT_PULSE_WIDTH and change it's value to 0. If there are no pulses, the servo won't turn. Arduino will start sending signal after first servo.write() call. Remember, that there will be no holding torque until that time.
Possible cause
When your Arduino Uno starts up two things are going on at the same time
Arduino Uno runs it's bootloader and servo pin is in input mode
Servo gets power and moves a bit while getting no signal
After bootloader finished your, program starts and call to attach is perfomred.
I could reproduce the effect with my Arduino starter kid and its includes cheap servo.

Power problems stacked Arduino shields

I have a weird problem. I am currently building a BB-8. Therefore, I am using an Arduino Uno. On top, I have stacked an Adafruit Motor Shield v2.3 and, again, on top of this, I have stacked the Sparkfun USB Host Shield. The Arduino is powered by a 9V-Block battery, the motors are powered separately by two 18650 Li-Ion batteries. To control the two Pololu motors, which have a stall current of 1.6 amps each, I use a Xbox 360 wireless controller, where the receiver is connected to the USB Host Shield.
Now to my problem. Every seems to work fine, until i cover everything with a styrofoam hemisphere. Yes, you've read right. If that happens, the controller signals is lost and does not connect again, unless I restart the Arduino. I have uploaded a small video on youtube, where you can see the problem.
I guess, this is a power problem, since this issue does not occur, when I connect the Xbox receiver to my Mac. Has anyone an idea, how to solve this problem?
I already tried another power source. And the USB host shield should give enough power, since the specs are saying, that 500 mA is no problem, and hit is exactly the USB 2.0 spec. The combination of the shield shouldn't be a problem, too. I carefully chose this shields, because the motor shield is just using the pins A4 and A5, the USB host shield is using some of the digital pins, so I think there is no interference.
Thank you for your help.
EDIT
I have tested it a bit more now and i think i can reduce the probable reasons. First, i tried some other power supplies, from AA batteries on the VIN pin to external power adaptors. Next, i tried other xbox receivers and controllers. I also tried a playstation 3 controller with a Bluetooth dongle. Nothing solved the problem. I also covered the Arduino with other things than styrofoam, like a garbage can, cardboard and some metal box. This worked, so the problem was only with styrofoam. Now i haven't covered the Arduino, but i slowly got closer. About 20 cm from the Arduino, it stopped working. My clue: static electricity. Do you think this can be a problem? And if yes, how can i solve this?
Try use single battery + separate voltage regulators for every load. Otherwise if one of the batteries discharges while other are ok, it can take all power of the system, something like short-circuit. Also you can receive a trouble if do error in ground connections.
Select good battery, which can provide enough power. If cant find a battery which can supply enough current think about using low current batteries in series to achieve extra voltage. Then reduce voltage using dc-dc step down converter.
For example if you have a battery of 24V which provides 1A (power p1 = 24*1). It can provide 5A if reduce the voltage to 5V using dc-dc. (power p2 = 5*5). Because p1*h=p2, where [h=0.8 - efficiency].
So, I solved the problem. As is mentioned in my question, the problem was static electricity. I primed the styrofoam sphere with some special primer to make the styrofoam a little more stable and so on. That's it. Luckily I didn't touch the Arduino with the sphere. I think it would have damaged the Arduino.

PIC or ARDUINO for servo motor controling

Im a PIC fan. I have not used arduino. but I have got a problems when Im going to control servos with pic.
1) when PIc is controlling the servo it cannot do enything else. so during that period it cannot get the sensor readings.
2) after driving the servo to a certain position and now when the pic is doing something else, the pic does not further more generate the pwm signal in the servo connected pin. so the servo may rotate back due to the load.
now my first question is will arduino genarate the pulse continously in the attached pin after the codes
servo s;
s.attach(13);
s.write(120);
or are there eny librarys to control multi servos using PIC in mikroc to avoid the above mentioned problems.
or is it better to use two PICs one to drive servos only and the other for processing and sensor reading, and connect them using I2C.
please I need help from an expert. please reply. thank you...
Yes the Arduino is able to generate the pwm continuously.
Arduino langage is C/C++ with some build in features like analogWrite()for pwm, which make it really easy to program.
Regarding your "when something is running, it can't do anything else" problem, that's one of the major limitation of the Arduino platform as is. You can overcome those limitations by using ISR (Interrupt Service Routine), timers and hardware interrupts.
If you're comfortable with C/C++, you can also use a Real Time Operating System (RTOS) which lets you run think like a regular operating system would: allow cpu time to each task so fast that they seem to run in parallel. But that's not as easy to use as the basic Arduino features, so think carefully if you really need those functions (scheduler, "multi-task", round rubin, etc.)
Hope it helps!
I am planning a similar project, using a PIC16F872, to control a servo motor. I am thinking of using a 32 kHz crystal to have a PWM suitable, of 35Hz and pulse width centred on 1.05 mS. In my case I will first be doing A/D measurements; then when required running the motor. The motor will have a continuous signal until a 'stop' switch gives an interrupt to the PIC.
I should mention that I have modified the servo for continuous running by disconnecting the feedback pot.

Resources