PIC or ARDUINO for servo motor controling - arduino

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.

Related

Small PWM module?

I'm trying to find a fitting module/component for a project, but have a hard time finding the right thing.
I need a PWM module/component that can provide a PWM signal and can be controlled via Arduino, preferably TX/RX.
I've used this one previously, and it works great, but it is bulky due to the screen and buttons which I don't really need.
It would be perfect to find the same module but without the screen and buttons.
What it needs to do:
Duty cycle 0-100%
Frequency 1-10 kHz
5 V preferably
Communication via tx/rx or other Arduino compatible protocol
1-2 channels
As small as possible
I've seen some Adafruit modules, but they have at least 16 channels which is not necessary. Would also work, but if I can find an even smaller alternative that would be great.
Any suggestions?
(And no, the Arduino's PWM signals do not work in my case.)
The standard Arduino analogWrite() can't do what you want without trickery, but most Arduino hardware can, so there's no real need for a separate PWM IC or module; you just need to code the Arduino's MCU's timer peripheral to do what you want.
You can do that "by hand", but I would try first to see if an alternative library like TimerOne can get you the PWM you specify. For SAMD21-based Arduinos there is this library (that I wrote), among others.
If you insist on having a separate module for your PWM, just google around (modules exist, but recommendations are not done here), or simply use a second Arduino of your choice as a dedicated PWM generator.

Arduino + GSM shield V2 // How to use buzzer signal

I have a GSM shield V2 for Arduino, and I want some buzzer to make some noise when there is an incoming call. At this link http://www.thaieasyelec.net/archives/Manual/M10_HD_V1.00.pdf page 44 I found that by connecting a simple transistor and a buzzer to the actual "buzzer" pin I should be able to produce sound. I tried and that does not work as expected, all I get is noise from the GND of the shield, that typical GSM noise that everyone know of.
I also tried to connect another arduino as to analog read the buzzer signal, but I get nothing that look like a ringing tone.
Has anyone any idea? Did I forget to setup some things software wise? So far it seems that the buzzer behaviour is completely unrelated to anything code wise, there is just that "buzzer" pin, and that's it, nothing more to set up.
Any help would be much appreciated !
Cheers
Here's a great beeper/alarm part I've used in a couple of recent projects. It is loud but can be muffled. It's self-driving, so all you have to do it supply it enough current at its rated voltage, like through a transistor or Darlington. It has a wide voltage range, and runs great from 3.3V up to 20, So it's ideal for microcontroller projects at 3.3V or 5V. No need to fiddle with timers or PWM to make it beep. Try out this great part.. Drive it from any output pin to a small-signal transistor with a beta of 50 or better and you'll be good to go. Turn output pin on, it starts. Turn output pin off, it stops. I made mine "chirp" like the alarm on a car security system. Easiest thing in the world.

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.

How to control a stepper motor using Infrared IR Receiver?

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.

Arduino TinyGPS no data

I am using the TinyGPS library and am trying to display information to get to a specific latitude/longitude via an LCD screen.
I am not getting any data. The output of directionto is "broke" and distanceto and bearingto is 0.
Code redacted
And here is what my pins/hardware look like: http://i.imgur.com/7iDBwxm.jpg
I am using an Arduino Uno, LCD shield and GPS shield by ITead Studio.
I am hoping it is either the pins or not having a GPS signal.
Reddit post: Arduino TinyGPS help
The baud rate for SoftSerial should be 9600.
You need to debug the system step by step to understand where the problem is.
I would start using only the serial monitor and no display.
Please note that when you switch on a GPS that has been moved for several hundred km, and the same is when you switch it on for the first time, may take a while to get the satellites and start giving out some data. Make sure you are in a open area and wait for 5 to 10 minutes before you declare it as "not working". The next time you will switch it on will be much quicker.
I have checked the documentation of your shield and what they also say is to make sure the Micro SD card you use is support SPI mode but not just the SD mode, also don’t forget to format it into FAT16 , and add a “datalog.txt” file on your card for Arduino to log the information.
Try that and then read the data on the sd card to make sure that is logging.
Come back with the outcome of the above tests and we will try to support you further.

Resources