Pages: [1]   Go Down
Author Topic: LCD issue related to servo code??  (Read 1220 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi


I have my arduino uno setup with the following servo and lcd

http://www.hobbytronics.co.uk/radio-control/servos/hd1800a-micro-servo
http://www.hobbytronics.co.uk/pololu-lcd-16x2

Both work fine when controlled separately, but when combined into one project, the LCD is unreadable and the servo is sat idle, so its not a current related issue.

See attached code for reference

I started by commented out the servo related code and when servoMain.attach(10); is commented out the LCD works fine,

Any help would be appreciated.






* LCD_example_2.ino (2.37 KB - downloaded 12 times.)
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 40
Posts: 4397
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I started by commented out the servo related code and when servoMain.attach(10); is commented out the LCD works fine....

Try leaving the code alone but do not connect the actual servo.  If the LCD still works then the servo itself (not the servo code) is causing the problem.

Don
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2927
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It is also a Very POOR Idea to power the Servo from the same power supply that powers the Arduino... The issue is that there is a Very High "inrush" current that will cripple momentarily the 5V source on the Arduino board... Not so very good an idea, and a very frequent cause of failures in projects utilizing servo's or motors for that matter and One Last Point. The USB Power supply isn't a very solid supply, there is a requuired thermal fuse that has a finite resistance of about .25 to .5 ohms (from previous experience with poly fuses) and If powered from your computers USB bus there are frequently issues with poor regulation, noise and Poor voltage regulation. *IMO the only good reason for USB power is to Program the device. A Backlight will cause serious regulation issues as it can draw up to 300 mA. Small loads, Led's, small reed relays might be OK but if you are designing a light cube to work from a 9V battery or the USB Bus or a new controller for your robot... tethered to your computer.
You might have some issues with available power and regulation.

Doc
Logged

--> WA7EMS <--
“The solution of every problem is another problem.” -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1857
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi


I have my arduino uno setup with the following servo and lcd

http://www.hobbytronics.co.uk/radio-control/servos/hd1800a-micro-servo
http://www.hobbytronics.co.uk/pololu-lcd-16x2

Both work fine when controlled separately, but when combined into one project, the LCD is unreadable and the servo is sat idle, so its not a current related issue.

See attached code for reference

I started by commented out the servo related code and when servoMain.attach(10); is commented out the LCD works fine,

Any help would be appreciated.

I would imagine even if it is not moving, once you call the attach function for the servo, it is drawing power, and you don't have enough power for both the lcd and the servo.  I had a similar thing when I connected my servo, and the lcd shield I had -- the machine kept rebooting at different times.  The usual solution is to wire the servos separately, and connect the grounds between the two power systems.  Here is a link I picked up when I discovered I couldn't do both on plain USB power: http://rcarduino.blogspot.com/2012/04/servo-problems-with-arduino-part-1.html.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the help, if remove the servo for my circuit and run the code complete (nothing commented out), the LCD is still unreadable, so the issue isn't servo or current related

any ideas
Logged

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1857
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks for the help, if remove the servo for my circuit and run the code complete (nothing commented out), the LCD is still unreadable, so the issue isn't servo or current related

any ideas
Hmmm, that reminds me, the Servo library has this warning:

The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12.

The tutorial for LiquidCrystal says you should hook up the lcd to pin 9 with PWM.  So you might need to rearrange the wiring to move the LiquidCrystal PWM to another PWM pin (3, 5, 6,or 11), but you may then have to move wires on other pins, to get to to one of the PWM pins.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Hmmm, that reminds me, the Servo library has this warning:

The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega. On boards other than the Mega, use of the library disables analogWrite() (PWM) functionality on pins 9 and 10, whether or not there is a Servo on those pins. On the Mega, up to 12 servos can be used without interfering with PWM functionality; use of 12 to 23 motors will disable PWM on pins 11 and 12.

The tutorial for LiquidCrystal says you should hook up the lcd to pin 9 with PWM.  So you might need to rearrange the wiring to move the LiquidCrystal PWM to another PWM pin (3, 5, 6,or 11), but you may then have to move wires on other pins, to get to to one of the PWM pins.

Thanks Michael, thats worked, just had to swap pin 9 to 6, thanks again smiley
Logged

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 54
Posts: 1857
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Michael, thats worked, just had to swap pin 9 to 6, thanks again smiley
You are welcome.  I'm glad it worked.
Logged

Pages: [1]   Go Up
Jump to: